- }
-
- private isSchemaEmpty(): boolean {
- return this.policyTypeSchema.schemaObject === '{}';
- }
-
- modifyInstance(instance: PolicyInstance): void {
- this.policySvc.getPolicyInstance(instance.policy_id).subscribe(
- (refreshedJson: any) => {
- instance = refreshedJson;
- this.dialog.open(
- PolicyInstanceDialogComponent,
- getPolicyDialogProperties(this.policyTypeSchema, instance, this.darkMode)).afterClosed().subscribe(
- (_: any) => {
- this.instanceDataSource.getPolicyInstances();
- }
- );
- },
- (httpError: HttpErrorResponse) => {
- this.notificationService.error('Could not refresh instance. Please try again.' + httpError.message);
- }
- );
- }
-
- hasInstances(): boolean {
- return this.instanceDataSource.rowCount > 0;
- }
-
- toLocalTime(utcTime: string): string {
- const date = new Date(utcTime);
- const toutc = date.toUTCString();
- return new Date(toutc + ' UTC').toLocaleString();
-
- }
-
- deleteInstance(instance: PolicyInstance): void {
- this.confirmDialogService
- .openConfirmDialog('Are you sure you want to delete this policy instance?')
- .afterClosed().subscribe(
- (res: any) => {
- if (res) {
- this.policySvc.deletePolicy(instance.policy_id)
- .subscribe(
- (response: HttpResponse<Object>) => {
- switch (response.status) {
- case 204:
- this.notificationService.success('Delete succeeded!');
- this.instanceDataSource.getPolicyInstances();
- break;
- default:
- this.notificationService.warn('Delete failed ' + response.status + ' ' + response.body);
- }
- },
- (error: HttpErrorResponse) => {
- this.errorDialogService.displayError(error.statusText + ', ' + error.error);
- });
- }
- });
- }