Skip to content

Commit 0fb45a9

Browse files
authored
πŸ› [Frontend] Fix: Templates listing (#7673)
1 parent 306fe84 commit 0fb45a9

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

β€Žservices/static-webserver/client/source/class/osparc/dashboard/Dashboard.jsβ€Ž

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ qx.Class.define("osparc.dashboard.Dashboard", {
6969
appearance: {
7070
init: "dashboard",
7171
refine: true
72-
}
72+
},
7373
},
7474

7575
statics: {
7676
PADDING: 15
7777
},
7878

79+
events: {
80+
"preResourcesLoaded": "qx.event.type.Event",
81+
},
82+
7983
members: {
8084
__studyBrowser: null,
8185
__templateBrowser: null,
@@ -181,12 +185,15 @@ qx.Class.define("osparc.dashboard.Dashboard", {
181185
this.add(tabPage);
182186
}, this);
183187

188+
let preResourcesLoaded = false;
184189
const preResourcePromises = [];
185190
const groupsStore = osparc.store.Groups.getInstance();
186191
preResourcePromises.push(groupsStore.fetchGroupsAndMembers());
187192
preResourcePromises.push(osparc.store.Services.getServicesLatest(false));
188193
Promise.all(preResourcePromises)
189194
.then(() => {
195+
preResourcesLoaded = true;
196+
this.fireEvent("preResourcesLoaded");
190197
if (this.__studyBrowser) {
191198
this.__studyBrowser.initResources();
192199
}
@@ -196,15 +203,24 @@ qx.Class.define("osparc.dashboard.Dashboard", {
196203
if (this.__dataBrowser) {
197204
this.__dataBrowser.initResources();
198205
}
199-
200-
this.addListener("changeSelection", e => {
201-
const selectedTab = e.getData()[0];
202-
if (selectedTab && selectedTab.resourceBrowser) {
203-
selectedTab.resourceBrowser.initResources();
204-
}
205-
}, this);
206206
})
207207
.catch(err => console.error(err));
208+
209+
this.addListener("changeSelection", e => {
210+
const selectedTab = e.getData()[0];
211+
if (selectedTab && selectedTab.resourceBrowser) {
212+
// avoid changing the selection when the PreResources are not yet loaded
213+
if (preResourcesLoaded) {
214+
selectedTab.resourceBrowser.initResources();
215+
} else {
216+
const initTab = () => {
217+
selectedTab.resourceBrowser.initResources()
218+
this.removeListener("preResourcesLoaded", initTab);
219+
};
220+
this.addListener("preResourcesLoaded", initTab, this);
221+
}
222+
}
223+
}, this);
208224
},
209225

210226
__createStudyBrowser: function() {

β€Žservices/static-webserver/client/source/class/osparc/dashboard/SearchBarFilter.jsβ€Ž

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,25 @@ qx.Class.define("osparc.dashboard.SearchBarFilter", {
4545
HEIGHT: 36,
4646

4747
getSharedWithOptions: function(resourceType) {
48-
if (resourceType === "service") {
49-
resourceType = "app";
50-
}
48+
const resourceAlias = osparc.product.Utils.resourceTypeToAlias(resourceType, {
49+
firstUpperCase: true,
50+
plural: true
51+
});
5152
return [{
5253
id: "show-all",
53-
label: qx.locale.Manager.tr("All") + " " + osparc.product.Utils.resourceTypeToAlias(resourceType, {
54-
firstUpperCase: true,
55-
plural: true
56-
}),
54+
label: qx.locale.Manager.tr("All") + " " + resourceAlias,
5755
icon: "@FontAwesome5Solid/home/20"
5856
}, {
5957
id: "my-resources",
60-
label: qx.locale.Manager.tr("My") + " " + osparc.product.Utils.resourceTypeToAlias(resourceType, {
61-
firstUpperCase: true,
62-
plural: true
63-
}),
58+
label: qx.locale.Manager.tr("My") + " " + resourceAlias,
6459
icon: "@FontAwesome5Solid/user/20"
6560
}, {
6661
id: "shared-with-me",
6762
label: qx.locale.Manager.tr("Shared with Me"),
6863
icon: "@FontAwesome5Solid/users/20"
6964
}, {
7065
id: "shared-with-everyone",
71-
label: qx.locale.Manager.tr("Public") + " " + osparc.product.Utils.resourceTypeToAlias(resourceType, {
72-
firstUpperCase: true,
73-
plural: true
74-
}),
66+
label: qx.locale.Manager.tr("Public") + " " + resourceAlias,
7567
icon: "@FontAwesome5Solid/globe/20"
7668
}];
7769
}

β€Žservices/static-webserver/client/source/class/osparc/product/Utils.jsβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ qx.Class.define("osparc.product.Utils", {
139139
case "template":
140140
return this.getTemplateAlias(options);
141141
case "service":
142-
return this.getServiceAlias(options);
142+
// return this.getServiceAlias(options);
143+
// Do not use this alias anymore, use "app" instead
144+
return this.getAppAlias(options);
143145
case "hypertool":
144146
return this.getHypertoolAlias(options);
145147
case "app":

β€Žservices/static-webserver/client/source/class/osparc/store/Services.jsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ qx.Class.define("osparc.store.Services", {
360360
__addServiceToCache: function(service) {
361361
const key = service.key;
362362
const version = service.version;
363+
service["resourceType"] = "service";
363364
this.__addToCache(key, version, service);
364365
},
365366

0 commit comments

Comments
Β (0)