Skip to content

Commit 844196b

Browse files
committed
duration
1 parent edc686a commit 844196b

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTable", {
3232
});
3333

3434
const columnModel = this.getTableColumnModel();
35-
columnModel.setColumnVisible(this.self().COLS.PURCHASE_ID.column, false);
35+
columnModel.setColumnVisible(this.self().COLS.CHECKOUT_ID.column, false);
3636
columnModel.setColumnVisible(this.self().COLS.ITEM_ID.column, false);
3737
columnModel.setDataCellRenderer(this.self().COLS.COST.column, new qx.ui.table.cellrenderer.Number());
3838

@@ -41,10 +41,10 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTable", {
4141

4242
statics: {
4343
COLS: {
44-
PURCHASE_ID: {
45-
id: "purchaseId",
44+
CHECKOUT_ID: {
45+
id: "checkoutId",
4646
column: 0,
47-
label: qx.locale.Manager.tr("PurchaseId"),
47+
label: qx.locale.Manager.tr("CheckoutId"),
4848
width: 150
4949
},
5050
ITEM_ID: {
@@ -65,10 +65,10 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTable", {
6565
label: qx.locale.Manager.tr("Start"),
6666
width: 150
6767
},
68-
END: {
69-
id: "end",
68+
DURATION: {
69+
id: "duration",
7070
column: 4,
71-
label: qx.locale.Manager.tr("End"),
71+
label: qx.locale.Manager.tr("Duration"),
7272
width: 150
7373
},
7474
SEATS: {
@@ -77,15 +77,9 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTable", {
7777
label: qx.locale.Manager.tr("Seats"),
7878
width: 50
7979
},
80-
COST: {
81-
id: "cost",
82-
column: 6,
83-
label: qx.locale.Manager.tr("Credits"),
84-
width: 60
85-
},
8680
USER: {
8781
id: "user",
88-
column: 7,
82+
column: 6,
8983
label: qx.locale.Manager.tr("User"),
9084
width: 100
9185
},

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTableModel", {
3333
}
3434
this.setSortColumnIndexWithoutSortingData(checkoutsCols.START.column);
3535
this.setSortAscendingWithoutSortingData(false);
36+
this.setColumnSortable(checkoutsCols.DURATION.column, false);
3637
},
3738

3839
properties: {
@@ -135,14 +136,21 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTableModel", {
135136
const licensedItemId = checkoutsItem["licensedItemId"];
136137
const licensedItem = licensedItems.find(licItem => licItem["licensedItemId"] === licensedItemId);
137138
const vipModel = vipModels.find(vipMdl => licensedItem && (vipMdl["modelId"] == licensedItem["name"]));
139+
let start = "";
140+
let duration = "";
141+
if (checkoutsItem["startedAt"]) {
142+
start = osparc.utils.Utils.formatDateAndTime(new Date(checkoutsItem["startedAt"]));
143+
if (checkoutsItem["stoppedAt"]) {
144+
duration = osparc.utils.Utils.formatMsToHHMMSS(new Date(checkoutsItem["stoppedAt"]) - new Date(checkoutsItem["startedAt"]));
145+
}
146+
}
138147
data.push({
139-
[checkoutsCols.PURCHASE_ID.id]: checkoutsItem["licensedItemPurchaseId"],
148+
[checkoutsCols.CHECKOUT_ID.id]: checkoutsItem["licensed_item_checkout_id"],
140149
[checkoutsCols.ITEM_ID.id]: licensedItemId,
141150
[checkoutsCols.ITEM_LABEL.id]: vipModel ? vipModel["name"] : "unknown model",
142-
[checkoutsCols.START.id]: osparc.utils.Utils.formatDateAndTime(new Date(checkoutsItem["startAt"])),
143-
[checkoutsCols.END.id]: osparc.utils.Utils.formatDateAndTime(new Date(checkoutsItem["expireAt"])),
151+
[checkoutsCols.START.id]: start,
152+
[checkoutsCols.DURATION.id]: duration,
144153
[checkoutsCols.SEATS.id]: checkoutsItem["numOfSeats"],
145-
[checkoutsCols.COST.id]: checkoutsItem["pricingUnitCost"] ? ("-" + parseFloat(checkoutsItem["pricingUnitCost"]).toFixed(2)) : "", // show it negative
146154
[checkoutsCols.USER.id]: checkoutsItem["purchasedByUser"],
147155
});
148156
});

0 commit comments

Comments
 (0)