stu01509 commented on code in PR #148:
URL: https://github.com/apache/yunikorn-web/pull/148#discussion_r1398214897


##########
src/app/components/nodes-view/nodes-view.component.ts:
##########
@@ -137,7 +137,7 @@ export class NodesViewComponent implements OnInit {
       )
       .subscribe((data) => {
         this.nodeDataSource.data = data;
-        console.log(data);
+        this.formatColumn()

Review Comment:
   Please help to add the semicolon.
   
   ```ts
   this.formatColumn();
   ```



##########
src/app/components/nodes-view/nodes-view.component.ts:
##########
@@ -188,6 +188,20 @@ export class NodesViewComponent implements OnInit {
     return this.allocDataSource.data && this.allocDataSource.data.length === 0;
   }
 
+  formatColumn(){
+    if(this.nodeDataSource.data.length==0){
+      return
+    }
+    this.nodeColumnIds.forEach((colId)=>{
+      let emptyCell=this.nodeDataSource.data.filter((node)=>{
+        return (node as any)[colId]=="" || (node as any)[colId]=="n/a"
+      })
+      if (emptyCell.length==this.nodeDataSource.data.length){
+        this.nodeColumnIds = this.nodeColumnIds.filter(el => el!==colId)
+      }
+    })

Review Comment:
   In JavaScript, Please use the[ strict 
equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality)
 `===` to compare the two values.
   
   Maybe could change to this
   ```ts
     formatColumn() {
       if (this.nodeDataSource.data.length === 0) {
         return;
       }
       this.nodeColumnIds.forEach((colId) => {
         const emptyCell = this.nodeDataSource.data.filter((node) => {
           return node.colId === '' || node.colId === 'n/a';
         })
         if (emptyCell.length === this.nodeDataSource.data.length) {
           this.nodeColumnIds = this.nodeColumnIds.filter(el => el !== colId);
         }
       })
     }
   ```
   
   And in here 
https://github.com/apache/yunikorn-web/blob/master/src/app/models/node-info.model.ts#L33,
 add the `colId` type
   
   ```ts
   export class NodeInfo {
     isSelected = false;
     constructor(
       public nodeId: string,
       public hostName: string,
       public rackName: string,
       public partitionName: string,
       public capacity: string,
       public allocated: string,
       public occupied: string,
       public available: string,
       public utilized: string,
       public colId: string,
       public allocations: AllocationInfo[] | null
     ) {}
   
     setAllocations(allocs: AllocationInfo[]) {
       this.allocations = allocs;
     }
   }
   ``` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to