Skip to content

Commit 29ba3fd

Browse files
committed
JobsTableModel
1 parent 9478e7f commit 29ba3fd

File tree

2 files changed

+30
-52
lines changed

2 files changed

+30
-52
lines changed

services/static-webserver/client/source/class/osparc/jobs/JobsTable.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ qx.Class.define("osparc.jobs.JobsTable", {
6363
label: qx.locale.Manager.tr("Progress"),
6464
width: 100
6565
},
66-
SUBMITTED: {
67-
id: "submitted",
66+
SUBMIT: {
67+
id: "submit",
6868
column: 4,
6969
label: qx.locale.Manager.tr("Submitted"),
7070
width: 150
7171
},
72-
STARTED: {
73-
id: "started",
72+
START: {
73+
id: "start",
7474
column: 5,
7575
label: qx.locale.Manager.tr("Started"),
7676
width: 150

services/static-webserver/client/source/class/osparc/jobs/JobsTableModel.js

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,24 @@
1919
qx.Class.define("osparc.jobs.JobsTableModel", {
2020
extend: qx.ui.table.model.Remote,
2121

22-
construct(walletId, filters) {
22+
construct(filters) {
2323
this.base(arguments);
2424

25-
const checkoutsCols = osparc.jobs.JobsTable.COLS;
26-
const colLabels = Object.values(checkoutsCols).map(col => col.label);
27-
const colIDs = Object.values(checkoutsCols).map(col => col.id);
28-
25+
const jobsCols = osparc.jobs.JobsTable.COLS;
26+
const colLabels = Object.values(jobsCols).map(col => col.label);
27+
const colIDs = Object.values(jobsCols).map(col => col.id);
2928
this.setColumns(colLabels, colIDs);
30-
this.setWalletId(walletId);
29+
3130
if (filters) {
3231
this.setFilters(filters);
3332
}
34-
this.setSortColumnIndexWithoutSortingData(checkoutsCols.START.column);
33+
34+
this.setSortColumnIndexWithoutSortingData(jobsCols.SUBMIT.column);
3535
this.setSortAscendingWithoutSortingData(false);
36-
this.setColumnSortable(checkoutsCols.DURATION.column, false);
36+
this.setColumnSortable(jobsCols.INSTANCE.column, false);
3737
},
3838

3939
properties: {
40-
walletId: {
41-
check: "Number",
42-
nullable: true
43-
},
44-
4540
filters: {
4641
check: "Object",
4742
init: null
@@ -56,7 +51,7 @@ qx.Class.define("osparc.jobs.JobsTableModel", {
5651
orderBy: {
5752
check: "Object",
5853
init: {
59-
field: "startAt",
54+
field: "started_at",
6055
direction: "desc"
6156
}
6257
},
@@ -65,7 +60,7 @@ qx.Class.define("osparc.jobs.JobsTableModel", {
6560
statics: {
6661
SERVER_MAX_LIMIT: 49,
6762
COLUMN_ID_TO_DB_COLUMN_MAP: {
68-
0: "startAt",
63+
0: "started_at",
6964
},
7065
},
7166

@@ -81,22 +76,22 @@ qx.Class.define("osparc.jobs.JobsTableModel", {
8176

8277
// overridden
8378
_loadRowCount() {
84-
const walletId = this.getWalletId();
8579
const urlParams = {
8680
offset: 0,
8781
limit: 1,
8882
filters: this.getFilters() ?
8983
JSON.stringify({
90-
"startAt": this.getFilters()
84+
"started_at": this.getFilters()
9185
}) :
9286
null,
9387
orderBy: JSON.stringify(this.getOrderBy()),
9488
};
9589
const options = {
9690
resolveWResponse: true
9791
};
98-
osparc.store.LicensedItems.getInstance().getCheckedOutLicensedItems(walletId, urlParams, options)
99-
.then(resp => this._onRowCountLoaded(resp["_meta"].total))
92+
const jobsStore = osparc.store.Jobs.getInstance();
93+
jobsStore.fetchJobs(urlParams, options)
94+
.then(jobs => this._onRowCountLoaded(jobs.length))
10095
.catch(() => this._onRowCountLoaded(null));
10196
},
10297

@@ -107,7 +102,6 @@ qx.Class.define("osparc.jobs.JobsTableModel", {
107102
const lastRow = Math.min(qxLastRow, this._rowCount - 1);
108103
// Returns a request promise with given offset and limit
109104
const getFetchPromise = (offset, limit=this.self().SERVER_MAX_LIMIT) => {
110-
const walletId = this.getWalletId();
111105
const urlParams = {
112106
limit,
113107
offset,
@@ -118,36 +112,20 @@ qx.Class.define("osparc.jobs.JobsTableModel", {
118112
null,
119113
orderBy: JSON.stringify(this.getOrderBy())
120114
};
121-
const licensedItemsStore = osparc.store.LicensedItems.getInstance();
122-
return Promise.all([
123-
licensedItemsStore.getLicensedItems(),
124-
licensedItemsStore.getCheckedOutLicensedItems(walletId, urlParams),
125-
])
126-
.then(values => {
127-
const licensedItems = values[0];
128-
const checkoutsItems = values[1];
129-
115+
const jobsStore = osparc.store.Jobs.getInstance();
116+
jobsStore.fetchJobs(urlParams)
117+
.then(jobs => {
130118
const data = [];
131-
const checkoutsCols = osparc.desktop.credits.JobsTable.COLS;
132-
checkoutsItems.forEach(checkoutsItem => {
133-
const licensedItemId = checkoutsItem["licensedItemId"];
134-
const licensedItem = licensedItems[licensedItemId];
135-
let start = "";
136-
let duration = "";
137-
if (checkoutsItem["startedAt"]) {
138-
start = osparc.utils.Utils.formatDateAndTime(new Date(checkoutsItem["startedAt"]));
139-
if (checkoutsItem["stoppedAt"]) {
140-
duration = osparc.utils.Utils.formatMsToHHMMSS(new Date(checkoutsItem["stoppedAt"]) - new Date(checkoutsItem["startedAt"]));
141-
}
142-
}
119+
const jobsCols = osparc.desktop.credits.JobsTable.COLS;
120+
jobs.forEach(job => {
143121
data.push({
144-
[checkoutsCols.CHECKOUT_ID.id]: checkoutsItem["licensedItemCheckoutId"],
145-
[checkoutsCols.ITEM_ID.id]: licensedItemId,
146-
[checkoutsCols.ITEM_LABEL.id]: licensedItem ? licensedItem.getDisplayName() : "unknown model",
147-
[checkoutsCols.START.id]: start,
148-
[checkoutsCols.DURATION.id]: duration,
149-
[checkoutsCols.SEATS.id]: checkoutsItem["numOfSeats"],
150-
[checkoutsCols.USER.id]: checkoutsItem["userEmail"],
122+
[jobsCols.JOB_ID.id]: job.getJobId(),
123+
[jobsCols.SOLVER.id]: job.getSolver(),
124+
[jobsCols.STATUS.id]: job.getStatus(),
125+
[jobsCols.PROGRESS.id]: job.getProgress(),
126+
[jobsCols.SUBMIT.id]: job.getSubmittedAt(),
127+
[jobsCols.START.id]: job.getStartedAt(),
128+
[jobsCols.INSTANCE.id]: job.getInstance(),
151129
});
152130
});
153131
return data;

0 commit comments

Comments
 (0)