Adding 'no records found' when table is empty 89/6889/2
authorychacon <yennifer.chacon@est.tech>
Mon, 18 Oct 2021 07:01:41 +0000 (09:01 +0200)
committerychacon <yennifer.chacon@est.tech>
Tue, 19 Oct 2021 13:04:40 +0000 (15:04 +0200)
Issue-ID: NONRTRIC-555
Signed-off-by: ychacon <yennifer.chacon@est.tech>
Change-Id: Ia3c3915c37d3d3105812b1d75072957d8b37a594

webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.html
webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.scss
webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts
webapp-frontend/src/app/ei-coordinator/producers-list/producers-list.component.html
webapp-frontend/src/app/ei-coordinator/producers-list/producers-list.component.scss
webapp-frontend/src/app/ei-coordinator/producers-list/producers-list.component.spec.ts
webapp-frontend/src/app/ei-coordinator/producers-list/producers-list.component.ts

index 619011d..a54e763 100644 (file)
@@ -103,9 +103,19 @@ limitations under the License.
             </mat-header-cell>
             <mat-cell *matCellDef="let job"> {{job.status}} </mat-cell>
         </ng-container>
             </mat-header-cell>
             <mat-cell *matCellDef="let job"> {{job.status}} </mat-cell>
         </ng-container>
-        <mat-header-row *matHeaderRowDef="['jobId', 'prodIds', 'typeId', 'owner', 'targetUri', 'status']"></mat-header-row>
+        
+        <ng-container matColumnDef="noRecordsFound">
+            <mat-footer-cell *matFooterCellDef>No records found.</mat-footer-cell>
+        </ng-container>
+
+        <mat-header-row *matHeaderRowDef="['jobId', 'prodIds', 'typeId', 'owner', 'targetUri', 'status']" [ngClass]="{'display-none': !this.hasJobs()}">
+        </mat-header-row>
         <mat-row *matRowDef="let row; columns: ['jobId', 'prodIds', 'typeId', 'owner', 'targetUri', 'status'];"></mat-row>
         <mat-row *matRowDef="let row; columns: ['jobId', 'prodIds', 'typeId', 'owner', 'targetUri', 'status'];"></mat-row>
+
+        <mat-footer-row *matFooterRowDef="['noRecordsFound']" [ngClass]="{'display-none': this.hasJobs()}">
+        </mat-footer-row>
+
     </mat-table>
     </mat-table>
-    <mat-paginator [length]="jobs()?.length" [pageSize]="10" [pageSizeOptions]="[5, 10, 25, 100]" showFirstLastButtons
+    <mat-paginator [length]="this.jobsNumber()" [pageSize]="10" [pageSizeOptions]="[5, 10, 25, 100]" showFirstLastButtons
         class="ei-coordinator-table mat-elevation-z8"></mat-paginator>
 </div>
\ No newline at end of file
         class="ei-coordinator-table mat-elevation-z8"></mat-paginator>
 </div>
\ No newline at end of file
index 18f2410..c131630 100644 (file)
 .polling-checkbox{\r
     margin: 0 10px;\r
     font-size: 0.75em;\r
 .polling-checkbox{\r
     margin: 0 10px;\r
     font-size: 0.75em;\r
+}\r
+\r
+.display-none {\r
+    display: none;\r
+  }\r
+\r
+.spinner-container mat-spinner {\r
+margin: 0 auto 0 auto;\r
 }
\ No newline at end of file
 }
\ No newline at end of file
index 097e450..fce9e61 100644 (file)
@@ -280,8 +280,12 @@ export class JobsListComponent implements OnInit {
     this.refresh$.next("");
   }
 
     this.refresh$.next("");
   }
 
+  jobsNumber() : number {
+    return this.jobsDataSource.data.length;
+  }
+
   hasJobs(): boolean {
   hasJobs(): boolean {
-    return this.jobs().length > 0;
+    return this.jobsNumber() > 0;
   }
 
 }
   }
 
 }
index 37b405a..cd79b6e 100644 (file)
@@ -63,7 +63,16 @@ limitations under the License.
       <mat-cell *matCellDef="let producer"> {{this.getProducerStatus(producer)}} </mat-cell>
     </ng-container>
 
       <mat-cell *matCellDef="let producer"> {{this.getProducerStatus(producer)}} </mat-cell>
     </ng-container>
 
-    <mat-header-row *matHeaderRowDef="['id', 'types', 'status']"></mat-header-row>
+    <ng-container matColumnDef="noRecordsFound">
+      <mat-footer-cell *matFooterCellDef>No records found.</mat-footer-cell>
+    </ng-container>
+
+    <mat-header-row *matHeaderRowDef="['id', 'types', 'status']" [ngClass]="{'display-none': !this.hasProducers()}">
+    </mat-header-row>
     <mat-row *matRowDef="let row; columns: ['id', 'types', 'status'];"></mat-row>
     <mat-row *matRowDef="let row; columns: ['id', 'types', 'status'];"></mat-row>
+
+    <mat-footer-row *matFooterRowDef="['noRecordsFound']" [ngClass]="{'display-none': this.hasProducers()}">
+    </mat-footer-row>
+
   </mat-table>
 </div>
   </mat-table>
 </div>
index a94c1a5..56c891d 100644 (file)
 .mat-form-field {
   font-size: 14px;
   width: 100%;
 .mat-form-field {
   font-size: 14px;
   width: 100%;
+}
+.display-none {
+  display: none;
+}
+.spinner-container mat-spinner {
+  margin: 0 auto 0 auto;
 }
\ No newline at end of file
 }
\ No newline at end of file
index 5846ffd..cc3b255 100644 (file)
@@ -73,8 +73,10 @@ describe('ProducersListComponent', () => {
       } as Producer;
 
       setServiceSpy();
       } as Producer;
 
       setServiceSpy();
+
       component.loadProducers();
       const actualProducers: Producer[] = component.producers();
       component.loadProducers();
       const actualProducers: Producer[] = component.producers();
+      expect(actualProducers.length).toEqual(2);
       expect(actualProducers).toEqual([producer1, producer2]);
     });
 
       expect(actualProducers).toEqual([producer1, producer2]);
     });
 
index 5fe0c85..64f4ef2 100644 (file)
@@ -171,7 +171,7 @@ export class ProducersListComponent implements OnInit {
   }
 
   hasProducers(): boolean {
   }
 
   hasProducers(): boolean {
-    return this.producers().length > 0;
+    return this.producersDataSource.data.length > 0;
   }
 
 }
   }
 
 }