Improvements in the GUI
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / policy-control / policy-instance-dialog.component.html
1 <!--
2   ========================LICENSE_START=================================
3   O-RAN-SC
4   %%
5   Copyright (C) 2019 Nordix Foundation
6   %%
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18   ========================LICENSE_END===================================
19   -->
20
21 <div class="text-muted logo" fxLayout="row" fxLayoutGap="50px" fxLayoutAlign="space-around center">
22     <div *ngIf="policyInstanceId">[{{this.ric}}] {{policyInstanceId}}</div>
23 </div>
24 <div class="mat-elevation-z8 header row" [ngClass]="{'header-dark': darkMode}">
25     <div class="logo">
26         <img src="../../assets/oran-logo.png" width="30px" height="30px" style="position: relative; z-index: 50" />
27         <svg class="logo__icon" viewBox="150.3 22.2 1000 50">
28             <text class="logo__text" [ngClass]="{'logo__text-dark': darkMode}" font-size="30" font-weight="600"
29                 letter-spacing=".1em" transform="translate(149 56)">
30                 <tspan *ngIf="jsonSchemaObject.title"> {{this.jsonSchemaObject.title}}</tspan>
31                 <tspan *ngIf="!jsonSchemaObject.title"> {{this.policyTypeName}}</tspan>
32             </text>
33         </svg>
34     </div>
35 </div>
36
37 <div class="text-muted" *ngIf="jsonSchemaObject.description">{{jsonSchemaObject.description}}</div>
38
39 <div [formGroup]="instanceForm" fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-sm="column"
40     fxLayoutAlign.lt-sm="flex-start center">
41
42     <mat-card class="card" [ngClass]="{'card-dark': darkMode}">
43         <mat-form-field *ngIf="!this.policyInstanceId">
44             <mat-select id="ricSelector" formControlName="ricSelector" matInput required [(value)]="this.ric"
45                 placeholder="Target"
46                 matTooltip="Element where the policy instance resides, e.g. a gNodeB or Near-RT RIC">
47                 <mat-option *ngFor="let ric of this.allRics" [value]="ric">
48                     {{ric}}
49                 </mat-option>
50             </mat-select>
51             <div *ngIf="ricSelector.invalid && (ricSelector.dirty || ricSelector.touched)">
52                 <div *ngIf="ricSelector.errors.required">
53                     <mat-error role="alert">This field is required.</mat-error>
54                 </div>
55             </div>
56         </mat-form-field>
57
58         <h4 class="default-cursor" (click)="toggleVisible('form')">
59             <mat-icon matTooltip="Properties">{{isVisible.form ? 'expand_less' : 'expand_more'}}</mat-icon>
60             Properties
61         </h4>
62         <div *ngIf="isVisible.form" class="json-schema-form" [@expandSection]="true">
63             <div *ngIf="!formActive">{{jsonFormStatusMessage}}</div>
64
65             <json-schema-form *ngIf="formActive" loadExternalAssets="true" [form]="jsonSchemaObject"
66                 [(data)]="jsonObject" [options]="jsonFormOptions" [framework]="'material-design'" [language]="'en'"
67                 (onChanges)="onChanges($event)" (onSubmit)="onSubmit($event)" (isValid)="isValid($event)"
68                 (validationErrors)="validationErrors($event)">
69             </json-schema-form>
70         </div>
71         <hr />
72         <button mat-raised-button (click)="this.onClose()">Close</button>
73         <button mat-raised-button (click)="this.onSubmit()" [disabled]="!this.formIsValid || !this.ric"
74             class="submitBtn">Submit</button>
75         <hr />
76         <h4 [class.text-danger]="!formIsValid && !isVisible.json" [class.default-cursor]="formIsValid || isVisible.json"
77             (click)="toggleVisible('json')">
78             <mat-icon matTooltip="Json">{{isVisible.json ? 'expand_less' : 'expand_more'}}</mat-icon>
79             Json
80         </h4>
81         <div *ngIf="isVisible.json" fxLayout="column" [@expandSection]="true">
82             <div>
83                 <strong *ngIf="formIsValid || prettyValidationErrors" [class.text-muted]="formIsValid"
84                     [class.text-danger]="!formIsValid">
85                     {{formIsValid ? 'Json' : 'Not valid'}}
86                 </strong>
87                 <span *ngIf="!formIsValid && !prettyValidationErrors">Invalid form</span>
88                 <span *ngIf="prettyValidationErrors">— errors:</span>
89                 <div *ngIf="prettyValidationErrors" class="text-danger" [innerHTML]="prettyValidationErrors"></div>
90             </div>
91             <div>
92                 <pre [class.text__dark]="this.darkMode">{{prettyLiveFormData}}</pre>
93             </div>
94         </div>
95
96         <h4 class="default-cursor" (click)="toggleVisible('schema')">
97             <mat-icon matTooltip="Json Schema">{{isVisible.schema ? 'expand_less' : 'expand_more'}}</mat-icon>
98             Json Schema
99         </h4>
100         <div *ngIf="isVisible.schema" fxLayout="column" [@expandSection]="true">
101             <strong class="text-muted">Schema</strong>
102             <pre [class.text__dark]="this.darkMode">{{schemaAsString}}</pre>
103         </div>
104     </mat-card>
105 </div>