Skip to content

Commit 8df1e20

Browse files
authored
πŸŽ¨πŸ› [Frontend] Runs and Tasks sorting (ITISFoundation#7790)
1 parent 5d519af commit 8df1e20

File tree

11 files changed

+75
-18
lines changed

11 files changed

+75
-18
lines changed

β€Žservices/static-webserver/client/source/class/osparc/data/Permissions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,12 @@ qx.Class.define("osparc.data.Permissions", {
163163
"dashboard.services.read"
164164
];
165165
}
166+
166167
if (osparc.product.Utils.getProductName() !== "osparc") {
167168
// data tab only available in osparc and testers
168-
fromUserToTester = [
169+
fromUserToTester.push(
169170
"dashboard.data.read"
170-
];
171+
);
171172
}
172173

173174
fromUserToTester.forEach(onlyTester => {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,11 @@ qx.Class.define("osparc.data.Resources", {
352352
endpoints: {
353353
getPageLatest: {
354354
method: "GET",
355-
url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by=%7B%22field%22:%22submitted_at%22,%22direction%22:%22desc%22%7D&filter_only_running={runningOnly}&filters={filters}"
355+
url: statics.API + "/computations/-/iterations/latest?offset={offset}&limit={limit}&order_by={orderBy}&filter_only_running={runningOnly}&filters={filters}"
356356
},
357357
getPageHistory: {
358358
method: "GET",
359-
url: statics.API + "/computations/{studyId}/iterations?offset={offset}&limit={limit}&order_by=%7B%22field%22:%22submitted_at%22,%22direction%22:%22desc%22%7D&include_children={includeChildren}"
359+
url: statics.API + "/computations/{studyId}/iterations?offset={offset}&limit={limit}&order_by={orderBy}&include_children={includeChildren}"
360360
},
361361
}
362362
},
@@ -365,7 +365,7 @@ qx.Class.define("osparc.data.Resources", {
365365
endpoints: {
366366
getPageLatest: {
367367
method: "GET",
368-
url: statics.API + "/computations/{studyId}/iterations/latest/tasks?offset={offset}&limit={limit}&include_children={includeChildren}"
368+
url: statics.API + "/computations/{studyId}/iterations/latest/tasks?offset={offset}&limit={limit}&order_by={orderBy}&include_children={includeChildren}"
369369
},
370370
}
371371
},

β€Žservices/static-webserver/client/source/class/osparc/data/SubJob.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ qx.Class.define("osparc.data.SubJob", {
104104
progress: subJobData["progress"],
105105
startedAt: subJobData["startedAt"] ? new Date(subJobData["startedAt"]) : null,
106106
endedAt: subJobData["endedAt"] ? new Date(subJobData["endedAt"]) : null,
107+
osparcCredits: subJobData["osparcCredits"] === null ? null : -1*parseFloat(subJobData["osparcCredits"]),
107108
});
108109
},
109110
},

β€Žservices/static-webserver/client/source/class/osparc/info/StudyLarge.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ qx.Class.define("osparc.info.StudyLarge", {
5757

5858
const vBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(10));
5959

60-
if (this.getStudy().getTemplateType() && osparc.data.Permissions.getInstance().isTester()) {
60+
if (
61+
this.__canIWrite() &&
62+
this.getStudy().getTemplateType() &&
63+
osparc.data.Permissions.getInstance().isTester()
64+
) {
6165
// let testers change the template type
6266
const hBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({
6367
alignY: "middle",

β€Žservices/static-webserver/client/source/class/osparc/jobs/ActivityOverview.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ qx.Class.define("osparc.jobs.ActivityOverview", {
100100
runsHistoryTitleLayout.add(runsHistoryTitleHelper);
101101
runsHistoryLayout.add(runsHistoryTitleLayout);
102102

103+
const introText = new qx.ui.basic.Label(this.tr("Select a Run to check the details")).set({
104+
paddingLeft: 10,
105+
});
106+
runsHistoryLayout.add(introText);
107+
103108
const projectUuid = projectData["uuid"];
104109
const includeChildren = true;
105110
const runningOnly = false;

β€Žservices/static-webserver/client/source/class/osparc/jobs/RunsBrowser.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ qx.Class.define("osparc.jobs.RunsBrowser", {
2424

2525
this._setLayout(new qx.ui.layout.VBox(10));
2626

27+
this.getChildControl("intro-label");
2728
const jobsFilter = this.getChildControl("jobs-filter");
2829
const runningCB = this.getChildControl("running-only-cb");
2930
const runsTable = this.getChildControl("runs-table");
@@ -52,6 +53,10 @@ qx.Class.define("osparc.jobs.RunsBrowser", {
5253
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
5354
this._add(control);
5455
break;
56+
case "intro-label":
57+
control = new qx.ui.basic.Label(this.tr("Select a Run to check the details"));
58+
this.getChildControl("header-filter").add(control);
59+
break;
5560
case "jobs-filter":
5661
control = new osparc.filter.TextFilter("text", "jobsList").set({
5762
allowStretchX: true,

β€Žservices/static-webserver/client/source/class/osparc/jobs/RunsTable.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,34 +87,33 @@ qx.Class.define("osparc.jobs.RunsTable", {
8787
column: 1,
8888
label: qx.locale.Manager.tr("Project"),
8989
width: 150,
90-
sortable: true
9190
},
9291
STATE: {
9392
id: "state",
9493
column: 2,
9594
label: qx.locale.Manager.tr("Status"),
96-
width: 150
95+
width: 150,
9796
},
9897
SUBMIT: {
9998
id: "submit",
10099
column: 3,
101100
label: qx.locale.Manager.tr("Queued"),
102101
width: 130,
103-
sortable: true
102+
sortableMap: "submitted_at",
104103
},
105104
START: {
106105
id: "start",
107106
column: 4,
108107
label: qx.locale.Manager.tr("Started"),
109108
width: 130,
110-
sortable: true
109+
sortableMap: "started_at",
111110
},
112111
END: {
113112
id: "end",
114113
column: 5,
115114
label: qx.locale.Manager.tr("Ended"),
116115
width: 130,
117-
sortable: true
116+
sortableMap: "ended_at",
118117
},
119118
ACTION_CANCEL: {
120119
id: "action_cancel",

β€Žservices/static-webserver/client/source/class/osparc/jobs/RunsTableModel.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
3636
this.setSortColumnIndexWithoutSortingData(jobsCols.SUBMIT.column);
3737
this.setSortAscendingWithoutSortingData(false);
3838
Object.values(jobsCols).forEach(col => {
39-
this.setColumnSortable(col.column, Boolean(col.sortable));
39+
this.setColumnSortable(col.column, Boolean(col.sortableMap));
4040
});
4141
},
4242

@@ -66,7 +66,7 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
6666
orderBy: {
6767
check: "Object",
6868
init: {
69-
field: "submitted_at",
69+
field: "submitted_at", // submitted_at|started_at|ended_at
7070
direction: "desc"
7171
}
7272
},
@@ -86,6 +86,17 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
8686
members: {
8787
__includeChildren: false,
8888

89+
// overridden
90+
sortByColumn(columnIndex, ascending) {
91+
const jobsCols = osparc.jobs.RunsTable.COLS;
92+
const colInfo = Object.values(jobsCols).find(col => col.column === columnIndex);
93+
this.setOrderBy({
94+
field: colInfo.sortableMap,
95+
direction: ascending ? "asc" : "desc"
96+
})
97+
this.base(arguments, columnIndex, ascending)
98+
},
99+
89100
// overridden
90101
_loadRowCount() {
91102
const offset = 0;

β€Žservices/static-webserver/client/source/class/osparc/jobs/SubRunsTable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ qx.Class.define("osparc.jobs.SubRunsTable", {
9090
id: "start",
9191
column: 6,
9292
label: qx.locale.Manager.tr("Started"),
93-
width: 130
93+
width: 130,
94+
sortableMap: "started_at",
9495
},
9596
END: {
9697
id: "end",

β€Žservices/static-webserver/client/source/class/osparc/jobs/SubRunsTableModel.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ qx.Class.define("osparc.jobs.SubRunsTableModel", {
3030
this.setSortColumnIndexWithoutSortingData(subJobsCols.START.column);
3131
this.setSortAscendingWithoutSortingData(false);
3232
Object.values(subJobsCols).forEach(col => {
33-
this.setColumnSortable(col.column, false);
33+
this.setColumnSortable(col.column, Boolean(col.sortableMap));
3434
});
3535

3636
this.setProjectUuid(projectUuid);
@@ -47,12 +47,35 @@ qx.Class.define("osparc.jobs.SubRunsTableModel", {
4747
init: false,
4848
event: "changeFetching"
4949
},
50+
51+
orderBy: {
52+
check: "Object",
53+
init: {
54+
field: "started_at", // started_at
55+
direction: "desc"
56+
}
57+
},
58+
},
59+
60+
statics: {
61+
SERVER_MAX_LIMIT: 49,
5062
},
5163

5264
members: {
65+
// overridden
66+
sortByColumn(columnIndex, ascending) {
67+
const subJobsCols = osparc.jobs.SubRunsTable.COLS;
68+
const colInfo = Object.values(subJobsCols).find(col => col.column === columnIndex);
69+
this.setOrderBy({
70+
field: colInfo.sortableMap,
71+
direction: ascending ? "asc" : "desc"
72+
})
73+
this.base(arguments, columnIndex, ascending)
74+
},
75+
5376
// overridden
5477
_loadRowCount() {
55-
osparc.store.Jobs.getInstance().fetchSubJobs(this.getProjectUuid())
78+
osparc.store.Jobs.getInstance().fetchSubJobs(this.getProjectUuid(), this.getOrderBy())
5679
.then(subJobs => {
5780
this._onRowCountLoaded(subJobs.length)
5881
})
@@ -68,7 +91,7 @@ qx.Class.define("osparc.jobs.SubRunsTableModel", {
6891
const lastRow = Math.min(qxLastRow, this._rowCount - 1);
6992
// Returns a request promise with given offset and limit
7093
const getFetchPromise = () => {
71-
return osparc.store.Jobs.getInstance().fetchSubJobs(this.getProjectUuid())
94+
return osparc.store.Jobs.getInstance().fetchSubJobs(this.getProjectUuid(), this.getOrderBy())
7295
.then(subJobs => {
7396
const data = [];
7497
const subJobsCols = osparc.jobs.SubRunsTable.COLS;

0 commit comments

Comments
Β (0)