Fix PolicyInstanceComponent and add test coverage
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / policy / policy-instance / policy-instance.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 <div>
21     Number of instances: {{noInstances()}}
22     <button id="createButton" mat-icon-button (click)="createPolicyInstance(policyTypeSchema)">
23         <mat-icon id="createIcon" matTooltip="Create instance">add_box</mat-icon>
24     </button>
25     <button id="refreshButton" mat-icon-button color="primary" (click)="refreshTable()">
26         <mat-icon id="refreshIcon">refresh</mat-icon>
27     </button>
28 </div>
29
30 <mat-table class="instances-table mat-elevation-z8" id="policiesTable" [dataSource]="instanceDataSource" matSort
31     (matSortChange)="getSortedData($event)" matSortDisableClear multiTemplateDataRows>
32
33     <ng-container matColumnDef="instanceId">
34         <mat-header-cell mat-sort-header *matHeaderCellDef matTooltip="The ID of the policy instance">
35             <div id="idSortStop" (click)="stopSort($event)">
36                 <form style="display: flex" [formGroup]="policyInstanceForm">
37                     <mat-form-field>
38                         <input id="policyInstanceIdFilter" matInput formControlName="id">
39                         <mat-placeholder>Instance</mat-placeholder>
40                     </mat-form-field>
41                 </form>
42             </div>
43         </mat-header-cell>
44         <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{instance.policy_id}}
45         </mat-cell>
46     </ng-container>
47
48     <ng-container matColumnDef="ric">
49         <mat-header-cell mat-sort-header *matHeaderCellDef
50             matTooltip="Element where the policy instance resides, e.g. a gNodeB or Near-RT RIC">
51             <div id="targetSortStop" (click)="stopSort($event)">
52                 <form style="display: flex" [formGroup]="policyInstanceForm">
53                     <mat-form-field>
54                         <input id="policyInstanceTargetFilter" matInput formControlName="target">
55                         <mat-placeholder>Target</mat-placeholder>
56                     </mat-form-field>
57                 </form>
58             </div>
59         </mat-header-cell>
60         <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{instance.ric_id}}
61         </mat-cell>
62     </ng-container>
63
64     <ng-container matColumnDef="service">
65         <mat-header-cell mat-sort-header *matHeaderCellDef
66             matTooltip="The service that created the policy instance, and is responsible for its lifecycle">
67             <div id="ownerSortStop" (click)="stopSort($event)">
68                 <form style="display: flex" [formGroup]="policyInstanceForm">
69                     <mat-form-field>
70                         <input id="policyInstanceOwnerFilter" matInput formControlName="owner">
71                         <mat-placeholder>Owner</mat-placeholder>
72                     </mat-form-field>
73                 </form>
74             </div>
75         </mat-header-cell>
76         <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{instance.service_id}}
77         </mat-cell>
78     </ng-container>
79
80     <ng-container matColumnDef="lastModified">
81         <mat-header-cell mat-sort-header *matHeaderCellDef
82             matTooltip="The time of the last modification of the policy instance">
83             <div id="lastModifiedSortStop" (click)="stopSort($event)">
84                 <form style="display: flex" [formGroup]="policyInstanceForm">
85                     <mat-form-field>
86                         <input id="policyInstanceLastModifiedFilter" matInput formControlName="lastModified">
87                         <mat-placeholder>Last modified</mat-placeholder>
88                     </mat-form-field>
89                 </form>
90             </div>
91         </mat-header-cell>
92         <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{toLocalTime(instance.lastModified)}}
93         </mat-cell>
94     </ng-container>
95
96     <ng-container matColumnDef="action">
97         <mat-header-cell class="action-cell" *matHeaderCellDef>Action</mat-header-cell>
98         <mat-cell class="action-cell" *matCellDef="let instance">
99             <button mat-icon-button id="{{instance.policy_id + 'EditButton'}}" (click)="modifyInstance(instance)" matTooltip="Edit the policy instance">
100                 <mat-icon>edit</mat-icon>
101             </button>
102             <button mat-icon-button id="{{instance.policy_id + 'DeleteButton'}}" color="warn" (click)="deleteInstance(instance)"
103                 matTooltip="Delete the policy instance">
104                 <mat-icon>delete</mat-icon>
105             </button>
106         </mat-cell>
107     </ng-container>
108
109     <ng-container matColumnDef="noRecordsFound">
110         <mat-footer-cell *matFooterCellDef>No records found.</mat-footer-cell>
111     </ng-container>
112
113     <mat-header-row *matHeaderRowDef="['instanceId', 'ric', 'service', 'lastModified', 'action']">
114     </mat-header-row>
115     <mat-row *matRowDef="let instance; columns: ['instanceId', 'ric', 'service', 'lastModified', 'action'];"></mat-row>
116 </mat-table>