Improve no type policy handling
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / policy-control / no-type-policy-instance-dialog.component.html
index 393d40b..71c63be 100644 (file)
@@ -18,6 +18,9 @@
   ========================LICENSE_END===================================
   -->
 
+<div class="text-muted logo" fxLayout="row" fxLayoutGap="50px" fxLayoutAlign="space-around center">
+    <div *ngIf="policyInstanceId">{{policyInstanceId}}</div>
+</div>
 <div class="mat-elevation-z8 header row" [ngClass]="{'header-dark': darkMode}">
     <div class="logo">
         <img src="../../assets/oran-logo.png" width="30px" height="30px" style="position: relative; z-index: 50" />
         </svg>
     </div>
 </div>
+<br />
+<div class="text-muted">Enter policy statements (JSON).</div>
 
-<div class="text-muted">Since this is a policy type without a schema, the user will have to make sure that the content
-    of the policy has the necessary content. This dialog will only validate that it is a valid JSON string.</div>
+<div [formGroup]="instanceForm" fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-sm="column"
+    fxLayoutAlign.lt-sm="flex-start center">
 
-<form [formGroup]="instanceForm" novalidate autocomplete="off">
-    <div mat-dialog-content>
+    <mat-card class="card" [ngClass]="{'card-dark': darkMode}">
         <mat-form-field *ngIf="!this.policyInstanceId">
-            <mat-label [class.text-danger]="!this.ric">Select RIC</mat-label>
+            <mat-label>Select RIC</mat-label>
             <mat-select id="ricSelector" formControlName="ricSelector" matInput required [(value)]="this.ric">
                 <mat-option *ngFor="let ric of this.allRics" [value]="ric">
                     {{ric}}
                 </mat-option>
             </mat-select>
-            <div *ngIf="ricSelector.invalid && (ricSelector.dirty || ricSelector.touched)"
-                class="alert alert-danger">
+            <div *ngIf="ricSelector.invalid && (ricSelector.dirty || ricSelector.touched)" class="alert mat-error"
+                style="width: 300px;">
                 <div *ngIf="ricSelector.errors.required">
-                    A Ric must be selected.
+                    <mat-error role="alert">
+                        A Ric must be selected.
+                    </mat-error>
                 </div>
             </div>
         </mat-form-field>
         <mat-form-field style="width: 800px;">
             <mat-label>Policy content</mat-label>
             <textarea id="policyJsonTextArea" formControlName="policyJsonTextArea" matInput cdkTextareaAutosize
-                cdkAutosizeMinRows="10" required>
+                cdkAutosizeMinRows="10" required [(value)]="this.policyJson">
             </textarea>
-            <div *ngIf="policyJsonTextArea.invalid && (policyJsonTextArea.dirty || policyJsonTextArea.touched)"
-                class="alert alert-danger">
+            <div *ngIf="policyJsonTextArea.invalid && (policyJsonTextArea.dirty || policyJsonTextArea.touched)">
                 <div *ngIf="policyJsonTextArea.errors.required">
-                    The policy body is required.
+                    <mat-error role="alert">
+                        The policy body is required.
+                    </mat-error>
                 </div>
                 <div *ngIf="policyJsonTextArea.errors.invalidJson">
-                    The policy body must be a valid JSON.
+                    <mat-error role="alert">
+                        The policy body must be a valid JSON.
+                    </mat-error>
                 </div>
             </div>
         </mat-form-field>
-    </div>
-    <div mat-dialog-actions class="modal-footer justify-content-center">
-        <button mat-raised-button (click)="this.onSubmit()" class="submitBtn" [disabled]="!instanceForm.valid">
-            Submit
-        </button>
-        <button mat-raised-button class="mat-raised-button" [mat-dialog-close]="false">Close</button>
-    </div>
-</form>
\ No newline at end of file
+        <div mat-dialog-actions>
+            <button (click)="formatJsonInput();" class="mat-raised-button" [disabled]="!policyJsonTextArea.valid">
+                Format JSON
+            </button>
+            <button mat-raised-button class="mat-raised-button" [mat-dialog-close]="false">Close</button>
+            <button mat-raised-button (click)="this.onSubmit()" class="submitBtn" [disabled]="!instanceForm.valid">
+                Submit
+            </button>
+        </div>
+    </mat-card>
+</div>
\ No newline at end of file