Skip to content

Commit

Permalink
Merge pull request primefaces#525 from atretyak1985/issue_#NNTR-558
Browse files Browse the repository at this point in the history
[NNTR-558]Added functionality - closes the modal window after navigating to ano…
  • Loading branch information
Gunnsteinn Hall authored May 5, 2020
2 parents 69f39c4 + 48faac6 commit 8a9362d
Show file tree
Hide file tree
Showing 19 changed files with 314 additions and 89 deletions.
21 changes: 16 additions & 5 deletions src/common/modal_dialog/confirm_dialog.component.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Component, Input, Output, EventEmitter, AfterViewInit, OnDestroy } from '@angular/core';
import { CommonHelpers } from 'common/helpers';


@Component({
selector: 'confirm-dialog',
templateUrl: 'confirm_dialog.component.html'
})

export class ConfirmDialogComponent {
export class ConfirmDialogComponent implements AfterViewInit, OnDestroy {
private static dialogSelector: string = '#confirm-dialog';
@Input() isAdmin: boolean = false;
@Input() headerText: string = 'Dialog';
@Input() bodyText: string = 'Are you sure you want to do this?';
@Output() onConfirm = new EventEmitter();

ngAfterViewInit() {
CommonHelpers.dialogBackHandler(ConfirmDialogComponent.dialogSelector);
}

ngOnDestroy() {
jQuery(ConfirmDialogComponent.dialogSelector).off();
jQuery(window).off('popstate');
}

show() {
jQuery('#confirm-dialog').modal('show');
jQuery(ConfirmDialogComponent.dialogSelector).modal('show');
}

hide() {
jQuery('#confirm-dialog').modal('hide');
jQuery(ConfirmDialogComponent.dialogSelector).modal('hide');
}

clickConfirm() {
this.onConfirm.emit();
this.onConfirm.emit();
}
}
19 changes: 15 additions & 4 deletions src/common/modal_dialog/export_csv_dialog.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { Component, Input, Output, EventEmitter, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
import { CommonHelpers } from 'common/helpers';


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

export class ExportCSVDialogComponent implements OnInit {
export class ExportCSVDialogComponent implements OnInit, AfterViewInit, OnDestroy {
private static dialogSelector: string = '#export-csv-dialog';
@Input() headerText: string = 'Dialog';
@Input() limit: number = 200;
@Output() onExportCSV = new EventEmitter<number>();
Expand All @@ -27,13 +29,22 @@ export class ExportCSVDialogComponent implements OnInit {
} as RequestExportForm;
}

ngAfterViewInit() {
CommonHelpers.dialogBackHandler(ExportCSVDialogComponent.dialogSelector);
}

ngOnDestroy() {
jQuery(ExportCSVDialogComponent.dialogSelector).off();
jQuery(window).off('popstate');
}

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

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

exportCSVConfirm() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class RuleListComponent extends BaseList {
@ViewChild('editForm', { static: false }) editForm: RuleFormComponent;
private static deleteModalSelector: string = '#delete-confirm';
private static editModalSelector: string = '#label-edit-dialog';
private static createModalSelector: string = '#rule-create-dialog';
public ADD_BENCHMARK_HEIGHT: number;
public currentItem: RuleListItem;
private listSubscription: Subscription;
Expand Down Expand Up @@ -51,11 +52,14 @@ export class RuleListComponent extends BaseList {
super.ngAfterViewInit();
CommonHelpers.dialogBackHandler(RuleListComponent.deleteModalSelector);
CommonHelpers.dialogBackHandler(RuleListComponent.editModalSelector);
CommonHelpers.dialogBackHandler(RuleListComponent.createModalSelector);
}

ngOnDestroy() {
super.ngOnDestroy();
jQuery(RuleListComponent.deleteModalSelector).off();
jQuery(RuleListComponent.editModalSelector).off();
jQuery(RuleListComponent.createModalSelector).off();
jQuery(window).off('popstate');
this.listSubscription.unsubscribe();
}
Expand Down
16 changes: 14 additions & 2 deletions src/organization/admin/download/download.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { DownloadService } from './download.service';
import { DownloadListResponse } from './download.response';
import { SpinnerService } from '../../../common/spinner/spinner.service';
import * as FileSaver from 'file-saver';
import { CommonHelpers } from 'common/helpers';


@Component({
templateUrl: './download.component.html',
providers: [DownloadService]
})

export class DownloadComponent implements OnInit {
export class DownloadComponent implements OnInit, AfterViewInit, OnDestroy {
private static downloadModalSelector: string = '#reveal-signupkey-dlg';
public isRequesting: boolean;
public response: DownloadListResponse;

Expand All @@ -21,6 +24,15 @@ export class DownloadComponent implements OnInit {
this.refresh();
}

ngAfterViewInit() {
CommonHelpers.dialogBackHandler(DownloadComponent.downloadModalSelector);
}

ngOnDestroy() {
jQuery(DownloadComponent.downloadModalSelector).off();
jQuery(window).off('popstate');
}

refresh() {
this.spinnerService.setState(true);
this.service.getList().subscribe(
Expand Down
3 changes: 3 additions & 0 deletions src/organization/admin/user/user_list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { UserService } from './user.service';
export class UserListComponent extends BaseList {
private static deleteModalSelector: string = '#delete-confirm';
private static resendEmailModalSelector: string = '#resend-confirm';
private static deleteDomaingroupModalSelector: string = '#delete-domaingroup-confirm';
public currentItem: UserListItem;
public currentDomainGroup: AdGroupItem;
public showAddUser: boolean;
Expand Down Expand Up @@ -89,12 +90,14 @@ export class UserListComponent extends BaseList {
super.ngAfterViewInit();
CommonHelpers.dialogBackHandler(UserListComponent.resendEmailModalSelector);
CommonHelpers.dialogBackHandler(UserListComponent.deleteModalSelector);
CommonHelpers.dialogBackHandler(UserListComponent.deleteDomaingroupModalSelector);
}

ngOnDestroy() {
super.ngOnDestroy();
jQuery(UserListComponent.deleteModalSelector).off();
jQuery(UserListComponent.resendEmailModalSelector).off();
jQuery(UserListComponent.deleteDomaingroupModalSelector).off();
jQuery(window).off('popstate');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Breadcrumb } from '../../common/breadcrumb/breadcrumb.model';
import { BenchmarkRuleDevicesService } from './benchmark-rule-devices.service';
import { BaseList } from 'common/list/base-list';
import { CreateExceptionDialogComponent } from './create-exception-dialog.component';
import { CommonHelpers } from 'common/helpers';


@Component({
Expand All @@ -15,6 +16,7 @@ import { CreateExceptionDialogComponent } from './create-exception-dialog.compon
})

export class BenchmarkRuleDevicesComponent extends BaseList {
private static removeExceptionModalSelector: string = '#remove-exception-confirm';
@ViewChild(CreateExceptionDialogComponent, { static: false }) createExceptionDialog: CreateExceptionDialogComponent;
private benchmarkProfileId: string;
private ruleId: string;
Expand Down Expand Up @@ -47,6 +49,16 @@ export class BenchmarkRuleDevicesComponent extends BaseList {
];
}

ngAfterViewInit() {
CommonHelpers.dialogBackHandler(BenchmarkRuleDevicesComponent.removeExceptionModalSelector);
super.ngAfterViewInit();
}

ngOnDestroy() {
jQuery(BenchmarkRuleDevicesComponent.removeExceptionModalSelector).off();
jQuery(window).off('popstate');
}

listResponseHandler(response: RuleDetailDeviceListResponse) {
super.listResponseHandler(response);
if (response) {
Expand Down Expand Up @@ -138,7 +150,7 @@ export class BenchmarkRuleDevicesComponent extends BaseList {
this.createExceptionDialog.setIssue(this.benchmarkProfileId, this.response.issue_id);
this.createExceptionDialog.setSection(this.response.section);
this.createExceptionDialog.setDevices(this.selectedItems);
jQuery('#create-exception-dialog').modal('show');
this.createExceptionDialog.show();
}

markAllItemsSelected(event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, Output } from '@angular/core';
import { Component, EventEmitter, Output, AfterViewInit, OnDestroy } from '@angular/core';
import { AccountService } from '../../account/account.service';
import { SpinnerService } from '../../common/spinner/spinner.service';
import { CommonHelpers } from '../../common/helpers';
Expand All @@ -11,8 +11,8 @@ import { BasicResponse } from '../../common/response';
selector: 'create-exception-dialog'
})

export class CreateExceptionDialogComponent {
private static dialogSelector = '#profile-update-dialog';
export class CreateExceptionDialogComponent implements AfterViewInit, OnDestroy {
private static dialogSelector: string = '#create-exception-dialog';
@Output() exceptionApproved: EventEmitter<any> = new EventEmitter<any>();
public comment: string;
public deviceItems: Array<RulesDetailDeviceListItem>;
Expand All @@ -31,6 +31,19 @@ export class CreateExceptionDialogComponent {
CommonHelpers.dialogBackHandler(CreateExceptionDialogComponent.dialogSelector);
}

ngOnDestroy() {
jQuery(CreateExceptionDialogComponent.dialogSelector).off();
jQuery(window).off('popstate');
}

show() {
jQuery(CreateExceptionDialogComponent.dialogSelector).modal('show');
}

hide() {
jQuery(CreateExceptionDialogComponent.dialogSelector).modal('hide');
}

setIssue(profileId, issueId: string) {
this.profileId = profileId;
this.issueId = issueId;
Expand Down Expand Up @@ -70,7 +83,7 @@ export class CreateExceptionDialogComponent {
this.spinnerService.setState(true);
this.createException().subscribe(
(data: BasicResponse) => {
jQuery('#create-exception-dialog').modal('hide');
this.hide();
this.spinnerService.setState(false);
this.exceptionApproved.emit();
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { Component, Input, Output, EventEmitter, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
import { DeviceDetailService } from 'organization/device/device-detail.service';
import { AccountService } from 'account/account.service';
import { SpinnerService } from 'common/spinner/spinner.service';
import { CommonHelpers } from 'common/helpers';


@Component({
selector: 'device-exclude-exception-dialog',
templateUrl: 'device_exclude_exception_dialog.component.html'
})

export class DeviceExcludeExceptionDialogComponent implements OnInit {
export class DeviceExcludeExceptionDialogComponent implements OnInit, AfterViewInit, OnDestroy {
private static dialogSelector: string = '#device-exclude-exception-dialog';
@Input() deviceId: string;
@Output() refresh = new EventEmitter();
private exclusionProfileId: number;
Expand All @@ -26,24 +28,37 @@ export class DeviceExcludeExceptionDialogComponent implements OnInit {
this.id = parseInt(this.deviceId);
}

ngAfterViewInit() {
CommonHelpers.dialogBackHandler(DeviceExcludeExceptionDialogComponent.dialogSelector);
}

ngOnDestroy() {
jQuery(DeviceExcludeExceptionDialogComponent.dialogSelector).off();
jQuery(window).off('popstate');
}

show(profileId: number) {
this.exclusionProfileId = profileId;
this.exclusionComment = '';
jQuery('#device-exclude-exception-dialog').modal('show');
jQuery(DeviceExcludeExceptionDialogComponent.dialogSelector).modal('show');
}

hide() {
jQuery(DeviceExcludeExceptionDialogComponent.dialogSelector).modal('hide');
}

clickCreateBaselineExceptionConfirm() {
this.deviceDetailService.createDeviceBaselineException(this.id, this.exclusionProfileId, this.exclusionComment)
.subscribe(
(data: any) => {
this.spinnerService.setState(false);
this.refresh.emit();
},
err => {
this.accountService.handleError(err);
this.spinnerService.setState(false);
}
);
jQuery('#device-exclude-exception-dialog').modal('hide');
.subscribe(
(data: any) => {
this.spinnerService.setState(false);
this.refresh.emit();
},
err => {
this.accountService.handleError(err);
this.spinnerService.setState(false);
}
);
this.hide();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, EventEmitter, Output, OnInit } from '@angular/core';
import { Component, Input, EventEmitter, Output, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
import { LabelListItem, LabelListResponse } from 'organization/admin/label/label.response';
import { DeviceDetailService } from 'organization/device/device-detail.service';
import { FlashService } from 'common/flash/flash.service';
Expand All @@ -7,14 +7,16 @@ import { BasicResponse } from 'common/response';
import { LabelService } from 'organization/admin/label/label.service';
import { DeviceLabelItem } from 'organization/device/device_response';
import { Subscription } from 'rxjs';
import { CommonHelpers } from 'common/helpers';


@Component({
selector: 'device-label-dialog',
templateUrl: 'device_label_dialog.component.html'
})

export class DeviceLabelDialogComponent implements OnInit {
export class DeviceLabelDialogComponent implements OnInit, AfterViewInit, OnDestroy {
private static dialogSelector: string = '#device-label-dialog';
@Input() deviceId: string;
@Input() labels: DeviceLabelItem[];
@Output() refresh = new EventEmitter();
Expand All @@ -33,15 +35,25 @@ export class DeviceLabelDialogComponent implements OnInit {
this.id = parseInt(this.deviceId);
}

ngAfterViewInit() {
CommonHelpers.dialogBackHandler(DeviceLabelDialogComponent.dialogSelector);
}

ngOnDestroy() {
this.labelSubscription.unsubscribe();
}
this.labelSubscription.unsubscribe();
jQuery(DeviceLabelDialogComponent.dialogSelector).off();
jQuery(window).off('popstate');
}

show() {
jQuery('#device-label-dialog').modal('show');
jQuery(DeviceLabelDialogComponent.dialogSelector).modal('show');
this.setLabels();
}

hide() {
jQuery(DeviceLabelDialogComponent.dialogSelector).modal('hide');
}

setLabels() {
this.labelSubscription = this.labelService.listResponse$.subscribe(
(data: LabelListResponse) => {
Expand Down Expand Up @@ -80,7 +92,7 @@ export class DeviceLabelDialogComponent implements OnInit {
this.accountService.handleError(err);
}
);
jQuery('#device-label-dialog').modal('hide');
this.hide();
}
}

Expand Down
Loading

0 comments on commit 8a9362d

Please sign in to comment.