Skip to content

Commit

Permalink
Fix data reloading issues for device detail vulnerability table
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnsth committed Dec 11, 2018
1 parent 5ea2a4a commit dbc164a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/organization/device/device.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export class DeviceService extends TableCache {
return this.accountService.executeGet(`/organization/${this.accountService.getOrganizationId()}/device/${id}/detail`);
}

getVulnerabilities(deviceId: number, page: number, limit: number) {
if (this.vulnDetailPage == page) {
getVulnerabilities(deviceId: number, page: number, limit: number, force: boolean) {
if (this.vulnDetailPage == page && !force) {
return;
}
this.spinnerService.setState(true);
Expand Down
15 changes: 10 additions & 5 deletions src/organization/device/device_detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export class DeviceDetailComponent implements OnInit{
];

this.vulnerabilityEnabled = this.service.accountService.isVulnerabilityEnabled(this.service.accountService.getCurrentOrganization());

this.refresh();
}

Expand Down Expand Up @@ -116,7 +115,9 @@ export class DeviceDetailComponent implements OnInit{
p => {
this.setResponse(p);
this.spinnerService.setState(false);
this.loadVulnerabilityData();
if (this.vulnResponse) {
this.loadVulnerabilityData();
}
},
err => {
this.spinnerService.setState(false);
Expand All @@ -139,7 +140,12 @@ export class DeviceDetailComponent implements OnInit{
}

loadVulnerabilityData() {
this.service.getVulnerabilities(parseInt(this.deviceId), 1, this.ROWS);
let currentPage = 1;
if (this.ptable && this.ptable.first) {
currentPage = this.ptable.first / this.ROWS + 1;
this.ptable.setScrollPosition(0);
}
this.service.getVulnerabilities(parseInt(this.deviceId), currentPage, this.ROWS, true);
}

getVulnColumnWidth(field) {
Expand All @@ -155,10 +161,9 @@ export class DeviceDetailComponent implements OnInit{
this.savedScrollPos = 0;
}


vulnSortingChanged(event) {
//loadMore, ptable in case with lazy and virtual scroll enabled calls the same function
this.service.getVulnerabilities(parseInt(this.deviceId), (event.first ? event.first : 0) / this.ROWS + 1, this.ROWS);
this.service.getVulnerabilities(parseInt(this.deviceId), (event.first ? event.first : 0) / this.ROWS + 1, this.ROWS, false);
}

setFocusToList() {
Expand Down

0 comments on commit dbc164a

Please sign in to comment.