Skip to content

Commit

Permalink
Filters required in Device Detail -> Vulnerabilities tab primefaces#154
Browse files Browse the repository at this point in the history
and
Filters required in Device Detail -> Software tab primefaces#155
and
Filters required in Device Detail -> Users tab primefaces#156
and
Filters required in Device Detail -> Group Policy Objects tab primefaces#157
  • Loading branch information
atretyak1985 committed Mar 13, 2019
1 parent 10ed43f commit 7d310a5
Show file tree
Hide file tree
Showing 16 changed files with 662 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -18,6 +19,8 @@ export class DeviceGroupPolicyService {
private detailSorting: Array<ColumnSort>;
private detailObserver: any;
private detailPage: number;
public profileFilters: Filter[];
public userFiltersState: Object;

constructor(
public accountService: AccountService,
Expand All @@ -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) {
Expand All @@ -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)

Expand All @@ -62,4 +67,20 @@ export class DeviceGroupPolicyService {
});

}

setProfileFilters(filters: Filter[]) {
this.profileFilters = filters;
}

getFilters() {
let filters = new Array<Filter>();
if (this.userFiltersState) {
filters = FilterBuilder.getConstructedFilters(this.userFiltersState);
}
if (this.profileFilters != null) {
filters = filters.concat(this.profileFilters);
}

return filters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
31 changes: 29 additions & 2 deletions src/organization/device/detail/software/device-software.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -18,6 +19,8 @@ export class DeviceSoftwareService {
private detailSorting: Array<ColumnSort>;
private detailObserver: any;
private detailPage: number;
public profileFilters: Filter[];
public userFiltersState: Object;

constructor(
public accountService: AccountService,
Expand All @@ -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) {
Expand All @@ -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)

Expand All @@ -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 => {
Expand All @@ -62,4 +73,20 @@ export class DeviceSoftwareService {
});

}

setProfileFilters(filters: Filter[]) {
this.profileFilters = filters;
}

getFilters() {
let filters = new Array<Filter>();
if (this.userFiltersState) {
filters = FilterBuilder.getConstructedFilters(this.userFiltersState);
}
if (this.profileFilters != null) {
filters = filters.concat(this.profileFilters);
}

return filters;
}
}
6 changes: 2 additions & 4 deletions src/organization/device/detail/user/device-user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 22 additions & 1 deletion src/organization/device/detail/user/device-user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -18,6 +19,8 @@ export class DeviceUserService {
private detailSorting: Array<ColumnSort>;
private detailObserver: any;
private detailPage: number;
public profileFilters: Filter[];
public userFiltersState: Object;

constructor(
public accountService: AccountService,
Expand All @@ -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) {
Expand All @@ -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)

Expand All @@ -62,4 +67,20 @@ export class DeviceUserService {
});

}

setProfileFilters(filters: Filter[]) {
this.profileFilters = filters;
}

getFilters() {
let filters = new Array<Filter>();
if (this.userFiltersState) {
filters = FilterBuilder.getConstructedFilters(this.userFiltersState);
}
if (this.profileFilters != null) {
filters = filters.concat(this.profileFilters);
}

return filters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ColumnWithSort>;
public totalRecords: number;
public items: Array<DeviceVulnerabilityItem>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -18,6 +19,8 @@ export class DeviceVulnerabilityService {
private detailSorting: Array<ColumnSort>;
private detailObserver: any;
private detailPage: number;
public profileFilters: Filter[];
public userFiltersState: Object;

constructor(
public accountService: AccountService,
Expand All @@ -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) {
Expand All @@ -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)

Expand All @@ -62,4 +67,20 @@ export class DeviceVulnerabilityService {
});

}

setProfileFilters(filters: Filter[]) {
this.profileFilters = filters;
}

getFilters() {
let filters = new Array<Filter>();
if (this.userFiltersState) {
filters = FilterBuilder.getConstructedFilters(this.userFiltersState);
}
if (this.profileFilters != null) {
filters = filters.concat(this.profileFilters);
}

return filters;
}
}
Loading

0 comments on commit 7d310a5

Please sign in to comment.