Skip to content

Commit

Permalink
🎨 [Frontend] Expose tags in Usage table (#6961)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Dec 16, 2024
1 parent 854af6e commit 848339f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ qx.Class.define("osparc.dashboard.CardBase", {

filterText: function(checks, text) {
if (text) {
const includesSome = checks.some(check => check.toLowerCase().trim().includes(text.toLowerCase()));
const includesSome = checks.some(check => check && check.toLowerCase().trim().includes(text.toLowerCase()));
return !includesSome;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,11 @@ qx.Class.define("osparc.data.Resources", {
},
getWithWallet: {
method: "GET",
url: statics.API + "/services/-/resource-usages?wallet_id={walletId}&offset={offset}&limit={limit}&filters={filters}&order_by={orderBy}"
url: statics.API + "/services/-/resource-usages?wallet_id={walletId}&offset={offset}&limit={limit}"
},
getWithWallet2: {
getWithWalletFiltered: {
method: "GET",
url: statics.API + "/services/-/resource-usages?wallet_id={walletId}&offset={offset}&limit={limit}"
url: statics.API + "/services/-/resource-usages?wallet_id={walletId}&offset={offset}&limit={limit}&filters={filters}&order_by={orderBy}"
},
getUsagePerService: {
method: "GET",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ qx.Class.define("osparc.desktop.credits.CurrentUsage", {
limit: 10
}
};
osparc.data.Resources.fetch("resourceUsage", "getWithWallet2", params)
osparc.data.Resources.fetch("resourceUsage", "getWithWallet", params)
.then(data => {
const currentTasks = data.filter(d => (d.project_id === currentStudy.getUuid()) && d.service_run_status === "RUNNING");
let cost = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ qx.Class.define("osparc.desktop.credits.UsageTable", {
column: 7,
label: qx.locale.Manager.tr("User"),
width: 140
}
},
TAGS: {
id: "tags",
column: 7,
label: qx.locale.Manager.tr("Tags"),
width: 140
},
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ qx.Class.define("osparc.desktop.credits.UsageTableModel", {
// 4: (not used) SORTING BY DURATION
5: "service_run_status",
6: "credit_cost",
7: "user_email"
7: "user_email",
8: "projects_tags",
}
},

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

// overridden
_loadRowCount() {
const endpoint = this.getWalletId() == null ? "get" : "getWithWallet"
const endpoint = this.getWalletId() == null ? "get" : "getWithWalletFiltered"
const params = {
url: {
walletId: this.getWalletId(),
Expand Down Expand Up @@ -109,7 +110,7 @@ qx.Class.define("osparc.desktop.credits.UsageTableModel", {
const lastRow = Math.min(qxLastRow, this._rowCount - 1)
// Returns a request promise with given offset and limit
const getFetchPromise = (offset, limit=this.self().SERVER_MAX_LIMIT) => {
const endpoint = this.getWalletId() == null ? "get" : "getWithWallet"
const endpoint = this.getWalletId() == null ? "get" : "getWithWalletFiltered"
return osparc.data.Resources.fetch("resourceUsage", endpoint, {
url: {
walletId: this.getWalletId(),
Expand Down Expand Up @@ -149,7 +150,8 @@ qx.Class.define("osparc.desktop.credits.UsageTableModel", {
[usageCols.DURATION.id]: duration,
[usageCols.STATUS.id]: qx.lang.String.firstUp(rawRow["service_run_status"].toLowerCase()),
[usageCols.COST.id]: rawRow["credit_cost"] ? parseFloat(rawRow["credit_cost"]).toFixed(2) : "",
[usageCols.USER.id]: rawRow["user_email"]
[usageCols.USER.id]: rawRow["user_email"],
[usageCols.TAGS.id]: rawRow["project_tags"],
})
})
return data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
const found = this.__anatomicalModels.find(model => model["modelId"] === modelId);
if (found) {
found["purchases"].push(purchaseData);
this.__populateModels();
this.__populateModels(modelId);
anatomicModelDetails.setAnatomicalModelsData(found);
}
})
Expand All @@ -317,7 +317,7 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
.catch(err => console.error(err));
},

__populateModels: function() {
__populateModels: function(selectModelId) {
const models = this.__anatomicalModels;

this.__anatomicalModelsModel.removeAll();
Expand Down Expand Up @@ -358,6 +358,18 @@ qx.Class.define("osparc.vipMarket.VipMarket", {
sortModel(sortBy);
models.forEach(model => this.__anatomicalModelsModel.append(qx.data.marshal.Json.createModel(model)));
}, this);

// select model after timeout, there is something that changes the selection to empty after populating the list
setTimeout(() => {
const modelsUIList = this.getChildControl("models-list");
if (selectModelId) {
const entryFound = modelsUIList.getSelectables().find(entry => "getModelId" in entry && entry.getModelId() === selectModelId);
modelsUIList.setSelection([entryFound]);
} else if (modelsUIList.getSelectables().length) {
// select first
modelsUIList.setSelection([modelsUIList.getSelectables()[0]]);
}
}, 100);
},

__sendImportModelMessage: function(modelId) {
Expand Down

0 comments on commit 848339f

Please sign in to comment.