Small modifications to instance dialogs 43/3743/3
authorelinuxhenrik <henrik.b.andersson@est.tech>
Tue, 19 May 2020 07:37:02 +0000 (09:37 +0200)
committerelinuxhenrik <henrik.b.andersson@est.tech>
Tue, 19 May 2020 09:41:19 +0000 (11:41 +0200)
Change-Id: Iaacccc5d92287577488001d2f1e9cacc4e61c49f
Issue-ID: NONRTRIC-212
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/config/PolicyControllerMockConfiguration.java
webapp-frontend/package.json
webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.html
webapp-frontend/src/app/policy-control/no-type-policy-instance-dialog.component.ts
webapp-frontend/src/app/policy-control/policy-instance-dialog.component.html
webapp-frontend/src/app/policy-control/policy-instance-dialog.component.ts

index 89a3ede..6fb657b 100644 (file)
@@ -77,13 +77,13 @@ public class PolicyControllerMockConfiguration {
         public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, Object json,
             String ric) {
             database.putInstance(policyTypeIdString, policyInstanceId, json, ric);
-            return new ResponseEntity<>("Policy was put successfully", HttpStatus.OK);
+            return new ResponseEntity<>(HttpStatus.OK);
         }
 
         @Override
         public ResponseEntity<String> deletePolicy(String policyInstanceId) {
             database.deleteInstance(policyInstanceId);
-            return new ResponseEntity<>("Policy was deleted successfully", HttpStatus.NO_CONTENT);
+            return new ResponseEntity<>(HttpStatus.OK);
         }
 
         @Override
index e9e9ee0..dd68902 100644 (file)
@@ -26,8 +26,9 @@
     "@kubernetes/client-node": "^0.10.3",
     "@material/radio": "^2.3.0",
     "@types/chart.js": "^2.9.11",
+    "@types/uuid": "^7.0.3",
     "angular-bootstrap-md": "^7.5.4",
-    "angular6-json-schema-form": "^7.3.0",
+    "angular6-json-schema-form": "^8.0.0",
     "bootstrap": "^4.4.1",
     "chart.js": "^2.9.3",
     "core-js": "^2.6.11",
index 393d40b..b3211c0 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>
-
-<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>
+<br/>
+<div class="text-muted">Enter policy statements (JSON).</div>
 
 <form [formGroup]="instanceForm" novalidate autocomplete="off">
     <div mat-dialog-content>
         <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">
+                class="alert mat-error">
                 <div *ngIf="ricSelector.errors.required">
                     A Ric must be selected.
                 </div>
@@ -56,7 +58,7 @@
                 cdkAutosizeMinRows="10" required>
             </textarea>
             <div *ngIf="policyJsonTextArea.invalid && (policyJsonTextArea.dirty || policyJsonTextArea.touched)"
-                class="alert alert-danger">
+                class="alert mat-error">
                 <div *ngIf="policyJsonTextArea.errors.required">
                     The policy body is required.
                 </div>
@@ -66,7 +68,7 @@
             </div>
         </mat-form-field>
     </div>
-    <div mat-dialog-actions class="modal-footer justify-content-center">
+    <div mat-dialog-actions>
         <button mat-raised-button (click)="this.onSubmit()" class="submitBtn" [disabled]="!instanceForm.valid">
             Submit
         </button>
index da05ebb..d7671a3 100644 (file)
@@ -33,8 +33,6 @@ import * as uuid from 'uuid';
   styleUrls: ['./no-type-policy-instance-dialog.component.scss']
 })
 export class NoTypePolicyInstanceDialogComponent implements OnInit {
-
-  // Declare following variables as Public variable. Private variables should not be used in template HTML
   instanceForm: FormGroup;
 
   policyInstanceId: string; // null if not yet created
index d447c70..f0b20bb 100644 (file)
@@ -17,6 +17,7 @@
   limitations under the License.
   ========================LICENSE_END===================================
   -->
+
 <div class="text-muted logo" fxLayout="row" fxLayoutGap="50px" fxLayoutAlign="space-around center">
     <div *ngIf="policyInstanceId">{{policyInstanceId}}</div>
 </div>
 
 <div class="text-muted" *ngIf="jsonSchemaObject.description">{{jsonSchemaObject.description}}</div>
 
-<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-sm="column" fxLayoutAlign.lt-sm="flex-start center">
+<div [formGroup]="instanceForm" fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-sm="column"
+    fxLayoutAlign.lt-sm="flex-start center">
 
 
     <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-select [(value)]="this.ric">
+            <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>
@@ -83,7 +85,7 @@
                 <div *ngIf="prettyValidationErrors" class="text-danger" [innerHTML]="prettyValidationErrors"></div>
             </div>
             <div>
-                <pre [class.text__dark]='this.darkMode'>{{prettyLiveFormData}}</pre>
+                <pre [class.text__dark]="this.darkMode">{{prettyLiveFormData}}</pre>
             </div>
         </div>
 
@@ -93,7 +95,7 @@
         </h4>
         <div *ngIf="isVisible.schema" fxLayout="column" [@expandSection]="true">
             <strong class="text-muted">Schema</strong>
-            <pre [class.text__dark]='this.darkMode'>{{schemaAsString}}</pre>
+            <pre [class.text__dark]="this.darkMode">{{schemaAsString}}</pre>
         </div>
     </mat-card>
 </div>
\ No newline at end of file
index 8ab798e..3c330e5 100644 (file)
@@ -29,6 +29,7 @@ import { ErrorDialogService } from '../services/ui/error-dialog.service';
 import { NotificationService } from './../services/ui/notification.service';
 import { UiService } from '../services/ui/ui.service';
 import { HttpErrorResponse } from '@angular/common/http';
+import { FormGroup, FormControl, Validators } from '@angular/forms';
 
 
 @Component({
@@ -49,6 +50,8 @@ import { HttpErrorResponse } from '@angular/common/http';
     ],
 })
 export class PolicyInstanceDialogComponent implements OnInit, AfterViewInit {
+    instanceForm: FormGroup;
+
 
     formActive = false;
     isVisible = {
@@ -120,6 +123,11 @@ export class PolicyInstanceDialogComponent implements OnInit, AfterViewInit {
         this.ui.darkModeState.subscribe((isDark) => {
             this.darkMode = isDark;
         });
+        this.instanceForm = new FormGroup({
+            'ricSelector': new FormControl(this.ric, [
+                Validators.required
+            ])
+        });
         if (!this.policyInstanceId) {
             this.fetchRics();
         }
@@ -155,15 +163,15 @@ export class PolicyInstanceDialogComponent implements OnInit, AfterViewInit {
         this.liveFormData = formData;
     }
 
-    get prettyLiveFormData() {
+    get prettyLiveFormData(): string {
         return JSON.stringify(this.liveFormData, null, 2);
     }
 
-    get schemaAsString() {
+    get schemaAsString(): string {
         return JSON.stringify(this.jsonSchemaObject, null, 2);
     }
 
-    get jsonAsString() {
+    get jsonAsString(): string {
         return JSON.stringify(this.jsonObject, null, 2);
     }