Skip to content

Commit

Permalink
Merge pull request primefaces#506 from atretyak1985/issue_#NNTR-511
Browse files Browse the repository at this point in the history
[NNTR-511]Switch framework UI
  • Loading branch information
Gunnsteinn Hall authored Apr 1, 2020
2 parents 769e7e4 + 0af38a8 commit f428391
Show file tree
Hide file tree
Showing 45 changed files with 364 additions and 255 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div id="device-export-dialog" class="modal fade" role="dialog" tabindex="-1">
<div id="export-csv-dialog" class="modal fade" role="dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title">Export assets list</h2>
<h2 class="modal-title">{{ headerText }}</h2>
</div>
<div class="modal-body" style="padding:40px; background-color: #ffffff">
<div class="customize-column-dropdown">
Expand All @@ -12,7 +12,7 @@ <h2 class="modal-title">Export assets list</h2>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-default btn-lg btn-lg-width">Cancel</button>
<button type="button" class="btn btn-lg btn-success btn-lg-width" (click)="exportCSV()">Export CSV</button>
<button type="button" class="btn btn-lg btn-success btn-lg-width" (click)="exportCSVConfirm()">Export CSV</button>
</div>
</div>
</div>
Expand Down
46 changes: 46 additions & 0 deletions src/common/modal_dialog/export_csv_dialog.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';


@Component({
selector: 'export-csv-dialog',
templateUrl: 'export_csv_dialog.component.html'
})

export class ExportCSVDialogComponent implements OnInit {
@Input() headerText: string = 'Dialog';
@Input() limit: number = 200;
@Output() onExportCSV = new EventEmitter<number>();
public itemExportForm: RequestExportForm;
public exportLimitOptions: any = [
{ label: '50', value: 50 },
{ label: '200', value: 200 },
{ label: '1000', value: 1000 },
{ label: '5000', value: 5000 },
{ label: '10000', value: 10000 }
];

constructor() { }

ngOnInit() {
this.itemExportForm = {
limit: this.limit
} as RequestExportForm;
}

show() {
this.itemExportForm['limit'] = this.limit;
jQuery('#export-csv-dialog').modal('show');
}

hide() {
jQuery('#export-csv-dialog').modal('hide');
}

exportCSVConfirm() {
this.onExportCSV.emit(this.itemExportForm.limit);
}
}

export interface RequestExportForm {
limit: number;
}
33 changes: 18 additions & 15 deletions src/common/nancommon.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ import { RatingFilterSectionComponent } from './side_filter/side_filter_section/
import { SelectButtonModule } from 'primeng/primeng';
import { TableModule } from 'primeng/table';
import { AssetTypeFilterComponent } from './filter_pane/asset-type-filter.component';
import { DeviceLabelDialogComponent } from 'organization/device/modal/device_detail/device_label_dialog.component';
import { RequestRechecksDialogComponent } from 'organization/device/modal/device_detail/request_rechecks_dialog.component';
import { PdfReportDialogComponent } from 'organization/device/modal/device_detail/pdf_report_dialog.component';
import { DeviceExcludeExceptionDialogComponent } from 'organization/device/modal/device_detail/device_exclude_exception_dialog.component';
import { DeviceRemoveExceptionDialogComponent } from 'organization/device/modal/device_detail/device_remove_exception_dialog.component';
import { DeviceColumnsDialogComponent } from 'organization/device/modal/device_list/device_columns_dialog.component';
import { DeviceLabelDialogComponent } from 'organization/device/modal_dialog/device_detail/device_label_dialog.component';
import { RequestRechecksDialogComponent } from 'organization/device/modal_dialog/device_detail/request_rechecks_dialog.component';
import { PdfReportDialogComponent } from 'organization/device/modal_dialog/device_detail/pdf_report_dialog.component';
import { DeviceExcludeExceptionDialogComponent } from 'organization/device/modal_dialog/device_detail/device_exclude_exception_dialog.component';
import { DeviceRemoveExceptionDialogComponent } from 'organization/device/modal_dialog/device_detail/device_remove_exception_dialog.component';
import { DeviceColumnsDialogComponent } from 'organization/device/modal_dialog/device_list/device_columns_dialog.component';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { DeviceUpgradeDialogComponent } from 'organization/device/modal/device_list/device_upgrade_dialog.component';
import { DeviceExportDialogComponent } from 'organization/device/modal/device_list/device_export_dialog.component';
import { ApplyLabelDialogComponent } from 'organization/device/modal/device_list/apply_label_dialog.component';
import { WhitelistingStateDialogComponent } from 'organization/software/table/dialog/whitelisting_state_dialog.component';
import { ConfirmDialogComponent } from './modal-dialog/confirm_dialog.component';
import { DeviceUpgradeDialogComponent } from 'organization/device/modal_dialog/device_list/device_upgrade_dialog.component';
import { ExportCSVDialogComponent } from 'common/modal_dialog/export_csv_dialog.component';
import { ApplyLabelDialogComponent } from 'organization/device/modal_dialog/device_list/apply_label_dialog.component';
import { WhitelistingStateDialogComponent } from 'organization/software/modal_dialog/whitelisting_state_dialog.component';
import { ConfirmDialogComponent } from './modal_dialog/confirm_dialog.component';
import { WhitelistingFilterComponent } from './filter_pane/whitelisting-filter.component';
import { RiscFilterSectionComponent } from './side_filter/side_filter_section/risc-filter-section.component';
import { SwitchingFrameworkDialogComponent } from 'organization/issue/modal_dialog/switching_framework_dialog.component';


