Tweaks for Policy Control UI
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / policy / policy-instance / policy-instance.component.html
index eca57ab..3203c0d 100644 (file)
   limitations under the License.
   ========================LICENSE_END===================================
   -->
-<table #table mat-table class="instances-table mat-elevation-z8" [ngClass]="{'table-dark': darkMode}" matSort
-    multiTemplateDataRows [dataSource]="instanceDataSource">
+<div>
+    Number of instances: {{instanceCount()}}
+    <button id="createButton" mat-icon-button (click)="createPolicyInstance(policyTypeSchema)">
+        <mat-icon id="createIcon" matTooltip="Create instance">add_box</mat-icon>
+    </button>
+    <button id="refreshButton" mat-icon-button color="primary" (click)="refreshTable()">
+        <mat-icon id="refreshIcon">refresh</mat-icon>
+    </button>
+</div>
+
+<mat-table class="instances-table mat-elevation-z8" id="policiesTable" [dataSource]="instanceDataSource" matSort
+    (matSortChange)="getSortedData($event)" matSortDisableClear multiTemplateDataRows>
 
     <ng-container matColumnDef="instanceId">
         <mat-header-cell mat-sort-header *matHeaderCellDef matTooltip="The ID of the policy instance">
-            Instance
+            <div id="idSortStop" (click)="stopSort($event)">
+                <form style="display: flex" [formGroup]="policyInstanceForm">
+                    <mat-form-field>
+                        <input id="policyInstanceIdFilter" matInput formControlName="id">
+                        <mat-placeholder>Instance</mat-placeholder>
+                    </mat-form-field>
+                </form>
+            </div>
         </mat-header-cell>
-        <mat-cell *matCellDef="let element" (click)="modifyInstance(element)">{{element.policy_id}}
+        <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{instance.policy_id}}
         </mat-cell>
     </ng-container>
 
     <ng-container matColumnDef="ric">
         <mat-header-cell mat-sort-header *matHeaderCellDef
             matTooltip="Element where the policy instance resides, e.g. a gNodeB or Near-RT RIC">
-            Target
+            <div id="targetSortStop" (click)="stopSort($event)">
+                <form style="display: flex" [formGroup]="policyInstanceForm">
+                    <mat-form-field>
+                        <input id="policyInstanceTargetFilter" matInput formControlName="target">
+                        <mat-placeholder>Target</mat-placeholder>
+                    </mat-form-field>
+                </form>
+            </div>
         </mat-header-cell>
-        <mat-cell *matCellDef="let element" (click)="modifyInstance(element)">{{element.ric_id}}
+        <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{instance.ric_id}}
         </mat-cell>
     </ng-container>
 
     <ng-container matColumnDef="service">
         <mat-header-cell mat-sort-header *matHeaderCellDef
             matTooltip="The service that created the policy instance, and is responsible for its lifecycle">
-            Owner
+            <div id="ownerSortStop" (click)="stopSort($event)">
+                <form style="display: flex" [formGroup]="policyInstanceForm">
+                    <mat-form-field>
+                        <input id="policyInstanceOwnerFilter" matInput formControlName="owner">
+                        <mat-placeholder>Owner</mat-placeholder>
+                    </mat-form-field>
+                </form>
+            </div>
         </mat-header-cell>
-        <mat-cell *matCellDef="let element" (click)="modifyInstance(element)">{{element.service_id}}
+        <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{instance.service_id}}
         </mat-cell>
     </ng-container>
 
     <ng-container matColumnDef="lastModified">
         <mat-header-cell mat-sort-header *matHeaderCellDef
             matTooltip="The time of the last modification of the policy instance">
-            Last modified
+            <div id="lastModifiedSortStop" (click)="stopSort($event)">
+                <form style="display: flex" [formGroup]="policyInstanceForm">
+                    <mat-form-field>
+                        <input id="policyInstanceLastModifiedFilter" matInput formControlName="lastModified">
+                        <mat-placeholder>Last modified</mat-placeholder>
+                    </mat-form-field>
+                </form>
+            </div>
         </mat-header-cell>
-        <mat-cell *matCellDef="let element" (click)="modifyInstance(element)">{{toLocalTime(element.lastModified)}}
+        <mat-cell *matCellDef="let instance" (click)="modifyInstance(instance)">{{toLocalTime(instance.lastModified)}}
         </mat-cell>
     </ng-container>
 
     <ng-container matColumnDef="action">
         <mat-header-cell class="action-cell" *matHeaderCellDef>Action</mat-header-cell>
         <mat-cell class="action-cell" *matCellDef="let instance">
-            <button mat-icon-button (click)="modifyInstance(instance)" matTooltip="Edit the policy instance">
+            <button mat-icon-button id="{{instance.policy_id + 'EditButton'}}" (click)="modifyInstance(instance)" matTooltip="Edit the policy instance">
                 <mat-icon>edit</mat-icon>
             </button>
-            <button mat-icon-button color="warn" (click)="deleteInstance(instance)"
+            <button mat-icon-button id="{{instance.policy_id + 'DeleteButton'}}" color="warn" (click)="deleteInstance(instance)"
                 matTooltip="Delete the policy instance">
                 <mat-icon>delete</mat-icon>
             </button>
         <mat-footer-cell *matFooterCellDef>No records found.</mat-footer-cell>
     </ng-container>
 
-    <mat-header-row *matHeaderRowDef="['instanceId', 'ric', 'service', 'lastModified', 'action']"
-        [ngClass]="{'display-none': !this.hasInstances()}">
+    <mat-header-row *matHeaderRowDef="['instanceId', 'ric', 'service', 'lastModified', 'action']" [ngClass]="{'display-none': !this.hasInstances()}">
     </mat-header-row>
     <mat-row *matRowDef="let instance; columns: ['instanceId', 'ric', 'service', 'lastModified', 'action'];"></mat-row>
 
     <mat-footer-row *matFooterRowDef="['noRecordsFound']" [ngClass]="{'display-none': this.hasInstances()}">
     </mat-footer-row>
 
-</table>
-
-<div class="spinner-container" *ngIf="instanceDataSource.loading$ | async">
-    <mat-spinner diameter="50"></mat-spinner>
-</div>
\ No newline at end of file
+</mat-table>