From d7a2c1dc0704bb774e0a8445a3918f9fc51e19f4 Mon Sep 17 00:00:00 2001 From: elinuxhenrik Date: Wed, 20 May 2020 14:40:50 +0200 Subject: [PATCH] Improve no type policy handling Add button to format the JSON when it is valid. Align the look of the dialogs for with type and without type. Add required warning text for Ric selector in dialog with type. Put Submit button to the right to align with the Delete Policy dialog. Change-Id: I61402f91b3f3d9bd58c24e0680da4c8f721c43e3 Issue-ID: NONRTRIC-212 Signed-off-by: elinuxhenrik --- .../no-type-policy-instance-dialog.component.html | 48 +++++++++++++--------- .../no-type-policy-instance-dialog.component.ts | 10 ++++- .../policy-instance-dialog.component.html | 7 +++- .../policy-instance-dialog.component.ts | 2 + 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.html b/webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.html index b3211c0..71c63be 100644 --- a/webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.html +++ b/webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.html @@ -32,11 +32,13 @@ -
+
Enter policy statements (JSON).
-
-
+
+ + Select RIC @@ -44,10 +46,12 @@ {{ric}} -
+
- A Ric must be selected. + + A Ric must be selected. +
@@ -55,23 +59,29 @@ Policy content -
+
- The policy body is required. + + The policy body is required. +
- The policy body must be a valid JSON. + + The policy body must be a valid JSON. +
-
-
- - -
- \ No newline at end of file +
+ + + +
+ +
\ No newline at end of file diff --git a/webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.ts b/webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.ts index d7671a3..8c2a114 100644 --- a/webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.ts +++ b/webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.ts @@ -48,7 +48,7 @@ export class NoTypePolicyInstanceDialogComponent implements OnInit { @Inject(MAT_DIALOG_DATA) private data, private ui: UiService) { this.policyInstanceId = data.instanceId; - this.policyJson = data.instanceJson ? JSON.stringify(JSON.parse(data.instanceJson), null, 2) : ''; + this.policyJson = data.instanceJson ? this.formatJsonString(data.instanceJson) : ''; this.ric = data.ric; } @@ -105,6 +105,14 @@ export class NoTypePolicyInstanceDialogComponent implements OnInit { complete() { } }); } + + private formatJsonString(jsonToFormat: string) { + return JSON.stringify(JSON.parse(jsonToFormat), null, 2); + } + + formatJsonInput() { + this.policyJson = this.formatJsonString(this.policyJsonTextArea.value); + } } export function jsonValidator(): ValidatorFn { diff --git a/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.html b/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.html index f0b20bb..1e4145f 100644 --- a/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.html +++ b/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.html @@ -49,6 +49,11 @@ {{ric}} +
+
+ A Ric must be selected. +
+

@@ -65,9 +70,9 @@


+ -

diff --git a/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.ts b/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.ts index 3c330e5..3dcd79a 100644 --- a/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.ts +++ b/webapp-frontend/src/app/policy-control/policy-instance-dialog.component.ts @@ -136,6 +136,8 @@ export class PolicyInstanceDialogComponent implements OnInit, AfterViewInit { ngAfterViewInit() { } + get ricSelector() { return this.instanceForm.get('ricSelector'); } + onSubmit() { if (this.policyInstanceId == null) { this.policyInstanceId = uuid.v4(); -- 2.16.6