Skip to content

Commit 848339f

Browse files
authored
🎨 [Frontend] Expose tags in Usage table (#6961)
1 parent 854af6e commit 848339f

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

services/static-webserver/client/source/class/osparc/dashboard/CardBase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
8585

8686
filterText: function(checks, text) {
8787
if (text) {
88-
const includesSome = checks.some(check => check.toLowerCase().trim().includes(text.toLowerCase()));
88+
const includesSome = checks.some(check => check && check.toLowerCase().trim().includes(text.toLowerCase()));
8989
return !includesSome;
9090
}
9191
return false;

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,11 @@ qx.Class.define("osparc.data.Resources", {
418418
},
419419
getWithWallet: {
420420
method: "GET",
421-
url: statics.API + "/services/-/resource-usages?wallet_id={walletId}&offset={offset}&limit={limit}&filters={filters}&order_by={orderBy}"
421+
url: statics.API + "/services/-/resource-usages?wallet_id={walletId}&offset={offset}&limit={limit}"
422422
},
423-
getWithWallet2: {
423+
getWithWalletFiltered: {
424424
method: "GET",
425-
url: statics.API + "/services/-/resource-usages?wallet_id={walletId}&offset={offset}&limit={limit}"
425+
url: statics.API + "/services/-/resource-usages?wallet_id={walletId}&offset={offset}&limit={limit}&filters={filters}&order_by={orderBy}"
426426
},
427427
getUsagePerService: {
428428
method: "GET",

services/static-webserver/client/source/class/osparc/desktop/credits/CurrentUsage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ qx.Class.define("osparc.desktop.credits.CurrentUsage", {
6666
limit: 10
6767
}
6868
};
69-
osparc.data.Resources.fetch("resourceUsage", "getWithWallet2", params)
69+
osparc.data.Resources.fetch("resourceUsage", "getWithWallet", params)
7070
.then(data => {
7171
const currentTasks = data.filter(d => (d.project_id === currentStudy.getUuid()) && d.service_run_status === "RUNNING");
7272
let cost = 0;

services/static-webserver/client/source/class/osparc/desktop/credits/UsageTable.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ qx.Class.define("osparc.desktop.credits.UsageTable", {
114114
column: 7,
115115
label: qx.locale.Manager.tr("User"),
116116
width: 140
117-
}
117+
},
118+
TAGS: {
119+
id: "tags",
120+
column: 7,
121+
label: qx.locale.Manager.tr("Tags"),
122+
width: 140
123+
},
118124
}
119125
}
120126
});

services/static-webserver/client/source/class/osparc/desktop/credits/UsageTableModel.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ qx.Class.define("osparc.desktop.credits.UsageTableModel", {
6060
// 4: (not used) SORTING BY DURATION
6161
5: "service_run_status",
6262
6: "credit_cost",
63-
7: "user_email"
63+
7: "user_email",
64+
8: "projects_tags",
6465
}
6566
},
6667

@@ -76,7 +77,7 @@ qx.Class.define("osparc.desktop.credits.UsageTableModel", {
7677

7778
// overridden
7879
_loadRowCount() {
79-
const endpoint = this.getWalletId() == null ? "get" : "getWithWallet"
80+
const endpoint = this.getWalletId() == null ? "get" : "getWithWalletFiltered"
8081
const params = {
8182
url: {
8283
walletId: this.getWalletId(),
@@ -109,7 +110,7 @@ qx.Class.define("osparc.desktop.credits.UsageTableModel", {
109110
const lastRow = Math.min(qxLastRow, this._rowCount - 1)
110111
// Returns a request promise with given offset and limit
111112
const getFetchPromise = (offset, limit=this.self().SERVER_MAX_LIMIT) => {
112-
const endpoint = this.getWalletId() == null ? "get" : "getWithWallet"
113+
const endpoint = this.getWalletId() == null ? "get" : "getWithWalletFiltered"
113114
return osparc.data.Resources.fetch("resourceUsage", endpoint, {
114115
url: {
115116
walletId: this.getWalletId(),
@@ -149,7 +150,8 @@ qx.Class.define("osparc.desktop.credits.UsageTableModel", {
149150
[usageCols.DURATION.id]: duration,
150151
[usageCols.STATUS.id]: qx.lang.String.firstUp(rawRow["service_run_status"].toLowerCase()),
151152
[usageCols.COST.id]: rawRow["credit_cost"] ? parseFloat(rawRow["credit_cost"]).toFixed(2) : "",
152-
[usageCols.USER.id]: rawRow["user_email"]
153+
[usageCols.USER.id]: rawRow["user_email"],
154+
[usageCols.TAGS.id]: rawRow["project_tags"],
153155
})
154156
})
155157
return data

services/static-webserver/client/source/class/osparc/vipMarket/VipMarket.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
296296
const found = this.__anatomicalModels.find(model => model["modelId"] === modelId);
297297
if (found) {
298298
found["purchases"].push(purchaseData);
299-
this.__populateModels();
299+
this.__populateModels(modelId);
300300
anatomicModelDetails.setAnatomicalModelsData(found);
301301
}
302302
})
@@ -317,7 +317,7 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
317317
.catch(err => console.error(err));
318318
},
319319

320-
__populateModels: function() {
320+
__populateModels: function(selectModelId) {
321321
const models = this.__anatomicalModels;
322322

323323
this.__anatomicalModelsModel.removeAll();
@@ -358,6 +358,18 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
358358
sortModel(sortBy);
359359
models.forEach(model => this.__anatomicalModelsModel.append(qx.data.marshal.Json.createModel(model)));
360360
}, this);
361+
362+
// select model after timeout, there is something that changes the selection to empty after populating the list
363+
setTimeout(() => {
364+
const modelsUIList = this.getChildControl("models-list");
365+
if (selectModelId) {
366+
const entryFound = modelsUIList.getSelectables().find(entry => "getModelId" in entry && entry.getModelId() === selectModelId);
367+
modelsUIList.setSelection([entryFound]);
368+
} else if (modelsUIList.getSelectables().length) {
369+
// select first
370+
modelsUIList.setSelection([modelsUIList.getSelectables()[0]]);
371+
}
372+
}, 100);
361373
},
362374

363375
__sendImportModelMessage: function(modelId) {

0 commit comments

Comments
 (0)