Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Usage overview: request per wallet #4688

Merged
merged 27 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b6c46f6
Wallets also in staging
odeimaiz Aug 16, 2023
3bf7aa7
paddingRight
odeimaiz Aug 16, 2023
fc1f193
minor
odeimaiz Aug 16, 2023
94c3a7e
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 16, 2023
0063f9e
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 17, 2023
d73db24
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 18, 2023
0a164e7
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 22, 2023
ad99f7c
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 23, 2023
884d863
Merge remote-tracking branch 'upstream/master'
odeimaiz Aug 24, 2023
f95895c
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 24, 2023
d2f5ef0
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 25, 2023
25586ff
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 28, 2023
69c9634
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 29, 2023
01d28a6
git pushMerge remote-tracking branch 'upstream/master'
odeimaiz Aug 30, 2023
2d386f7
resourceUsage endpoint updated
odeimaiz Aug 30, 2023
561e373
Merge branch 'master' into update/containers-to-services
odeimaiz Aug 30, 2023
ed377a0
resourceUsagePerWallet
odeimaiz Aug 30, 2023
051061c
use resourceUsagePerWallet
odeimaiz Aug 30, 2023
c1b29f7
wallet selector in Usage Overview
odeimaiz Aug 30, 2023
266d716
minor
odeimaiz Aug 30, 2023
e1377ad
refactoring
odeimaiz Aug 30, 2023
8fbecae
Merge branch 'master' into update/containers-to-services
odeimaiz Aug 30, 2023
d1d2e67
usage table
odeimaiz Aug 30, 2023
48ce656
minors
odeimaiz Aug 30, 2023
3ab7b01
Merge branch 'master' into update/containers-to-services
odeimaiz Aug 30, 2023
cb72681
Merge branch 'update/containers-to-services' of github.com:odeimaiz/o…
odeimaiz Aug 30, 2023
54cf76d
Merge branch 'master' into update/containers-to-services
odeimaiz Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,26 @@ qx.Class.define("osparc.component.resourceUsage.Overview", {

this._setLayout(new qx.ui.layout.VBox(15));

const walletSelector = this.getChildControl("wallet-selector");
walletSelector.exclude();
osparc.desktop.credits.Utils.areWalletsEnabled()
.then(walletsEnabled => {
if (walletsEnabled) {
walletSelector.show();
}
});

const loadingImage = this.getChildControl("loading-image");
loadingImage.show();
const table = this.getChildControl("usage-table");
table.exclude();

this.__fetchData();
walletSelector.addListener("changeSelection", () => {
this.__prevRequestParams = null;
this.__nextRequestParams = null;
this.__fetchData();
});
},

statics: {
Expand All @@ -53,6 +67,21 @@ qx.Class.define("osparc.component.resourceUsage.Overview", {
_createChildControlImpl: function(id) {
let control;
switch (id) {
case "wallet-selector": {
control = osparc.desktop.credits.Utils.createWalletSelector("read", false, true).set({
allowGrowX: false
});
// select "All wallets" by default
control.getSelectables()[0].setLabel("All wallets");
const layout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
const selectLabel = new qx.ui.basic.Label(this.tr("Select Wallet")).set({
alignY: "middle"
});
layout.add(selectLabel);
layout.add(control);
this._add(layout);
break;
}
case "loading-image":
control = new qx.ui.basic.Image().set({
source: "@FontAwesome5Solid/circle-notch/64",
Expand Down Expand Up @@ -144,10 +173,7 @@ qx.Class.define("osparc.component.resourceUsage.Overview", {
params.url.offset = osparc.utils.Utils.getParamFromURL(this.__prevRequestParams, "offset");
params.url.limit = osparc.utils.Utils.getParamFromURL(this.__prevRequestParams, "limit");
}
const options = {
resolveWResponse: true
};
return osparc.data.Resources.fetch("resourceUsage", "getPage", params, undefined, options);
return this.__getCommonRequest(params);
},

__getNextRequest: function() {
Expand All @@ -161,9 +187,20 @@ qx.Class.define("osparc.component.resourceUsage.Overview", {
params.url.offset = osparc.utils.Utils.getParamFromURL(this.__nextRequestParams, "offset");
params.url.limit = osparc.utils.Utils.getParamFromURL(this.__nextRequestParams, "limit");
}
return this.__getCommonRequest(params);
},

__getCommonRequest: function(params) {
const options = {
resolveWResponse: true
};

const walletSelector = this.getChildControl("wallet-selector");
let walletId = walletSelector.getSelection()[0].walletId;
if (walletId) {
params.url["walletId"] = walletId.toString();
return osparc.data.Resources.fetch("resourceUsagePerWallet", "getPage", params, undefined, options);
}
return osparc.data.Resources.fetch("resourceUsage", "getPage", params, undefined, options);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ qx.Class.define("osparc.component.resourceUsage.OverviewTable", {

const columnModel = this.getTableColumnModel();
columnModel.getBehavior().setWidth(this.self().COLUMNS.duration.pos, 60);
columnModel.getBehavior().setWidth(this.self().COLUMNS.processors.pos, 80);
columnModel.getBehavior().setWidth(this.self().COLUMNS.coreHours.pos, 80);
columnModel.getBehavior().setWidth(this.self().COLUMNS.status.pos, 70);
columnModel.getBehavior().setWidth(this.self().COLUMNS.wallet.pos, 80);
columnModel.setDataCellRenderer(this.self().COLUMNS.duration.pos, new qx.ui.table.cellrenderer.Number());
columnModel.setDataCellRenderer(this.self().COLUMNS.processors.pos, new qx.ui.table.cellrenderer.Number());
columnModel.setDataCellRenderer(this.self().COLUMNS.coreHours.pos, new qx.ui.table.cellrenderer.Number());
},

statics: {
Expand All @@ -63,20 +58,12 @@ qx.Class.define("osparc.component.resourceUsage.OverviewTable", {
pos: 4,
title: "Duration"
},
processors: {
pos: 5,
title: "Processors"
},
coreHours: {
pos: 6,
title: "Core Hours"
},
status: {
pos: 7,
pos: 5,
title: "Status"
},
wallet: {
pos: 8,
pos: 6,
title: "Wallet"
}
}
Expand All @@ -91,19 +78,20 @@ qx.Class.define("osparc.component.resourceUsage.OverviewTable", {
const cols = this.self().COLUMNS;
datas.forEach(data => {
const newData = [];
newData[cols["project"].pos] = data["project_name"] ? data["project_name"] : data["project_uuid"];
newData[cols["node"].pos] = data["node_label"] ? data["node_label"] : data["node_uuid"];
newData[cols["project"].pos] = data["project_name"] ? data["project_name"] : data["project_id"];
newData[cols["node"].pos] = data["node_name"] ? data["node_name"] : data["node_id"];
if (data["service_key"]) {
const parts = data["service_key"].split("/");
const serviceName = parts.pop();
newData[cols["service"].pos] = serviceName + ":" + data["service_version"];
}
newData[cols["start"].pos] = osparc.utils.Utils.formatDateAndTime(new Date(data["start_time"]));
newData[cols["duration"].pos] = data["duration"];
newData[cols["processors"].pos] = data["processors"];
newData[cols["coreHours"].pos] = data["core_hours"];
newData[cols["status"].pos] = qx.lang.String.firstUp(data["status"]);
newData[cols["wallet"].pos] = data["wallet_label"] ? data["wallet_label"] : "Wallet ID?";
const startTime = new Date(data["started_at"]);
newData[cols["start"].pos] = osparc.utils.Utils.formatDateAndTime(startTime);
const stopTime = new Date(data["stopped_at"]);
const durationTimeSec = (stopTime - startTime)/1000;
newData[cols["duration"].pos] = durationTimeSec;
newData[cols["status"].pos] = qx.lang.String.firstUp(data["service_run_status"].toLowerCase());
newData[cols["wallet"].pos] = data["wallet_label"] ? data["wallet_label"] : "unknown";
newDatas.push(newData);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,20 @@ qx.Class.define("osparc.data.Resources", {
}
},
"resourceUsage": {
useCache: true,
useCache: false,
endpoints: {
getPage: {
method: "GET",
url: statics.API + "/resource-usage/services?offset={offset}&limit={limit}"
}
}
},
"resourceUsagePerWallet": {
useCache: false,
endpoints: {
getPage: {
method: "GET",
url: statics.API + "/resource-usage/containers?offset={offset}&limit={limit}"
url: statics.API + "/resource-usage/services?wallet_id={walletId}&offset={offset}&limit={limit}"
}
}
},
Expand Down