Add functionality to truncate amount of instances
[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: {{instanceCount()}}
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 class="spinner-container" style="display: flex; justify-content: center; align-items: center;"
29         *ngIf="loading$ | async">
30         <mat-spinner></mat-spinner>
31     </div>
32     <div id="truncated" *ngIf="truncated" class="alert">
33         Too many instances! Only {{slice}} results will be shown.
34     </div>
35 </div>
36
37 <mat-table class="instances-table mat-elevation-z8" id="policiesTable" [dataSource]="instanceDataSource" matSort
38     (matSortChange)="getSortedData($event)" matSortDisableClear multiTemplateDataRows>
39
40     <ng-container matColumnDef="instanceId">
41         <mat-header-cell mat-sort-header *matHeaderCellDef matTooltip="The ID of the policy instance">
42             <div id="idSortStop" (click)="stopSort($event)">
43                 <form style="display: flex" [formGroup]="policyInstanceForm">
44                     <mat-form-field>
45                         <input id="policyInstanceIdFilter" matInput formControlName="id">
46                         <mat-placeholder>Instance</mat-placeholder>
47                     </mat-form-field>
48                 </form>
49             </div>
50         </mat-header-cell>
51         <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{instance.policy_id}}
52         </mat-cell>
53     </ng-container>
54
55     <ng-container matColumnDef="ric">
56         <mat-header-cell mat-sort-header *matHeaderCellDef
57             matTooltip="Element where the policy instance resides, e.g. a gNodeB or Near-RT RIC">
58             <div id="targetSortStop" (click)="stopSort($event)">
59                 <form style="display: flex" [formGroup]="policyInstanceForm">
60                     <mat-form-field>
61                         <input id="policyInstanceTargetFilter" matInput formControlName="target">
62                         <mat-placeholder>Target</mat-placeholder>
63                     </mat-form-field>
64                 </form>
65             </div>
66         </mat-header-cell>
67         <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{instance.ric_id}}
68         </mat-cell>
69     </ng-container>
70
71     <ng-container matColumnDef="service">
72         <mat-header-cell mat-sort-header *matHeaderCellDef
73             matTooltip="The service that created the policy instance, and is responsible for its lifecycle">
74             <div id="ownerSortStop" (click)="stopSort($event)">
75                 <form style="display: flex" [formGroup]="policyInstanceForm">
76                     <mat-form-field>
77                         <input id="policyInstanceOwnerFilter" matInput formControlName="owner">
78                         <mat-placeholder>Owner</mat-placeholder>
79                     </mat-form-field>
80                 </form>
81             </div>
82         </mat-header-cell>
83         <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{instance.service_id}}
84         </mat-cell>
85     </ng-container>
86
87     <ng-container matColumnDef="lastModified">
88         <mat-header-cell mat-sort-header *matHeaderCellDef
89             matTooltip="The time of the last modification of the policy instance">
90             <div id="lastModifiedSortStop" (click)="stopSort($event)">
91                 <form style="display: flex" [formGroup]="policyInstanceForm">
92                     <mat-form-field>
93                         <input id="policyInstanceLastModifiedFilter" matInput formControlName="lastModified">
94                         <mat-placeholder>Last modified</mat-placeholder>
95                     </mat-form-field>
96                 </form>
97             </div>
98         </mat-header-cell>
99         <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{toLocalTime(instance.lastModified)}}
100         </mat-cell>
101     </ng-container>
102
103     <ng-container matColumnDef="action">
104         <mat-header-cell class="action-cell" *matHeaderCellDef>Action</mat-header-cell>
105         <mat-cell class="action-cell" *matCellDef="let instance">
106             <button mat-icon-button id="{{instance.policy_id + 'EditButton'}}" (click)="modifyInstance(instance)" matTooltip="Edit the policy instance">
107                 <mat-icon>edit</mat-icon>
108             </button>
109             <button mat-icon-button id="{{instance.policy_id + 'DeleteButton'}}" color="warn" (click)="deleteInstance(instance)"
110                 matTooltip="Delete the policy instance">
111                 <mat-icon>delete</mat-icon>
112             </button>
113         </mat-cell>
114     </ng-container>
115
116     <ng-container matColumnDef="noRecordsFound">
117         <mat-footer-cell *matFooterCellDef>No records found.</mat-footer-cell>
118     </ng-container>
119
120     <mat-header-row *matHeaderRowDef="['instanceId', 'ric', 'service', 'lastModified', 'action']" [ngClass]="{'display-none': !this.hasInstances()}">
121     </mat-header-row>
122     <mat-row *matRowDef="let instance; columns: ['instanceId', 'ric', 'service', 'lastModified', 'action'];"></mat-row>
123
124     <mat-footer-row *matFooterRowDef="['noRecordsFound']" [ngClass]="{'display-none': this.hasInstances()}">
125     </mat-footer-row>
126
127 </mat-table>