@NgModule({
Expand All @@ -67,7 +68,7 @@ import { RiscFilterSectionComponent } from './side_filter/side_filter_section/ri
LabelCreateDialogComponent,
DeviceColumnsDialogComponent,
DeviceUpgradeDialogComponent,
DeviceExportDialogComponent,
ExportCSVDialogComponent,
ApplyLabelDialogComponent,
OSFilterSectionComponent,
RatingFilterSectionComponent,
Expand All @@ -82,7 +83,8 @@ import { RiscFilterSectionComponent } from './side_filter/side_filter_section/ri
WhitelistingStateDialogComponent,
ConfirmDialogComponent,
WhitelistingFilterComponent,
RiscFilterSectionComponent
RiscFilterSectionComponent,
SwitchingFrameworkDialogComponent
],
imports: [
// Angular modules
Expand Down Expand Up @@ -124,7 +126,7 @@ import { RiscFilterSectionComponent } from './side_filter/side_filter_section/ri
LabelCreateDialogComponent,
DeviceColumnsDialogComponent,
DeviceUpgradeDialogComponent,
DeviceExportDialogComponent,
ExportCSVDialogComponent,
ApplyLabelDialogComponent,
OSFilterSectionComponent,
RatingFilterSectionComponent,
Expand All @@ -139,7 +141,8 @@ import { RiscFilterSectionComponent } from './side_filter/side_filter_section/ri
WhitelistingStateDialogComponent,
ConfirmDialogComponent,
WhitelistingFilterComponent,
RiscFilterSectionComponent
RiscFilterSectionComponent,
SwitchingFrameworkDialogComponent
]
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { SettingTabSoftwareService } from './software.service';
import { BasicResponse } from 'account/basic_response';
import { ConfirmDialogComponent } from 'common/modal-dialog/confirm_dialog.component';
import { ConfirmDialogComponent } from 'common/modal_dialog/confirm_dialog.component';


@Component({
Expand Down
10 changes: 5 additions & 5 deletions src/organization/device/device_detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { DeviceSubnetService } from './detail/subnet/device-subnet.service';
import { DeviceIssueService } from './detail/issue/device-issue.service';
import { DeviceIssueComponent } from './detail/issue/device-issue.component';
import { DeviceActivityLogComponent } from './detail/activity_log/device-activity_log.component';
import { DeviceLabelDialogComponent } from './modal/device_detail/device_label_dialog.component';
import { RequestRechecksDialogComponent } from './modal/device_detail/request_rechecks_dialog.component';
import { PdfReportDialogComponent } from './modal/device_detail/pdf_report_dialog.component';
import { DeviceExcludeExceptionDialogComponent } from './modal/device_detail/device_exclude_exception_dialog.component';
import { DeviceRemoveExceptionDialogComponent } from './modal/device_detail/device_remove_exception_dialog.component';
import { DeviceLabelDialogComponent } from './modal_dialog/device_detail/device_label_dialog.component';
import { RequestRechecksDialogComponent } from './modal_dialog/device_detail/request_rechecks_dialog.component';
import { PdfReportDialogComponent } from './modal_dialog/device_detail/pdf_report_dialog.component';
import { DeviceExcludeExceptionDialogComponent } from './modal_dialog/device_detail/device_exclude_exception_dialog.component';
import { DeviceRemoveExceptionDialogComponent } from './modal_dialog/device_detail/device_remove_exception_dialog.component';


@Component({
Expand Down
12 changes: 10 additions & 2 deletions src/organization/device/device_list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ <h1 class="panel-title">
(emitCustomizedColumns)='emitCustomizedColumns($event)'>
</device-columns-dialog>

<device-export-dialog [selectedItems]='selectedItems' [limit]='200'></device-export-dialog>
<export-csv-dialog
[headerText]="'Export assets list'"
[limit]='200'
(onExportCSV)="exportCSV($event)">
</export-csv-dialog>

<device-upgrade-dialog [selectedItems]='selectedItems' [limit]='10000' (refresh)='refresh()'></device-upgrade-dialog>
<device-upgrade-dialog
[selectedItems]='selectedItems'
[limit]='10000'
(refresh)='refresh()'>
</device-upgrade-dialog>
32 changes: 26 additions & 6 deletions src/organization/device/device_list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { DeviceListItem, DeviceListResponse, ApplyLabelListItem } from './device
import { ColumnWithSort } from 'common/object';
import { LabelCreateDialogComponent } from 'organization/admin/label/label_create_dialog.component';
import { BaseDevice } from './base/base_device';
import { DeviceColumnsDialogComponent } from './modal/device_list/device_columns_dialog.component';
import { DeviceExportDialogComponent } from './modal/device_list/device_export_dialog.component';
import { DeviceUpgradeDialogComponent } from './modal/device_list/device_upgrade_dialog.component';
import { ApplyLabelDialogComponent } from './modal/device_list/apply_label_dialog.component';
import { DeviceColumnsDialogComponent } from './modal_dialog/device_list/device_columns_dialog.component';
import { ExportCSVDialogComponent } from '../../common/modal_dialog/export_csv_dialog.component';
import { DeviceUpgradeDialogComponent } from './modal_dialog/device_list/device_upgrade_dialog.component';
import { ApplyLabelDialogComponent } from './modal_dialog/device_list/apply_label_dialog.component';
import * as FileSaver from 'file-saver';


@Component({
Expand All @@ -22,7 +23,7 @@ import { ApplyLabelDialogComponent } from './modal/device_list/apply_label_dialo
export class DeviceListComponent extends BaseDevice {
@ViewChild(LabelCreateDialogComponent, { static: true }) labelCreateDialog: LabelCreateDialogComponent;
@ViewChild(DeviceColumnsDialogComponent, { static: true }) deviceColumnsDialog: DeviceColumnsDialogComponent;
@ViewChild(DeviceExportDialogComponent, { static: true }) deviceExportDialog: DeviceExportDialogComponent;
@ViewChild(ExportCSVDialogComponent, { static: true }) exportCSVDialog: ExportCSVDialogComponent;
@ViewChild(DeviceUpgradeDialogComponent, { static: true }) deviceUpgradeDialog: DeviceUpgradeDialogComponent;
@ViewChild(ApplyLabelDialogComponent, { static: true }) applyLabelDialog: ApplyLabelDialogComponent;
public disabledColumns: Object;
Expand Down Expand Up @@ -146,7 +147,26 @@ export class DeviceListComponent extends BaseDevice {
}

clickOpenExportDialog() {
this.deviceExportDialog.show();
this.exportCSVDialog.show();
}

exportCSV(limit: number) {
const selectedItemIds = this.selectedItems.map((item) => {
return item.id;
});
const filename = 'nanitor_device_list.csv';
this.service.spinnerService.setState(true);
this.service.getDevicesInCsv(selectedItemIds, limit).subscribe(
(blob: Blob) => {
FileSaver.saveAs(blob, filename);
this.service.spinnerService.setState(false);
},
err => {
this.service.spinnerService.setState(false);
this.flashService.addItemFromStatus(400, 'Failed to export CSV', true);
}
);
this.exportCSVDialog.hide();
}

emitCustomizedColumns(event) {
Expand Down
4 changes: 0 additions & 4 deletions src/organization/device/device_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ export interface RequestCheckinForm {
patches_recheck: boolean;
}

export interface RequestExportForm {
limit: number;
}

export interface ApplyLabelListItem extends LabelListItem {
state: any;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { RequestExportForm } from '../../device_response';
import { BasicResponse } from 'common/response';
import { DeviceService } from '../../device.service';
import { AccountService } from 'account/account.service';
Expand Down Expand Up @@ -54,3 +53,7 @@ export class DeviceUpgradeDialogComponent implements OnInit {
);
}
}

export interface RequestExportForm {
limit: number;
}
22 changes: 22 additions & 0 deletions src/organization/issue/issue-compliance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ import { SpinnerService } from 'common/spinner/spinner.service';

@Injectable()
export class IssueComplianceService extends BaseListService {
private _frameworkId: number;
public get frameworkId(): number {
return this._frameworkId;
}
public set frameworkId(value: number) {
this._frameworkId = value;
}

constructor(protected accountService: AccountService, protected spinnerService: SpinnerService) {
super(accountService, spinnerService);

this.frameworkId = null;
this.path = `/organization/${this.accountService.getOrganizationId()}/issue/compliance_list`;
}

Expand All @@ -17,4 +26,17 @@ export class IssueComplianceService extends BaseListService {
data['parent_control_id'] = controlId;
return this.accountService.executePost(`/organization/${this.accountService.getOrganizationId()}/issue/compliance_list`, data);
}

getRequest(requestPage) {
let request = {
filters: this.getFilters(),
limit: this.requestLimit,
sort: this.listSorting,
page: requestPage,
};
if (this.frameworkId !== null) {
request['org_framework_id'] = this.frameworkId;
}
return request;
}
}
Loading

0 comments on commit f428391

Please sign in to comment.