andybi7676 commented on a change in pull request #812:
URL: https://github.com/apache/submarine/pull/812#discussion_r758922302



##########
File path: 
submarine-workbench/workbench-web/src/app/pages/workbench/model/model-home/model-home.component.ts
##########
@@ -38,80 +39,23 @@ export class ModelHomeComponent implements OnInit {
   listOfChosenTags = [];
 
   ngOnInit() {
-    this.modelCards = [
-      {
-        'name': "Model One",
-        'createTime': "2021-10-12",
-        'updatedTime': "2021-10-13", 
-        'tags': ["image", 'text'],
-        'description': "first model",
-      }, 
-      {
-        'name': "Model Two",
-        'createTime': "2021-10-12",
-        'updatedTime': "2021-10-13", 
-        'tags': ["speech"],
-        'description': "second model",
-      },
-      {
-        'name': "Model Three",
-        'createTime': "2021-10-12",
-        'updatedTime': "2021-10-13", 
-        'tags': ["speech"],
-        'description': "The third model has very long description for 
description shorten testing, 1234567890 A recurrent neural network (RNN) is a 
class of artificial neural networks where connections between nodes form a 
directed graph along a temporal sequence. This allows it to exhibit temporal 
dynamic behavior. Derived from feedforward neural networks, RNNs can use their 
internal state (memory) to process variable length sequences of inputs",
-      },
-      {
-        'name': "ModelFour",
-        'createTime': "2021-10-18",
-        'updatedTime': "2021-10-19", 
-        'tags': ["nlp", 'ssl'],
-        'description': "BERT, a famous ssl model in NLP.",
-      },
-      {
-        'name': "ModelFive",
-        'createTime': "2021-10-18",
-        'updatedTime': "2021-10-19", 
-        'tags': ["speech", 'ssl'],
-        'description': "huBERT, a famous ssl model in SP.",
-      },
-      {
-        'name': "ModelSix",
-        'createTime': "2021-10-18",
-        'updatedTime': "2021-10-19", 
-        'tags': ["CV", 'ssl'],
-        'description': "SimCLR, a famous ssl model in CV.",
-      },
-      {
-        'name': "ModelFour",
-        'createTime': "2021-10-18",
-        'updatedTime': "2021-10-19", 
-        'tags': ["nlp", 'ssl'],
-        'description': "BERT, a famous ssl model in NLP.",
-      },
-      {
-        'name': "ModelFive",
-        'createTime': "2021-10-18",
-        'updatedTime': "2021-10-19", 
-        'tags': ["speech", 'ssl'],
-        'description': "huBERT, a famous ssl model in SP.",
-      },
-      {
-        'name': "ModelSix",
-        'createTime': "2021-10-18",
-        'updatedTime': "2021-10-19", 
-        'tags': ["CV", 'ssl'],
-        'description': "SimCLR, a famous ssl model in CV.",
-      },
-    ];
-    
-    this.onDisplayModelCards = this.modelCards.map(card => card);
-    let tags = [];
-    this.modelCards.map((card) => {
-      Array.prototype.push.apply(tags, card.tags);
+    this.fetchModelCards();
+    this.modelService.emitInfo(null);
+  }
+  
+  fetchModelCards = () => {
+    this.modelService.fetchModelList().subscribe((res) => {
+      this.modelCards = res;
+      this.onDisplayModelCards = this.modelCards.map(card => card);
+      let tags = [];
+      this.modelCards.map((card) => {
+        Array.prototype.push.apply(tags, card.tags);
+      });
+      let tags_set = new Set(tags);
+      tags = Array.from(tags_set);

Review comment:
       I took a look at JavaScript Set. It turns out that JS Set does not have 
built-in functionality for union operation. So I think the previous 
implementation might be the simplest as well. 
   
![image](https://user-images.githubusercontent.com/59821107/143985271-5fea4c38-eef1-4568-9814-4ce0dce973bb.png)
   This figure shows that if we want to union two sets, we still need to 
convert the sets to an array and then regenerate a new set. 
   Another solution is to add the elements one by one. However, this is not 
more efficient and requires more code.




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