+ createPolicyInstance(policyTypeSchema: PolicyTypeSchema): void {
+ let dialogRef = this.dialog.open(
+ PolicyInstanceDialogComponent,
+ getPolicyDialogProperties(policyTypeSchema, null, this.darkMode)
+ );
+ const info: PolicyTypeInfo = this.getPolicyTypeInfo(policyTypeSchema);
+ dialogRef.afterClosed().subscribe((_) => {
+ info.isExpanded.next(info.isExpanded.getValue());
+ });
+ }
+
+ 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.getPolicyInstances();
+ break;
+ default:
+ this.notificationService.warn(
+ "Delete failed " + response.status + " " + response.body
+ );
+ }
+ },
+ (error: HttpErrorResponse) => {
+ this.errorDialogService.displayError(
+ error.statusText + ", " + error.error
+ );
+ }
+ );
+ }
+ });
+ }