Skip to content

Commit

Permalink
duration
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz committed Jan 15, 2025
1 parent edc686a commit 844196b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTable", {
});

const columnModel = this.getTableColumnModel();
columnModel.setColumnVisible(this.self().COLS.PURCHASE_ID.column, false);
columnModel.setColumnVisible(this.self().COLS.CHECKOUT_ID.column, false);
columnModel.setColumnVisible(this.self().COLS.ITEM_ID.column, false);
columnModel.setDataCellRenderer(this.self().COLS.COST.column, new qx.ui.table.cellrenderer.Number());

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

statics: {
COLS: {
PURCHASE_ID: {
id: "purchaseId",
CHECKOUT_ID: {
id: "checkoutId",
column: 0,
label: qx.locale.Manager.tr("PurchaseId"),
label: qx.locale.Manager.tr("CheckoutId"),
width: 150
},
ITEM_ID: {
Expand All @@ -65,10 +65,10 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTable", {
label: qx.locale.Manager.tr("Start"),
width: 150
},
END: {
id: "end",
DURATION: {
id: "duration",
column: 4,
label: qx.locale.Manager.tr("End"),
label: qx.locale.Manager.tr("Duration"),
width: 150
},
SEATS: {
Expand All @@ -77,15 +77,9 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTable", {
label: qx.locale.Manager.tr("Seats"),
width: 50
},
COST: {
id: "cost",
column: 6,
label: qx.locale.Manager.tr("Credits"),
width: 60
},
USER: {
id: "user",
column: 7,
column: 6,
label: qx.locale.Manager.tr("User"),
width: 100
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTableModel", {
}
this.setSortColumnIndexWithoutSortingData(checkoutsCols.START.column);
this.setSortAscendingWithoutSortingData(false);
this.setColumnSortable(checkoutsCols.DURATION.column, false);
},

properties: {
Expand Down Expand Up @@ -135,14 +136,21 @@ qx.Class.define("osparc.desktop.credits.CheckoutsTableModel", {
const licensedItemId = checkoutsItem["licensedItemId"];
const licensedItem = licensedItems.find(licItem => licItem["licensedItemId"] === licensedItemId);
const vipModel = vipModels.find(vipMdl => licensedItem && (vipMdl["modelId"] == licensedItem["name"]));
let start = "";
let duration = "";
if (checkoutsItem["startedAt"]) {
start = osparc.utils.Utils.formatDateAndTime(new Date(checkoutsItem["startedAt"]));
if (checkoutsItem["stoppedAt"]) {
duration = osparc.utils.Utils.formatMsToHHMMSS(new Date(checkoutsItem["stoppedAt"]) - new Date(checkoutsItem["startedAt"]));
}
}
data.push({
[checkoutsCols.PURCHASE_ID.id]: checkoutsItem["licensedItemPurchaseId"],
[checkoutsCols.CHECKOUT_ID.id]: checkoutsItem["licensed_item_checkout_id"],
[checkoutsCols.ITEM_ID.id]: licensedItemId,
[checkoutsCols.ITEM_LABEL.id]: vipModel ? vipModel["name"] : "unknown model",
[checkoutsCols.START.id]: osparc.utils.Utils.formatDateAndTime(new Date(checkoutsItem["startAt"])),
[checkoutsCols.END.id]: osparc.utils.Utils.formatDateAndTime(new Date(checkoutsItem["expireAt"])),
[checkoutsCols.START.id]: start,
[checkoutsCols.DURATION.id]: duration,
[checkoutsCols.SEATS.id]: checkoutsItem["numOfSeats"],
[checkoutsCols.COST.id]: checkoutsItem["pricingUnitCost"] ? ("-" + parseFloat(checkoutsItem["pricingUnitCost"]).toFixed(2)) : "", // show it negative
[checkoutsCols.USER.id]: checkoutsItem["purchasedByUser"],
});
});
Expand Down

0 comments on commit 844196b

Please sign in to comment.