From 7d310a5e82a8ff60e3d16be95588d1af1158be5f Mon Sep 17 00:00:00 2001 From: Andriy Tretyak Date: Tue, 12 Mar 2019 18:16:17 +0200 Subject: [PATCH] Filters required in Device Detail -> Vulnerabilities tab #154 and Filters required in Device Detail -> Software tab #155 and Filters required in Device Detail -> Users tab #156 and Filters required in Device Detail -> Group Policy Objects tab #157 --- .../device-group-policy.component.ts | 6 +- .../device-group-policy.service.ts | 23 +- .../incident/device-incident.component.ts | 3 +- .../detail/patch/device-patch.component.ts | 3 +- .../software/device-software.component.ts | 9 +- .../software/device-software.service.ts | 31 +- .../detail/user/device-user.component.ts | 6 +- .../device/detail/user/device-user.service.ts | 23 +- .../device-vulnerability.component.ts | 7 +- .../device-vulnerability.service.ts | 23 +- .../device/device_detail.component.html | 506 ++++++++++-------- .../device/device_detail.component.ts | 135 +++-- .../device/device_list.component.ts | 4 +- .../incident/incident_devices.service.ts | 160 ++++++ src/organization/organization.module.ts | 10 +- .../vulnerability_list.component.ts | 1 + 16 files changed, 662 insertions(+), 288 deletions(-) create mode 100644 src/organization/incident/incident_devices.service.ts diff --git a/src/organization/device/detail/group-policy/device-group-policy.component.ts b/src/organization/device/detail/group-policy/device-group-policy.component.ts index 08f1daf249d..2b981db0c72 100755 --- a/src/organization/device/detail/group-policy/device-group-policy.component.ts +++ b/src/organization/device/detail/group-policy/device-group-policy.component.ts @@ -7,15 +7,13 @@ import { Router } from '@angular/router'; @Component({ selector: 'device-group-policy', - templateUrl: 'device-group-policy.component.html', - providers: [DeviceGroupPolicyService] + templateUrl: 'device-group-policy.component.html' }) export class DeviceGroupPolicyComponent implements OnInit { @Input() deviceId; - @Input() listHeight; - + @Input() listHeight: string; @ViewChild('table') table: Table; public ROWS: number = 20; diff --git a/src/organization/device/detail/group-policy/device-group-policy.service.ts b/src/organization/device/detail/group-policy/device-group-policy.service.ts index 9fdc12eb690..7b29e20ae20 100755 --- a/src/organization/device/detail/group-policy/device-group-policy.service.ts +++ b/src/organization/device/detail/group-policy/device-group-policy.service.ts @@ -4,7 +4,8 @@ import { Observable } from 'rxjs'; import { AccountService } from 'account/account.service'; import { SpinnerService } from 'common/spinner/spinner.service'; import { DeviceGroupPolicyRequest, DeviceGroupPolicyResponse, DeviceGroupPolicyItem } from './device-group-policy.response'; -import { map, debounceTime, share } from 'rxjs/operators'; +import { share } from 'rxjs/operators'; +import { FilterBuilder } from 'common/filter_builder/filter-builder'; @Injectable() export class DeviceGroupPolicyService { @@ -18,6 +19,8 @@ export class DeviceGroupPolicyService { private detailSorting: Array; private detailObserver: any; private detailPage: number; + public profileFilters: Filter[]; + public userFiltersState: Object; constructor( public accountService: AccountService, @@ -28,6 +31,7 @@ export class DeviceGroupPolicyService { this.detailRequest = new DeviceGroupPolicyRequest(); this.detailUserFilters = []; this.detailPage = 0; + this.userFiltersState = {}; } getGroupPolisies(deviceId: number, page: number, limit: number, force: boolean) { @@ -41,6 +45,7 @@ export class DeviceGroupPolicyService { this.detailRequest.page = page; this.detailRequest.limit = limit; this.detailRequest.device_id = deviceId; + this.detailRequest.filters = this.getFilters(); this.accountService.executePost(`/organization/${this.accountService.getOrganizationId()}/device/group_policy_list`, this.detailRequest) @@ -62,4 +67,20 @@ export class DeviceGroupPolicyService { }); } + + setProfileFilters(filters: Filter[]) { + this.profileFilters = filters; + } + + getFilters() { + let filters = new Array(); + if (this.userFiltersState) { + filters = FilterBuilder.getConstructedFilters(this.userFiltersState); + } + if (this.profileFilters != null) { + filters = filters.concat(this.profileFilters); + } + + return filters; + } } diff --git a/src/organization/device/detail/incident/device-incident.component.ts b/src/organization/device/detail/incident/device-incident.component.ts index a12dd1d0ae3..4ad0dfd4a62 100755 --- a/src/organization/device/detail/incident/device-incident.component.ts +++ b/src/organization/device/detail/incident/device-incident.component.ts @@ -7,8 +7,7 @@ import { Severity } from 'common/enum'; @Component({ selector: 'device-incident', - templateUrl: 'device-incident.component.html', - providers: [DeviceIncidentService] + templateUrl: 'device-incident.component.html' }) export class DeviceIncidentComponent implements OnInit { diff --git a/src/organization/device/detail/patch/device-patch.component.ts b/src/organization/device/detail/patch/device-patch.component.ts index 690c06dbd77..f68e6d26314 100755 --- a/src/organization/device/detail/patch/device-patch.component.ts +++ b/src/organization/device/detail/patch/device-patch.component.ts @@ -7,8 +7,7 @@ import { Router } from '@angular/router'; @Component({ selector: 'device-patch', - templateUrl: 'device-patch.component.html', - providers: [DevicePatchService] + templateUrl: 'device-patch.component.html' }) export class DevicePatchComponent implements OnInit { diff --git a/src/organization/device/detail/software/device-software.component.ts b/src/organization/device/detail/software/device-software.component.ts index 43f8d68c830..e2e119a0d32 100755 --- a/src/organization/device/detail/software/device-software.component.ts +++ b/src/organization/device/detail/software/device-software.component.ts @@ -4,18 +4,17 @@ import { Table } from 'primeng/table'; import { DeviceSoftwareService } from './device-software.service'; import { DeviceSoftwareItem, DeviceSoftwareResponse } from './device-software.response'; + @Component({ selector: 'device-software', - templateUrl: 'device-software.component.html', - providers: [DeviceSoftwareService] + templateUrl: 'device-software.component.html' }) export class DeviceSoftwareComponent implements OnInit { @Input() deviceId; - @Input() listHeight; - @ViewChild('table') table: Table; + @Input() listHeight: string; public ROWS: number = 20; @@ -25,7 +24,7 @@ export class DeviceSoftwareComponent implements OnInit { private response: DeviceSoftwareResponse; constructor( - private service: DeviceSoftwareService, + public service: DeviceSoftwareService, private renderer: Renderer2 ) { this.response = null; diff --git a/src/organization/device/detail/software/device-software.service.ts b/src/organization/device/detail/software/device-software.service.ts index edbcf2150e3..ff91cadd484 100755 --- a/src/organization/device/detail/software/device-software.service.ts +++ b/src/organization/device/detail/software/device-software.service.ts @@ -4,7 +4,8 @@ import { Observable } from 'rxjs'; import { AccountService } from 'account/account.service'; import { SpinnerService } from 'common/spinner/spinner.service'; import { DeviceSoftwareRequest, DeviceSoftwareResponse, DeviceSoftwareItem } from './device-software.response'; -import { map, debounceTime, share } from 'rxjs/operators'; +import { share } from 'rxjs/operators'; +import { FilterBuilder } from 'common/filter_builder/filter-builder'; @Injectable() export class DeviceSoftwareService { @@ -18,6 +19,8 @@ export class DeviceSoftwareService { private detailSorting: Array; private detailObserver: any; private detailPage: number; + public profileFilters: Filter[]; + public userFiltersState: Object; constructor( public accountService: AccountService, @@ -28,6 +31,7 @@ export class DeviceSoftwareService { this.detailRequest = new DeviceSoftwareRequest(); this.detailUserFilters = []; this.detailPage = 0; + this.userFiltersState = {}; } getSoftware(deviceId: number, page: number, limit: number, force: boolean) { @@ -41,6 +45,8 @@ export class DeviceSoftwareService { this.detailRequest.page = page; this.detailRequest.limit = limit; this.detailRequest.device_id = deviceId; + this.detailRequest.filters = this.getFilters(); + this.accountService.executePost(`/organization/${this.accountService.getOrganizationId()}/device/software_list`, this.detailRequest) @@ -52,7 +58,12 @@ export class DeviceSoftwareService { } this.detailPage = page; this.detailItems = this.detailResponse.items; - this.detailObserver.next(this.detailResponse); + + if(this.detailObserver) + { + this.detailObserver.next(this.detailResponse); + } + this.spinnerService.setState(false); }, error => { @@ -62,4 +73,20 @@ export class DeviceSoftwareService { }); } + + setProfileFilters(filters: Filter[]) { + this.profileFilters = filters; + } + + getFilters() { + let filters = new Array(); + if (this.userFiltersState) { + filters = FilterBuilder.getConstructedFilters(this.userFiltersState); + } + if (this.profileFilters != null) { + filters = filters.concat(this.profileFilters); + } + + return filters; + } } diff --git a/src/organization/device/detail/user/device-user.component.ts b/src/organization/device/detail/user/device-user.component.ts index 51aeda927dc..b736acf59b0 100755 --- a/src/organization/device/detail/user/device-user.component.ts +++ b/src/organization/device/detail/user/device-user.component.ts @@ -7,15 +7,13 @@ import { Router } from '@angular/router'; @Component({ selector: 'device-user', - templateUrl: 'device-user.component.html', - providers: [DeviceUserService] + templateUrl: 'device-user.component.html' }) export class DeviceUserComponent implements OnInit { @Input() deviceId; - @Input() listHeight; - + @Input() listHeight: string; @ViewChild('table') table: Table; public ROWS: number = 20; diff --git a/src/organization/device/detail/user/device-user.service.ts b/src/organization/device/detail/user/device-user.service.ts index ea2979df9f0..4b2f068b8a3 100755 --- a/src/organization/device/detail/user/device-user.service.ts +++ b/src/organization/device/detail/user/device-user.service.ts @@ -4,7 +4,8 @@ import { Observable } from 'rxjs'; import { AccountService } from 'account/account.service'; import { SpinnerService } from 'common/spinner/spinner.service'; import { DeviceUserRequest, DeviceUserResponse, DeviceUserItem } from './device-user.response'; -import { map, debounceTime, share } from 'rxjs/operators'; +import { share } from 'rxjs/operators'; +import { FilterBuilder } from 'common/filter_builder/filter-builder'; @Injectable() export class DeviceUserService { @@ -18,6 +19,8 @@ export class DeviceUserService { private detailSorting: Array; private detailObserver: any; private detailPage: number; + public profileFilters: Filter[]; + public userFiltersState: Object; constructor( public accountService: AccountService, @@ -28,6 +31,7 @@ export class DeviceUserService { this.detailRequest = new DeviceUserRequest(); this.detailUserFilters = []; this.detailPage = 0; + this.userFiltersState = {}; } getUsers(deviceId: number, page: number, limit: number, force: boolean) { @@ -41,6 +45,7 @@ export class DeviceUserService { this.detailRequest.page = page; this.detailRequest.limit = limit; this.detailRequest.device_id = deviceId; + this.detailRequest.filters = this.getFilters(); this.accountService.executePost(`/organization/${this.accountService.getOrganizationId()}/device/loggedinuser_list`, this.detailRequest) @@ -62,4 +67,20 @@ export class DeviceUserService { }); } + + setProfileFilters(filters: Filter[]) { + this.profileFilters = filters; + } + + getFilters() { + let filters = new Array(); + if (this.userFiltersState) { + filters = FilterBuilder.getConstructedFilters(this.userFiltersState); + } + if (this.profileFilters != null) { + filters = filters.concat(this.profileFilters); + } + + return filters; + } } diff --git a/src/organization/device/detail/vulnerability/device-vulnerability.component.ts b/src/organization/device/detail/vulnerability/device-vulnerability.component.ts index 38901077418..2a5a478b92f 100755 --- a/src/organization/device/detail/vulnerability/device-vulnerability.component.ts +++ b/src/organization/device/detail/vulnerability/device-vulnerability.component.ts @@ -7,19 +7,16 @@ import { Router } from '@angular/router'; @Component({ selector: 'device-vulnerability', - templateUrl: 'device-vulnerability.component.html', - providers: [DeviceVulnerabilityService] + templateUrl: 'device-vulnerability.component.html' }) export class DeviceVulnerabilityComponent implements OnInit { @Input() deviceId; - @Input() listHeight; - @ViewChild('table') table: Table; + @Input() listHeight: string; public ROWS: number = 20; - public cols: Array; public totalRecords: number; public items: Array; diff --git a/src/organization/device/detail/vulnerability/device-vulnerability.service.ts b/src/organization/device/detail/vulnerability/device-vulnerability.service.ts index 34c47f8ba1a..ad916e76eba 100755 --- a/src/organization/device/detail/vulnerability/device-vulnerability.service.ts +++ b/src/organization/device/detail/vulnerability/device-vulnerability.service.ts @@ -4,7 +4,8 @@ import { Filter, ColumnSort } from 'common/object'; import { Observable } from 'rxjs'; import { AccountService } from 'account/account.service'; import { SpinnerService } from 'common/spinner/spinner.service'; -import { map, debounceTime, share } from 'rxjs/operators'; +import { share } from 'rxjs/operators'; +import { FilterBuilder } from 'common/filter_builder/filter-builder'; @Injectable() export class DeviceVulnerabilityService { @@ -18,6 +19,8 @@ export class DeviceVulnerabilityService { private detailSorting: Array; private detailObserver: any; private detailPage: number; + public profileFilters: Filter[]; + public userFiltersState: Object; constructor( public accountService: AccountService, @@ -28,6 +31,7 @@ export class DeviceVulnerabilityService { this.detailRequest = new DeviceVulnerabilityRequest(); this.detailUserFilters = []; this.detailPage = 0; + this.userFiltersState = {}; } getVulnerabilities(deviceId: number, page: number, limit: number, force: boolean) { @@ -41,6 +45,7 @@ export class DeviceVulnerabilityService { this.detailRequest.page = page; this.detailRequest.limit = limit; this.detailRequest.device_id = deviceId; + this.detailRequest.filters = this.getFilters(); this.accountService.executePost(`/organization/${this.accountService.getOrganizationId()}/device/vulnerability/list`, this.detailRequest) @@ -62,4 +67,20 @@ export class DeviceVulnerabilityService { }); } + + setProfileFilters(filters: Filter[]) { + this.profileFilters = filters; + } + + getFilters() { + let filters = new Array(); + if (this.userFiltersState) { + filters = FilterBuilder.getConstructedFilters(this.userFiltersState); + } + if (this.profileFilters != null) { + filters = filters.concat(this.profileFilters); + } + + return filters; + } } diff --git a/src/organization/device/device_detail.component.html b/src/organization/device/device_detail.component.html index 19e046225f6..0e8a9ff5527 100644 --- a/src/organization/device/device_detail.component.html +++ b/src/organization/device/device_detail.component.html @@ -1,253 +1,303 @@
-
-
-
-

- Details for {{ response.item.hostname }} - - -

+ + + + + + + + + + + + +
+ + + + + + + + + + + + +
-
-