chenyulin0719 commented on code in PR #180:
URL: https://github.com/apache/yunikorn-web/pull/180#discussion_r1581750328


##########
src/app/components/queues-view/queues-view.component.ts:
##########
@@ -226,4 +230,14 @@ export class QueuesViewComponent implements OnInit {
       });
     }
   }
+
+  loadStoredPartition(defaultValue = ''): string {
+    const storedPartition = localStorage.getItem('selectedPartitionAndQueue');
+    if (storedPartition && storedPartition.indexOf(':') > 0) return 
storedPartition.split(':')[0];
+    return defaultValue;
+  }
+
+  storeSelectedPartition() {
+    localStorage.setItem('selectedPartitionAndQueue', this.partitionSelected + 
':');
+  }

Review Comment:
   Is it possible to move below localStorage functions into same module?  or 
move to utils? 
   If it's ok we can create another Jira to refactor it.
   
   1. (app-view) loadStoredPartition(defaultValue = '')
   2. (app-view) storeQueueSelection()
   3. (node-view) loadStoredPartition(defaultValue = '')
   4. (node-view) storeSelectedPartition() {
   5. (queue-view) loadStoredPartition(defaultValue = '')
   6. (queue-view) storeSelectedPartition() {
   



##########
src/app/components/apps-view/apps-view.component.ts:
##########
@@ -161,14 +163,33 @@ export class AppsViewComponent implements OnInit {
         if (data && data.rootQueue) {
           const leafQueueList = this.generateLeafQueueList(data.rootQueue);
           this.leafQueueList = [new DropdownItem('-- Select --', ''), 
...leafQueueList];
-          this.leafQueueSelected = '';
           this.fetchApplicationsUsingQueryParams();
+          this.setDefaultQueue(leafQueueList);
         } else {
           this.leafQueueList = [new DropdownItem('-- Select --', '')];
         }
       });
   }
 
+  setDefaultQueue(queueList: DropdownItem[]): void {
+    const storedPartitionAndQueue = 
localStorage.getItem('selectedPartitionAndQueue');
+    if (!storedPartitionAndQueue || storedPartitionAndQueue.indexOf(':') < 0) 
return;

Review Comment:
   How about open queue selection if no data in local storage?
   
   ```
       if (!storedPartitionAndQueue || storedPartitionAndQueue.indexOf(':') < 
0) {
         setTimeout(() => this.openQueueSelection(), 0);
         return;
       }
   ```



##########
src/app/components/apps-view/apps-view.component.ts:
##########
@@ -301,35 +325,65 @@ export class AppsViewComponent implements OnInit {
       this.appDataSource.data = [];
       this.removeRowSelection();
       this.fetchAppListForPartitionAndQueue(this.partitionSelected, 
this.leafQueueSelected);
+      this.storeQueueSelection();
     } else {
       this.searchText = '';
       this.leafQueueSelected = '';
       this.appDataSource.data = [];
       this.removeRowSelection();
+      this.clearQueueSelection();
     }
   }
 
-  formatResources(colValue:string):string[]{
-    const arr:string[]=colValue.split("<br/>")
+  formatResources(colValue: string): string[] {
+    const arr: string[] = colValue.split('<br/>');
     // Check if there are "cpu" or "Memory" elements in the array
-    const hasCpu = arr.some((item) => item.toLowerCase().includes("cpu"));
-    const hasMemory = arr.some((item) => 
item.toLowerCase().includes("memory"));
+    const hasCpu = arr.some((item) => item.toLowerCase().includes('cpu'));
+    const hasMemory = arr.some((item) => 
item.toLowerCase().includes('memory'));
     if (!hasCpu) {
-      arr.unshift("CPU: n/a");
+      arr.unshift('CPU: n/a');
     }
     if (!hasMemory) {
-      arr.unshift("Memory: n/a");
+      arr.unshift('Memory: n/a');
     }
 
     // Concatenate the two arrays, with "cpu" and "Memory" elements first
-    const cpuAndMemoryElements = arr.filter((item) => 
item.toLowerCase().includes("CPU") || item.toLowerCase().includes("Memory"));
-    const otherElements = arr.filter((item) => 
!item.toLowerCase().includes("CPU") && !item.toLowerCase().includes("Memory"));
+    const cpuAndMemoryElements = arr.filter(
+      (item) => item.toLowerCase().includes('CPU') || 
item.toLowerCase().includes('Memory')
+    );
+    const otherElements = arr.filter(
+      (item) => !item.toLowerCase().includes('CPU') && 
!item.toLowerCase().includes('Memory')
+    );
     const result = cpuAndMemoryElements.concat(otherElements);
 
     return result;
   }
 
-  toggle(){
+  clearQueueSelection() {
+    localStorage.removeItem('selectedPartitionAndQueue');
+    this.leafQueueSelected = '';
+    this.openQueueSelection();
+  }
+
+  storeQueueSelection() {
+    localStorage.setItem(
+      'selectedPartitionAndQueue',
+      this.partitionSelected + ':' + this.leafQueueSelected
+    );
+  }
+
+  loadStoredPartition(defaultValue = ''): string {
+    const storedPartition = localStorage.getItem('selectedPartitionAndQueue');
+    if (storedPartition && storedPartition.indexOf(':') > 0) return 
storedPartition.split(':')[0];
+    return defaultValue;
+  }
+
+  openQueueSelection() {
+    // setTimeout(() => this.queueSelect.open(), 100);

Review Comment:
   The comment is redundant? Can you remove it.



-- 
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