Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ qx.Class.define("osparc.data.Resources", {
"runs": {
useCache: false, // handled in osparc.store.Jobs
endpoints: {
getPageLatestActive: {
getPageLatest: {
method: "GET",
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=true"
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}"
},
getPageHistory: {
method: "GET",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ qx.Class.define("osparc.jobs.ActivityOverview", {

const projectUuid = projectData["uuid"];
const includeChildren = true;
const runsTable = new osparc.jobs.RunsTable(projectUuid, includeChildren);
const runningOnly = false;
const runsTable = new osparc.jobs.RunsTable(projectUuid, includeChildren, runningOnly);
const columnModel = runsTable.getTableColumnModel();
// Hide project name column
columnModel.setColumnVisible(osparc.jobs.RunsTable.COLS.PROJECT_NAME.column, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ qx.Class.define("osparc.jobs.RunsBrowser", {
this._setLayout(new qx.ui.layout.VBox(10));

const jobsFilter = this.getChildControl("jobs-filter");
const jobsTable = this.getChildControl("runs-table");
const runningCB = this.getChildControl("running-only-cb");
const runsTable = this.getChildControl("runs-table");

jobsFilter.getChildControl("textfield").addListener("input", e => {
const filterText = e.getData();
jobsTable.getTableModel().setFilters({
text: filterText,
});
runsTable.getTableModel().setFilterString(filterText);
});

this.__reloadInterval = setInterval(() => this.getChildControl("runs-table").reloadRuns(), 10*1000);
runningCB.bind("value", runsTable, "runningOnly");

this.__reloadInterval = setInterval(() => this.reloadRuns(), 10*1000);
},

events: {
Expand All @@ -60,10 +61,18 @@ qx.Class.define("osparc.jobs.RunsBrowser", {
flex: 1
});
break;
case "running-only-cb":
control = new qx.ui.form.CheckBox().set({
value: true,
label: qx.locale.Manager.tr("Active only"),
});
this.getChildControl("header-filter").add(control);
break;
case "runs-table": {
const projectUuid = null;
const includeChildren = false;
control = new osparc.jobs.RunsTable(projectUuid, includeChildren);
const runningOnly = true;
control = new osparc.jobs.RunsTable(projectUuid, includeChildren, runningOnly);
control.addListener("runSelected", e => this.fireDataEvent("runSelected", e.getData()));
this._add(control);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@
qx.Class.define("osparc.jobs.RunsTable", {
extend: qx.ui.table.Table,

construct: function(projectUuid = null, includeChildren = false) {
construct: function(projectUuid = null, includeChildren = false, runningOnly = true) {
this.base(arguments);

this.set({
projectUuid,
runningOnly,
});

const model = new osparc.jobs.RunsTableModel(projectUuid, includeChildren);
this.bind("projectUuid", model, "projectUuid");
this.bind("runningOnly", model, "runningOnly");
this.setTableModel(model);

this.set({
Expand All @@ -47,6 +54,22 @@ qx.Class.define("osparc.jobs.RunsTable", {
this.__attachHandlers();
},

properties: {
projectUuid: {
check: "String",
init: null,
nullable: true,
event: "changeProjectUuid",
},

runningOnly: {
check: "Boolean",
init: true,
nullable: false,
event: "changeRunningOnly",
},
},

events: {
"runSelected": "qx.event.type.Data",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
construct: function(projectUuid = null, includeChildren = false) {
this.base(arguments);

this.__projectUuid = projectUuid;
this.__includeChildren = includeChildren;

this.set({
projectUuid,
});

const jobsCols = osparc.jobs.RunsTable.COLS;
const colLabels = Object.values(jobsCols).map(col => col.label);
const colIDs = Object.values(jobsCols).map(col => col.id);
Expand All @@ -38,6 +41,22 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
},

properties: {
projectUuid: {
check: "String",
init: null,
nullable: true,
event: "changeProjectUuid",
apply: "reloadData",
},

runningOnly: {
check: "Boolean",
init: true,
nullable: false,
event: "changeRunningOnly",
apply: "reloadData",
},

isFetching: {
check: "Boolean",
init: false,
Expand All @@ -51,26 +70,32 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
direction: "desc"
}
},

filterString: {
nullable: true,
check : "String",
init: "",
},
},

statics: {
SERVER_MAX_LIMIT: 49,
},

members: {
__projectUuid: null,
__includeChildren: false,

// overridden
_loadRowCount() {
const offset = 0;
const limit = 1;
const orderBy = JSON.stringify(this.getOrderBy());
const resolveWResponse = true;
let promise;
if (this.__projectUuid) {
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.__projectUuid, this.__includeChildren, offset, limit, JSON.stringify(this.getOrderBy()), resolveWResponse);
if (this.getProjectUuid()) {
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.getProjectUuid(), this.__includeChildren, offset, limit, orderBy, resolveWResponse);
} else {
promise = osparc.store.Jobs.getInstance().fetchJobsActive(offset, limit, JSON.stringify(this.getOrderBy()), resolveWResponse);
promise = osparc.store.Jobs.getInstance().fetchJobsActive(this.getRunningOnly(), offset, limit, orderBy, resolveWResponse);
}
promise
.then(resp => {
Expand All @@ -88,11 +113,12 @@ qx.Class.define("osparc.jobs.RunsTableModel", {
const lastRow = Math.min(qxLastRow, this._rowCount - 1);
// Returns a request promise with given offset and limit
const getFetchPromise = (offset, limit) => {
const orderBy = JSON.stringify(this.getOrderBy());
let promise;
if (this.__projectUuid) {
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.__projectUuid, this.__includeChildren, offset, limit, JSON.stringify(this.getOrderBy()));
if (this.getProjectUuid()) {
promise = osparc.store.Jobs.getInstance().fetchJobsHistory(this.getProjectUuid(), this.__includeChildren, offset, limit, orderBy);
} else {
promise = osparc.store.Jobs.getInstance().fetchJobsActive(offset, limit, JSON.stringify(this.getOrderBy()));
promise = osparc.store.Jobs.getInstance().fetchJobsActive(this.getRunningOnly(), offset, limit, orderBy);
}
return promise
.then(jobs => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ qx.Class.define("osparc.store.Jobs", {

members: {
fetchJobsActive: function(
runningOnly = true,
offset = 0,
limit = this.self().SERVER_MAX_LIMIT,
orderBy = {
Expand All @@ -48,6 +49,7 @@ qx.Class.define("osparc.store.Jobs", {
) {
const params = {
url: {
runningOnly,
offset,
limit,
orderBy: JSON.stringify(orderBy),
Expand All @@ -56,9 +58,11 @@ qx.Class.define("osparc.store.Jobs", {
const options = {
resolveWResponse: true
};
return osparc.data.Resources.fetch("runs", "getPageLatestActive", params, options)
return osparc.data.Resources.fetch("runs", "getPageLatest", params, options)
.then(jobsResp => {
this.fireDataEvent("changeJobsActive", jobsResp["_meta"]["total"]);
if (runningOnly) {
this.fireDataEvent("changeJobsActive", jobsResp["_meta"]["total"]);
}
const jobsActive = [];
if ("data" in jobsResp) {
jobsResp["data"].forEach(jobActiveData => {
Expand Down
Loading