Skip to content

Commit a9fb226

Browse files
committed
new model
1 parent 9a33acb commit a9fb226

File tree

6 files changed

+105
-167
lines changed

6 files changed

+105
-167
lines changed

services/static-webserver/client/source/class/osparc/data/Job.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,38 @@ qx.Class.define("osparc.data.Job", {
2222
this.base(arguments);
2323

2424
this.set({
25-
jobId: jobData["job_id"],
26-
solver: jobData["solver"],
27-
status: jobData["status"],
28-
progress: jobData["progress"],
29-
submittedAt: jobData["submitted_at"] ? new Date(jobData["submitted_at"]) : null,
30-
startedAt: jobData["started_at"] ? new Date(jobData["started_at"]) : null,
31-
instance: jobData["instance"],
25+
projectUuid: jobData["projectUuid"],
26+
state: jobData["state"],
27+
submittedAt: jobData["submittedAt"] ? new Date(jobData["submittedAt"]) : null,
28+
startedAt: jobData["startedAt"] ? new Date(jobData["startedAt"]) : null,
29+
endedAt: jobData["endedAt"] ? new Date(jobData["endedAt"]) : null,
30+
info: jobData["info"] || null,
3231
});
32+
33+
if (jobData["info"] && jobData["info"]["project_name"]) {
34+
this.setProjectName(jobData["info"]["project_name"]);
35+
}
3336
},
3437

3538
properties: {
36-
jobId: {
39+
projectUuid: {
3740
check: "String",
3841
nullable: false,
3942
init: null,
4043
},
4144

42-
solver: {
45+
projectName: {
4346
check: "String",
4447
nullable: false,
4548
init: null,
4649
},
4750

48-
status: {
51+
state: {
4952
check: "String",
5053
nullable: false,
5154
init: null,
5255
},
5356

54-
progress: {
55-
check: "Number",
56-
init: null,
57-
nullable: true,
58-
},
59-
6057
submittedAt: {
6158
check: "Date",
6259
init: null,
@@ -69,10 +66,10 @@ qx.Class.define("osparc.data.Job", {
6966
nullable: true,
7067
},
7168

72-
instance: {
73-
check: "String",
74-
nullable: false,
69+
endedAt: {
70+
check: "Date",
7571
init: null,
72+
nullable: true,
7673
},
7774

7875
info: {

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ qx.Class.define("osparc.data.Resources", {
324324
endpoints: {
325325
getPage: {
326326
method: "GET",
327-
url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by={orderBy}"
327+
// url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by={orderBy}"
328+
url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by=%7B%22field%22:%22submitted_at%22,%22direction%22:%22desc%22%7D"
328329
},
329330
}
330331
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ qx.Class.define("osparc.jobs.JobsButton", {
7676
const number = this.getChildControl("number");
7777

7878
const jobsStore = osparc.store.Jobs.getInstance();
79-
const nJobs = jobsStore.getJobs().length;
79+
const nJobs = jobsStore.getJobs().length > 20 ? "20+" : jobsStore.getJobs().length;
8080
number.setValue(nJobs.toString());
8181
nJobs ? this.show() : this.exclude();
8282
},

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

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ qx.Class.define("osparc.jobs.JobsTable", {
3232
});
3333

3434
const columnModel = this.getTableColumnModel();
35-
columnModel.setColumnVisible(this.self().COLS.JOB_ID.column, true);
35+
columnModel.setColumnVisible(this.self().COLS.PROJECT_UUID.column, false);
3636

3737
Object.values(this.self().COLS).forEach(col => columnModel.setColumnWidth(col.column, col.width));
3838

@@ -44,81 +44,73 @@ qx.Class.define("osparc.jobs.JobsTable", {
4444
const fontButtonRendererStop = new osparc.ui.table.cellrenderer.ImageButtonRenderer("stop", iconPathStop);
4545
columnModel.setDataCellRenderer(this.self().COLS.ACTION_STOP.column, fontButtonRendererStop);
4646

47-
const iconPathDelete = "osparc/trash-text.svg";
48-
const fontButtonRendererDelete = new osparc.ui.table.cellrenderer.ImageButtonRenderer("delete", iconPathDelete);
49-
columnModel.setDataCellRenderer(this.self().COLS.ACTION_DELETE.column, fontButtonRendererDelete);
50-
51-
const iconPathLogs = "osparc/logs-text.svg";
52-
const fontButtonRendererLogs = new osparc.ui.table.cellrenderer.ImageButtonRenderer("logs", iconPathLogs);
53-
columnModel.setDataCellRenderer(this.self().COLS.ACTION_LOGS.column, fontButtonRendererLogs);
54-
5547
this.__attachHandlers();
5648
},
5749

5850
statics: {
5951
COLS: {
60-
JOB_ID: {
52+
PROJECT_UUID: {
6153
id: "jobId",
6254
column: 0,
63-
label: qx.locale.Manager.tr("Job Id"),
55+
label: qx.locale.Manager.tr("Project Id"),
6456
width: 170
6557
},
66-
SOLVER: {
67-
id: "solver",
58+
PROJECT_NAME: {
59+
id: "projectName",
6860
column: 1,
69-
label: qx.locale.Manager.tr("Solver"),
70-
width: 100
61+
label: qx.locale.Manager.tr("Project Name"),
62+
width: 170
7163
},
72-
STATUS: {
73-
id: "status",
64+
STATE: {
65+
id: "state",
7466
column: 2,
75-
label: qx.locale.Manager.tr("Status"),
67+
label: qx.locale.Manager.tr("State"),
7668
width: 170
7769
},
78-
PROGRESS: {
79-
id: "progress",
80-
column: 3,
81-
label: qx.locale.Manager.tr("Progress"),
82-
width: 80
83-
},
8470
SUBMIT: {
8571
id: "submit",
86-
column: 4,
72+
column: 3,
8773
label: qx.locale.Manager.tr("Submitted"),
8874
width: 130
8975
},
9076
START: {
9177
id: "start",
92-
column: 5,
78+
column: 4,
9379
label: qx.locale.Manager.tr("Started"),
9480
width: 130
9581
},
82+
END: {
83+
id: "end",
84+
column: 5,
85+
label: qx.locale.Manager.tr("Ended"),
86+
width: 130
87+
},
9688
INFO: {
9789
id: "info",
9890
column: 6,
9991
label: qx.locale.Manager.tr("Info"),
10092
width: 40
10193
},
102-
INSTANCE: {
103-
id: "instance",
104-
column: 7,
105-
label: qx.locale.Manager.tr("Instance"),
106-
width: 90
107-
},
10894
ACTION_STOP: {
10995
id: "info",
96+
column: 7,
97+
label: "",
98+
width: 40
99+
},
100+
ACTION_RUN: {
101+
id: "action_run",
110102
column: 8,
111103
label: "",
112104
width: 40
113105
},
114-
ACTION_DELETE: {
115-
id: "info",
106+
ACTION_RETRY: {
107+
id: "action_retry",
116108
column: 9,
117109
label: "",
118110
width: 40
119111
},
120-
ACTION_LOGS: {
121-
id: "info",
112+
ACTION_MORE: {
113+
id: "action_more",
122114
column: 10,
123115
label: "",
124116
width: 40

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

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

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

2525
const jobsCols = osparc.jobs.JobsTable.COLS;
2626
const colLabels = Object.values(jobsCols).map(col => col.label);
2727
const colIDs = Object.values(jobsCols).map(col => col.id);
2828
this.setColumns(colLabels, colIDs);
2929

30-
if (filters) {
31-
this.setFilters(filters);
32-
}
33-
3430
this.setSortColumnIndexWithoutSortingData(jobsCols.SUBMIT.column);
3531
this.setSortAscendingWithoutSortingData(false);
32+
this.setColumnSortable(jobsCols.STATE.column, false);
3633
this.setColumnSortable(jobsCols.INFO.column, false);
3734
this.setColumnSortable(jobsCols.ACTION_STOP.column, false);
38-
this.setColumnSortable(jobsCols.ACTION_DELETE.column, false);
39-
this.setColumnSortable(jobsCols.ACTION_LOGS.column, false);
35+
this.setColumnSortable(jobsCols.ACTION_RUN.column, false);
36+
this.setColumnSortable(jobsCols.ACTION_RETRY.column, false);
37+
this.setColumnSortable(jobsCols.ACTION_MORE.column, false);
4038
},
4139

4240
properties: {
@@ -46,84 +44,27 @@ qx.Class.define("osparc.jobs.JobsTableModel", {
4644
event: "changeFetching"
4745
},
4846

49-
filters: {
50-
check: "Object",
51-
init: null,
52-
apply: "reloadData", // force reload
53-
},
54-
5547
orderBy: {
5648
check: "Object",
5749
init: {
58-
field: "started_at",
50+
field: "submitted_at",
5951
direction: "desc"
6052
}
6153
},
6254
},
6355

64-
statics: {
65-
SERVER_MAX_LIMIT: 49,
66-
COLUMN_ID_TO_DB_COLUMN_MAP: {
67-
0: "started_at",
68-
},
69-
},
70-
7156
members: {
72-
// this should be done by the backend
73-
__filterJobs: function(jobs) {
74-
const filters = this.getFilters();
75-
return jobs.filter(job => {
76-
if (filters) {
77-
let match = false;
78-
[
79-
"jobId",
80-
"solver",
81-
"status",
82-
"instance",
83-
].forEach(filterableField => {
84-
const getter = "get" + qx.lang.String.firstUp(filterableField);
85-
const value = job[getter]();
86-
// lowercase both
87-
if (!match && value && value.toLowerCase().includes(filters.text.toLowerCase())) {
88-
match = true;
89-
}
90-
});
91-
return match;
92-
}
93-
return true;
94-
});
95-
},
96-
97-
// overridden
98-
sortByColumn(columnIndex, ascending) {
99-
this.setOrderBy({
100-
field: this.self().COLUMN_ID_TO_DB_COLUMN_MAP[columnIndex],
101-
direction: ascending ? "asc" : "desc"
102-
})
103-
this.base(arguments, columnIndex, ascending);
104-
},
105-
10657
// overridden
10758
_loadRowCount() {
108-
const urlParams = {
109-
offset: 0,
110-
limit: 1,
111-
filters: this.getFilters() ?
112-
JSON.stringify({
113-
"started_at": this.getFilters()
114-
}) :
115-
null,
116-
orderBy: JSON.stringify(this.getOrderBy()),
117-
};
118-
const options = {
119-
resolveWResponse: true
120-
};
121-
osparc.store.Jobs.getInstance().fetchJobs(urlParams, options)
59+
const offset = 0;
60+
const limit = 1;
61+
osparc.store.Jobs.getInstance().fetchJobs(offset, limit, JSON.stringify(this.getOrderBy()))
12262
.then(jobs => {
123-
const filteredJobs = this.__filterJobs(jobs);
124-
this._onRowCountLoaded(filteredJobs.length);
63+
this._onRowCountLoaded(jobs.length)
64+
})
65+
.catch(() => {
66+
this._onRowCountLoaded(null)
12567
})
126-
.catch(() => this._onRowCountLoaded(null));
12768
},
12869

12970
// overridden
@@ -132,31 +73,19 @@ qx.Class.define("osparc.jobs.JobsTableModel", {
13273

13374
const lastRow = Math.min(qxLastRow, this._rowCount - 1);
13475
// Returns a request promise with given offset and limit
135-
const getFetchPromise = (offset, limit=this.self().SERVER_MAX_LIMIT) => {
136-
const urlParams = {
137-
limit,
138-
offset,
139-
filters: this.getFilters() ?
140-
JSON.stringify({
141-
"started_at": this.getFilters()
142-
}) :
143-
null,
144-
orderBy: JSON.stringify(this.getOrderBy())
145-
};
146-
return osparc.store.Jobs.getInstance().fetchJobs(urlParams)
76+
const getFetchPromise = (offset, limit) => {
77+
return osparc.store.Jobs.getInstance().fetchJobs(offset, limit, JSON.stringify(this.getOrderBy()))
14778
.then(jobs => {
148-
const filteredJobs = this.__filterJobs(jobs);
14979
const data = [];
15080
const jobsCols = osparc.jobs.JobsTable.COLS;
151-
filteredJobs.forEach(job => {
81+
jobs.forEach(job => {
15282
data.push({
153-
[jobsCols.JOB_ID.id]: job.getJobId(),
154-
[jobsCols.SOLVER.id]: job.getSolver(),
155-
[jobsCols.STATUS.id]: job.getStatus(),
156-
[jobsCols.PROGRESS.id]: job.getProgress() ? (job.getProgress() + "%") : "-",
83+
[jobsCols.PROJECT_UUID.id]: job.getProjectUuid(),
84+
[jobsCols.PROJECT_NAME.id]: job.getProjectName(),
85+
[jobsCols.STATE.id]: job.getState(),
15786
[jobsCols.SUBMIT.id]: job.getSubmittedAt() ? osparc.utils.Utils.formatDateAndTime(job.getSubmittedAt()) : "-",
15887
[jobsCols.START.id]: job.getStartedAt() ? osparc.utils.Utils.formatDateAndTime(job.getStartedAt()) : "-",
159-
[jobsCols.INSTANCE.id]: job.getInstance(),
88+
[jobsCols.START.id]: job.getEndedAt() ? osparc.utils.Utils.formatDateAndTime(job.getEndedAt()) : "-",
16089
});
16190
});
16291
return data;

0 commit comments

Comments
 (0)