Skip to content

Commit

Permalink
Merge pull request primefaces#174 from atretyak1985/issue_#156
Browse files Browse the repository at this point in the history
Device detail users issues (address primefaces#156)
  • Loading branch information
gunnsth authored Mar 26, 2019
2 parents e056970 + f03ac3b commit 511ca8a
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild, Renderer2 } from '@angular/core';
import { Component, OnInit, Input, ViewChild, Renderer2, Output, EventEmitter } from '@angular/core';
import { ColumnWithSort } from 'common/object';
import { Table } from 'primeng/table';
import { DeviceGroupPolicyItem, DeviceGroupPolicyResponse } from './device-group-policy.response';
Expand All @@ -15,6 +15,7 @@ export class DeviceGroupPolicyComponent implements OnInit {
@Input() deviceId;
@Input() listHeight: string;
@ViewChild('table') table: Table;
@Output() countChanged = new EventEmitter<number>();

public ROWS: number = 20;

Expand Down Expand Up @@ -45,6 +46,7 @@ export class DeviceGroupPolicyComponent implements OnInit {
this.response = p;
this.totalRecords = this.response.total;
this.items = this.response.items;
this.countChanged.next(this.response.total);
},
err => {
this.service.spinnerService.setState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild, Renderer2 } from '@angular/core';
import { Component, OnInit, Input, ViewChild, Renderer2, Output, EventEmitter } from '@angular/core';
import { ColumnWithSort } from 'common/object';
import { Table } from 'primeng/table';
import { DeviceIncidentService } from './device-incident.service';
Expand All @@ -17,6 +17,7 @@ export class DeviceIncidentComponent implements OnInit {
@Input() listHeight;

@ViewChild('table') table: Table;
@Output() countChanged = new EventEmitter<number>();

public ROWS: number = 20;

Expand Down Expand Up @@ -51,6 +52,7 @@ export class DeviceIncidentComponent implements OnInit {
this.response = p;
this.totalRecords = this.response.total;
this.items = this.response.items;
this.countChanged.next(this.response.total);
},
err => {
this.service.spinnerService.setState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild, Renderer2 } from '@angular/core';
import { Component, OnInit, Input, ViewChild, Renderer2, Output, EventEmitter } from '@angular/core';
import { ColumnWithSort } from 'common/object';
import { Table } from 'primeng/table';
import { DevicePatchService } from './device-patch.service';
Expand All @@ -16,6 +16,7 @@ export class DevicePatchComponent implements OnInit {
@Input() listHeight;

@ViewChild('table') table: Table;
@Output() countChanged = new EventEmitter<number>();

public ROWS: number = 20;

Expand Down Expand Up @@ -46,6 +47,7 @@ export class DevicePatchComponent implements OnInit {
this.response = p;
this.totalRecords = this.response.total;
this.items = this.response.items;
this.countChanged.next(this.response.total);
},
err => {
this.service.spinnerService.setState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild, Renderer2 } from '@angular/core';
import { Component, OnInit, Input, ViewChild, Renderer2, Output, EventEmitter } from '@angular/core';
import { ColumnWithSort } from 'common/object';
import { Table } from 'primeng/table';
import { DeviceSoftwareService } from './device-software.service';
Expand All @@ -15,6 +15,7 @@ export class DeviceSoftwareComponent implements OnInit {
@Input() deviceId;
@ViewChild('table') table: Table;
@Input() listHeight: string;
@Output() countChanged = new EventEmitter<number>();

public ROWS: number = 20;

Expand All @@ -34,17 +35,19 @@ export class DeviceSoftwareComponent implements OnInit {
ngOnInit() {
this.cols = [
{ field: 'name', header: 'Name', order: 0, width: '200px', disabled: true },
{ field: 'version', header: 'Version', order: 0 , width: '200px', disabled: true },
{ field: 'publisher', header: 'Publisher', order: 0 , width: '200px', disabled: true },
{ field: 'created_at', header: 'Created At', order: 0 , width: '200px', disabled: true },
{ field: 'num_vulnerabilities', header: '#Vulnerabilities', order: 0 , width: '200px', disabled: true }

{ field: 'version', header: 'Version', order: 0, width: '200px', disabled: true },
{ field: 'publisher', header: 'Publisher', order: 0, width: '200px', disabled: true },
{ field: 'created_at', header: 'Created At', order: 0, width: '200px', disabled: true },
{ field: 'num_vulnerabilities', header: '#Vulnerabilities', order: 0, width: '200px', disabled: true }
];

this.service.detailResponse$.subscribe((p: any) => {
this.service.spinnerService.setState(false);
this.response = p;
this.totalRecords = this.response.total;
this.items = this.response.items;
this.countChanged.next(this.response.total);
},
err => {
this.service.spinnerService.setState(false);
Expand Down
4 changes: 3 additions & 1 deletion src/organization/device/detail/user/device-user.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild, Renderer2 } from '@angular/core';
import { Component, OnInit, Input, ViewChild, Renderer2, Output, EventEmitter } from '@angular/core';
import { ColumnWithSort } from 'common/object';
import { Table } from 'primeng/table';
import { DeviceUserItem, DeviceUserResponse } from './device-user.response';
Expand All @@ -15,6 +15,7 @@ export class DeviceUserComponent implements OnInit {
@Input() deviceId;
@Input() listHeight: string;
@ViewChild('table') table: Table;
@Output() countChanged = new EventEmitter<number>();

public ROWS: number = 20;

Expand Down Expand Up @@ -49,6 +50,7 @@ export class DeviceUserComponent implements OnInit {
this.response = p;
this.totalRecords = this.response.total;
this.items = this.response.items;
this.countChanged.next(this.response.total);
},
err => {
this.service.spinnerService.setState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild, Renderer2 } from '@angular/core';
import { Component, OnInit, Input, ViewChild, Renderer2, Output, EventEmitter } from '@angular/core';
import { ColumnWithSort } from 'common/object';
import { DeviceVulnerabilityService } from './device-vulnerability.service';
import { DeviceVulnerabilityItem, DeviceVulnerabilityResponse } from './device-vulnerability.response';
Expand All @@ -15,6 +15,7 @@ export class DeviceVulnerabilityComponent implements OnInit {
@Input() deviceId;
@ViewChild('table') table: Table;
@Input() listHeight: string;
@Output() countChanged = new EventEmitter<number>();

public ROWS: number = 20;
public cols: Array<ColumnWithSort>;
Expand Down Expand Up @@ -43,6 +44,7 @@ export class DeviceVulnerabilityComponent implements OnInit {
this.response = p;
this.totalRecords = this.response.total;
this.items = this.response.items;
this.countChanged.next(this.response.total);
},
err => {
this.service.spinnerService.setState(false);
Expand Down
36 changes: 18 additions & 18 deletions src/organization/device/device_detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,18 @@ <h2>Credentials2</h2>
<div>
<ul class="nav-tabs-nanitor list-inline">
<li id="tab1" class="active"><a (click)="setTabSelected(CONFIGURATION_TAB_INDEX)">Configurations</a></li>
<li id="tab2" *ngIf="vulnerabilityEnabled && response.num_vulnerabilities > 0"><a (click)="setTabSelected(VULNERABILITY_TAB_INDEX)">Vulnerabilities
({{ response.num_vulnerabilities }})</a></li>
<li id="tab3" *ngIf="response.num_incidents > 0"><a (click)="setTabSelected(INCIDENT_TAB_INDEX)">Incidents
({{ response.num_incidents }})</a></li>
<li id="tab4" *ngIf="response.num_patches > 0"><a (click)="setTabSelected(PATCH_TAB_INDEX)">Patches
({{ response.num_patches }})</a></li>
<li id="tab5" *ngIf="response.num_loggedinusers > 0"><a (click)="setTabSelected(USER_TAB_INDEX)">Users
({{ response.num_loggedinusers }})</a></li>
<li id="tab6" *ngIf="response.num_gpos > 0"><a (click)="setTabSelected(GROUP_POLICY_TAB_INDEX)">Group
Policies ({{ response.num_gpos }})</a></li>
<li id="tab7" *ngIf="response.num_software > 0"><a (click)="setTabSelected(SOFTWARE_TAB_INDEX)">Software
({{ response.num_software }})</a></li>
<li id="tab2" *ngIf="vulnerabilityEnabled && numVulnerabilities > 0 || isVulnerabilitiesTabActive"><a (click)="setTabSelected(VULNERABILITY_TAB_INDEX)">Vulnerabilities
({{ numVulnerabilities }})</a></li>
<li id="tab3" *ngIf="numIncidents > 0 || isIncidentsTabActive"><a (click)="setTabSelected(INCIDENT_TAB_INDEX)">Incidents
({{ numIncidents }})</a></li>
<li id="tab4" *ngIf="numPatches > 0 || isPatchesTabActive"><a (click)="setTabSelected(PATCH_TAB_INDEX)">Patches
({{ numPatches }})</a></li>
<li id="tab5" *ngIf="numLoggedinusers > 0 || isLoggedinusersTabActive"><a (click)="setTabSelected(USER_TAB_INDEX)">Users
({{ numLoggedinusers }})</a></li>
<li id="tab6" *ngIf="numGpos > 0 || isGposTabActive"><a (click)="setTabSelected(GROUP_POLICY_TAB_INDEX)">Group
Policies ({{ numGpos }})</a></li>
<li id="tab7" *ngIf="numSoftware > 0 || isSoftwareTabActive"><a (click)="setTabSelected(SOFTWARE_TAB_INDEX)">Software
({{ numSoftware }})</a></li>
</ul>
</div>
<div class="table-responsive" style="overflow: hidden; margin-top: 10px;" *ngIf="isTabSelected(CONFIGURATION_TAB_INDEX)">
Expand Down Expand Up @@ -291,22 +291,22 @@ <h2>Credentials2</h2>
</div>

<div class="container-fluid white-wrapper device-detail" *ngIf="isTabSelected(VULNERABILITY_TAB_INDEX)">
<device-vulnerability #vulnerabilityId [deviceId]="deviceId" [listHeight]="listHeight"></device-vulnerability>
<device-vulnerability #vulnerabilityId [deviceId]="deviceId" [listHeight]="listHeight" (countChanged)="countChanged($event)"></device-vulnerability>
</div>
<div class="container-fluid white-wrapper device-detail" *ngIf="isTabSelected(INCIDENT_TAB_INDEX)">
<device-incident #incidentId [deviceId]="deviceId" [listHeight]="listHeight"></device-incident>
<device-incident #incidentId [deviceId]="deviceId" [listHeight]="listHeight" (countChanged)="countChanged($event)"></device-incident>
</div>
<div class="container-fluid white-wrapper device-detail" *ngIf="isTabSelected(PATCH_TAB_INDEX)">
<device-patch #patchId [deviceId]="deviceId" [listHeight]="listHeight"></device-patch>
<device-patch #patchId [deviceId]="deviceId" [listHeight]="listHeight" (countChanged)="countChanged($event)"></device-patch>
</div>
<div class="container-fluid white-wrapper device-detail" *ngIf="isTabSelected(USER_TAB_INDEX)">
<device-user #userId [deviceId]="deviceId" [listHeight]="listHeight"></device-user>
<device-user #userId [deviceId]="deviceId" [listHeight]="listHeight" (countChanged)="countChanged($event)"></device-user>
</div>
<div class="container-fluid white-wrapper device-detail" *ngIf="isTabSelected(GROUP_POLICY_TAB_INDEX)">
<device-group-policy #groupPolicyId [deviceId]="deviceId" [listHeight]="listHeight"></device-group-policy>
<device-group-policy #groupPolicyId [deviceId]="deviceId" [listHeight]="listHeight" (countChanged)="countChanged($event)"></device-group-policy>
</div>
<div class="container-fluid white-wrapper device-detail" *ngIf="isTabSelected(SOFTWARE_TAB_INDEX)">
<device-software #softwareId [deviceId]="deviceId" [listHeight]="listHeight"></device-software>
<device-software #softwareId [deviceId]="deviceId" [listHeight]="listHeight" (countChanged)="countChanged($event)"></device-software>
</div>
</div>
</div>
Expand Down
48 changes: 46 additions & 2 deletions src/organization/device/device_detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ export class DeviceDetailComponent implements OnInit {
public PATCH_TAB_INDEX = 4;
public INCIDENT_TAB_INDEX = 3;
public CONFIGURATION_TAB_INDEX = 1;

public numGpos = 0;
public numIncidents = 0;
public numLoggedinusers = 0;
public numPatches = 0;
public numSoftware = 0;
public numVulnerabilities = 0;
public isGposTabActive = false;
public isIncidentsTabActive = false;
public isLoggedinusersTabActive = false;
public isPatchesTabActive = false;
public isSoftwareTabActive = false;
public isVulnerabilitiesTabActive = false;

constructor(private serviceDeviceGroupPolicy: DeviceGroupPolicyService, private serviceDeviceSoftware: DeviceSoftwareService, private serviceDeviceUser : DeviceUserService,
private serviceDeviceVulnerability: DeviceVulnerabilityService, private service: DeviceService, private route: ActivatedRoute, private router: Router,
Expand Down Expand Up @@ -304,6 +315,18 @@ export class DeviceDetailComponent implements OnInit {
}
}
this.response = r;
this.numGpos = this.response.num_gpos;
this.numIncidents = this.response.num_incidents;
this.numLoggedinusers = this.response.num_loggedinusers;
this.numPatches = this.response.num_patches;
this.numSoftware = this.response.num_software;
this.numVulnerabilities = this.response.num_vulnerabilities;
this.isVulnerabilitiesTabActive = this.response.num_vulnerabilities > 0;
this.isGposTabActive = this.response.num_gpos > 0;
this.isIncidentsTabActive = this.response.num_incidents > 0;
this.isLoggedinusersTabActive = this.response.num_loggedinusers > 0;
this.isPatchesTabActive = this.response.num_patches > 0;
this.isSoftwareTabActive = this.response.num_software > 0;
this.breadcrumbService.setBreadcrumbLabel(this.response.item.hostname);
this.breadcrumbService.replaceBreadcrumbUrl(this.getRoutePath('/device'), this.getRoutePath('/device') + '?id=' + this.response.item.id);
}
Expand Down Expand Up @@ -479,7 +502,7 @@ export class DeviceDetailComponent implements OnInit {
this.serviceDeviceGroupPolicy.userFiltersState = {};
}
if (this.isTabSelected(this.SOFTWARE_TAB_INDEX)) {
this.serviceDeviceSoftware.userFiltersState = {};
this.serviceDeviceSoftware.userFiltersState = {};
}
callback();
}
Expand Down Expand Up @@ -577,6 +600,27 @@ export class DeviceDetailComponent implements OnInit {
onResize($event) {
this.listHeight = this.getListHeight();
}

countChanged(event) {
if(this.isTabSelected(this.VULNERABILITY_TAB_INDEX)) {
this.numVulnerabilities = event;
}
else if(this.isTabSelected(this.USER_TAB_INDEX)) {
this.numLoggedinusers = event;
}
else if(this.isTabSelected(this.GROUP_POLICY_TAB_INDEX)) {
this.numGpos = event;
}
else if(this.isTabSelected(this.SOFTWARE_TAB_INDEX)) {
this.numSoftware = event;
}
else if(this.isTabSelected(this.INCIDENT_TAB_INDEX)) {
this.numIncidents = event;
}
else if(this.isTabSelected(this.PATCH_TAB_INDEX)) {
this.numPatches = event;
}
}
}

class Profile {
Expand Down
7 changes: 6 additions & 1 deletion src/organization/device/device_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ export interface DeviceDetailResponse {
available_assignments: Array<DeviceAvailableAssigmentItem>;
assignments: Array<DeviceAssigmentItem>;
loggedin_users: Array<LoggedInUserDetailItem>;
num_vulnerabilities: number;
software_inventory: Array<DeviceSoftwareItem>;
num_gpos: number;
num_incidents: number;
num_loggedinusers: number;
num_patches: number;
num_software: number;
num_vulnerabilities: number;
}


Expand Down

0 comments on commit 511ca8a

Please sign in to comment.