From 08021e75cc6de7d665cfb7452d39c01949630a1a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 11:54:23 +0200 Subject: [PATCH 001/100] rename header --- .../class/osparc/dashboard/StudyBrowser.js | 53 ++++++++++++------- ...rkspaceHeader.js => StudyBrowserHeader.js} | 2 +- 2 files changed, 36 insertions(+), 19 deletions(-) rename services/static-webserver/client/source/class/osparc/dashboard/{WorkspaceHeader.js => StudyBrowserHeader.js} (99%) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index bc22291e7bc..de825764045 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -49,6 +49,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, properties: { + currentContext: { + check: ["studiesAndFolders", "workspaces", "search", "bin"], + nullable: false, + init: "studiesAndFolders", + event: "changeCurrentContext" + }, + currentWorkspaceId: { check: "Number", nullable: true, @@ -101,7 +108,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { members: { __dontShowTutorial: null, - __workspaceHeader: null, + __header: null, __workspacesList: null, __foldersList: null, @@ -177,7 +184,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { const folderId = this.getCurrentFolderId(); const workspaceId = this.getCurrentWorkspaceId(); - if (workspaceId === -1 || workspaceId === -2) { + if (this.getCurrentContext() !== "studiesAndFolders") { return; } this.__setFoldersToList([]); @@ -412,7 +419,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __addNewFolderButton: function() { const currentWorkspaceId = this.getCurrentWorkspaceId(); if (currentWorkspaceId) { - if (currentWorkspaceId === -1 || currentWorkspaceId === -2) { + if (this.getCurrentContext() !== "studiesAndFolders") { return; } const currentWorkspace = osparc.store.Workspaces.getInstance().getWorkspace(this.getCurrentWorkspaceId()); @@ -697,11 +704,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __addNewStudyButtons: function() { + if (this.getCurrentContext() !== "studiesAndFolders") { + return; + } const currentWorkspaceId = this.getCurrentWorkspaceId(); if (currentWorkspaceId) { - if (currentWorkspaceId === -2) { - return; - } const currentWorkspace = osparc.store.Workspaces.getInstance().getWorkspace(currentWorkspaceId); if (currentWorkspace && !currentWorkspace.getMyAccessRights()["write"]) { // If user can't write in workspace, do not show plus buttons @@ -827,8 +834,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._createSearchBar(); if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { - const workspaceHeader = this.__workspaceHeader = new osparc.dashboard.WorkspaceHeader(); - this._addToLayout(workspaceHeader); + const header = this.__header = new osparc.dashboard.StudyBrowserHeader(); + this._addToLayout(header); } this._createResourcesLayout(); @@ -900,7 +907,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __connectContexts: function() { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { - const workspaceHeader = this.__workspaceHeader; + const workspaceHeader = this.__header; workspaceHeader.addListener("contextChanged", () => { const workspaceId = workspaceHeader.getCurrentWorkspaceId(); const folderId = workspaceHeader.getCurrentFolderId(); @@ -940,31 +947,41 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.resetSelection(); this.setMultiSelection(false); + let currentContext = null; + switch (workspaceId) { + case -2: + currentContext = "search"; + break; + case -1: + currentContext = "workspaces"; + break; + default: + currentContext = "studiesAndFolders"; + break; + } this.set({ + currentContext, currentWorkspaceId: workspaceId, currentFolderId: folderId, }); this.invalidateStudies(); this._resourcesContainer.setResourcesToList([]); - if (workspaceId === -2) { - // Search result: no folders, just studies + if (currentContext === "search") { this.__setFoldersToList([]); this.__reloadStudies(); - } else if (workspaceId === -1) { - // Workspaces + } else if (currentContext === "workspaces") { this._searchBarFilter.resetFilters(); this.__reloadWorkspaces(); - } else { - // Actual workspace + } else if (currentContext === "studiesAndFolders") { this._searchBarFilter.resetFilters(); this.__reloadFolders(); this.__reloadStudies(); } - // notify workspaceHeader - const workspaceHeader = this.__workspaceHeader; - workspaceHeader.set({ + // notify header + const header = this.__header; + header.set({ currentWorkspaceId: workspaceId, currentFolderId: folderId, }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js similarity index 99% rename from services/static-webserver/client/source/class/osparc/dashboard/WorkspaceHeader.js rename to services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 819a8bf07bb..4ee9dd1b4c4 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -20,7 +20,7 @@ * */ -qx.Class.define("osparc.dashboard.WorkspaceHeader", { +qx.Class.define("osparc.dashboard.StudyBrowserHeader", { extend: qx.ui.core.Widget, construct: function() { From 0439637ab74c377eaca3d6916c861f3e1865eec3 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 12:33:57 +0200 Subject: [PATCH 002/100] currentContext prop in header --- .../class/osparc/dashboard/StudyBrowser.js | 24 ++++++++++--------- .../osparc/dashboard/StudyBrowserHeader.js | 7 ++++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index de825764045..e397d509a55 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -936,17 +936,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __changeContext: function(workspaceId, folderId) { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { - if ( - workspaceId !== -2 && // reload studies for a new search - workspaceId === this.getCurrentWorkspaceId() && - folderId === this.getCurrentFolderId() - ) { - // didn't really change - return; - } - - this.resetSelection(); - this.setMultiSelection(false); let currentContext = null; switch (workspaceId) { case -2: @@ -959,6 +948,18 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { currentContext = "studiesAndFolders"; break; } + + if ( + currentContext !== "search" && // reload studies for a new search + workspaceId === this.getCurrentWorkspaceId() && + folderId === this.getCurrentFolderId() + ) { + // didn't really change + return; + } + + this.resetSelection(); + this.setMultiSelection(false); this.set({ currentContext, currentWorkspaceId: workspaceId, @@ -982,6 +983,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // notify header const header = this.__header; header.set({ + currentContext, currentWorkspaceId: workspaceId, currentFolderId: folderId, }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 4ee9dd1b4c4..8e9136dfaaf 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -48,6 +48,13 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }, properties: { + currentContext: { + check: ["studiesAndFolders", "workspaces", "search", "bin"], + nullable: false, + init: "studiesAndFolders", + event: "changeCurrentContext" + }, + currentWorkspaceId: { check: "Number", nullable: true, From a61bd97ae1b182d76b6941a114d72023eeb30c6c Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 13:00:14 +0200 Subject: [PATCH 003/100] use currentContext --- .../class/osparc/dashboard/StudyBrowserHeader.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 8e9136dfaaf..fa34dd064bd 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -52,7 +52,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { check: ["studiesAndFolders", "workspaces", "search", "bin"], nullable: false, init: "studiesAndFolders", - event: "changeCurrentContext" + event: "changeCurrentContext", + apply: "__buildLayout" }, currentWorkspaceId: { @@ -183,7 +184,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { return control || this.base(arguments, id); }, - __buildLayout: function(workspaceId) { + __buildLayout: function() { this.getChildControl("icon"); const title = this.getChildControl("workspace-title"); this.getChildControl("breadcrumbs"); @@ -191,19 +192,21 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { this.resetAccessRights(); this.resetMyAccessRights(); - if (workspaceId === -2) { + const currentContext = this.getCurrentContext(); + if (currentContext === "search") { this.__setIcon("@FontAwesome5Solid/search/24"); title.set({ value: this.tr("Search results"), cursor: "auto", }); - } else if (workspaceId === -1) { + } else if (currentContext === "workspaces") { this.__setIcon(osparc.store.Workspaces.iconPath(32)); title.set({ value: this.tr("Shared Workspaces"), cursor: "auto", }) - } else { + } else if (currentContext === "studiesAndFolders") { + const workspaceId = this.getCurrentWorkspaceId(); title.set({ cursor: "pointer" }); @@ -339,7 +342,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { const win = osparc.ui.window.Window.popUpInWindow(permissionsView, title, 300, 200); permissionsView.addListener("workspaceUpdated", () => { win.close(); - this.__buildLayout(this.getCurrentWorkspaceId()); + this.__buildLayout(); }, this); }, From f47ac8f14ee16c67ca0d9bec486e3d5a5dfca631 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 13:02:28 +0200 Subject: [PATCH 004/100] minor --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index e397d509a55..35b20561949 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -907,10 +907,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __connectContexts: function() { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { - const workspaceHeader = this.__header; - workspaceHeader.addListener("contextChanged", () => { - const workspaceId = workspaceHeader.getCurrentWorkspaceId(); - const folderId = workspaceHeader.getCurrentFolderId(); + const header = this.__header; + header.addListener("contextChanged", () => { + const workspaceId = header.getCurrentWorkspaceId(); + const folderId = header.getCurrentFolderId(); this.__changeContext(workspaceId, folderId); }, this); From 8f1f52494020a6551c2466d36c9596bcb09d42a9 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 13:03:11 +0200 Subject: [PATCH 005/100] "locationChanged" --- .../source/class/osparc/dashboard/ContextBreadcrumbs.js | 4 ++-- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- .../source/class/osparc/dashboard/StudyBrowserHeader.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js b/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js index f31ad07941c..0e29f60fdb8 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js @@ -27,7 +27,7 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { }, events: { - "contextChanged": "qx.event.type.Data", + "locationChanged": "qx.event.type.Data", }, properties: { @@ -94,7 +94,7 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { currentWorkspaceId: workspaceId, currentFolderId: folderId, }); - this.fireDataEvent("contextChanged", { + this.fireDataEvent("locationChanged", { workspaceId, folderId, }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 35b20561949..8cf6c2a65e5 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -908,7 +908,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __connectContexts: function() { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { const header = this.__header; - header.addListener("contextChanged", () => { + header.addListener("locationChanged", () => { const workspaceId = header.getCurrentWorkspaceId(); const folderId = header.getCurrentFolderId(); this.__changeContext(workspaceId, folderId); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index fa34dd064bd..fa7ed0f7e3d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -42,7 +42,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }, events: { - "contextChanged": "qx.event.type.Data", + "locationChanged": "qx.event.type.Data", "workspaceUpdated": "qx.event.type.Data", "deleteWorkspaceRequested": "qx.event.type.Data" }, @@ -121,8 +121,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { this.bind("currentFolderId", control, "currentFolderId"); control.bind("currentWorkspaceId", this, "currentWorkspaceId"); control.bind("currentFolderId", this, "currentFolderId"); - control.addListener("contextChanged", e => { - this.fireDataEvent("contextChanged", e.getData()) + control.addListener("locationChanged", e => { + this.fireDataEvent("locationChanged", e.getData()) }); this._add(control); break; @@ -213,7 +213,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { title.addListener("tap", () => { const folderId = null; this.setCurrentFolderId(folderId); - this.fireDataEvent("contextChanged", { + this.fireDataEvent("locationChanged", { workspaceId, folderId, }); From 842fabece405499b8ee80049b00faf58055583ee Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 13:08:33 +0200 Subject: [PATCH 006/100] more renaming --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- .../source/class/osparc/dashboard/WorkspacesAndFoldersTree.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 8cf6c2a65e5..96268121e1f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -915,7 +915,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, this); const workspacesAndFoldersTree = this._resourceFilter.getWorkspacesAndFoldersTree(); - workspacesAndFoldersTree.addListener("contextChanged", e => { + workspacesAndFoldersTree.addListener("locationChanged", e => { const context = e.getData(); const workspaceId = context["workspaceId"]; const folderId = context["folderId"]; diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js index 46382726935..dc1b6a94a65 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js @@ -83,7 +83,7 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", { const item = selection.getItem(0); const workspaceId = item.getWorkspaceId(); const folderId = item.getFolderId(); - this.fireDataEvent("contextChanged", { + this.fireDataEvent("locationChanged", { workspaceId, folderId, }); @@ -93,7 +93,7 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", { events: { "openChanged": "qx.event.type.Event", - "contextChanged": "qx.event.type.Data", + "locationChanged": "qx.event.type.Data", }, properties: { From a8d50e689658972e2584a478345fa187a7cab1d6 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 13:29:42 +0200 Subject: [PATCH 007/100] Trash context --- .../class/osparc/dashboard/ResourceFilter.js | 27 +++++++++-- .../class/osparc/dashboard/StudyBrowser.js | 45 ++++++++----------- .../osparc/dashboard/StudyBrowserHeader.js | 8 +++- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js index 18464aa3755..89d85e6384a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js @@ -29,11 +29,12 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { this.__tagButtons = []; this.__serviceTypeButtons = []; - this._setLayout(new qx.ui.layout.VBox(30)); + this._setLayout(new qx.ui.layout.VBox(20)); this.__buildLayout(); }, events: { + "trashContext": "qx.event.type.Event", "changeSharedWith": "qx.event.type.Data", "changeSelectedTags": "qx.event.type.Data", "changeServiceType": "qx.event.type.Data" @@ -42,6 +43,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { members: { __resourceType: null, __workspacesAndFoldersTree: null, + __trashButton: null, __sharedWithButtons: null, __tagButtons: null, __serviceTypeButtons: null, @@ -49,6 +51,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { __buildLayout: function() { if (this.__resourceType === "study" && osparc.utils.DisabledPlugins.isFoldersEnabled()) { this._add(this.__createWorkspacesAndFoldersTree()); + this._add(this.__createTrashBin()); } else { this._add(this.__createSharedWithFilterLayout()); } @@ -62,15 +65,14 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { } }, - /* WORKSPACES AND FOLDERS */ __createWorkspacesAndFoldersTree: function() { const workspacesAndFoldersTree = this.__workspacesAndFoldersTree = new osparc.dashboard.WorkspacesAndFoldersTree(); // Height needs to be calculated manually to make it flexible workspacesAndFoldersTree.set({ - minHeight: 100, + minHeight: 60, maxHeight: 400, - height: 100, + height: 60, }); workspacesAndFoldersTree.addListener("openChanged", () => { const rowConfig = workspacesAndFoldersTree.getPane().getRowConfig(); @@ -85,6 +87,23 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { }, /* /WORKSPACES AND FOLDERS */ + /* TRASH BIN */ + __createTrashBin: function() { + const trashButton = this.__trashButton = new qx.ui.toolbar.RadioButton().set({ + appearance: "filter-toggle-button", + label: this.tr("Trash"), + icon: "@FontAwesome5Solid/trash/18", + }); + trashButton.addListener("changeValue", e => { + const trashEnabled = e.getData(); + if (trashEnabled) { + this.fireEvent("trashContext"); + } + }); + return trashButton; + }, + /* /TRASH BIN */ + /* SHARED WITH */ __createSharedWithFilterLayout: function() { const sharedWithLayout = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 96268121e1f..5bd63932440 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -50,7 +50,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { properties: { currentContext: { - check: ["studiesAndFolders", "workspaces", "search", "bin"], + check: ["studiesAndFolders", "workspaces", "search", "trash"], nullable: false, init: "studiesAndFolders", event: "changeCurrentContext" @@ -389,7 +389,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _workspaceSelected: function(workspaceId) { - this.__changeContext(workspaceId, null); + this.__changeContext("studiesAndWorkspaces", workspaceId, null); }, _workspaceUpdated: function() { @@ -449,7 +449,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _folderSelected: function(folderId) { - this.__changeContext(this.getCurrentWorkspaceId(), folderId); + this.__changeContext("studiesAndWorkspaces", this.getCurrentWorkspaceId(), folderId); }, _folderUpdated: function() { @@ -911,7 +911,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { header.addListener("locationChanged", () => { const workspaceId = header.getCurrentWorkspaceId(); const folderId = header.getCurrentFolderId(); - this.__changeContext(workspaceId, folderId); + this.__changeContext("studiesAndWorkspaces", workspaceId, folderId); }, this); const workspacesAndFoldersTree = this._resourceFilter.getWorkspacesAndFoldersTree(); @@ -919,38 +919,29 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const context = e.getData(); const workspaceId = context["workspaceId"]; const folderId = context["folderId"]; - this.__changeContext(workspaceId, folderId); + this.__changeContext("studiesAndWorkspaces", workspaceId, folderId); }, this); + this._resourceFilter.addListener("trashContext", () => { + this.__changeContext("trash"); + }); + this._searchBarFilter.addListener("filterChanged", e => { const filterData = e.getData(); if (filterData.text) { - this.__changeContext(-2, null); + this.__changeContext("search"); } else { // Back to My Workspace - this.__changeContext(null, null); + this.__changeContext("studiesAndWorkspaces", null, null); } }); } }, - __changeContext: function(workspaceId, folderId) { + __changeContext: function(context, workspaceId, folderId) { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { - let currentContext = null; - switch (workspaceId) { - case -2: - currentContext = "search"; - break; - case -1: - currentContext = "workspaces"; - break; - default: - currentContext = "studiesAndFolders"; - break; - } - if ( - currentContext !== "search" && // reload studies for a new search + context !== "search" && // reload studies for a new search workspaceId === this.getCurrentWorkspaceId() && folderId === this.getCurrentFolderId() ) { @@ -961,20 +952,20 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.resetSelection(); this.setMultiSelection(false); this.set({ - currentContext, + currentContext: context, currentWorkspaceId: workspaceId, currentFolderId: folderId, }); this.invalidateStudies(); this._resourcesContainer.setResourcesToList([]); - if (currentContext === "search") { + if (context === "search") { this.__setFoldersToList([]); this.__reloadStudies(); - } else if (currentContext === "workspaces") { + } else if (context === "workspaces") { this._searchBarFilter.resetFilters(); this.__reloadWorkspaces(); - } else if (currentContext === "studiesAndFolders") { + } else if (context === "studiesAndFolders") { this._searchBarFilter.resetFilters(); this.__reloadFolders(); this.__reloadStudies(); @@ -983,7 +974,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // notify header const header = this.__header; header.set({ - currentContext, + currentContext: context, currentWorkspaceId: workspaceId, currentFolderId: folderId, }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index fa7ed0f7e3d..e775ff929d3 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -49,7 +49,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { properties: { currentContext: { - check: ["studiesAndFolders", "workspaces", "search", "bin"], + check: ["studiesAndFolders", "workspaces", "search", "trash"], nullable: false, init: "studiesAndFolders", event: "changeCurrentContext", @@ -199,6 +199,12 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { value: this.tr("Search results"), cursor: "auto", }); + } else if (currentContext === "trash") { + this.__setIcon("@FontAwesome5Solid/trash/24"); + title.set({ + value: this.tr("asdfasdfasdfasfd"), + cursor: "auto", + }); } else if (currentContext === "workspaces") { this.__setIcon(osparc.store.Workspaces.iconPath(32)); title.set({ From ba6bb24176c52addbdda18c76b1171a3d244f6d1 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 13:37:16 +0200 Subject: [PATCH 008/100] minor --- .../source/class/osparc/dashboard/StudyBrowser.js | 12 ++++++------ .../class/osparc/dashboard/StudyBrowserHeader.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 5bd63932440..09d7931e759 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -389,7 +389,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _workspaceSelected: function(workspaceId) { - this.__changeContext("studiesAndWorkspaces", workspaceId, null); + this.__changeContext("studiesAndFolders", workspaceId, null); }, _workspaceUpdated: function() { @@ -449,7 +449,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _folderSelected: function(folderId) { - this.__changeContext("studiesAndWorkspaces", this.getCurrentWorkspaceId(), folderId); + this.__changeContext("studiesAndFolders", this.getCurrentWorkspaceId(), folderId); }, _folderUpdated: function() { @@ -911,7 +911,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { header.addListener("locationChanged", () => { const workspaceId = header.getCurrentWorkspaceId(); const folderId = header.getCurrentFolderId(); - this.__changeContext("studiesAndWorkspaces", workspaceId, folderId); + this.__changeContext("studiesAndFolders", workspaceId, folderId); }, this); const workspacesAndFoldersTree = this._resourceFilter.getWorkspacesAndFoldersTree(); @@ -919,7 +919,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const context = e.getData(); const workspaceId = context["workspaceId"]; const folderId = context["folderId"]; - this.__changeContext("studiesAndWorkspaces", workspaceId, folderId); + this.__changeContext("studiesAndFolders", workspaceId, folderId); }, this); this._resourceFilter.addListener("trashContext", () => { @@ -932,13 +932,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__changeContext("search"); } else { // Back to My Workspace - this.__changeContext("studiesAndWorkspaces", null, null); + this.__changeContext("studiesAndFolders", null, null); } }); } }, - __changeContext: function(context, workspaceId, folderId) { + __changeContext: function(context, workspaceId = null, folderId = null) { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { if ( context !== "search" && // reload studies for a new search diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index e775ff929d3..ff9ebb65804 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -202,7 +202,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { } else if (currentContext === "trash") { this.__setIcon("@FontAwesome5Solid/trash/24"); title.set({ - value: this.tr("asdfasdfasdfasfd"), + value: this.tr("Trash: Items in the bin will be permanently deleted after 30 days."), cursor: "auto", }); } else if (currentContext === "workspaces") { From 916c496016e4e1132fc1e9eec988055d0868c21a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 13:51:18 +0200 Subject: [PATCH 009/100] trash default to false --- .../source/class/osparc/dashboard/ResourceFilter.js | 1 + .../client/source/class/osparc/dashboard/StudyBrowser.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js index 89d85e6384a..71f172f3d3a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js @@ -90,6 +90,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { /* TRASH BIN */ __createTrashBin: function() { const trashButton = this.__trashButton = new qx.ui.toolbar.RadioButton().set({ + value: false, appearance: "filter-toggle-button", label: this.tr("Trash"), icon: "@FontAwesome5Solid/trash/18", diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 09d7931e759..a7916d6337d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -918,8 +918,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { workspacesAndFoldersTree.addListener("locationChanged", e => { const context = e.getData(); const workspaceId = context["workspaceId"]; - const folderId = context["folderId"]; - this.__changeContext("studiesAndFolders", workspaceId, folderId); + if (workspaceId === -1) { + this.__changeContext("workspaces"); + } else { + const folderId = context["folderId"]; + this.__changeContext("studiesAndFolders", workspaceId, folderId); + } }, this); this._resourceFilter.addListener("trashContext", () => { From 458329864e122cdefed3bc169e245646acc26894 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 13:59:52 +0200 Subject: [PATCH 010/100] unused --- .../osparc/dashboard/ContextBreadcrumbs.js | 47 ++++--------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js b/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js index 0e29f60fdb8..bb86d639e12 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js @@ -73,12 +73,12 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { if (parentFolder) { this._addAt(this.__createArrow(), 0); const upstreamButton = this.__createFolderButton(parentFolder); - this._addAt(upstreamButton, 0); + if (upstreamButton) { + this._addAt(upstreamButton, 0); + } this.__createUpstreamButtons(parentFolder); } else { this._addAt(this.__createArrow(), 0); - const homeButton = this.__createFolderButton(); - this._addAt(homeButton, 0); } } }, @@ -100,33 +100,9 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { }); }, - __createRootButton: function() { - const workspaceId = this.getCurrentWorkspaceId(); - let rootButton = null; - if (workspaceId) { - if (workspaceId === -1) { - rootButton = new qx.ui.form.Button(this.tr("Shared Workspaces"), osparc.store.Workspaces.iconPath()); - } else { - const workspace = osparc.store.Workspaces.getInstance().getWorkspace(workspaceId); - rootButton = new qx.ui.form.Button(workspace.getName(), osparc.store.Workspaces.iconPath()).set({ - maxWidth: 200 - }); - workspace.bind("name", rootButton, "label"); - } - } else { - rootButton = new qx.ui.form.Button(this.tr("My Workspace"), "@FontAwesome5Solid/home/14"); - } - rootButton.addListener("execute", () => { - const folderId = null; - this.__changeFolder(folderId); - }); - return rootButton; - }, - __createFolderButton: function(folder) { - let folderButton = null; if (folder) { - folderButton = new qx.ui.form.Button(folder.getName()).set({ + const folderButton = new qx.ui.form.Button(folder.getName()).set({ maxWidth: 200 }); folder.bind("name", folderButton, "label"); @@ -134,19 +110,14 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { const folderId = folder ? folder.getFolderId() : null; this.__changeFolder(folderId); }, this); - } else { - folderButton = this.__createRootButton(); - // Do not show root folder folderButton.set({ - visibility: "excluded" + backgroundColor: "transparent", + textColor: "text", + gap: 5 }); + return folderButton; } - folderButton.set({ - backgroundColor: "transparent", - textColor: "text", - gap: 5 - }); - return folderButton; + return null; }, __createArrow: function() { From 54710a10346fda512e43f58cd87dc99a4e1c59eb Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 14:00:43 +0200 Subject: [PATCH 011/100] currentContext prop in ContextBreadcrumbs --- .../class/osparc/dashboard/ContextBreadcrumbs.js | 10 +++++++++- .../class/osparc/dashboard/StudyBrowserHeader.js | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js b/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js index bb86d639e12..c84e6cf8a51 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js @@ -31,6 +31,14 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { }, properties: { + currentContext: { + check: ["studiesAndFolders", "workspaces", "search", "trash"], + nullable: false, + init: "studiesAndFolders", + event: "changeCurrentContext", + apply: "__rebuild" + }, + currentWorkspaceId: { check: "Number", nullable: true, @@ -52,7 +60,7 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { __rebuild: function() { this._removeAll(); - if (this.getCurrentWorkspaceId() === -2) { + if (this.getCurrentContext() !== "studiesAndFolders") { return; } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index ff9ebb65804..9ab022a2f1c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -119,6 +119,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { control = new osparc.dashboard.ContextBreadcrumbs(); this.bind("currentWorkspaceId", control, "currentWorkspaceId"); this.bind("currentFolderId", control, "currentFolderId"); + this.bind("currentContext", control, "currentContext"); control.bind("currentWorkspaceId", this, "currentWorkspaceId"); control.bind("currentFolderId", this, "currentFolderId"); control.addListener("locationChanged", e => { From b5e88f163d695769dd7e26221ee17ec869e469f8 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 14:05:12 +0200 Subject: [PATCH 012/100] bad merge --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 9d915073028..3981df1c89d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -182,7 +182,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { !osparc.auth.Manager.getInstance().isLoggedIn() || !osparc.utils.DisabledPlugins.isFoldersEnabled() || this.getCurrentContext() !== "studiesAndFolders" || - this.__loadingFolders || + this.__loadingFolders ) { return; } @@ -191,7 +191,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const folderId = this.getCurrentFolderId(); this.__loadingFolders = true; this.__setFoldersToList([]); - const folderId = this.getCurrentFolderId(); osparc.store.Folders.getInstance().fetchFolders(folderId, workspaceId, this.getOrderBy()) .then(folders => { this.__setFoldersToList(folders); From 8cec162853d3e0bee5b01567c9ce71a2ae6c64cf Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 14:07:44 +0200 Subject: [PATCH 013/100] SelectStudies button --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 3981df1c89d..31b00f8ec3e 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1143,8 +1143,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { })) }); this.bind("multiSelection", selectButton, "value"); - this.bind("currentWorkspaceId", selectButton, "visibility", { - converter: currentWorkspaceId => [-2, -1].includes(currentWorkspaceId) ? "excluded" : "visible" + this.bind("currentContext", selectButton, "visibility", { + converter: currentContext => currentContext === "studiesAndFolders" ? "excluded" : "visible" }); return selectButton; }, From 39e6a50bc2599a9a7589ef8793fefa1512745d4e Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 14:11:50 +0200 Subject: [PATCH 014/100] minor --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 31b00f8ec3e..c7ab79c7388 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1144,7 +1144,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }); this.bind("multiSelection", selectButton, "value"); this.bind("currentContext", selectButton, "visibility", { - converter: currentContext => currentContext === "studiesAndFolders" ? "excluded" : "visible" + converter: currentContext => currentContext === "studiesAndFolders" ? "visible" : "excluded" }); return selectButton; }, From 7b37517706a894d786e7df8437a0850d5e34ff70 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 14:18:11 +0200 Subject: [PATCH 015/100] more context checks --- .../source/class/osparc/dashboard/StudyBrowser.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index c7ab79c7388..1e336b60d8b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -200,10 +200,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __reloadStudies: function() { - const workspaceId = this.getCurrentWorkspaceId(); if ( !osparc.auth.Manager.getInstance().isLoggedIn() || - workspaceId === -1 || // listing workspaces + this.getCurrentContext() === "workspaces" || this._loadingResourcesBtn.isFetching() ) { return; @@ -953,6 +952,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { if ( context !== "search" && // reload studies for a new search + context === this.getCurrentContext() && workspaceId === this.getCurrentWorkspaceId() && folderId === this.getCurrentFolderId() ) { @@ -960,14 +960,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return; } - this._loadingResourcesBtn.setFetching(false); - this.resetSelection(); - this.setMultiSelection(false); this.set({ currentContext: context, currentWorkspaceId: workspaceId, currentFolderId: folderId, }); + this._loadingResourcesBtn.setFetching(false); + this.resetSelection(); + this.setMultiSelection(false); this.invalidateStudies(); this._resourcesContainer.setResourcesToList([]); From 99b4f4ba7f1d0fd0e8c48f6c8bc866c919c3752d Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 14:22:55 +0200 Subject: [PATCH 016/100] PROJECTS_TRASH_RETENTION_DAYS --- .../class/osparc/dashboard/StudyBrowserHeader.js | 3 ++- .../client/source/class/osparc/store/StaticInfo.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 9ab022a2f1c..8520642a6e3 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -202,8 +202,9 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }); } else if (currentContext === "trash") { this.__setIcon("@FontAwesome5Solid/trash/24"); + const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); title.set({ - value: this.tr("Trash: Items in the bin will be permanently deleted after 30 days."), + value: this.tr(`Trash: Items in the bin will be permanently deleted after ${trashDays} days.`), cursor: "auto", }); } else if (currentContext === "workspaces") { diff --git a/services/static-webserver/client/source/class/osparc/store/StaticInfo.js b/services/static-webserver/client/source/class/osparc/store/StaticInfo.js index 1681a801cf4..92642490e2d 100644 --- a/services/static-webserver/client/source/class/osparc/store/StaticInfo.js +++ b/services/static-webserver/client/source/class/osparc/store/StaticInfo.js @@ -69,6 +69,16 @@ qx.Class.define("osparc.store.StaticInfo", { return null; }, + getTrashRetentionDays: function() { + const staticKey = "webserverProjects"; + const wsStaticData = this.getValue(staticKey); + const key = "PROJECTS_TRASH_RETENTION_DAYS"; + if (key in wsStaticData) { + return wsStaticData[key]; + } + return null; + }, + getAccountDeletionRetentionDays: function() { const staticKey = "webserverLogin"; const wsStaticData = this.getValue(staticKey); From 34e535bade9bbd82dc0e542856d26d707670a662 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 14:38:44 +0200 Subject: [PATCH 017/100] pass context --- .../source/class/osparc/dashboard/StudyBrowser.js | 2 +- .../osparc/dashboard/WorkspacesAndFoldersTree.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 1e336b60d8b..fa994198c43 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -997,7 +997,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { currentWorkspaceId: workspaceId, currentFolderId: folderId, }); - workspacesAndFoldersTree.contextChanged(workspaceId, folderId); + workspacesAndFoldersTree.contextChanged(context); } }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js index dc1b6a94a65..93f1125049e 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js @@ -288,17 +288,18 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", { } }, - contextChanged: function() { - const workspaceId = this.getCurrentWorkspaceId(); - const folderId = this.getCurrentFolderId(); - + contextChanged: function(context) { const selection = this.getSelection(); if (selection) { selection.removeAll(); } - const contextModel = this.__getModel(workspaceId, folderId); - if (contextModel) { - selection.push(contextModel); + if (context === "studiesAndFolders" || context === "workspaces") { + const workspaceId = context === "workspaces" ? -1 : this.getCurrentWorkspaceId(); + const folderId = this.getCurrentFolderId(); + const locationModel = this.__getModel(workspaceId, folderId); + if (locationModel) { + selection.push(locationModel); + } } }, } From 139d61e1820dd8b98ed4d2096d65224d5ca24e77 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 14:51:13 +0200 Subject: [PATCH 018/100] defaults --- .../client/source/class/osparc/dashboard/StudyBrowserHeader.js | 2 +- .../client/source/class/osparc/store/StaticInfo.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 8520642a6e3..3f1dc17b5a9 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -201,7 +201,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { cursor: "auto", }); } else if (currentContext === "trash") { - this.__setIcon("@FontAwesome5Solid/trash/24"); + this.__setIcon("@FontAwesome5Solid/trash/20"); const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); title.set({ value: this.tr(`Trash: Items in the bin will be permanently deleted after ${trashDays} days.`), diff --git a/services/static-webserver/client/source/class/osparc/store/StaticInfo.js b/services/static-webserver/client/source/class/osparc/store/StaticInfo.js index 92642490e2d..2ac96fd58b0 100644 --- a/services/static-webserver/client/source/class/osparc/store/StaticInfo.js +++ b/services/static-webserver/client/source/class/osparc/store/StaticInfo.js @@ -76,7 +76,7 @@ qx.Class.define("osparc.store.StaticInfo", { if (key in wsStaticData) { return wsStaticData[key]; } - return null; + return "unknown"; }, getAccountDeletionRetentionDays: function() { From 2a40d9fbbdb7e5abc5bfa915ec3824a576efffd7 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 15:10:25 +0200 Subject: [PATCH 019/100] getPageTrashed --- .../class/osparc/dashboard/StudyBrowser.js | 4 +++- .../source/class/osparc/data/Resources.js | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index fa994198c43..25fe16844d8 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -695,7 +695,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { resolveWResponse: true }; - if ("text" in requestParams) { + if (this.getCurrentContext() === "trash") { + return osparc.data.Resources.fetch("studies", "getPageTrashed", params, options); + } else if ("text" in requestParams) { return osparc.data.Resources.fetch("studies", "getPageSearch", params, options); } return osparc.data.Resources.fetch("studies", "getPage", params, options); diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index 9d591c0d1ee..ee868d3400b 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -119,6 +119,16 @@ qx.Class.define("osparc.data.Resources", { method: "GET", url: statics.API + "/projects?type=user" }, + getOne: { + useCache: false, + method: "GET", + url: statics.API + "/projects/{studyId}" + }, + getActive: { + useCache: false, + method: "GET", + url: statics.API + "/projects/active?client_session_id={tabId}" + }, getPage: { useCache: false, method: "GET", @@ -129,15 +139,10 @@ qx.Class.define("osparc.data.Resources", { method: "GET", url: statics.API + "/projects:search?offset={offset}&limit={limit}&text={text}&tag_ids={tagIds}&order_by={orderBy}" }, - getOne: { - useCache: false, - method: "GET", - url: statics.API + "/projects/{studyId}" - }, - getActive: { + getPageTrashed: { useCache: false, method: "GET", - url: statics.API + "/projects/active?client_session_id={tabId}" + url: statics.API + "/projects?filters={'trashed':true}&offset={offset}&limit={limit}&order_by={orderBy}" }, postToTemplate: { method: "POST", From 3b362a9a082886b07e4f49ab4fea8fd68876ea09 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 15:18:27 +0200 Subject: [PATCH 020/100] Trash studies --- .../class/osparc/dashboard/StudyBrowser.js | 44 +++++++++++++++++++ .../source/class/osparc/data/Resources.js | 8 ++++ .../client/source/class/osparc/store/Store.js | 37 ++++++++++++++++ 3 files changed, 89 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 25fe16844d8..4577c762bb5 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -864,6 +864,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const studiesMoveButton = this.__createMoveStudiesButton(false); this._toolbar.add(studiesMoveButton); + const studiesTrashButton = this.__createTrashButton(false); + this._toolbar.add(studiesTrashButton); + const studiesDeleteButton = this.__createDeleteButton(false); this._toolbar.add(studiesDeleteButton); @@ -1107,6 +1110,19 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return moveStudiesButton; }, + __createTrashButton: function() { + const trashButton = new qx.ui.form.Button(this.tr("Trash"), "@FontAwesome5Solid/trash/14").set({ + appearance: "danger-button", + visibility: "excluded" + }); + osparc.utils.Utils.setIdToWidget(trashButton, "deleteStudiesBtn"); + trashButton.addListener("execute", () => { + const selection = this._resourcesContainer.getSelection(); + this.__trashStudies(selection.map(button => this.__getStudyData(button.getUuid(), false)), false); + }, this); + return trashButton; + }, + __createDeleteButton: function() { const deleteButton = new qx.ui.form.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/14").set({ appearance: "danger-button", @@ -1693,6 +1709,34 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { req.send(body); }, + __trashStudy: function(studyData) { + const myGid = osparc.auth.Data.getInstance().getGroupId(); + const collabGids = Object.keys(studyData["accessRights"]); + const amICollaborator = collabGids.indexOf(myGid) > -1; + + let operationPromise = null; + if (collabGids.length > 1 && amICollaborator) { + const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]); + // remove collaborator + delete arCopy[myGid]; + operationPromise = osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy); + } else { + // trash study + operationPromise = osparc.store.Store.getInstance().trashStudy(studyData.uuid); + } + operationPromise + .then(() => this.__removeFromStudyList(studyData.uuid)) + .catch(err => { + console.error(err); + osparc.FlashMessenger.getInstance().logAs(err, "ERROR"); + }) + .finally(() => this.resetSelection()); + }, + + __trashStudies: function(studiesData) { + studiesData.forEach(studyData => this.__trashStudy(studyData)); + }, + __doDeleteStudy: function(studyData) { const myGid = osparc.auth.Data.getInstance().getGroupId(); const collabGids = Object.keys(studyData["accessRights"]); diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index ee868d3400b..c211a66cef7 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -192,6 +192,14 @@ qx.Class.define("osparc.data.Resources", { method: "PATCH", url: statics.API + "/projects/{studyId}" }, + trash: { + method: "POST", + url: statics.API + "/projects/{studyId}:trash" + }, + untrash: { + method: "POST", + url: statics.API + "/projects/{studyId}:untrash" + }, delete: { method: "DELETE", url: statics.API + "/projects/{studyId}" diff --git a/services/static-webserver/client/source/class/osparc/store/Store.js b/services/static-webserver/client/source/class/osparc/store/Store.js index 3a180897e28..d14a806cc6f 100644 --- a/services/static-webserver/client/source/class/osparc/store/Store.js +++ b/services/static-webserver/client/source/class/osparc/store/Store.js @@ -427,6 +427,43 @@ qx.Class.define("osparc.store.Store", { } }, + trashStudy: function(studyId) { + const params = { + url: { + studyId + } + }; + return new Promise((resolve, reject) => { + osparc.data.Resources.fetch("studies", "trash", params) + .then(() => { + this.remove("studies", "uuid", studyId); + resolve(); + }) + .catch(err => { + console.error(err); + reject(err); + }); + }); + }, + + untrashStudy: function(studyId) { + const params = { + url: { + studyId + } + }; + return new Promise((resolve, reject) => { + osparc.data.Resources.fetch("studies", "untrash", params) + .then(() => { + resolve(); + }) + .catch(err => { + console.error(err); + reject(err); + }); + }); + }, + deleteStudy: function(studyId) { const params = { url: { From f3b25e3626689e1e8bf759fc52b7ece3a00bf610 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 15:20:27 +0200 Subject: [PATCH 021/100] studiesTrashButton visibility --- .../source/class/osparc/dashboard/StudyBrowser.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 4577c762bb5..3ac509cee8e 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -898,15 +898,21 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }); this._resourcesContainer.addListener("changeSelection", e => { + const currentContext = this.getCurrentContext(); const selection = e.getData(); studiesMoveButton.set({ - visibility: selection.length ? "visible" : "excluded", + visibility: selection.length && currentContext === "studiesAndFolders" ? "visible" : "excluded", label: selection.length > 1 ? this.tr("Move selected")+" ("+selection.length+")" : this.tr("Move") }); + studiesTrashButton.set({ + visibility: selection.length && currentContext === "studiesAndFolders" ? "visible" : "excluded", + label: selection.length > 1 ? this.tr("Trash selected")+" ("+selection.length+")" : this.tr("Trash") + }); + studiesDeleteButton.set({ - visibility: selection.length ? "visible" : "excluded", + visibility: selection.length && currentContext === "trash" ? "visible" : "excluded", label: selection.length > 1 ? this.tr("Delete selected")+" ("+selection.length+")" : this.tr("Delete") }); }); From f9835269978630538c6348c25317b1a105ae6bdb Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 15:31:56 +0200 Subject: [PATCH 022/100] trashing --- .../class/osparc/dashboard/StudyBrowser.js | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 3ac509cee8e..c9252f6afc9 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1139,7 +1139,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const selection = this._resourcesContainer.getSelection(); const preferencesSettings = osparc.Preferences.getInstance(); if (preferencesSettings.getConfirmDeleteStudy()) { - const win = this.__createConfirmWindow(selection.map(button => button.getTitle())); + const win = this.__createConfirmDeleteWindow(selection.map(button => button.getTitle())); win.center(); win.open(); win.addListener("close", () => { @@ -1534,13 +1534,33 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _deleteResourceRequested: function(studyId) { - this.__deleteStudyRequested(this.__getStudyData(studyId)); + if (this.getCurrentContext() === "trash") { + this.__deleteStudyRequested(this.__getStudyData(studyId)); + } else { + this.__trashStudyRequested(this.__getStudyData(studyId)); + } + }, + + __trashStudyRequested: function(studyData) { + const preferencesSettings = osparc.Preferences.getInstance(); + if (preferencesSettings.getConfirmDeleteStudy()) { + const win = this.__createConfirmTrashWindow([studyData.name]); + win.center(); + win.open(); + win.addListener("close", () => { + if (win.getConfirmed()) { + this.__trashStudy(studyData); + } + }, this); + } else { + this.__trashStudy(studyData); + } }, __deleteStudyRequested: function(studyData) { const preferencesSettings = osparc.Preferences.getInstance(); if (preferencesSettings.getConfirmDeleteStudy()) { - const win = this.__createConfirmWindow([studyData.name]); + const win = this.__createConfirmDeleteWindow([studyData.name]); win.center(); win.open(); win.addListener("close", () => { @@ -1553,6 +1573,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } }, + __getTrashStudyMenuButton: function(studyData) { + const trashButton = new qx.ui.menu.Button(this.tr("Trash"), "@FontAwesome5Solid/trash/12"); + trashButton["deleteButton"] = true; + trashButton.set({ + appearance: "menu-button" + }); + osparc.utils.Utils.setIdToWidget(trashButton, "studyItemMenuDelete"); + trashButton.addListener("execute", () => this.__trashStudyRequested(studyData), this); + return trashButton; + }, + __getDeleteStudyMenuButton: function(studyData) { const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); deleteButton["deleteButton"] = true; @@ -1771,11 +1802,30 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { studiesData.forEach(studyData => this.__doDeleteStudy(studyData)); }, - __createConfirmWindow: function(studyNames) { - const rUSure = this.tr("Are you sure you want to delete"); + __deleteConfirmationWindow: function(msg, studyNames) { const studiesText = osparc.product.Utils.getStudyAlias({plural: true}); - const msg = rUSure + (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText} ?` : ` ${studyNames[0]}?`) + msg += (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText} ?` : ` ${studyNames[0]}?`); const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + confirmText: this.tr("Trash"), + confirmAction: "delete" + }); + osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteStudyBtn"); + return confirmationWin; + }, + + __createConfirmTrashWindow: function(studyNames) { + const rUSure = this.tr("Are you sure you want to move to the trash"); + const confirmationWin = this.__deleteConfirmationWindow(rUSure, studyNames).set({ + confirmText: this.tr("Trash"), + confirmAction: "delete" + }); + osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteStudyBtn"); + return confirmationWin; + }, + + __createConfirmDeleteWindow: function(studyNames) { + const rUSure = this.tr("Are you sure you want to delete"); + const confirmationWin = this.__deleteConfirmationWindow(rUSure, studyNames).set({ confirmText: this.tr("Delete"), confirmAction: "delete" }); From c29267b4881d8b2cc69cd0fdfd37e65fe767bf73 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 15:42:40 +0200 Subject: [PATCH 023/100] n days message --- .../class/osparc/dashboard/StudyBrowser.js | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index c9252f6afc9..6a5eb269d8e 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1124,7 +1124,19 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { osparc.utils.Utils.setIdToWidget(trashButton, "deleteStudiesBtn"); trashButton.addListener("execute", () => { const selection = this._resourcesContainer.getSelection(); - this.__trashStudies(selection.map(button => this.__getStudyData(button.getUuid(), false)), false); + const preferencesSettings = osparc.Preferences.getInstance(); + if (preferencesSettings.getConfirmDeleteStudy()) { + const win = this.__createConfirmTrashWindow(selection.map(button => button.getTitle())); + win.center(); + win.open(); + win.addListener("close", () => { + if (win.getConfirmed()) { + this.__trashStudies(selection.map(button => this.__getStudyData(button.getUuid(), false)), false); + } + }, this); + } else { + this.__trashStudies(selection.map(button => this.__getStudyData(button.getUuid(), false)), false); + } }, this); return trashButton; }, @@ -1802,21 +1814,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { studiesData.forEach(studyData => this.__doDeleteStudy(studyData)); }, - __deleteConfirmationWindow: function(msg, studyNames) { + __createConfirmTrashWindow: function(studyNames) { + let msg = this.tr("Are you sure you want to move to the trash"); const studiesText = osparc.product.Utils.getStudyAlias({plural: true}); - msg += (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText} ?` : ` ${studyNames[0]}?`); + msg += (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText}?` : ` ${studyNames[0]}?`); + const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); + msg += "

" + this.tr(`They will be permanently deleted after ${trashDays} days.`); const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ - confirmText: this.tr("Trash"), - confirmAction: "delete" - }); - osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteStudyBtn"); - return confirmationWin; - }, - - __createConfirmTrashWindow: function(studyNames) { - const rUSure = this.tr("Are you sure you want to move to the trash"); - const confirmationWin = this.__deleteConfirmationWindow(rUSure, studyNames).set({ - confirmText: this.tr("Trash"), + confirmText: this.tr("Move to Trash"), confirmAction: "delete" }); osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteStudyBtn"); @@ -1824,8 +1829,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __createConfirmDeleteWindow: function(studyNames) { - const rUSure = this.tr("Are you sure you want to delete"); - const confirmationWin = this.__deleteConfirmationWindow(rUSure, studyNames).set({ + let msg = this.tr("Are you sure you want to delete"); + const studiesText = osparc.product.Utils.getStudyAlias({plural: true}); + msg += (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText}?` : ` ${studyNames[0]}?`); + const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ confirmText: this.tr("Delete"), confirmAction: "delete" }); From ee599160ecf7d193fb8e16482ce09540562a7583 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 24 Oct 2024 15:58:14 +0200 Subject: [PATCH 024/100] minor --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 6a5eb269d8e..6d9f3b3fbf8 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1819,7 +1819,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const studiesText = osparc.product.Utils.getStudyAlias({plural: true}); msg += (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText}?` : ` ${studyNames[0]}?`); const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); - msg += "

" + this.tr(`They will be permanently deleted after ${trashDays} days.`); + msg += "

" + (studyNames.length > 1 ? "It" : "They") + this.tr(` will be permanently deleted after ${trashDays} days.`); const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ confirmText: this.tr("Move to Trash"), confirmAction: "delete" From eeb96487b41bfd5f1fa8327c41d4105ffbe4b3a0 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 25 Oct 2024 10:32:55 +0200 Subject: [PATCH 025/100] minor --- .../client/source/class/osparc/dashboard/ListButtonBase.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonBase.js index 099a9d0488c..86decb00157 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonBase.js @@ -51,8 +51,8 @@ qx.Class.define("osparc.dashboard.ListButtonBase", { PROGRESS: 4, TAGS: 5, ICONS_LAYOUT: 6, - SHARED: 7, - OWNER: 8, + OWNER: 7, + SHARED: 8, LAST_CHANGE: 9, TSR: 10, HITS: 11, From e6f662a966478db3461be2cb5c91e758a6b5596d Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 25 Oct 2024 11:01:05 +0200 Subject: [PATCH 026/100] empty-trash-button --- .../class/osparc/dashboard/StudyBrowser.js | 4 ++ .../osparc/dashboard/StudyBrowserHeader.js | 53 +++++++++++++++---- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 6d9f3b3fbf8..f4285a357f9 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -252,6 +252,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._resourcesContainer.getFlatList().nextRequest = resp["_links"]["next"]; this.__addStudiesToList(studies); + if (this.getCurrentContext() === "trash") { + this.__header.getChildControl("empty-trash-button").setVisibility(this._resourcesList.length ? "visible" : "excluded"); + } + // Show Quick Start if there are no studies in the root folder of the personal workspace const quickStartInfo = osparc.product.quickStart.Utils.getQuickStart(); if (quickStartInfo) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 3f1dc17b5a9..a16935b5ef7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -89,7 +89,17 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }, statics: { - HEIGHT: 36 + HEIGHT: 36, + POS: { + ICON: 0, + TITLE: 1, + BREADCRUMBS: 2, + EDIT_BUTTON: 3, + SHARE_LAYOUT: 4, + ROLE_LAYOUT: 5, + DESCRIPTION: 2, + EMPTY_TRASH_BUTTON: 3, + } }, members: { @@ -106,14 +116,14 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { allowGrowY: true, decorator: "rounded", }); - this._add(control); + this._addAt(control, this.self().POS.ICON); break; - case "workspace-title": + case "title": control = new qx.ui.basic.Label().set({ font: "text-16", alignY: "middle", }); - this._add(control); + this._addAt(control, this.self().POS.TITLE); break; case "breadcrumbs": control = new osparc.dashboard.ContextBreadcrumbs(); @@ -125,7 +135,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { control.addListener("locationChanged", e => { this.fireDataEvent("locationChanged", e.getData()) }); - this._add(control); + this._addAt(control, this.self().POS.BREADCRUMBS); break; case "edit-button": control = new qx.ui.form.MenuButton().set({ @@ -142,14 +152,14 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { control.getContentElement().setStyles({ "border-radius": `${22 / 2}px` }); - this._add(control); + this._addAt(control, this.self().POS.EDIT_BUTTON); break; case "share-layout": this.__addSpacer(); control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({ alignY: "middle" })); - this._add(control); + this._addAt(control, this.self().POS.SHARE_LAYOUT); break; case "share-text": { control = new qx.ui.basic.Label().set({ @@ -164,7 +174,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({ alignY: "middle" })); - this._add(control); + this._addAt(control, this.self().POS.ROLE_LAYOUT); break; case "role-text": { control = new qx.ui.basic.Label().set({ @@ -180,6 +190,23 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { layout.addAt(control, 1); break; } + case "description": { + control = new qx.ui.basic.Label().set({ + font: "text-14", + alignY: "middle", + }); + this._addAt(control, this.self().POS.DESCRIPTION); + break; + } + case "empty-trash-button": { + control = new qx.ui.form.Button(this.tr("Empty Trash"), "@FontAwesome5Solid/trash/14").set({ + appearance: "danger-button", + allowGrowY: false, + }); + control.addListener("execute", () => console.log("Empty trash")); + this._addAt(control, this.self().POS.EMPTY_TRASH_BUTTON); + break; + } } return control || this.base(arguments, id); @@ -187,11 +214,14 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { __buildLayout: function() { this.getChildControl("icon"); - const title = this.getChildControl("workspace-title"); + const title = this.getChildControl("title"); this.getChildControl("breadcrumbs"); this.getChildControl("edit-button").exclude(); this.resetAccessRights(); this.resetMyAccessRights(); + const description = this.getChildControl("description"); + description.resetValue(); + this.getChildControl("empty-trash-button").exclude(); const currentContext = this.getCurrentContext(); if (currentContext === "search") { @@ -204,9 +234,12 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { this.__setIcon("@FontAwesome5Solid/trash/20"); const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); title.set({ - value: this.tr(`Trash: Items in the bin will be permanently deleted after ${trashDays} days.`), + value: this.tr("Trash:"), cursor: "auto", }); + description.set({ + value: this.tr(`Items in the bin will be permanently deleted after ${trashDays} days.`) + }); } else if (currentContext === "workspaces") { this.__setIcon(osparc.store.Workspaces.iconPath(32)); title.set({ From 34d3d709d2c5c38244458109ea21e09945813b2e Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 25 Oct 2024 11:14:30 +0200 Subject: [PATCH 027/100] emptyTrash --- .../class/osparc/dashboard/StudyBrowser.js | 24 +++++++++++++++++++ .../osparc/dashboard/StudyBrowserHeader.js | 5 ++-- .../source/class/osparc/data/Resources.js | 12 ++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index f4285a357f9..e930cbf04ad 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -847,6 +847,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { const header = this.__header = new osparc.dashboard.StudyBrowserHeader(); + this.__header.addListener("emptyTrashRequested", () => this.__emptyTrash(), this); this._addToLayout(header); } @@ -1170,6 +1171,20 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return deleteButton; }, + __emptyTrash: function() { + const win = this.__createConfirmEmptyTrashWindow(); + win.center(); + win.open(); + win.addListener("close", () => { + if (win.getConfirmed()) { + osparc.data.Resources.fetch("trash", "delete") + .then(() => { + this.__resetStudiesList(); + }); + } + }, this); + }, + __createSelectButton: function() { const selectButton = new qx.ui.form.ToggleButton().set({ appearance: "form-button-outlined", @@ -1844,6 +1859,15 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return confirmationWin; }, + __createConfirmEmptyTrashWindow: function() { + const msg = this.tr("Items in the bin will be permanently deleted"); + const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + confirmText: this.tr("Delete forever"), + confirmAction: "delete" + }); + return confirmationWin; + }, + // TASKS // __tasksReceived: function(tasks) { tasks.forEach(taskData => this._taskDataReceived(taskData)); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index a16935b5ef7..1f3ac0bb52d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -44,7 +44,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { events: { "locationChanged": "qx.event.type.Data", "workspaceUpdated": "qx.event.type.Data", - "deleteWorkspaceRequested": "qx.event.type.Data" + "deleteWorkspaceRequested": "qx.event.type.Data", + "emptyTrashRequested": "qx.event.type.Event", }, properties: { @@ -203,7 +204,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { appearance: "danger-button", allowGrowY: false, }); - control.addListener("execute", () => console.log("Empty trash")); + control.addListener("execute", () => this.fireEvent("emptyTrashRequested")); this._addAt(control, this.self().POS.EMPTY_TRASH_BUTTON); break; } diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index c211a66cef7..6378d9ab26c 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -410,6 +410,18 @@ qx.Class.define("osparc.data.Resources", { } }, + /* + * TRASH + */ + "trash": { + endpoints: { + delete: { + method: "DELETE", + url: statics.API + "/trash" + } + } + }, + /* * SNAPSHOTS */ From 2181b772377768ab96405cc3bffc77b5df84979e Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 25 Oct 2024 11:23:00 +0200 Subject: [PATCH 028/100] Context switching for Trash --- .../source/class/osparc/dashboard/ResourceFilter.js | 10 ++++++++++ .../source/class/osparc/dashboard/StudyBrowser.js | 9 ++------- .../class/osparc/dashboard/WorkspacesAndFoldersTree.js | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js index 71f172f3d3a..347934479cd 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js @@ -65,6 +65,16 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { } }, + contextChanged: function(context, workspaceId, folderId) { + this.__workspacesAndFoldersTree.set({ + currentWorkspaceId: workspaceId, + currentFolderId: folderId, + }); + this.__workspacesAndFoldersTree.contextChanged(context); + + this.__trashButton.setValue(context === "trash"); + }, + /* WORKSPACES AND FOLDERS */ __createWorkspacesAndFoldersTree: function() { const workspacesAndFoldersTree = this.__workspacesAndFoldersTree = new osparc.dashboard.WorkspacesAndFoldersTree(); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index e930cbf04ad..96a1e997090 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1007,13 +1007,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { currentFolderId: folderId, }); - // notify workspacesAndFoldersTree - const workspacesAndFoldersTree = this._resourceFilter.getWorkspacesAndFoldersTree(); - workspacesAndFoldersTree.set({ - currentWorkspaceId: workspaceId, - currentFolderId: folderId, - }); - workspacesAndFoldersTree.contextChanged(context); + // notify Filters on the left + this._resourceFilter.contextChanged(context, workspaceId, folderId); } }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js index 93f1125049e..c462e694371 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js @@ -46,7 +46,7 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", { this.__initTree(); // preselect "My Workspace" - this.contextChanged(null, null); + this.contextChanged("studiesAndFolders"); osparc.store.Folders.getInstance().addListener("folderAdded", e => { const folder = e.getData(); From 33e758443c7ac0e627e2ca7288dbc2f990a4ef8f Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 25 Oct 2024 11:26:43 +0200 Subject: [PATCH 029/100] minor --- .../class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js index f643218243b..c1d3b5bc374 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js @@ -24,9 +24,7 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTreeItem", { this.set({ indent: 12, // defaults to 19, decorator: "rounded", - }); - - this.set({ + padding: 2, maxWidth: osparc.dashboard.ResourceBrowserBase.SIDE_SPACER_WIDTH - 12 }); From 53d674a68bb1a95ba0e1de385111926fa666627b Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 25 Oct 2024 11:34:01 +0200 Subject: [PATCH 030/100] refactor --- .../class/osparc/dashboard/StudyBrowser.js | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 96a1e997090..f534f4a2fd4 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -664,17 +664,23 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const requestParams = {}; requestParams.orderBy = JSON.stringify(this.getOrderBy()); - const filterData = this._searchBarFilter.getFilterData(); - // Use the ``search`` functionality only if the user types some text - // tags should only be used to filter the current context (search context ot workspace/folder context) - if (filterData.text) { - requestParams.text = filterData.text ? encodeURIComponent(filterData.text) : ""; // name, description and uuid - requestParams["tagIds"] = filterData.tags.length ? filterData.tags.join(",") : ""; - return requestParams; + switch (this.getCurrentContext()) { + case "studiesAndFolders": + requestParams.workspaceId = this.getCurrentWorkspaceId(); + requestParams.folderId = this.getCurrentFolderId(); + break; + case "search": { + // Use the ``search`` functionality only if the user types some text + // tags should only be used to filter the current context (search context ot workspace/folder context) + const filterData = this._searchBarFilter.getFilterData(); + if (filterData.text) { + requestParams.text = filterData.text ? encodeURIComponent(filterData.text) : ""; // name, description and uuid + requestParams["tagIds"] = filterData.tags.length ? filterData.tags.join(",") : ""; + } + break; + } } - requestParams.workspaceId = this.getCurrentWorkspaceId(); - requestParams.folderId = this.getCurrentFolderId(); return requestParams; }, @@ -699,12 +705,19 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { resolveWResponse: true }; - if (this.getCurrentContext() === "trash") { - return osparc.data.Resources.fetch("studies", "getPageTrashed", params, options); - } else if ("text" in requestParams) { - return osparc.data.Resources.fetch("studies", "getPageSearch", params, options); + let request = null; + switch (this.getCurrentContext()) { + case "trash": + request = osparc.data.Resources.fetch("studies", "getPageTrashed", params, options); + break; + case "search": + request = osparc.data.Resources.fetch("studies", "getPageSearch", params, options); + break; + case "studiesAndFolders": + request = osparc.data.Resources.fetch("studies", "getPage", params, options); + break; } - return osparc.data.Resources.fetch("studies", "getPage", params, options); + return request; }, invalidateStudies: function() { From c584dc05e0ec6eecbd9c68827b6b163e30f94fff Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 25 Oct 2024 11:37:29 +0200 Subject: [PATCH 031/100] caption --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index f534f4a2fd4..80799bb0b03 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -467,6 +467,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __showMoveToWorkspaceWarningMessage: function() { const msg = this.tr("The permissions will be taken from the new workspace."); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Move"), confirmText: this.tr("Move"), }); win.open(); @@ -1846,8 +1847,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const studiesText = osparc.product.Utils.getStudyAlias({plural: true}); msg += (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText}?` : ` ${studyNames[0]}?`); const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); - msg += "

" + (studyNames.length > 1 ? "It" : "They") + this.tr(` will be permanently deleted after ${trashDays} days.`); + msg += "

" + (studyNames.length > 1 ? "They" : "It") + this.tr(` will be permanently deleted after ${trashDays} days.`); const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Move to Trash"), confirmText: this.tr("Move to Trash"), confirmAction: "delete" }); @@ -1860,6 +1862,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const studiesText = osparc.product.Utils.getStudyAlias({plural: true}); msg += (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText}?` : ` ${studyNames[0]}?`); const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete"), confirmText: this.tr("Delete"), confirmAction: "delete" }); @@ -1870,6 +1873,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __createConfirmEmptyTrashWindow: function() { const msg = this.tr("Items in the bin will be permanently deleted"); const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete"), confirmText: this.tr("Delete forever"), confirmAction: "delete" }); From 6a2ec3373dd1916c5d2814b99ccb9efe1a911031 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 25 Oct 2024 11:40:44 +0200 Subject: [PATCH 032/100] trash button in card menu --- .../source/class/osparc/dashboard/StudyBrowser.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 80799bb0b03..9b604781524 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -880,13 +880,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const selectStudiesButton = this.__createSelectButton(); this._toolbar.add(selectStudiesButton); - const studiesMoveButton = this.__createMoveStudiesButton(false); + const studiesMoveButton = this.__createMoveStudiesButton(); this._toolbar.add(studiesMoveButton); - const studiesTrashButton = this.__createTrashButton(false); + const studiesTrashButton = this.__createTrashButton(); this._toolbar.add(studiesTrashButton); - const studiesDeleteButton = this.__createDeleteButton(false); + const studiesDeleteButton = this.__createDeleteButton(); this._toolbar.add(studiesDeleteButton); this._toolbar.add(new qx.ui.core.Spacer(), { @@ -1396,11 +1396,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } if (deleteAccess) { - const deleteButton = this.__getDeleteStudyMenuButton(studyData, false); - if (deleteButton) { - menu.addSeparator(); - menu.add(deleteButton); - } + const deleteButton = this.getCurrentContext() === "trash" ? this.__getDeleteStudyMenuButton(studyData, false) : this.__getTrashStudyMenuButton(studyData, false); + menu.addSeparator(); + menu.add(deleteButton); } card.evaluateMenuButtons(); From 23eb4451dca9f836fd551774ab6edc9fb2e98c8a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 25 Oct 2024 11:48:20 +0200 Subject: [PATCH 033/100] captions in Confirmation Dialogs --- .../client/source/class/osparc/dashboard/FolderButtonItem.js | 1 + .../client/source/class/osparc/dashboard/TemplateBrowser.js | 2 ++ .../client/source/class/osparc/dashboard/WorkspaceButtonItem.js | 1 + .../client/source/class/osparc/data/model/Node.js | 1 + .../client/source/class/osparc/desktop/SlideshowView.js | 1 + .../client/source/class/osparc/desktop/StudyEditor.js | 1 + .../client/source/class/osparc/desktop/WorkbenchView.js | 2 ++ .../source/class/osparc/desktop/organizations/MembersList.js | 1 + .../class/osparc/desktop/organizations/OrganizationsList.js | 1 + .../osparc/desktop/paymentMethods/PaymentMethodListItem.js | 1 + .../class/osparc/desktop/preferences/pages/ClustersPage.js | 1 + .../source/class/osparc/desktop/preferences/pages/TokensPage.js | 2 ++ .../client/source/class/osparc/notification/NotificationUI.js | 1 + .../client/source/class/osparc/share/Collaborators.js | 1 + .../client/source/class/osparc/share/CollaboratorsStudy.js | 1 + .../client/source/class/osparc/share/CollaboratorsWorkspace.js | 1 + .../static-webserver/client/source/class/osparc/task/TaskUI.js | 1 + 17 files changed, 20 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index 355b1db7c87..1489acf9ae7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -240,6 +240,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { __deleteStudyRequested: function() { const msg = this.tr("Are you sure you want to delete") + " " + this.getTitle() + "?"; const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete"), confirmText: this.tr("Delete"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index 2b200676688..1556ae7ecba 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -196,6 +196,7 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { const templatesText = osparc.product.Utils.getTemplateAlias({plural: true}); const msg = this.tr("Are you sure you want to update all ") + templatesText + "?"; const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Update"), confirmText: this.tr("Update all"), confirmAction: "create" }); @@ -327,6 +328,7 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { const rUSure = this.tr("Are you sure you want to delete "); const msg = rUSure + "" + templateData.name + "?"; const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete"), confirmText: this.tr("Delete"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js index dd7b80e5044..f5a0dbf93b6 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js @@ -250,6 +250,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { let msg = this.tr("Are you sure you want to delete") + " " + this.getTitle() + "?"; msg += "
" + this.tr("All the content of the workspace will be deleted."); const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete"), confirmText: this.tr("Delete"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/data/model/Node.js b/services/static-webserver/client/source/class/osparc/data/model/Node.js index b52c08dbf25..0a1be2d9ae8 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Node.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Node.js @@ -949,6 +949,7 @@ qx.Class.define("osparc.data.model.Node", { if (preferencesSettings.getConfirmStopNode()) { const msg = this.tr("Do you really want Stop and Save the current state?"); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Stop"), confirmText: this.tr("Stop") }); win.center(); diff --git a/services/static-webserver/client/source/class/osparc/desktop/SlideshowView.js b/services/static-webserver/client/source/class/osparc/desktop/SlideshowView.js index e4817393152..593088bc4cd 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/SlideshowView.js +++ b/services/static-webserver/client/source/class/osparc/desktop/SlideshowView.js @@ -456,6 +456,7 @@ qx.Class.define("osparc.desktop.SlideshowView", { if (preferencesSettings.getConfirmDeleteNode()) { const msg = this.tr("Are you sure you want to delete node?"); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete"), confirmText: this.tr("Delete"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js b/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js index 78ece737e9c..a9d3dbe8659 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js +++ b/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js @@ -598,6 +598,7 @@ qx.Class.define("osparc.desktop.StudyEditor", { this.getStudyLogger().info(null, "The pipeline is up-to-date"); const msg = this.tr("The pipeline is up-to-date. Do you want to re-run it?"); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Re-run"), confirmText: this.tr("Run"), confirmAction: "create" }); diff --git a/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js b/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js index ca51e61093b..2b7562cad2d 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js +++ b/services/static-webserver/client/source/class/osparc/desktop/WorkbenchView.js @@ -1119,6 +1119,7 @@ qx.Class.define("osparc.desktop.WorkbenchView", { if (!avoidConfirmation && preferencesSettings.getConfirmDeleteNode()) { const msg = this.tr("Are you sure you want to delete the selected node?"); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete"), confirmText: this.tr("Delete"), confirmAction: "delete" }); @@ -1140,6 +1141,7 @@ qx.Class.define("osparc.desktop.WorkbenchView", { if (preferencesSettings.getConfirmDeleteNode()) { const msg = this.tr("Are you sure you want to delete the selected ") + nodeIds.length + " nodes?"; const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete"), confirmText: this.tr("Delete"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js b/services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js index 2d065ba1dba..9e5808c72a2 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js +++ b/services/static-webserver/client/source/class/osparc/desktop/organizations/MembersList.js @@ -567,6 +567,7 @@ qx.Class.define("osparc.desktop.organizations.MembersList", { } rUSure += "

" + this.tr("If you Leave, the page will be reloaded."); const confirmationWin = new osparc.ui.window.Confirmation(rUSure).set({ + caption: this.tr("Leave Organization"), confirmText: this.tr("Leave"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js b/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js index 935c9cfc35b..aab4bef56ff 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js +++ b/services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js @@ -236,6 +236,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", { const name = org.getLabel(); const msg = this.tr("Are you sure you want to delete ") + name + "?"; const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete Organization"), confirmText: this.tr("Delete"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/desktop/paymentMethods/PaymentMethodListItem.js b/services/static-webserver/client/source/class/osparc/desktop/paymentMethods/PaymentMethodListItem.js index 61cb2b28f21..9342f10f066 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/paymentMethods/PaymentMethodListItem.js +++ b/services/static-webserver/client/source/class/osparc/desktop/paymentMethods/PaymentMethodListItem.js @@ -184,6 +184,7 @@ qx.Class.define("osparc.desktop.paymentMethods.PaymentMethodListItem", { __deletePressed: function() { const msg = this.tr("Are you sure you want to delete the Payment Method?"); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete Payment Method"), confirmText: this.tr("Delete"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/ClustersPage.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/ClustersPage.js index 447333712eb..be0a0eed354 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/ClustersPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/ClustersPage.js @@ -352,6 +352,7 @@ qx.Class.define("osparc.desktop.preferences.pages.ClustersPage", { const name = cluster.getName(); const msg = this.tr("Are you sure you want to delete ") + name + "?"; const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete Cluster"), confirmText: this.tr("Delete"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js index cd19c6f73df..ddc9d94f60f 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js @@ -144,6 +144,7 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", { const msg = this.tr("Do you want to delete the API key?"); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete API key"), confirmText: this.tr("Delete"), confirmAction: "delete" }); @@ -284,6 +285,7 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", { const msg = this.tr("Do you want to delete the Token?"); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Delete Token"), confirmText: this.tr("Delete"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js b/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js index 6ed2ee9356a..478133b46de 100644 --- a/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js +++ b/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js @@ -255,6 +255,7 @@ qx.Class.define("osparc.notification.NotificationUI", { if (myAccountWindow.openWallets()) { const msg = this.tr("Do you want to make it the default Credit Account?"); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Default Credit Account"), confirmAction: "create" }); win.center(); diff --git a/services/static-webserver/client/source/class/osparc/share/Collaborators.js b/services/static-webserver/client/source/class/osparc/share/Collaborators.js index 6bde9a32e86..a263b947e2a 100644 --- a/services/static-webserver/client/source/class/osparc/share/Collaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/Collaborators.js @@ -370,6 +370,7 @@ qx.Class.define("osparc.share.Collaborators", { msg += this.tr("If you remove yourself, there won't be any other Owners."); } const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Leave"), confirmText: this.tr("Leave"), confirmAction: "delete" }); diff --git a/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js b/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js index 80ecbe75006..e6b03e5818e 100644 --- a/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js +++ b/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js @@ -226,6 +226,7 @@ qx.Class.define("osparc.share.CollaboratorsStudy", { if (isOrganization) { const msg = this.tr(`Demoting to ${osparc.data.Roles.STUDY[1].label} will remove write access to all the members of the Organization. Are you sure?`); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Demote"), confirmAction: "delete", confirmText: this.tr("Yes") }); diff --git a/services/static-webserver/client/source/class/osparc/share/CollaboratorsWorkspace.js b/services/static-webserver/client/source/class/osparc/share/CollaboratorsWorkspace.js index 63c2a33b9a9..b1c3791e4a7 100644 --- a/services/static-webserver/client/source/class/osparc/share/CollaboratorsWorkspace.js +++ b/services/static-webserver/client/source/class/osparc/share/CollaboratorsWorkspace.js @@ -162,6 +162,7 @@ qx.Class.define("osparc.share.CollaboratorsWorkspace", { if (isOrganization) { const msg = this.tr(`Demoting to ${osparc.data.Roles.WORKSPACE[1].label} will remove write access to all the members of the Organization. Are you sure?`); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Demote"), confirmAction: "delete", confirmText: this.tr("Yes") }); diff --git a/services/static-webserver/client/source/class/osparc/task/TaskUI.js b/services/static-webserver/client/source/class/osparc/task/TaskUI.js index 6fe3a952ec9..513bf34ec91 100644 --- a/services/static-webserver/client/source/class/osparc/task/TaskUI.js +++ b/services/static-webserver/client/source/class/osparc/task/TaskUI.js @@ -118,6 +118,7 @@ qx.Class.define("osparc.task.TaskUI", { stopButton.addListener("tap", () => { const msg = this.tr("Are you sure you want to cancel the task?"); const win = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Cancel Task"), confirmText: this.tr("Cancel"), confirmAction: "delete" }); From 5931c4dec2fcbff3a1fcb5a094dafd1117aae181 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 10:43:01 +0100 Subject: [PATCH 034/100] list trashed studies --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 4 ++++ .../client/source/class/osparc/data/Resources.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index b2d5d0c59b9..26e077a942f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1005,6 +1005,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { if (context === "search") { this.__setFoldersToList([]); this.__reloadStudies(); + } else if (context === "trash") { + // for now, studies only + this.__setFoldersToList([]); + this.__reloadStudies(); } else if (context === "workspaces") { this._searchBarFilter.resetFilters(); this.__reloadWorkspaces(); diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index a5deccafd59..e7680c9737e 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -142,7 +142,7 @@ qx.Class.define("osparc.data.Resources", { getPageTrashed: { useCache: false, method: "GET", - url: statics.API + "/projects?filters={'trashed':true}&offset={offset}&limit={limit}&order_by={orderBy}" + url: statics.API + "/projects?filters={%22trashed%22:%22true%22}&offset={offset}&limit={limit}&order_by={orderBy}" }, postToTemplate: { method: "POST", From 22c073425956db7aea77d26da1a2b3bd183cceda Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 10:53:40 +0100 Subject: [PATCH 035/100] trashedAt property --- .../client/source/class/osparc/data/model/Study.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/data/model/Study.js b/services/static-webserver/client/source/class/osparc/data/model/Study.js index 912f838486f..d62445e0b3f 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Study.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Study.js @@ -58,7 +58,8 @@ qx.Class.define("osparc.data.model.Study", { state: studyData.state || this.getState(), quality: studyData.quality || this.getQuality(), permalink: studyData.permalink || this.getPermalink(), - dev: studyData.dev || this.getDev() + dev: studyData.dev || this.getDev(), + trashedAt: studyData.trashedAt ? new Date(studyData.trashedAt) : this.getTrashedAt(), }); const wbData = studyData.workbench || this.getWorkbench(); @@ -209,7 +210,13 @@ qx.Class.define("osparc.data.model.Study", { nullable: true, event: "changeReadOnly", init: true - } + }, + + trashedAt: { + check: "Date", + nullable: true, + init: null, + }, // ------ ignore for serializing ------ }, @@ -218,7 +225,8 @@ qx.Class.define("osparc.data.model.Study", { "permalink", "state", "pipelineRunning", - "readOnly" + "readOnly", + "trashedAt", ], IgnoreModelizationProps: [ From 5b7b6d435ba92a82d21d3d9abf0ddafed690b4cb Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 11:04:01 +0100 Subject: [PATCH 036/100] untrashStudy --- .../source/class/osparc/dashboard/CardBase.js | 2 +- .../class/osparc/dashboard/StudyBrowser.js | 42 +++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index 8d59dee3728..bbd5a6cf5a0 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -788,7 +788,7 @@ qx.Class.define("osparc.dashboard.CardBase", { if (moveToButton) { moveToButton.setEnabled(osparc.study.Utils.canMoveTo(resourceData)); } - const deleteButton = menuButtons.find(menuBtn => "deleteButton" in menuBtn); + const deleteButton = menuButtons.find(menuBtn => "trashButton" in menuBtn); if (deleteButton) { deleteButton.setEnabled(osparc.study.Utils.canBeDeleted(resourceData)); } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 26e077a942f..bcf3ee6b78b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1340,9 +1340,25 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const menu = card.getMenu(); const studyData = card.getResourceData(); + const trashed = Boolean(studyData["trashedAt"]); const writeAccess = osparc.data.model.Study.canIWrite(studyData["accessRights"]); const deleteAccess = osparc.data.model.Study.canIDelete(studyData["accessRights"]); + if (this.getCurrentContext() === "trash") { + if (trashed) { + if (writeAccess) { + const untrashButton = this.__getUntrashStudyMenuButton(studyData); + menu.add(untrashButton); + } + if (deleteAccess) { + const deleteButton = this.__getDeleteStudyMenuButton(studyData, false); + menu.addSeparator(); + menu.add(deleteButton); + } + } + return; + } + const openButton = this._getOpenMenuButton(studyData); if (openButton) { menu.add(openButton); @@ -1401,9 +1417,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } if (deleteAccess) { - const deleteButton = this.getCurrentContext() === "trash" ? this.__getDeleteStudyMenuButton(studyData, false) : this.__getTrashStudyMenuButton(studyData, false); + const trashButton = this.__getTrashStudyMenuButton(studyData, false); menu.addSeparator(); - menu.add(deleteButton); + menu.add(trashButton); } card.evaluateMenuButtons(); @@ -1618,7 +1634,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __getTrashStudyMenuButton: function(studyData) { const trashButton = new qx.ui.menu.Button(this.tr("Trash"), "@FontAwesome5Solid/trash/12"); - trashButton["deleteButton"] = true; + trashButton["trashButton"] = true; trashButton.set({ appearance: "menu-button" }); @@ -1627,6 +1643,16 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return trashButton; }, + __getUntrashStudyMenuButton: function(studyData) { + const trashButton = new qx.ui.menu.Button(this.tr("Restore"), "@FontAwesome5Solid/trash/12"); + trashButton["untrashButton"] = true; + trashButton.set({ + appearance: "menu-button" + }); + trashButton.addListener("execute", () => this.__untrashStudy(studyData), this); + return trashButton; + }, + __getDeleteStudyMenuButton: function(studyData) { const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); deleteButton["deleteButton"] = true; @@ -1789,6 +1815,16 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { req.send(body); }, + __untrashStudy: function(studyData) { + osparc.store.Store.getInstance().untrashStudy(studyData.uuid) + .then(() => this.__removeFromStudyList(studyData.uuid)) + .catch(err => { + console.error(err); + osparc.FlashMessenger.getInstance().logAs(err, "ERROR"); + }) + .finally(() => this.resetSelection()); + }, + __trashStudy: function(studyData) { const myGid = osparc.auth.Data.getInstance().getGroupId(); const collabGids = Object.keys(studyData["accessRights"]); From 7cc9eb2710aea842a3d55fa4d5fb6fdbb95fe32a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 11:14:16 +0100 Subject: [PATCH 037/100] restore_from_trash --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index bcf3ee6b78b..1c0131c2bbf 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1644,7 +1644,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __getUntrashStudyMenuButton: function(studyData) { - const trashButton = new qx.ui.menu.Button(this.tr("Restore"), "@FontAwesome5Solid/trash/12"); + const trashButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); trashButton["untrashButton"] = true; trashButton.set({ appearance: "menu-button" From 4e67d4d888687de73102a87ab2c0cfc425ab2298 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 13:46:24 +0100 Subject: [PATCH 038/100] trash folders --- .../client/source/class/osparc/data/Resources.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index e7680c9737e..fbd3e22c2ad 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -318,6 +318,11 @@ qx.Class.define("osparc.data.Resources", { method: "GET", url: statics.API + "/folders/{folderId}" }, + getPageTrashed: { + useCache: false, + method: "GET", + url: statics.API + "/folders?filters={%22trashed%22:%22true%22}&offset={offset}&limit={limit}&order_by={orderBy}" + }, post: { method: "POST", url: statics.API + "/folders" @@ -334,6 +339,14 @@ qx.Class.define("osparc.data.Resources", { method: "PUT", url: statics.API + "/folders/{folderId}/folders/{workspaceId}" }, + trash: { + method: "POST", + url: statics.API + "/folders/{folderId}:trash" + }, + untrash: { + method: "POST", + url: statics.API + "/folders/{folderId}:untrash" + }, } }, "workspaces": { From f1c8b32cd8c1c4b59661803989a924c416629a8b Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 14:14:26 +0100 Subject: [PATCH 039/100] minor --- .../client/source/class/osparc/data/Resources.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index fbd3e22c2ad..af99193da8c 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -1406,7 +1406,7 @@ qx.Class.define("osparc.data.Resources", { }); }, - getAllPages: function(resource, params = {}) { + getAllPages: function(resource, params = {}, endpoint = "getPage") { return new Promise((resolve, reject) => { let resources = []; let offset = 0; @@ -1415,7 +1415,6 @@ qx.Class.define("osparc.data.Resources", { } params["url"]["offset"] = offset; params["url"]["limit"] = 10; - const endpoint = "getPage"; const options = { resolveWResponse: true }; From 0bef5f855eb29e75612601ee438140d876d418d5 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 14:14:52 +0100 Subject: [PATCH 040/100] fetchTrashedFolders --- .../source/class/osparc/store/Folders.js | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/store/Folders.js b/services/static-webserver/client/source/class/osparc/store/Folders.js index 16385de935c..7ea5cb030bc 100644 --- a/services/static-webserver/client/source/class/osparc/store/Folders.js +++ b/services/static-webserver/client/source/class/osparc/store/Folders.js @@ -31,6 +31,17 @@ qx.Class.define("osparc.store.Folders", { "folderMoved": "qx.event.type.Data", }, + statics: { + curateOrderBy: function(orderBy) { + const curatedOrderBy = osparc.utils.Utils.deepCloneObject(orderBy); + if (curatedOrderBy.field !== "name") { + // only "modified_at" and "name" supported + curatedOrderBy.field = "modified_at"; + } + return curatedOrderBy; + }, + }, + members: { foldersCached: null, @@ -48,12 +59,7 @@ qx.Class.define("osparc.store.Folders", { }); } - const curatedOrderBy = osparc.utils.Utils.deepCloneObject(orderBy); - if (curatedOrderBy.field !== "name") { - // only "modified_at" and "name" supported - curatedOrderBy.field = "modified_at"; - } - + const curatedOrderBy = this.self().curateOrderBy(orderBy); const params = { url: { workspaceId, @@ -72,6 +78,33 @@ qx.Class.define("osparc.store.Folders", { }); }, + fetchTrashedFolders: function(orderBy = { + field: "modified_at", + direction: "desc" + }) { + if (osparc.auth.Data.getInstance().isGuest()) { + return new Promise(resolve => { + resolve([]); + }); + } + + const curatedOrderBy = this.self().curateOrderBy(orderBy); + const params = { + url: { + orderBy: JSON.stringify(curatedOrderBy), + } + }; + return osparc.data.Resources.getInstance().getAllPages("folders", params, "getPageTrashed") + .then(trashedFoldersData => { + const folders = []; + trashedFoldersData.forEach(folderData => { + const folder = this.__addToCache(folderData); + folders.push(folder); + }); + return folders; + }); + }, + postFolder: function(name, parentFolderId = null, workspaceId = null) { const newFolderData = { name, From 1fc2d66fe3971ff721bb7637d630f1571d3d6a4e Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 14:16:42 +0100 Subject: [PATCH 041/100] trashedAt for folder model --- .../client/source/class/osparc/data/model/Folder.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/data/model/Folder.js b/services/static-webserver/client/source/class/osparc/data/model/Folder.js index 1dd99d015a2..b8b9eb03b21 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Folder.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Folder.js @@ -37,6 +37,7 @@ qx.Class.define("osparc.data.model.Folder", { owner: folderData.owner, createdAt: new Date(folderData.createdAt), lastModified: new Date(folderData.modifiedAt), + trashedAt: folderData.trashedAt ? new Date(folderData.trashedAt) : this.getTrashedAt(), }); }, @@ -95,7 +96,13 @@ qx.Class.define("osparc.data.model.Folder", { nullable: true, init: null, event: "changeLastModified" - } + }, + + trashedAt: { + check: "Date", + nullable: true, + init: null, + }, }, statics: { From a957b58e202764397fb50b7fdbe8ab2099a042bc Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 14:17:37 +0100 Subject: [PATCH 042/100] list trashed folders in trash --- .../class/osparc/dashboard/StudyBrowser.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index fae2a082bdd..dabc256c85a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -171,17 +171,23 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { if ( !osparc.auth.Manager.getInstance().isLoggedIn() || !osparc.utils.DisabledPlugins.isFoldersEnabled() || - this.getCurrentContext() !== "studiesAndFolders" || + !["studiesAndFolders", "trash"].includes(this.getCurrentContext()) || this.__loadingFolders ) { return; } - const workspaceId = this.getCurrentWorkspaceId(); - const folderId = this.getCurrentFolderId(); this.__loadingFolders = true; this.__setFoldersToList([]); - osparc.store.Folders.getInstance().fetchFolders(folderId, workspaceId, this.getOrderBy()) + let request = null; + if (this.getCurrentContext() === "studiesAndFolders") { + const workspaceId = this.getCurrentWorkspaceId(); + const folderId = this.getCurrentFolderId(); + request = osparc.store.Folders.getInstance().fetchFolders(folderId, workspaceId, this.getOrderBy()) + } else if (this.getCurrentContext() === "trash") { + request = osparc.store.Folders.getInstance().fetchTrashedFolders(this.getOrderBy()) + } + request .then(folders => { this.__setFoldersToList(folders); }) @@ -1000,7 +1006,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__reloadStudies(); } else if (context === "trash") { // for now, studies only - this.__setFoldersToList([]); + this.__reloadFolders(); this.__reloadStudies(); } else if (context === "workspaces") { this._searchBarFilter.resetFilters(); From 5183da78cbf70b476c0dddc6a378b47d8dfd0d85 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 14:31:27 +0100 Subject: [PATCH 043/100] trash folder workflow --- .../osparc/dashboard/FolderButtonItem.js | 25 ++++++++++++++++++- .../osparc/dashboard/ResourceBrowserBase.js | 5 ++++ .../dashboard/ResourceContainerManager.js | 2 ++ .../class/osparc/dashboard/StudyBrowser.js | 6 +++++ .../source/class/osparc/store/Folders.js | 17 +++++++++++++ 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index 526f7032c27..c2807fd13e3 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -46,7 +46,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { "folderSelected": "qx.event.type.Data", "folderUpdated": "qx.event.type.Data", "moveFolderToRequested": "qx.event.type.Data", - "deleteFolderRequested": "qx.event.type.Data" + "trashFolderRequested": "qx.event.type.Data", + "deleteFolderRequested": "qx.event.type.Data", }, properties: { @@ -196,6 +197,10 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { menu.addSeparator(); + const trashButton = new qx.ui.menu.Button(this.tr("Trash"), "@FontAwesome5Solid/trash/12"); + trashButton.addListener("execute", () => this.__trashFolderRequested(), this); + menu.add(trashButton); + const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); deleteButton.addListener("execute", () => this.__deleteFolderRequested(), this); menu.add(deleteButton); @@ -237,6 +242,24 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { folderEditor.addListener("cancel", () => win.close()); }, + __trashFolderRequested: function() { + const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); + let msg = this.tr("Are you sure you want to move the Folder and all its content to the trash?"); + msg += "

" + this.tr("It will be permanently deleted after ") + trashDays + " days."; + const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Move to Trash"), + confirmText: this.tr("Move to Trash"), + confirmAction: "delete" + }); + confirmationWin.center(); + confirmationWin.open(); + confirmationWin.addListener("close", () => { + if (confirmationWin.getConfirmed()) { + this.fireDataEvent("trashFolderRequested", this.getFolderId()); + } + }, this); + }, + __deleteFolderRequested: function() { const msg = this.tr("Are you sure you want to delete") + " " + this.getTitle() + "?"; const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index 9334861f11c..7284536ca2d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -267,6 +267,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { resourcesContainer.addListener("emptyStudyClicked", e => this._deleteResourceRequested(e.getData())); resourcesContainer.addListener("folderUpdated", e => this._folderUpdated(e.getData())); resourcesContainer.addListener("moveFolderToRequested", e => this._moveFolderToRequested(e.getData())); + resourcesContainer.addListener("trashFolderRequested", e => this._trashFolderRequested(e.getData())); resourcesContainer.addListener("deleteFolderRequested", e => this._deleteFolderRequested(e.getData())); resourcesContainer.addListener("folderSelected", e => { const folderId = e.getData(); @@ -487,6 +488,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { throw new Error("Abstract method called!"); }, + _trashFolderRequested: function(folderId) { + throw new Error("Abstract method called!"); + }, + _deleteFolderRequested: function(folderId) { throw new Error("Abstract method called!"); }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 187f6b441d3..bf819549b81 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -75,6 +75,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { "folderSelected": "qx.event.type.Data", "folderUpdated": "qx.event.type.Data", "moveFolderToRequested": "qx.event.type.Data", + "trashFolderRequested": "qx.event.type.Data", "deleteFolderRequested": "qx.event.type.Data", "workspaceSelected": "qx.event.type.Data", "workspaceUpdated": "qx.event.type.Data", @@ -418,6 +419,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { "folderSelected", "folderUpdated", "moveFolderToRequested", + "trashFolderRequested", "deleteFolderRequested", ].forEach(eName => card.addListener(eName, e => this.fireDataEvent(eName, e.getData()))); return card; diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index dabc256c85a..603ca2a9a06 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -542,6 +542,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { .catch(err => console.error(err)); }, + _trashFolderRequested: function(folderId) { + osparc.store.Folders.getInstance().trashFolder(folderId, this.getCurrentWorkspaceId()) + .then(() => this.__reloadFolders()) + .catch(err => console.error(err)); + }, + _deleteFolderRequested: function(folderId) { osparc.store.Folders.getInstance().deleteFolder(folderId, this.getCurrentWorkspaceId()) .then(() => this.__reloadFolders()) diff --git a/services/static-webserver/client/source/class/osparc/store/Folders.js b/services/static-webserver/client/source/class/osparc/store/Folders.js index 7ea5cb030bc..3eccdd75c18 100644 --- a/services/static-webserver/client/source/class/osparc/store/Folders.js +++ b/services/static-webserver/client/source/class/osparc/store/Folders.js @@ -122,6 +122,23 @@ qx.Class.define("osparc.store.Folders", { }); }, + trashFolder: function(folderId, workspaceId) { + const params = { + "url": { + folderId + } + }; + return osparc.data.Resources.getInstance().fetch("folders", "trash", params) + .then(() => { + const folder = this.getFolder(folderId); + if (folder) { + this.__deleteFromCache(folderId, workspaceId); + this.fireDataEvent("folderRemoved", folder); + } + }) + .catch(console.error); + }, + deleteFolder: function(folderId, workspaceId) { const params = { "url": { From 8191c76fc496fa0bc58e1dfa0a004f01def1809a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 15:00:36 +0100 Subject: [PATCH 044/100] trashedAt --- .../client/source/class/osparc/store/Folders.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/store/Folders.js b/services/static-webserver/client/source/class/osparc/store/Folders.js index 3eccdd75c18..6185a1767e1 100644 --- a/services/static-webserver/client/source/class/osparc/store/Folders.js +++ b/services/static-webserver/client/source/class/osparc/store/Folders.js @@ -191,6 +191,8 @@ qx.Class.define("osparc.store.Folders", { folder.set("createdAt", new Date(folderData["createdAt"])); } else if (key === "modifiedAt") { folder.set("lastModified", new Date(folderData["modifiedAt"])); + } else if (key === "trashedAt") { + folder.set("trashedAt", new Date(folderData["trashedAt"])); } else { folder.set(key, folderData[key]); } From f0edc20a6d9fead34c1863b9546b405b26e04493 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 15:02:19 +0100 Subject: [PATCH 045/100] untrash and context binding --- .../osparc/dashboard/FolderButtonItem.js | 43 +++++++++++++------ .../osparc/dashboard/ResourceBrowserBase.js | 5 +++ .../dashboard/ResourceContainerManager.js | 10 +++++ .../class/osparc/dashboard/StudyBrowser.js | 7 +++ .../source/class/osparc/store/Folders.js | 17 ++++++++ 5 files changed, 68 insertions(+), 14 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index c2807fd13e3..eba93158037 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -47,6 +47,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { "folderUpdated": "qx.event.type.Data", "moveFolderToRequested": "qx.event.type.Data", "trashFolderRequested": "qx.event.type.Data", + "untrashFolderRequested": "qx.event.type.Data", "deleteFolderRequested": "qx.event.type.Data", }, @@ -85,7 +86,14 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { check: "Date", nullable: true, apply: "__applyLastModified" - } + }, + + currentContext: { + check: ["studiesAndFolders", "workspaces", "search", "trash"], + nullable: false, + init: "studiesAndFolders", + event: "changeCurrentContext" + }, }, members: { @@ -187,23 +195,30 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { position: "bottom-right" }); - const editButton = new qx.ui.menu.Button(this.tr("Rename..."), "@FontAwesome5Solid/pencil-alt/12"); - editButton.addListener("execute", () => this.__editFolder(), this); - menu.add(editButton); + if (this.getCurrentContext() === "trash") { + const trashButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); + trashButton.addListener("execute", () => this.fireDataEvent("untrashFolderRequested", this.getFolderId()), this); + + menu.addSeparator(); - const moveToButton = new qx.ui.menu.Button(this.tr("Move to..."), "@FontAwesome5Solid/folder/12"); - moveToButton.addListener("execute", () => this.fireDataEvent("moveFolderToRequested", this.getFolderId()), this); - menu.add(moveToButton); + const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); + deleteButton.addListener("execute", () => this.__deleteFolderRequested(), this); + menu.add(deleteButton); + } else { + const editButton = new qx.ui.menu.Button(this.tr("Rename..."), "@FontAwesome5Solid/pencil-alt/12"); + editButton.addListener("execute", () => this.__editFolder(), this); + menu.add(editButton); - menu.addSeparator(); + const moveToButton = new qx.ui.menu.Button(this.tr("Move to..."), "@FontAwesome5Solid/folder/12"); + moveToButton.addListener("execute", () => this.fireDataEvent("moveFolderToRequested", this.getFolderId()), this); + menu.add(moveToButton); - const trashButton = new qx.ui.menu.Button(this.tr("Trash"), "@FontAwesome5Solid/trash/12"); - trashButton.addListener("execute", () => this.__trashFolderRequested(), this); - menu.add(trashButton); + menu.addSeparator(); - const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); - deleteButton.addListener("execute", () => this.__deleteFolderRequested(), this); - menu.add(deleteButton); + const trashButton = new qx.ui.menu.Button(this.tr("Trash"), "@FontAwesome5Solid/trash/12"); + trashButton.addListener("execute", () => this.__trashFolderRequested(), this); + menu.add(trashButton); + } menuButton.setMenu(menu); }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index 7284536ca2d..6313776a5e1 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -268,6 +268,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { resourcesContainer.addListener("folderUpdated", e => this._folderUpdated(e.getData())); resourcesContainer.addListener("moveFolderToRequested", e => this._moveFolderToRequested(e.getData())); resourcesContainer.addListener("trashFolderRequested", e => this._trashFolderRequested(e.getData())); + resourcesContainer.addListener("untrashFolderRequested", e => this._untrashFolderRequested(e.getData())); resourcesContainer.addListener("deleteFolderRequested", e => this._deleteFolderRequested(e.getData())); resourcesContainer.addListener("folderSelected", e => { const folderId = e.getData(); @@ -492,6 +493,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { throw new Error("Abstract method called!"); }, + _untrashFolderRequested: function(folderId) { + throw new Error("Abstract method called!"); + }, + _deleteFolderRequested: function(folderId) { throw new Error("Abstract method called!"); }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index bf819549b81..a0b0c7e7adf 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -49,6 +49,13 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, properties: { + currentContext: { + check: ["studiesAndFolders", "workspaces", "search", "trash"], + nullable: false, + init: "studiesAndFolders", + event: "changeCurrentContext" + }, + mode: { check: ["grid", "list"], init: "grid", @@ -76,6 +83,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { "folderUpdated": "qx.event.type.Data", "moveFolderToRequested": "qx.event.type.Data", "trashFolderRequested": "qx.event.type.Data", + "untrashFolderRequested": "qx.event.type.Data", "deleteFolderRequested": "qx.event.type.Data", "workspaceSelected": "qx.event.type.Data", "workspaceUpdated": "qx.event.type.Data", @@ -415,11 +423,13 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { __createFolderCard: function(folder) { const card = new osparc.dashboard.FolderButtonItem(folder); + this.bind("currentContext", card, "currentContext"); [ "folderSelected", "folderUpdated", "moveFolderToRequested", "trashFolderRequested", + "untrashFolderRequested", "deleteFolderRequested", ].forEach(eName => card.addListener(eName, e => this.fireDataEvent(eName, e.getData()))); return card; diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 603ca2a9a06..585e3199201 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -548,6 +548,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { .catch(err => console.error(err)); }, + _untrashFolderRequested: function(folderId) { + osparc.store.Folders.getInstance().untrashFolder(folderId) + .then(() => this.__reloadFolders()) + .catch(err => console.error(err)); + }, + _deleteFolderRequested: function(folderId) { osparc.store.Folders.getInstance().deleteFolder(folderId, this.getCurrentWorkspaceId()) .then(() => this.__reloadFolders()) @@ -871,6 +877,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } this._createResourcesLayout(); + this.bind("currentContext", this._resourcesContainer, "currentContext"); const list = this._resourcesContainer.getFlatList(); if (list) { diff --git a/services/static-webserver/client/source/class/osparc/store/Folders.js b/services/static-webserver/client/source/class/osparc/store/Folders.js index 6185a1767e1..0355534c359 100644 --- a/services/static-webserver/client/source/class/osparc/store/Folders.js +++ b/services/static-webserver/client/source/class/osparc/store/Folders.js @@ -139,6 +139,23 @@ qx.Class.define("osparc.store.Folders", { .catch(console.error); }, + untrashFolder: function(folderId, workspaceId) { + const params = { + "url": { + folderId + } + }; + return osparc.data.Resources.getInstance().fetch("folders", "trash", params) + .then(() => { + console.log("untrashed"); + /* + const folder = this.__addToCache(folderData); + this.fireDataEvent("folderAdded", folder); + */ + }) + .catch(console.error); + }, + deleteFolder: function(folderId, workspaceId) { const params = { "url": { From 43d81f1f60713d706062af604d77300232d10bbe Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 15:16:06 +0100 Subject: [PATCH 046/100] populateMenu --- .../source/class/osparc/dashboard/FolderButtonItem.js | 7 +++---- .../class/osparc/dashboard/ResourceContainerManager.js | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index eba93158037..87ae46e2b30 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -92,7 +92,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { check: ["studiesAndFolders", "workspaces", "search", "trash"], nullable: false, init: "studiesAndFolders", - event: "changeCurrentContext" + event: "changeCurrentContext", }, }, @@ -153,8 +153,6 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { folder.bind("parentFolderId", this, "parentFolderId"); folder.bind("name", this, "title"); folder.bind("lastModified", this, "lastModified"); - - this.__addMenuButton(); }, __applyWorkspaceId: function(workspaceId) { @@ -187,7 +185,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { } }, - __addMenuButton: function() { + populateMenuButton: function() { const menuButton = this.getChildControl("menu-button"); menuButton.setVisibility("visible"); @@ -198,6 +196,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { if (this.getCurrentContext() === "trash") { const trashButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); trashButton.addListener("execute", () => this.fireDataEvent("untrashFolderRequested", this.getFolderId()), this); + menu.add(trashButton); menu.addSeparator(); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index a0b0c7e7adf..c64b6ec512d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -424,6 +424,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { __createFolderCard: function(folder) { const card = new osparc.dashboard.FolderButtonItem(folder); this.bind("currentContext", card, "currentContext"); + card.populateMenuButton(); [ "folderSelected", "folderUpdated", From aa10e477ffe6898600bf85a05f6fde5f712f2399 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 15:30:25 +0100 Subject: [PATCH 047/100] pass entire folder --- .../source/class/osparc/dashboard/FolderButtonItem.js | 2 +- .../class/osparc/dashboard/ResourceBrowserBase.js | 2 +- .../source/class/osparc/dashboard/StudyBrowser.js | 4 ++-- .../client/source/class/osparc/store/Folders.js | 11 ++++------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index 87ae46e2b30..a30e6c9a1a3 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -195,7 +195,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { if (this.getCurrentContext() === "trash") { const trashButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); - trashButton.addListener("execute", () => this.fireDataEvent("untrashFolderRequested", this.getFolderId()), this); + trashButton.addListener("execute", () => this.fireDataEvent("untrashFolderRequested", this.getFolder()), this); menu.add(trashButton); menu.addSeparator(); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index 6313776a5e1..649d1b294a5 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -493,7 +493,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { throw new Error("Abstract method called!"); }, - _untrashFolderRequested: function(folderId) { + _untrashFolderRequested: function(folder) { throw new Error("Abstract method called!"); }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 585e3199201..d888e018a54 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -548,8 +548,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { .catch(err => console.error(err)); }, - _untrashFolderRequested: function(folderId) { - osparc.store.Folders.getInstance().untrashFolder(folderId) + _untrashFolderRequested: function(folder) { + osparc.store.Folders.getInstance().untrashFolder(folder) .then(() => this.__reloadFolders()) .catch(err => console.error(err)); }, diff --git a/services/static-webserver/client/source/class/osparc/store/Folders.js b/services/static-webserver/client/source/class/osparc/store/Folders.js index 0355534c359..79160d2e840 100644 --- a/services/static-webserver/client/source/class/osparc/store/Folders.js +++ b/services/static-webserver/client/source/class/osparc/store/Folders.js @@ -139,19 +139,16 @@ qx.Class.define("osparc.store.Folders", { .catch(console.error); }, - untrashFolder: function(folderId, workspaceId) { + untrashFolder: function(folder) { const params = { "url": { - folderId + folderId: folder.getFolderId(), } }; - return osparc.data.Resources.getInstance().fetch("folders", "trash", params) + return osparc.data.Resources.getInstance().fetch("folders", "untrash", params) .then(() => { - console.log("untrashed"); - /* - const folder = this.__addToCache(folderData); + this.foldersCached.unshift(folder); this.fireDataEvent("folderAdded", folder); - */ }) .catch(console.error); }, From 9eda3d78f5901ece662d8af1348fbe7681702922 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 15:32:26 +0100 Subject: [PATCH 048/100] fix --- .../source/class/osparc/dashboard/WorkspacesAndFoldersTree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js index 0e4c2de0e17..c151776c586 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTree.js @@ -300,7 +300,7 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", { if (oldParentFolderId === undefined) { // it was removed, not moved // remove it from the cached models - const modelFound = this.__getModel(folder.getWorkspaceId(), folder.getParentFolderId()); + const modelFound = this.__getModel(folder.getWorkspaceId(), folder.getFolderId()); if (modelFound) { const index = this.__models.indexOf(modelFound); if (index > -1) { // only splice array when item is found From 245a10bf6c4b5c063df154f5d985c0e6dc26dc59 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 17:44:20 +0100 Subject: [PATCH 049/100] context saved in store --- .../class/osparc/dashboard/FolderButtonItem.js | 14 +++++--------- .../osparc/dashboard/ResourceContainerManager.js | 9 --------- .../source/class/osparc/dashboard/StudyBrowser.js | 2 +- .../client/source/class/osparc/store/Store.js | 6 ++++++ 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index a30e6c9a1a3..bb373312ab2 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -87,13 +87,6 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { nullable: true, apply: "__applyLastModified" }, - - currentContext: { - check: ["studiesAndFolders", "workspaces", "search", "trash"], - nullable: false, - init: "studiesAndFolders", - event: "changeCurrentContext", - }, }, members: { @@ -153,6 +146,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { folder.bind("parentFolderId", this, "parentFolderId"); folder.bind("name", this, "title"); folder.bind("lastModified", this, "lastModified"); + + this.__addMenuButton(); }, __applyWorkspaceId: function(workspaceId) { @@ -185,7 +180,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { } }, - populateMenuButton: function() { + __addMenuButton: function() { const menuButton = this.getChildControl("menu-button"); menuButton.setVisibility("visible"); @@ -193,7 +188,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { position: "bottom-right" }); - if (this.getCurrentContext() === "trash") { + const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); + if (studyBrowserContext === "trash") { const trashButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); trashButton.addListener("execute", () => this.fireDataEvent("untrashFolderRequested", this.getFolder()), this); menu.add(trashButton); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index c64b6ec512d..8ebb7b0516d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -49,13 +49,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, properties: { - currentContext: { - check: ["studiesAndFolders", "workspaces", "search", "trash"], - nullable: false, - init: "studiesAndFolders", - event: "changeCurrentContext" - }, - mode: { check: ["grid", "list"], init: "grid", @@ -423,8 +416,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { __createFolderCard: function(folder) { const card = new osparc.dashboard.FolderButtonItem(folder); - this.bind("currentContext", card, "currentContext"); - card.populateMenuButton(); [ "folderSelected", "folderUpdated", diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index d888e018a54..6113489062f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -877,7 +877,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } this._createResourcesLayout(); - this.bind("currentContext", this._resourcesContainer, "currentContext"); const list = this._resourcesContainer.getFlatList(); if (list) { @@ -993,6 +992,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __changeContext: function(context, workspaceId = null, folderId = null) { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { + osparc.store.Store.getInstance().setStudyBrowserContext(context); if ( context !== "search" && // reload studies for a new search context === this.getCurrentContext() && diff --git a/services/static-webserver/client/source/class/osparc/store/Store.js b/services/static-webserver/client/source/class/osparc/store/Store.js index 41dcfa0bc5f..0508cc2d7db 100644 --- a/services/static-webserver/client/source/class/osparc/store/Store.js +++ b/services/static-webserver/client/source/class/osparc/store/Store.js @@ -66,6 +66,12 @@ qx.Class.define("osparc.store.Store", { init: null, nullable: true }, + studyBrowserContext: { + check: ["studiesAndFolders", "workspaces", "search", "trash"], + init: "studiesAndFolders", + nullable: false, + event: "changeStudyBrowserContext", + }, studies: { check: "Array", init: [] From 8d4d51d16fd3c1465feab7012176473dd582bcdc Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Fri, 8 Nov 2024 17:52:23 +0100 Subject: [PATCH 050/100] minor --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 6113489062f..b2ae227c146 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -42,6 +42,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { construct: function() { this._resourceType = "study"; this.base(arguments); + + const store = osparc.store.Store.getInstance(); + this.bind("currentContext", store, "studyBrowserContext"); }, events: { @@ -992,7 +995,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __changeContext: function(context, workspaceId = null, folderId = null) { if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { - osparc.store.Store.getInstance().setStudyBrowserContext(context); if ( context !== "search" && // reload studies for a new search context === this.getCurrentContext() && From 1f72030f840ab59f1e954bad0d05450716338ae0 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 09:45:17 +0100 Subject: [PATCH 051/100] renames --- .../client/source/class/osparc/dashboard/CardBase.js | 6 +++--- .../source/class/osparc/dashboard/FolderButtonItem.js | 6 +++--- .../source/class/osparc/dashboard/StudyBrowser.js | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index 7ff09327600..0a234a1869a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -788,9 +788,9 @@ qx.Class.define("osparc.dashboard.CardBase", { if (moveToButton) { moveToButton.setEnabled(osparc.study.Utils.canMoveTo(resourceData)); } - const deleteButton = menuButtons.find(menuBtn => "trashButton" in menuBtn); - if (deleteButton) { - deleteButton.setEnabled(osparc.study.Utils.canBeDeleted(resourceData)); + const trashButton = menuButtons.find(menuBtn => "trashButton" in menuBtn); + if (trashButton) { + trashButton.setEnabled(osparc.study.Utils.canBeDeleted(resourceData)); } } }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index ba50707215b..96fcdb6e4eb 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -225,9 +225,9 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { trashButton.addListener("execute", () => this.__trashFolderRequested(), this); menu.add(trashButton); } else if (studyBrowserContext === "trash") { - const trashButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); - trashButton.addListener("execute", () => this.fireDataEvent("untrashFolderRequested", this.getFolder()), this); - menu.add(trashButton); + const restoreButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); + restoreButton.addListener("execute", () => this.fireDataEvent("untrashFolderRequested", this.getFolder()), this); + menu.add(restoreButton); menu.addSeparator(); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 2912a3fcf7b..a4659ce667a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1689,13 +1689,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __getUntrashStudyMenuButton: function(studyData) { - const trashButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); - trashButton["untrashButton"] = true; - trashButton.set({ + const restoreButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); + restoreButton["untrashButton"] = true; + restoreButton.set({ appearance: "menu-button" }); - trashButton.addListener("execute", () => this.__untrashStudy(studyData), this); - return trashButton; + restoreButton.addListener("execute", () => this.__untrashStudy(studyData), this); + return restoreButton; }, __getDeleteStudyMenuButton: function(studyData) { From 3a801604085c38b485c1ba4470b4c12588063d6f Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 09:46:23 +0100 Subject: [PATCH 052/100] workspace trashedAt --- .../client/source/class/osparc/data/model/Folder.js | 2 +- .../client/source/class/osparc/data/model/Workspace.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/data/model/Folder.js b/services/static-webserver/client/source/class/osparc/data/model/Folder.js index b8b9eb03b21..6a255a45dc5 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Folder.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Folder.js @@ -37,7 +37,7 @@ qx.Class.define("osparc.data.model.Folder", { owner: folderData.owner, createdAt: new Date(folderData.createdAt), lastModified: new Date(folderData.modifiedAt), - trashedAt: folderData.trashedAt ? new Date(folderData.trashedAt) : this.getTrashedAt(), + trashedAt: folderData.trashedAt ? new Date(folderData.trashedAt) : null, }); }, diff --git a/services/static-webserver/client/source/class/osparc/data/model/Workspace.js b/services/static-webserver/client/source/class/osparc/data/model/Workspace.js index 56023d1eb4e..6fca15ce04b 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Workspace.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Workspace.js @@ -37,6 +37,7 @@ qx.Class.define("osparc.data.model.Workspace", { accessRights: workspaceData.accessRights, createdAt: new Date(workspaceData.createdAt), modifiedAt: new Date(workspaceData.modifiedAt), + trashedAt: workspaceData.trashedAt ? new Date(workspaceData.trashedAt) : null, }); }, @@ -95,7 +96,13 @@ qx.Class.define("osparc.data.model.Workspace", { nullable: true, init: null, event: "changeModifiedAt" - } + }, + + trashedAt: { + check: "Date", + nullable: true, + init: null, + }, }, statics: { From 15ad214398c2ac7e70496a7d269a546870aed700 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 09:51:37 +0100 Subject: [PATCH 053/100] minor --- .../static-webserver/client/source/class/osparc/store/Folders.js | 1 + 1 file changed, 1 insertion(+) diff --git a/services/static-webserver/client/source/class/osparc/store/Folders.js b/services/static-webserver/client/source/class/osparc/store/Folders.js index 9e647fc3de7..236d35f2562 100644 --- a/services/static-webserver/client/source/class/osparc/store/Folders.js +++ b/services/static-webserver/client/source/class/osparc/store/Folders.js @@ -128,6 +128,7 @@ qx.Class.define("osparc.store.Folders", { return osparc.data.Resources.getInstance().getAllPages("folders", params, "getPageSearch") .then(foldersData => { const folders = []; + foldersData.forEach(folderData => { const folder = this.__addToCache(folderData); folders.push(folder); }); From d37fd522542bea2a460b907c929d597a34de74f4 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 09:55:42 +0100 Subject: [PATCH 054/100] search and trashed workspaces --- .../source/class/osparc/data/Resources.js | 18 ++++-- .../source/class/osparc/store/Workspaces.js | 58 +++++++++++++++++++ 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index 56ba4300716..2af997f689a 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -314,15 +314,15 @@ qx.Class.define("osparc.data.Resources", { method: "GET", url: statics.API + "/folders?workspace_id={workspaceId}&folder_id={folderId}&offset={offset}&limit={limit}&order_by={orderBy}" }, + getOne: { + method: "GET", + url: statics.API + "/folders/{folderId}" + }, getPageSearch: { useCache: false, method: "GET", url: statics.API + "/folders:search?offset={offset}&limit={limit}&text={text}&order_by={orderBy}" }, - getOne: { - method: "GET", - url: statics.API + "/folders/{folderId}" - }, getPageTrashed: { useCache: false, method: "GET", @@ -364,6 +364,16 @@ qx.Class.define("osparc.data.Resources", { method: "GET", url: statics.API + "/workspaces/{workspaceId}" }, + getPageSearch: { + useCache: false, + method: "GET", + url: statics.API + "/workspaces:search?offset={offset}&limit={limit}&text={text}&order_by={orderBy}" + }, + getPageTrashed: { + useCache: false, + method: "GET", + url: statics.API + "/workspaces?filters={%22trashed%22:%22true%22}&offset={offset}&limit={limit}&order_by={orderBy}" + }, post: { method: "POST", url: statics.API + "/workspaces" diff --git a/services/static-webserver/client/source/class/osparc/store/Workspaces.js b/services/static-webserver/client/source/class/osparc/store/Workspaces.js index 253ac714a1d..a08cef3f4d2 100644 --- a/services/static-webserver/client/source/class/osparc/store/Workspaces.js +++ b/services/static-webserver/client/source/class/osparc/store/Workspaces.js @@ -68,6 +68,64 @@ qx.Class.define("osparc.store.Workspaces", { }); }, + fetchTrashedWorkspaces: function(orderBy = { + field: "modified_at", + direction: "desc" + }) { + if (osparc.auth.Data.getInstance().isGuest()) { + return new Promise(resolve => { + resolve([]); + }); + } + + const curatedOrderBy = this.self().curateOrderBy(orderBy); + const params = { + url: { + orderBy: JSON.stringify(curatedOrderBy), + } + }; + return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageTrashed") + .then(trashedWorkspacesData => { + const workspaces = []; + trashedWorkspacesData.forEach(workspaceData => { + const workspace = this.__addToCache(workspaceData); + workspaces.push(workspace); + }); + return workspaces; + }); + }, + + searchWorkspaces: function( + text, + orderBy = { + field: "modified_at", + direction: "desc" + }, + ) { + if (osparc.auth.Data.getInstance().isGuest()) { + return new Promise(resolve => { + resolve([]); + }); + } + + const curatedOrderBy = this.self().curateOrderBy(orderBy); + const params = { + url: { + text, + orderBy: JSON.stringify(curatedOrderBy), + } + }; + return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageSearch") + .then(workspacesData => { + const workspaces = []; + workspacesData.forEach(workspaceData => { + const workspace = this.__addToCache(workspaceData); + workspaces.push(workspace); + }); + return workspaces; + }); + }, + postWorkspace: function(newWorkspaceData) { const params = { data: newWorkspaceData From b2035cf67333ce82a7bfad4eddcdd0d1f06da080 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 10:08:16 +0100 Subject: [PATCH 055/100] trashed and search workspaces --- .../class/osparc/dashboard/StudyBrowser.js | 40 +++++++++++++++++-- .../source/class/osparc/store/Workspaces.js | 23 ++--------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index a4659ce667a..5b929fb0adf 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -99,6 +99,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __workspacesList: null, __foldersList: null, __loadingFolders: null, + __loadingWorkspaces: null, // overridden initResources: function() { @@ -163,11 +164,40 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __reloadWorkspaces: function() { + if ( + !osparc.auth.Manager.getInstance().isLoggedIn() || + !osparc.utils.DisabledPlugins.isFoldersEnabled() || + this.getCurrentContext() === "studiesAndFolders" || + this.__loadingWorkspaces + ) { + return; + } + + let request = null; + switch (this.getCurrentContext()) { + case "search": { + const filterData = this._searchBarFilter.getFilterData(); + const text = filterData.text ? encodeURIComponent(filterData.text) : ""; + request = osparc.store.Workspaces.getInstance().searchWorkspaces(text); + break; + } + case "workspaces": { + request = osparc.store.Workspaces.getInstance().fetchWorkspaces(); + break; + } + case "trash": + request = osparc.store.Workspaces.getInstance().fetchTrashedWorkspaces(); + break; + } + + this.__loadingWorkspaces = true; this.__setWorkspacesToList([]); - osparc.store.Workspaces.getInstance().fetchWorkspaces() + request .then(workspaces => { this.__setWorkspacesToList(workspaces); - }); + }) + .catch(console.error) + .finally(() => this.__loadingWorkspaces = null); }, __reloadFolders: function() { @@ -180,7 +210,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return; } - this.__loadingFolders = true; let request = null; switch (this.getCurrentContext()) { case "search": { @@ -200,6 +229,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { break; } + this.__loadingFolders = true; this.__setFoldersToList([]); request .then(folders => { @@ -1032,10 +1062,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._toolbar.show(); if (context === "search") { + this.__reloadWorkspaces(); this.__reloadFolders(); this.__reloadStudies(); } else if (context === "trash") { - // for now, studies only + this._searchBarFilter.resetFilters(); + this.__reloadWorkspaces(); this.__reloadFolders(); this.__reloadStudies(); } else if (context === "workspaces") { diff --git a/services/static-webserver/client/source/class/osparc/store/Workspaces.js b/services/static-webserver/client/source/class/osparc/store/Workspaces.js index a08cef3f4d2..a6ea3bfb9df 100644 --- a/services/static-webserver/client/source/class/osparc/store/Workspaces.js +++ b/services/static-webserver/client/source/class/osparc/store/Workspaces.js @@ -68,23 +68,14 @@ qx.Class.define("osparc.store.Workspaces", { }); }, - fetchTrashedWorkspaces: function(orderBy = { - field: "modified_at", - direction: "desc" - }) { + fetchTrashedWorkspaces: function() { if (osparc.auth.Data.getInstance().isGuest()) { return new Promise(resolve => { resolve([]); }); } - const curatedOrderBy = this.self().curateOrderBy(orderBy); - const params = { - url: { - orderBy: JSON.stringify(curatedOrderBy), - } - }; - return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageTrashed") + return osparc.data.Resources.getInstance().getAllPages("workspaces", {}, "getPageTrashed") .then(trashedWorkspacesData => { const workspaces = []; trashedWorkspacesData.forEach(workspaceData => { @@ -95,24 +86,16 @@ qx.Class.define("osparc.store.Workspaces", { }); }, - searchWorkspaces: function( - text, - orderBy = { - field: "modified_at", - direction: "desc" - }, - ) { + searchWorkspaces: function(text) { if (osparc.auth.Data.getInstance().isGuest()) { return new Promise(resolve => { resolve([]); }); } - const curatedOrderBy = this.self().curateOrderBy(orderBy); const params = { url: { text, - orderBy: JSON.stringify(curatedOrderBy), } }; return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageSearch") From a3d299b4783b0772b02ab81713b6b88cbcf54e5a Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 10:14:32 +0100 Subject: [PATCH 056/100] minor --- .../class/osparc/dashboard/StudyBrowser.js | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 5b929fb0adf..5e4be8bb29f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1061,23 +1061,28 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._resourcesContainer.setResourcesToList([]); this._toolbar.show(); - if (context === "search") { - this.__reloadWorkspaces(); - this.__reloadFolders(); - this.__reloadStudies(); - } else if (context === "trash") { - this._searchBarFilter.resetFilters(); - this.__reloadWorkspaces(); - this.__reloadFolders(); - this.__reloadStudies(); - } else if (context === "workspaces") { - this._toolbar.hide(); - this._searchBarFilter.resetFilters(); - this.__reloadWorkspaces(); - } else if (context === "studiesAndFolders") { - this._searchBarFilter.resetFilters(); - this.__reloadFolders(); - this.__reloadStudies(); + switch (this.getCurrentContext()) { + case "studiesAndFolders": + this._searchBarFilter.resetFilters(); + this.__reloadFolders(); + this.__reloadStudies(); + break; + case "workspaces": + this._toolbar.hide(); + this._searchBarFilter.resetFilters(); + this.__reloadWorkspaces(); + break; + case "search": + this.__reloadWorkspaces(); + this.__reloadFolders(); + this.__reloadStudies(); + break; + case "trash": + this._searchBarFilter.resetFilters(); + this.__reloadWorkspaces(); + this.__reloadFolders(); + this.__reloadStudies(); + break; } // notify header From 8765c2cfad06c042d59f4841c3c973889feacae8 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 10:27:32 +0100 Subject: [PATCH 057/100] [skip ci] orderBy is required --- .../source/class/osparc/dashboard/StudyBrowser.js | 4 +++- .../client/source/class/osparc/store/Workspaces.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 5e4be8bb29f..5418abedec6 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -168,6 +168,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { !osparc.auth.Manager.getInstance().isLoggedIn() || !osparc.utils.DisabledPlugins.isFoldersEnabled() || this.getCurrentContext() === "studiesAndFolders" || + this.getCurrentContext() === "search" || // not yet implemented this.__loadingWorkspaces ) { return; @@ -308,6 +309,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const nStudies = "_meta" in resp ? resp["_meta"]["total"] : 0; if ( nStudies === 0 && + this.getCurrentContext() === "studiesAndFolders" && this.getCurrentWorkspaceId() === null && this.getCurrentFolderId() === null ) { @@ -1020,7 +1022,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, this); this._resourceFilter.addListener("trashContext", () => { - this.__changeContext("trash"); + this._changeContext("trash"); }); this._searchBarFilter.addListener("filterChanged", e => { diff --git a/services/static-webserver/client/source/class/osparc/store/Workspaces.js b/services/static-webserver/client/source/class/osparc/store/Workspaces.js index a6ea3bfb9df..aee9141b3ec 100644 --- a/services/static-webserver/client/source/class/osparc/store/Workspaces.js +++ b/services/static-webserver/client/source/class/osparc/store/Workspaces.js @@ -68,14 +68,23 @@ qx.Class.define("osparc.store.Workspaces", { }); }, - fetchTrashedWorkspaces: function() { + fetchTrashedWorkspaces: function(orderBy = { + field: "modified_at", + direction: "desc" + }) { if (osparc.auth.Data.getInstance().isGuest()) { return new Promise(resolve => { resolve([]); }); } - return osparc.data.Resources.getInstance().getAllPages("workspaces", {}, "getPageTrashed") + const curatedOrderBy = this.self().curateOrderBy(orderBy); + const params = { + url: { + orderBy: JSON.stringify(curatedOrderBy), + } + }; + return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageTrashed") .then(trashedWorkspacesData => { const workspaces = []; trashedWorkspacesData.forEach(workspaceData => { From a0879f923569cdfe8b60cedf8da69e2d402eb1c5 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 10:36:57 +0100 Subject: [PATCH 058/100] plus button --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 8 ++++++++ .../client/source/class/osparc/store/Workspaces.js | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 5418abedec6..924a30f07c8 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -426,6 +426,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._resourcesContainer.setWorkspacesToList(this.__workspacesList); this._resourcesContainer.reloadWorkspaces(); + this.__addNewWorkspaceButton(); + }, + + __addNewWorkspaceButton: function() { + if (this.getCurrentContext() !== "workspaces") { + return; + } + const newWorkspaceCard = new osparc.dashboard.WorkspaceButtonNew(); newWorkspaceCard.setCardKey("new-workspace"); newWorkspaceCard.subscribeToFilterGroup("searchBarFilter"); diff --git a/services/static-webserver/client/source/class/osparc/store/Workspaces.js b/services/static-webserver/client/source/class/osparc/store/Workspaces.js index aee9141b3ec..a9bcb1c6d43 100644 --- a/services/static-webserver/client/source/class/osparc/store/Workspaces.js +++ b/services/static-webserver/client/source/class/osparc/store/Workspaces.js @@ -46,6 +46,15 @@ qx.Class.define("osparc.store.Workspaces", { thumbnail, }; }, + + curateOrderBy: function(orderBy) { + const curatedOrderBy = osparc.utils.Utils.deepCloneObject(orderBy); + if (curatedOrderBy.field !== "name") { + // only "modified_at" and "name" supported + curatedOrderBy.field = "modified_at"; + } + return curatedOrderBy; + }, }, members: { From a6fa2c92988bce0f5d498cac733039ee338c40fc Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 13:43:40 +0100 Subject: [PATCH 059/100] trash untrash workspaces --- .../osparc/dashboard/ResourceBrowserBase.js | 2 + .../dashboard/ResourceContainerManager.js | 4 + .../class/osparc/dashboard/StudyBrowser.js | 16 +++- .../osparc/dashboard/WorkspaceButtonItem.js | 77 ++++++++++++++----- .../source/class/osparc/store/Workspaces.js | 31 ++++++++ 5 files changed, 106 insertions(+), 24 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index e515a1eef12..c2852c49780 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -290,6 +290,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { this._changeContext(context, workspaceId, folderId); }, this); resourcesContainer.addListener("workspaceUpdated", e => this._workspaceUpdated(e.getData())); + resourcesContainer.addListener("trashWorkspaceRequested", e => this._trashWorkspaceRequested(e.getData())); + resourcesContainer.addListener("untrashWorkspaceRequested", e => this._untrashWorkspaceRequested(e.getData())); resourcesContainer.addListener("deleteWorkspaceRequested", e => this._deleteWorkspaceRequested(e.getData())); this._addToLayout(resourcesContainer); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 659b264b1bc..8414b79b670 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -80,6 +80,8 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { "deleteFolderRequested": "qx.event.type.Data", "workspaceSelected": "qx.event.type.Data", "workspaceUpdated": "qx.event.type.Data", + "trashWorkspaceRequested": "qx.event.type.Data", + "untrashWorkspaceRequested": "qx.event.type.Data", "deleteWorkspaceRequested": "qx.event.type.Data", "changeContext": "qx.event.type.Data", }, @@ -385,6 +387,8 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { [ "workspaceSelected", "workspaceUpdated", + "trashWorkspaceRequested", + "untrashWorkspaceRequested", "deleteWorkspaceRequested", ].forEach(eName => card.addListener(eName, e => this.fireDataEvent(eName, e.getData()))); return card; diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 924a30f07c8..8f807398ab2 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -455,11 +455,21 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__reloadWorkspaceCards(); }, + _trashWorkspaceRequested: function(workspaceId) { + osparc.store.Workspaces.getInstance().trashWorkspace(workspaceId) + .then(() => this.__reloadWorkspaces()) + .catch(err => console.error(err)); + }, + + _untrashWorkspaceRequested: function(workspace) { + osparc.store.Workspaces.getInstance().untrashWorkspace(workspace) + .then(() => this.__reloadWorkspaces()) + .catch(err => console.error(err)); + }, + _deleteWorkspaceRequested: function(workspaceId) { osparc.store.Workspaces.getInstance().deleteWorkspace(workspaceId) - .then(() => { - this.__reloadWorkspaces(); - }) + .then(() => this.__reloadWorkspaces()) .catch(err => { console.error(err); osparc.FlashMessenger.logAs(err.message, "ERROR"); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js index 187be3598e2..ff4e4592dc6 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js @@ -45,7 +45,9 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { events: { "workspaceSelected": "qx.event.type.Data", "workspaceUpdated": "qx.event.type.Data", - "deleteWorkspaceRequested": "qx.event.type.Data" + "trashWorkspaceRequested": "qx.event.type.Data", + "untrashWorkspaceRequested": "qx.event.type.Data", + "deleteWorkspaceRequested": "qx.event.type.Data", }, properties: { @@ -183,31 +185,46 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { position: "bottom-right" }); - const editButton = new qx.ui.menu.Button(this.tr("Edit..."), "@FontAwesome5Solid/pencil-alt/12"); - editButton.addListener("execute", () => { - const workspace = this.getWorkspace(); - const workspaceEditor = new osparc.editor.WorkspaceEditor(workspace); - const title = this.tr("Edit Workspace"); - const win = osparc.ui.window.Window.popUpInWindow(workspaceEditor, title, 300, 150); - workspaceEditor.addListener("workspaceUpdated", () => { - win.close(); - this.fireDataEvent("workspaceUpdated", workspace.getWorkspaceId()); + const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); + if ( + studyBrowserContext === "search" || + studyBrowserContext === "workspaces" + ) { + const editButton = new qx.ui.menu.Button(this.tr("Edit..."), "@FontAwesome5Solid/pencil-alt/12"); + editButton.addListener("execute", () => { + const workspace = this.getWorkspace(); + const workspaceEditor = new osparc.editor.WorkspaceEditor(workspace); + const title = this.tr("Edit Workspace"); + const win = osparc.ui.window.Window.popUpInWindow(workspaceEditor, title, 300, 150); + workspaceEditor.addListener("workspaceUpdated", () => { + win.close(); + this.fireDataEvent("workspaceUpdated", workspace.getWorkspaceId()); + }); + workspaceEditor.addListener("cancel", () => win.close()); }); - workspaceEditor.addListener("cancel", () => win.close()); - }); - menu.add(editButton); + menu.add(editButton); + + const shareButton = new qx.ui.menu.Button(this.tr("Share..."), "@FontAwesome5Solid/share-alt/12"); + shareButton.addListener("execute", () => this.__openShareWith(), this); + menu.add(shareButton); - const shareButton = new qx.ui.menu.Button(this.tr("Share..."), "@FontAwesome5Solid/share-alt/12"); - shareButton.addListener("execute", () => this.__openShareWith(), this); - menu.add(shareButton); + menu.addSeparator(); - menu.addSeparator(); + const trashButton = new qx.ui.menu.Button(this.tr("Trash"), "@FontAwesome5Solid/trash/12"); + trashButton.addListener("execute", () => this.__trashWorkspaceRequested(), this); + menu.add(trashButton); + } else if (studyBrowserContext === "trash") { + const restoreButton = new qx.ui.menu.Button(this.tr("Restore"), "@MaterialIcons/restore_from_trash/16"); + restoreButton.addListener("execute", () => this.fireDataEvent("untrashWorkspaceRequested", this.getWorkspace()), this); + menu.add(restoreButton); - const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); - osparc.utils.Utils.setIdToWidget(deleteButton, "deleteWorkspaceMenuItem"); - deleteButton.addListener("execute", () => this.__deleteWorkspaceRequested(), this); - menu.add(deleteButton); + menu.addSeparator(); + const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); + osparc.utils.Utils.setIdToWidget(deleteButton, "deleteWorkspaceMenuItem"); + deleteButton.addListener("execute", () => this.__deleteWorkspaceRequested(), this); + menu.add(deleteButton); + } menuButton.setMenu(menu); } }, @@ -250,6 +267,24 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { permissionsView.addListener("updateAccessRights", () => this.__applyAccessRights(this.getWorkspace().getAccessRights()), this); }, + __trashWorkspaceRequested: function() { + const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); + let msg = this.tr("Are you sure you want to move the Workspace and all its content to the trash?"); + msg += "

" + this.tr("It will be permanently deleted after ") + trashDays + " days."; + const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Move to Trash"), + confirmText: this.tr("Move to Trash"), + confirmAction: "delete" + }); + confirmationWin.center(); + confirmationWin.open(); + confirmationWin.addListener("close", () => { + if (confirmationWin.getConfirmed()) { + this.fireDataEvent("trashWorkspaceRequested", this.getWorkspaceId()); + } + }, this); + }, + __deleteWorkspaceRequested: function() { let msg = this.tr("Are you sure you want to delete") + " " + this.getTitle() + "?"; msg += "
" + this.tr("All the content of the workspace will be deleted."); diff --git a/services/static-webserver/client/source/class/osparc/store/Workspaces.js b/services/static-webserver/client/source/class/osparc/store/Workspaces.js index a9bcb1c6d43..d614ee7bbc2 100644 --- a/services/static-webserver/client/source/class/osparc/store/Workspaces.js +++ b/services/static-webserver/client/source/class/osparc/store/Workspaces.js @@ -140,6 +140,37 @@ qx.Class.define("osparc.store.Workspaces", { }); }, + trashWorkspace: function(workspaceId) { + const params = { + "url": { + workspaceId + } + }; + return osparc.data.Resources.getInstance().fetch("workspaces", "trash", params) + .then(() => { + const workspace = this.getWorkspace(workspaceId); + if (workspace) { + this.__deleteFromCache(workspaceId); + this.fireDataEvent("workspaceRemoved", workspace); + } + }) + .catch(console.error); + }, + + untrashWorkspace: function(workspace) { + const params = { + "url": { + workspaceId: workspace.getWorkspaceId(), + } + }; + return osparc.data.Resources.getInstance().fetch("workspaces", "untrash", params) + .then(() => { + this.workspacesCached.unshift(workspace); + this.fireDataEvent("workspaceAdded", workspace); + }) + .catch(console.error); + }, + deleteWorkspace: function(workspaceId) { const params = { "url": { From 3767ba908b81221e8cb2a14b7478ae8526fe4d7f Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 13:45:52 +0100 Subject: [PATCH 060/100] [skip ci] add resources --- .../client/source/class/osparc/data/Resources.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index 2af997f689a..9ead30b5e43 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -386,6 +386,14 @@ qx.Class.define("osparc.data.Resources", { method: "DELETE", url: statics.API + "/workspaces/{workspaceId}" }, + trash: { + method: "POST", + url: statics.API + "/workspaces/{workspacesId}:trash" + }, + untrash: { + method: "POST", + url: statics.API + "/workspaces/{workspacesId}:untrash" + }, postAccessRights: { method: "POST", url: statics.API + "/workspaces/{workspaceId}/groups/{groupId}" From b6c6950ca6ebb2e6278e9637f46b018e4b4c05c9 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 13:56:43 +0100 Subject: [PATCH 061/100] [skip ci] handle cache --- .../source/class/osparc/data/Resources.js | 4 +-- .../source/class/osparc/store/Workspaces.js | 27 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index 9ead30b5e43..2f5340ab31a 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -388,11 +388,11 @@ qx.Class.define("osparc.data.Resources", { }, trash: { method: "POST", - url: statics.API + "/workspaces/{workspacesId}:trash" + url: statics.API + "/workspaces/{workspaceId}:trash" }, untrash: { method: "POST", - url: statics.API + "/workspaces/{workspacesId}:untrash" + url: statics.API + "/workspaces/{workspaceId}:untrash" }, postAccessRights: { method: "POST", diff --git a/services/static-webserver/client/source/class/osparc/store/Workspaces.js b/services/static-webserver/client/source/class/osparc/store/Workspaces.js index d614ee7bbc2..2a10fd70c81 100644 --- a/services/static-webserver/client/source/class/osparc/store/Workspaces.js +++ b/services/static-webserver/client/source/class/osparc/store/Workspaces.js @@ -70,8 +70,7 @@ qx.Class.define("osparc.store.Workspaces", { return osparc.data.Resources.getInstance().getAllPages("workspaces") .then(workspacesData => { workspacesData.forEach(workspaceData => { - const workspace = new osparc.data.model.Workspace(workspaceData); - this.__addToCache(workspace); + this.__addToCache(workspaceData); }); return this.workspacesCached; }); @@ -133,8 +132,7 @@ qx.Class.define("osparc.store.Workspaces", { }; return osparc.data.Resources.getInstance().fetch("workspaces", "post", params) .then(workspaceData => { - const newWorkspace = new osparc.data.model.Workspace(workspaceData); - this.__addToCache(newWorkspace); + const newWorkspace = this.__addToCache(workspaceData); this.fireDataEvent("workspaceAdded", newWorkspace); return newWorkspace; }); @@ -291,9 +289,24 @@ qx.Class.define("osparc.store.Workspaces", { return this.workspacesCached; }, - __addToCache: function(workspace) { - const found = this.workspacesCached.find(w => w.getWorkspaceId() === workspace.getWorkspaceId()); - if (!found) { + __addToCache: function(workspaceData) { + let workspace = this.workspacesCached.find(w => w.getWorkspaceId() === workspaceData["workspaceId"]); + if (workspace) { + const props = Object.keys(qx.util.PropertyUtil.getProperties(osparc.data.model.Workspace)); + // put + Object.keys(workspaceData).forEach(key => { + if (key === "createdAt") { + workspace.set("createdAt", new Date(workspaceData["createdAt"])); + } else if (key === "modifiedAt") { + workspace.set("lastModified", new Date(workspaceData["modifiedAt"])); + } else if (key === "trashedAt") { + workspace.set("trashedAt", new Date(workspaceData["trashedAt"])); + } else if (props.includes(key)) { + workspace.set(key, workspaceData[key]); + } + }); + } else { + workspace = new osparc.data.model.Workspace(workspaceData); this.workspacesCached.unshift(workspace); } }, From 3dcb204a4bc8decca90270fe6e30935ecd75a591 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 14:00:26 +0100 Subject: [PATCH 062/100] trashedBy property --- .../client/source/class/osparc/data/model/Workspace.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/data/model/Workspace.js b/services/static-webserver/client/source/class/osparc/data/model/Workspace.js index 6fca15ce04b..65592fb1789 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Workspace.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Workspace.js @@ -38,6 +38,7 @@ qx.Class.define("osparc.data.model.Workspace", { createdAt: new Date(workspaceData.createdAt), modifiedAt: new Date(workspaceData.modifiedAt), trashedAt: workspaceData.trashedAt ? new Date(workspaceData.trashedAt) : null, + trashedBy: workspaceData.trashedBy, }); }, @@ -103,6 +104,12 @@ qx.Class.define("osparc.data.model.Workspace", { nullable: true, init: null, }, + + trashedBy: { + check: "Number", + nullable: true, + init: null, + }, }, statics: { From 95296abab8b6783fa352c1e23767388f4e6621d4 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 14:06:40 +0100 Subject: [PATCH 063/100] [skip ci] trash/untrash workspaces working --- .../client/source/class/osparc/store/Workspaces.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/store/Workspaces.js b/services/static-webserver/client/source/class/osparc/store/Workspaces.js index 2a10fd70c81..13b70556dd0 100644 --- a/services/static-webserver/client/source/class/osparc/store/Workspaces.js +++ b/services/static-webserver/client/source/class/osparc/store/Workspaces.js @@ -298,7 +298,7 @@ qx.Class.define("osparc.store.Workspaces", { if (key === "createdAt") { workspace.set("createdAt", new Date(workspaceData["createdAt"])); } else if (key === "modifiedAt") { - workspace.set("lastModified", new Date(workspaceData["modifiedAt"])); + workspace.set("modifiedAt", new Date(workspaceData["modifiedAt"])); } else if (key === "trashedAt") { workspace.set("trashedAt", new Date(workspaceData["trashedAt"])); } else if (props.includes(key)) { @@ -309,6 +309,7 @@ qx.Class.define("osparc.store.Workspaces", { workspace = new osparc.data.model.Workspace(workspaceData); this.workspacesCached.unshift(workspace); } + return workspace; }, __deleteFromCache: function(workspaceId) { From 53dd3fac5b366502c042629539109b272aeafb5d Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 14:22:23 +0100 Subject: [PATCH 064/100] expose cleanAll --- .../class/osparc/dashboard/ResourceContainerManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 8414b79b670..dfb28f328e3 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -263,7 +263,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this.__resourcesList = resourcesList; }, - __cleanAll: function() { + cleanAll: function() { if (this.__workspacesContainer) { this.__workspacesContainer.removeAll(); } @@ -302,7 +302,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, __rebuildLayout: function(resourceType) { - this.__cleanAll(); + this.cleanAll(); if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { this.__addFoldersContainer(); } @@ -365,7 +365,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, reloadWorkspaces: function() { - this.__cleanAll(); + this.cleanAll(); this._add(this.__workspacesContainer); let workspacesCards = []; this.__workspacesList.forEach(workspaceData => workspacesCards.push(this.__workspaceToCard(workspaceData))); From 110c022eb1c4a7cc1e3263c5ecec9e967d6a48c8 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 14:37:52 +0100 Subject: [PATCH 065/100] minor --- .../source/class/osparc/dashboard/ResourceContainerManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index dfb28f328e3..4273dc012da 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -27,8 +27,8 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { paddingBottom: 60 }); - this.__foldersList = []; this.__workspacesList = []; + this.__foldersList = []; this.__resourcesList = []; this.__groupedContainersList = []; From ef9c40d9aebe1c5f98f2e2bee5915f4c9a9ee6f3 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 15:40:33 +0100 Subject: [PATCH 066/100] minor --- .../source/class/osparc/dashboard/StudyBrowser.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 8f807398ab2..3fab2f23f9b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -198,7 +198,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__setWorkspacesToList(workspaces); }) .catch(console.error) - .finally(() => this.__loadingWorkspaces = null); + .finally(() => { + this.__addNewWorkspaceButton(); + this.__loadingWorkspaces = null; + }); }, __reloadFolders: function() { @@ -237,7 +240,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__setFoldersToList(folders); }) .catch(console.error) - .finally(() => this.__loadingFolders = null); + .finally(() => { + this.__addNewFolderButton(); + this.__loadingFolders = null; + }); }, __reloadStudies: function() { @@ -425,8 +431,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __reloadWorkspaceCards: function() { this._resourcesContainer.setWorkspacesToList(this.__workspacesList); this._resourcesContainer.reloadWorkspaces(); - - this.__addNewWorkspaceButton(); }, __addNewWorkspaceButton: function() { @@ -481,8 +485,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __reloadFolderCards: function() { this._resourcesContainer.setFoldersToList(this.__foldersList); this._resourcesContainer.reloadFolders(); - - this.__addNewFolderButton(); }, __addNewFolderButton: function() { From b03779c2168d18fa96b38d4ca3142939c2b40a18 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 15:50:45 +0100 Subject: [PATCH 067/100] minor --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 3fab2f23f9b..6afcc4dd9a2 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -168,7 +168,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { !osparc.auth.Manager.getInstance().isLoggedIn() || !osparc.utils.DisabledPlugins.isFoldersEnabled() || this.getCurrentContext() === "studiesAndFolders" || - this.getCurrentContext() === "search" || // not yet implemented + this.getCurrentContext() === "search" || // not yet implemented for workspaces this.__loadingWorkspaces ) { return; From 1e2313f88042867f6e30c8ba91c0247d3d6878a4 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 16:50:12 +0100 Subject: [PATCH 068/100] [skip ci] undo --- .../class/osparc/dashboard/ResourceContainerManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 4273dc012da..57a9f2c3d39 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -263,7 +263,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this.__resourcesList = resourcesList; }, - cleanAll: function() { + __cleanAll: function() { if (this.__workspacesContainer) { this.__workspacesContainer.removeAll(); } @@ -302,7 +302,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, __rebuildLayout: function(resourceType) { - this.cleanAll(); + this.__cleanAll(); if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { this.__addFoldersContainer(); } @@ -365,7 +365,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, reloadWorkspaces: function() { - this.cleanAll(); + this.__cleanAll(); this._add(this.__workspacesContainer); let workspacesCards = []; this.__workspacesList.forEach(workspaceData => workspacesCards.push(this.__workspaceToCard(workspaceData))); From 1853e944ea19b4c3302bc254912581cc63951868 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 17:02:36 +0100 Subject: [PATCH 069/100] reset lists --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 3d0232b365d..b443638c3c9 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1078,9 +1078,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { currentWorkspaceId: workspaceId, currentFolderId: folderId, }); - this._loadingResourcesBtn.setFetching(false); this.resetSelection(); this.setMultiSelection(false); + + // reset lists + this.__setWorkspacesToList([]); + this.__setFoldersToList([]); + this._loadingResourcesBtn.setFetching(false); this.invalidateStudies(); this._resourcesContainer.setResourcesToList([]); From 6014609f920ecc03024a1ad6fad4b8a57262464e Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 17:02:51 +0100 Subject: [PATCH 070/100] minor --- .../osparc/dashboard/ResourceContainerManager.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 57a9f2c3d39..b48a84e189a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -34,9 +34,9 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { const workspacesContainer = this.__workspacesContainer = new osparc.dashboard.ToggleButtonContainer(); + this._add(workspacesContainer); workspacesContainer.setVisibility(osparc.utils.DisabledPlugins.isFoldersEnabled() ? "visible" : "excluded"); - const foldersContainer = this.__foldersContainer = new osparc.dashboard.ToggleButtonContainer(); this._add(foldersContainer); foldersContainer.setVisibility(osparc.utils.DisabledPlugins.isFoldersEnabled() ? "visible" : "excluded"); @@ -264,9 +264,13 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, __cleanAll: function() { - if (this.__workspacesContainer) { - this.__workspacesContainer.removeAll(); + if (this._getChildren().includes(this.__nonGroupedContainer)) { + this._remove(this.__nonGroupedContainer); } + if (this._getChildren().includes(this.__groupedContainers)) { + this._remove(this.__groupedContainers); + } + if (this.__nonGroupedContainer) { this.__nonGroupedContainer.removeAll(); this.__nonGroupedContainer = null; @@ -278,7 +282,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { groupedContainer.getContentContainer().removeAll(); }); this.__groupedContainersList = []; - this._removeAll(); }, __addFoldersContainer: function() { @@ -365,8 +368,9 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, reloadWorkspaces: function() { - this.__cleanAll(); - this._add(this.__workspacesContainer); + if (this.__workspacesContainer) { + this.__workspacesContainer.removeAll(); + } let workspacesCards = []; this.__workspacesList.forEach(workspaceData => workspacesCards.push(this.__workspaceToCard(workspaceData))); return workspacesCards; From b58b6fed5c3631569bd6693d44286aa1028fa021 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 17:06:14 +0100 Subject: [PATCH 071/100] Folders are not removed anymore --- .../source/class/osparc/dashboard/ResourceContainerManager.js | 3 --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 3 --- 2 files changed, 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index b48a84e189a..b5bfb91fe15 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -306,9 +306,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { __rebuildLayout: function(resourceType) { this.__cleanAll(); - if (osparc.utils.DisabledPlugins.isFoldersEnabled()) { - this.__addFoldersContainer(); - } if (this.getGroupBy()) { const noGroupContainer = this.__createGroupContainer("no-group", "No Group", "transparent"); this.__groupedContainers.add(noGroupContainer); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index b443638c3c9..7bc90b8df47 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -403,9 +403,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const cards = this._resourcesContainer.reloadCards("studies"); this.__configureStudyCards(cards); - // they were removed in the above reloadCards - this.__reloadFolders(); - this.__addNewStudyButtons(); const loadMoreBtn = this.__createLoadMoreButton(); From ef460139dd4a42511546fe66f104e05394e3af08 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 17:15:58 +0100 Subject: [PATCH 072/100] fixes --- .../osparc/dashboard/ResourceBrowserBase.js | 10 ++++++++-- .../dashboard/ResourceContainerManager.js | 19 ++++++++++--------- .../class/osparc/dashboard/ServiceBrowser.js | 6 +----- .../class/osparc/dashboard/StudyBrowser.js | 7 +------ .../class/osparc/dashboard/TemplateBrowser.js | 6 +----- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index c2852c49780..c007ca05f7e 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -244,7 +244,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { this._addToLayout(searchBarFilter); }, - _createResourcesLayout: function() { + _createResourcesLayout: function(flatListId) { const toolbar = this._toolbar = new qx.ui.toolbar.ToolBar().set({ backgroundColor: "transparent", spacing: 10, @@ -255,7 +255,13 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { this.__viewModeLayout = new qx.ui.toolbar.Part(); - const resourcesContainer = this._resourcesContainer = new osparc.dashboard.ResourceContainerManager(); + const resourcesContainer = this._resourcesContainer = new osparc.dashboard.ResourceContainerManager(this._resourceType); + if (flatListId) { + const list = this._resourcesContainer.getFlatList(); + if (list) { + osparc.utils.Utils.setIdToWidget(list, flatListId); + } + } if (this._resourceType === "study") { const viewMode = osparc.utils.Utils.localCache.getLocalStorageItem("studiesViewMode"); if (viewMode) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index b5bfb91fe15..2f5837a88ae 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -18,7 +18,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { extend: qx.ui.core.Widget, - construct: function() { + construct: function(resourceType) { this.base(arguments); this._setLayout(new qx.ui.layout.VBox(15)); @@ -32,14 +32,15 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this.__resourcesList = []; this.__groupedContainersList = []; + if (resourceType === "study") { + const workspacesContainer = this.__workspacesContainer = new osparc.dashboard.ToggleButtonContainer(); + this._add(workspacesContainer); + workspacesContainer.setVisibility(osparc.utils.DisabledPlugins.isFoldersEnabled() ? "visible" : "excluded"); - const workspacesContainer = this.__workspacesContainer = new osparc.dashboard.ToggleButtonContainer(); - this._add(workspacesContainer); - workspacesContainer.setVisibility(osparc.utils.DisabledPlugins.isFoldersEnabled() ? "visible" : "excluded"); - - const foldersContainer = this.__foldersContainer = new osparc.dashboard.ToggleButtonContainer(); - this._add(foldersContainer); - foldersContainer.setVisibility(osparc.utils.DisabledPlugins.isFoldersEnabled() ? "visible" : "excluded"); + const foldersContainer = this.__foldersContainer = new osparc.dashboard.ToggleButtonContainer(); + this._add(foldersContainer); + foldersContainer.setVisibility(osparc.utils.DisabledPlugins.isFoldersEnabled() ? "visible" : "excluded"); + } const nonGroupedContainer = this.__nonGroupedContainer = this.__createFlatList(); this._add(nonGroupedContainer); @@ -503,7 +504,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { } }) .finally(() => { - this._add(groupContainer); + this.__groupedContainers.add(groupContainer); this.__moveNoGroupToLast(); }); } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js index 15278743e54..5fbaa4ebaf7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js @@ -129,11 +129,7 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", { // LAYOUT // _createLayout: function() { this._createSearchBar(); - this._createResourcesLayout(); - const list = this._resourcesContainer.getFlatList(); - if (list) { - osparc.utils.Utils.setIdToWidget(list, "servicesList"); - } + this._createResourcesLayout("servicesList"); this.__addNewServiceButtons(); this._toolbar.add(new qx.ui.core.Spacer(), { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 7bc90b8df47..300991f47c2 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -943,12 +943,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._addToLayout(header); } - this._createResourcesLayout(); - - const list = this._resourcesContainer.getFlatList(); - if (list) { - osparc.utils.Utils.setIdToWidget(list, "studiesList"); - } + this._createResourcesLayout("studiesList"); const importStudyButton = this.__createImportButton(); const isDisabled = osparc.utils.DisabledPlugins.isImportDisabled(); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index 3ff37cd8412..0b6fc8ccd26 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -246,11 +246,7 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { // LAYOUT // _createLayout: function() { this._createSearchBar(); - this._createResourcesLayout(); - const list = this._resourcesContainer.getFlatList(); - if (list) { - osparc.utils.Utils.setIdToWidget(list, "templatesList"); - } + this._createResourcesLayout("templatesList"); const updateAllButton = this.__createUpdateAllButton(); if (updateAllButton) { From c54115fa7d25a174ff02cd1d1fa04249fefa75b8 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 17:18:50 +0100 Subject: [PATCH 073/100] minor --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 300991f47c2..2f8eedcb3e1 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1088,7 +1088,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__reloadStudies(); break; case "workspaces": - this._toolbar.hide(); + this._toolbar.exclude(); this._searchBarFilter.resetFilters(); this.__reloadWorkspaces(); break; From 019619a2d7876557f95d0bb99ab727c28f6ec5ed Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 17:37:54 +0100 Subject: [PATCH 074/100] both ways --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 2f8eedcb3e1..426c5030d0d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -706,6 +706,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // loose equality: will do a Number to String conversion if necessary sameContext &= key in reqParams && reqParams[key] == value; }); + // both ways + Object.entries(reqParams).forEach(([key, value]) => { + // loose equality: will do a Number to String conversion if necessary + sameContext &= key in currentParams && currentParams[key] == value; + }); return !sameContext; }, From 8444b831298099218d9fc34e2c6858f842c5b7e5 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 25 Nov 2024 18:00:58 +0100 Subject: [PATCH 075/100] minor --- .../source/class/osparc/dashboard/StudyBrowser.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 426c5030d0d..67b46c5164b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -453,7 +453,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _workspaceUpdated: function() { - this.__reloadWorkspaceCards(); + this.__reloadWorkspaces(); }, _trashWorkspaceRequested: function(workspaceId) { @@ -1081,15 +1081,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // reset lists this.__setWorkspacesToList([]); this.__setFoldersToList([]); - this._loadingResourcesBtn.setFetching(false); - this.invalidateStudies(); - this._resourcesContainer.setResourcesToList([]); + this._resourcesList = []; + this._resourcesContainer.setResourcesToList(this._resourcesList); + this._resourcesContainer.reloadCards("studies"); this._toolbar.show(); switch (this.getCurrentContext()) { case "studiesAndFolders": this._searchBarFilter.resetFilters(); this.__reloadFolders(); + this._loadingResourcesBtn.setFetching(false); + this.invalidateStudies(); this.__reloadStudies(); break; case "workspaces": @@ -1100,12 +1102,16 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { case "search": this.__reloadWorkspaces(); this.__reloadFolders(); + this._loadingResourcesBtn.setFetching(false); + this.invalidateStudies(); this.__reloadStudies(); break; case "trash": this._searchBarFilter.resetFilters(); this.__reloadWorkspaces(); this.__reloadFolders(); + this._loadingResourcesBtn.setFetching(false); + this.invalidateStudies(); this.__reloadStudies(); break; } From 0b26a7a389547bc3b42269eea1f73061fb54b8d8 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 10:11:37 +0100 Subject: [PATCH 076/100] createConfirmRemoveForMeWindow --- .../class/osparc/dashboard/StudyBrowser.js | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 67b46c5164b..df50f64d7b6 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1521,10 +1521,18 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } } + const myGid = osparc.auth.Data.getInstance().getGroupId(); + const collabGids = Object.keys(studyData["accessRights"]); + const amICollaborator = collabGids.indexOf(myGid) > -1; if (deleteAccess) { - const trashButton = this.__getTrashStudyMenuButton(studyData, false); menu.addSeparator(); + const trashButton = this.__getTrashStudyMenuButton(studyData, false); menu.add(trashButton); + } else if (amICollaborator) { + // if I'm a collaborator, let me remove myself from the study. In that case it would be a Delete for me + menu.addSeparator(); + const deleteButton = this.__getDeleteStudyMenuButton(studyData, false); + menu.add(deleteButton); } card.evaluateMenuButtons(); @@ -1730,6 +1738,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __deleteStudyRequested: function(studyData) { + // OM here const preferencesSettings = osparc.Preferences.getInstance(); if (preferencesSettings.getConfirmDeleteStudy()) { const win = this.__createConfirmDeleteWindow([studyData.name]); @@ -1962,6 +1971,20 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { .finally(() => this.resetSelection()); }, + __deleteCollaborator: function(studyData) { + const myGid = osparc.auth.Data.getInstance().getGroupId(); + const collabGids = Object.keys(studyData["accessRights"]); + const amICollaborator = collabGids.indexOf(myGid) > -1; + + if (collabGids.length > 1 && amICollaborator) { + const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]); + // remove collaborator + delete arCopy[myGid]; + // OM here + operationPromise = osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy); + } + }, + __trashStudies: function(studiesData) { studiesData.forEach(studyData => this.__trashStudy(studyData)); }, @@ -2009,6 +2032,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return confirmationWin; }, + __createConfirmRemoveForMeWindow: function(studyName) { + const msg = `'${studyName} ` + this.tr("will be removed from your list. Collaborators will still have access."); + const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ + caption: this.tr("Remove"), + confirmText: this.tr("Remove"), + confirmAction: "delete" + }); + osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteStudyBtn"); + return confirmationWin; + }, + __createConfirmDeleteWindow: function(studyNames) { let msg = this.tr("Are you sure you want to delete"); const studyAlias = osparc.product.Utils.getStudyAlias({plural: studyNames.length > 1}); From f57884eb5913d7c68a90ae4f902de88aa3f4cfb6 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 12:51:59 +0100 Subject: [PATCH 077/100] renaming --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index df50f64d7b6..5ce87d1062e 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -961,10 +961,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const studiesMoveButton = this.__createMoveStudiesButton(); this._toolbar.add(studiesMoveButton); - const studiesTrashButton = this.__createTrashButton(); + const studiesTrashButton = this.__createTrashStudiesButton(); this._toolbar.add(studiesTrashButton); - const studiesDeleteButton = this.__createDeleteButton(); + const studiesDeleteButton = this.__createDeleteStudiesButton(); this._toolbar.add(studiesDeleteButton); this._toolbar.add(new qx.ui.core.Spacer(), { @@ -1233,7 +1233,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return moveStudiesButton; }, - __createTrashButton: function() { + __createTrashStudiesButton: function() { const trashButton = new qx.ui.form.Button(this.tr("Trash"), "@FontAwesome5Solid/trash/14").set({ appearance: "danger-button", visibility: "excluded" @@ -1258,7 +1258,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return trashButton; }, - __createDeleteButton: function() { + __createDeleteStudiesButton: function() { const deleteButton = new qx.ui.form.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/14").set({ appearance: "danger-button", visibility: "excluded" From 5e6ebca78aa91589a033c431ffaff73078fdaf26 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 13:00:55 +0100 Subject: [PATCH 078/100] __removeMeFromCollaborators --- .../source/class/osparc/dashboard/StudyBrowser.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 5ce87d1062e..bb6098ef832 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1971,18 +1971,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { .finally(() => this.resetSelection()); }, - __deleteCollaborator: function(studyData) { + __removeMeFromCollaborators: function(studyData) { const myGid = osparc.auth.Data.getInstance().getGroupId(); const collabGids = Object.keys(studyData["accessRights"]); const amICollaborator = collabGids.indexOf(myGid) > -1; - if (collabGids.length > 1 && amICollaborator) { const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]); // remove collaborator delete arCopy[myGid]; - // OM here - operationPromise = osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy); + return osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy); } + return null; }, __trashStudies: function(studiesData) { @@ -1996,10 +1995,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { let operationPromise = null; if (collabGids.length > 1 && amICollaborator) { - const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]); - // remove collaborator - delete arCopy[myGid]; - operationPromise = osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy); + operationPromise = this.__removeMeFromCollaborators(studyData); + if (operationPromise === null) { + return; + } } else { // delete study operationPromise = osparc.store.Store.getInstance().deleteStudy(studyData.uuid); From 035ceb7b6f572364dac8e2ba1547519f19839390 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 13:06:18 +0100 Subject: [PATCH 079/100] [skip ci] refactor --- .../class/osparc/dashboard/StudyBrowser.js | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index bb6098ef832..8b013874b32 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1738,10 +1738,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __deleteStudyRequested: function(studyData) { - // OM here const preferencesSettings = osparc.Preferences.getInstance(); if (preferencesSettings.getConfirmDeleteStudy()) { - const win = this.__createConfirmDeleteWindow([studyData.name]); + const win = false ? this.__createConfirmRemoveForMeWindow(studyData.name) : this.__createConfirmDeleteWindow([studyData.name]); win.center(); win.open(); win.addListener("close", () => { @@ -1971,34 +1970,29 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { .finally(() => this.resetSelection()); }, - __removeMeFromCollaborators: function(studyData) { - const myGid = osparc.auth.Data.getInstance().getGroupId(); - const collabGids = Object.keys(studyData["accessRights"]); - const amICollaborator = collabGids.indexOf(myGid) > -1; - if (collabGids.length > 1 && amICollaborator) { - const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]); - // remove collaborator - delete arCopy[myGid]; - return osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy); - } - return null; - }, - __trashStudies: function(studiesData) { studiesData.forEach(studyData => this.__trashStudy(studyData)); }, - __doDeleteStudy: function(studyData) { + __deleteOrRemoveMe: function(studyData) { const myGid = osparc.auth.Data.getInstance().getGroupId(); const collabGids = Object.keys(studyData["accessRights"]); const amICollaborator = collabGids.indexOf(myGid) > -1; + return (collabGids.length > 1 && amICollaborator) ? "remove" : "delete"; + }, + __removeMeFromCollaborators: function(studyData) { + const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]); + // remove me from collaborators + const myGid = osparc.auth.Data.getInstance().getGroupId(); + delete arCopy[myGid]; + return osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy); + }, + + __doDeleteStudy: function(studyData) { let operationPromise = null; - if (collabGids.length > 1 && amICollaborator) { + if (this.__deleteOrRemoveMe(studyData) === "remove") { operationPromise = this.__removeMeFromCollaborators(studyData); - if (operationPromise === null) { - return; - } } else { // delete study operationPromise = osparc.store.Store.getInstance().deleteStudy(studyData.uuid); From b536c87939b2de9ddf9107d5dbb5db7726c1889e Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 13:13:58 +0100 Subject: [PATCH 080/100] workflow ready --- .../source/class/osparc/dashboard/StudyBrowser.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 8b013874b32..6fb27bdd20f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1521,14 +1521,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } } - const myGid = osparc.auth.Data.getInstance().getGroupId(); - const collabGids = Object.keys(studyData["accessRights"]); - const amICollaborator = collabGids.indexOf(myGid) > -1; if (deleteAccess) { menu.addSeparator(); const trashButton = this.__getTrashStudyMenuButton(studyData, false); menu.add(trashButton); - } else if (amICollaborator) { + } else if (this.__deleteOrRemoveMe(studyData) === "remove") { // if I'm a collaborator, let me remove myself from the study. In that case it would be a Delete for me menu.addSeparator(); const deleteButton = this.__getDeleteStudyMenuButton(studyData, false); @@ -1740,7 +1737,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __deleteStudyRequested: function(studyData) { const preferencesSettings = osparc.Preferences.getInstance(); if (preferencesSettings.getConfirmDeleteStudy()) { - const win = false ? this.__createConfirmRemoveForMeWindow(studyData.name) : this.__createConfirmDeleteWindow([studyData.name]); + const win = this.__deleteOrRemoveMe(studyData) === "remove" ? this.__createConfirmRemoveForMeWindow(studyData.name) : this.__createConfirmDeleteWindow([studyData.name]); win.center(); win.open(); win.addListener("close", () => { @@ -1975,10 +1972,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __deleteOrRemoveMe: function(studyData) { + const deleteAccess = osparc.data.model.Study.canIDelete(studyData["accessRights"]); const myGid = osparc.auth.Data.getInstance().getGroupId(); const collabGids = Object.keys(studyData["accessRights"]); const amICollaborator = collabGids.indexOf(myGid) > -1; - return (collabGids.length > 1 && amICollaborator) ? "remove" : "delete"; + return (!deleteAccess && collabGids.length > 1 && amICollaborator) ? "remove" : "delete"; }, __removeMeFromCollaborators: function(studyData) { From c7cfbfea529334cb822de4bf34481c35d6c3f633 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 13:31:33 +0100 Subject: [PATCH 081/100] show messages --- .../class/osparc/dashboard/StudyBrowser.js | 72 ++++++++++++------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 6fb27bdd20f..9ea2bb9de42 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -458,14 +458,28 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { _trashWorkspaceRequested: function(workspaceId) { osparc.store.Workspaces.getInstance().trashWorkspace(workspaceId) - .then(() => this.__reloadWorkspaces()) - .catch(err => console.error(err)); + .then(() => { + this.__reloadWorkspaces(); + const msg = this.tr("Successfully moved to Trash"); + osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + }) + .catch(err => { + console.error(err); + osparc.FlashMessenger.getInstance().logAs(err, "ERROR"); + }); }, _untrashWorkspaceRequested: function(workspace) { osparc.store.Workspaces.getInstance().untrashWorkspace(workspace) - .then(() => this.__reloadWorkspaces()) - .catch(err => console.error(err)); + .then(() => { + this.__reloadWorkspaces(); + const msg = this.tr("Successfully restored"); + osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + }) + .catch(err => { + console.error(err); + osparc.FlashMessenger.getInstance().logAs(err, "ERROR"); + }); }, _deleteWorkspaceRequested: function(workspaceId) { @@ -606,14 +620,28 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { _trashFolderRequested: function(folderId) { osparc.store.Folders.getInstance().trashFolder(folderId, this.getCurrentWorkspaceId()) - .then(() => this.__reloadFolders()) - .catch(err => console.error(err)); + .then(() => { + this.__reloadFolders(); + const msg = this.tr("Successfully moved to Trash"); + osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + }) + .catch(err => { + console.error(err); + osparc.FlashMessenger.getInstance().logAs(err, "ERROR"); + }) }, _untrashFolderRequested: function(folder) { osparc.store.Folders.getInstance().untrashFolder(folder) - .then(() => this.__reloadFolders()) - .catch(err => console.error(err)); + .then(() => { + this.__reloadFolders(); + const msg = this.tr("Successfully restored"); + osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + }) + .catch(err => { + console.error(err); + osparc.FlashMessenger.getInstance().logAs(err, "ERROR"); + }) }, _deleteFolderRequested: function(folderId) { @@ -1935,7 +1963,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __untrashStudy: function(studyData) { osparc.store.Store.getInstance().untrashStudy(studyData.uuid) - .then(() => this.__removeFromStudyList(studyData.uuid)) + .then(() => { + this.__removeFromStudyList(studyData.uuid); + const msg = this.tr("Successfully restored"); + osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + }) .catch(err => { console.error(err); osparc.FlashMessenger.getInstance().logAs(err, "ERROR"); @@ -1944,22 +1976,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __trashStudy: function(studyData) { - const myGid = osparc.auth.Data.getInstance().getGroupId(); - const collabGids = Object.keys(studyData["accessRights"]); - const amICollaborator = collabGids.indexOf(myGid) > -1; - - let operationPromise = null; - if (collabGids.length > 1 && amICollaborator) { - const arCopy = osparc.utils.Utils.deepCloneObject(studyData["accessRights"]); - // remove collaborator - delete arCopy[myGid]; - operationPromise = osparc.info.StudyUtils.patchStudyData(studyData, "accessRights", arCopy); - } else { - // trash study - operationPromise = osparc.store.Store.getInstance().trashStudy(studyData.uuid); - } - operationPromise - .then(() => this.__removeFromStudyList(studyData.uuid)) + osparc.store.Store.getInstance().trashStudy(studyData.uuid) + .then(() => { + this.__removeFromStudyList(studyData.uuid); + const msg = this.tr("Successfully moved to Trash"); + osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + }) .catch(err => { console.error(err); osparc.FlashMessenger.getInstance().logAs(err, "ERROR"); From bbce5c5602dbff8167f0fede98ff06877e639108 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 13:36:15 +0100 Subject: [PATCH 082/100] [skip ci] wording --- .../source/class/osparc/dashboard/StudyBrowser.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 9ea2bb9de42..25292a5dcde 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -2031,9 +2031,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __createConfirmTrashWindow: function(studyNames) { - let msg = this.tr("Are you sure you want to move to the trash"); - const studiesText = osparc.product.Utils.getStudyAlias({plural: true}); - msg += (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText}?` : ` ${studyNames[0]}?`); + let msg = this.tr("Are you sure you want to move"); + if (studyNames.length > 1) { + const studiesText = osparc.product.Utils.getStudyAlias({plural: true}); + msg += ` ${studyNames.length} ${studiesText} ` + } else { + msg += ` '${studyNames[0]}' `; + } + msg += this.tr("to the Trash?"); const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); msg += "

" + (studyNames.length > 1 ? "They" : "It") + this.tr(` will be permanently deleted after ${trashDays} days.`); const confirmationWin = new osparc.ui.window.Confirmation(msg).set({ From 3ee4c3fedac98e6b2da2972611a82e67787da8a7 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 14:36:11 +0100 Subject: [PATCH 083/100] trashed items are not selectable --- .../client/source/class/osparc/dashboard/CardBase.js | 8 ++++++++ .../source/class/osparc/dashboard/FolderButtonItem.js | 4 +++- .../source/class/osparc/dashboard/GridButtonItem.js | 3 +-- .../source/class/osparc/dashboard/ListButtonItem.js | 3 +-- .../client/source/class/osparc/dashboard/StudyBrowser.js | 2 +- .../source/class/osparc/dashboard/WorkspaceButtonItem.js | 4 +++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index 347718f56ea..3bcd200c2ee 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -395,6 +395,14 @@ qx.Class.define("osparc.dashboard.CardBase", { return this.getResourceType() === resourceType; }, + isItemNotClickable: function() { + const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); + return ( + this.getBlocked() === true || // It could be blocked by IN_USE or UNKNOWN_SERVICE + (this.isResourceType("study") && (studyBrowserContext === "trash")) // It could a trashed study + ); + }, + __applyResourceData: function(resourceData) { let uuid = null; let owner = null; diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index 96fcdb6e4eb..ac919b73579 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -241,7 +241,9 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { }, __itemSelected: function(newVal) { - if (newVal) { + const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); + // do not allow selecting workspace + if (studyBrowserContext !== "trash" && newVal) { this.fireDataEvent("folderSelected", this.getFolderId()); } this.setValue(false); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js index 828a0c74ba7..e9019262342 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js @@ -188,8 +188,7 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { }, __itemSelected: function() { - // It could be blocked by IN_USE or UNKNOWN_SERVICE - if (this.getBlocked() === true) { + if (this.isItemNotClickable()) { this.setValue(false); return; } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js index 71f59b970df..9c433550185 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js @@ -274,8 +274,7 @@ qx.Class.define("osparc.dashboard.ListButtonItem", { }, __itemSelected: function() { - // It could be blocked by IN_USE or UNKNOWN_SERVICE - if (this.getBlocked() === true) { + if (this.isItemNotClickable()) { this.setValue(false); return; } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 25292a5dcde..cc98a7961c2 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -655,7 +655,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { cards.forEach(card => { card.setMultiSelectionMode(this.getMultiSelection()); card.addListener("tap", e => { - if (card.getBlocked() === true) { + if (card.isItemNotClickable()) { card.setValue(false); } else { this.__itemClicked(card, e.getNativeEvent().shiftKey); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js index ff4e4592dc6..eb777ca5dd7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js @@ -254,7 +254,9 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { }, __itemSelected: function(newVal) { - if (newVal) { + const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); + // do not allow selecting workspace + if (studyBrowserContext !== "trash" && newVal) { this.fireDataEvent("workspaceSelected", this.getWorkspaceId()); } this.setValue(false); From 6c3bcaf7b6562c7857e6c50af6c9f11642ce9701 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 14:46:35 +0100 Subject: [PATCH 084/100] minor --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 4 ++-- .../client/source/class/osparc/store/Folders.js | 2 +- .../client/source/class/osparc/store/Workspaces.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index cc98a7961c2..062284abdd3 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -187,7 +187,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { break; } case "trash": - request = osparc.store.Workspaces.getInstance().fetchTrashedWorkspaces(); + request = osparc.store.Workspaces.getInstance().fetchAllTrashedWorkspaces(); break; } @@ -229,7 +229,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { break; } case "trash": - request = osparc.store.Folders.getInstance().fetchTrashedFolders(this.getOrderBy()); + request = osparc.store.Folders.getInstance().fetchAllTrashedFolders(this.getOrderBy()); break; } diff --git a/services/static-webserver/client/source/class/osparc/store/Folders.js b/services/static-webserver/client/source/class/osparc/store/Folders.js index 236d35f2562..4206cb212dd 100644 --- a/services/static-webserver/client/source/class/osparc/store/Folders.js +++ b/services/static-webserver/client/source/class/osparc/store/Folders.js @@ -78,7 +78,7 @@ qx.Class.define("osparc.store.Folders", { }); }, - fetchTrashedFolders: function(orderBy = { + fetchAllTrashedFolders: function(orderBy = { field: "modified_at", direction: "desc" }) { diff --git a/services/static-webserver/client/source/class/osparc/store/Workspaces.js b/services/static-webserver/client/source/class/osparc/store/Workspaces.js index 13b70556dd0..924312639de 100644 --- a/services/static-webserver/client/source/class/osparc/store/Workspaces.js +++ b/services/static-webserver/client/source/class/osparc/store/Workspaces.js @@ -76,7 +76,7 @@ qx.Class.define("osparc.store.Workspaces", { }); }, - fetchTrashedWorkspaces: function(orderBy = { + fetchAllTrashedWorkspaces: function(orderBy = { field: "modified_at", direction: "desc" }) { From 608aba3d35ce7bbd79a0a7a64b2c832a14003b14 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 14:50:07 +0100 Subject: [PATCH 085/100] setTrashedNElements --- .../client/source/class/osparc/dashboard/ResourceFilter.js | 6 ++++++ .../client/source/class/osparc/dashboard/StudyBrowser.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js index 33a3c53cea0..66d1b520d7b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js @@ -114,6 +114,12 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { }); return trashButton; }, + + setTrashedNElements: function(nElements) { + this.__trashButton.set({ + textColor: nElements ? "danger-red" : "text" + }); + }, /* /TRASH BIN */ /* SHARED WITH */ diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 062284abdd3..39c781bc815 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -462,6 +462,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__reloadWorkspaces(); const msg = this.tr("Successfully moved to Trash"); osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + this._resourceFilter.setTrashedNElements(1); }) .catch(err => { console.error(err); @@ -624,6 +625,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__reloadFolders(); const msg = this.tr("Successfully moved to Trash"); osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + this._resourceFilter.setTrashedNElements(1); }) .catch(err => { console.error(err); @@ -1981,6 +1983,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__removeFromStudyList(studyData.uuid); const msg = this.tr("Successfully moved to Trash"); osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + this._resourceFilter.setTrashedNElements(1); }) .catch(err => { console.error(err); From 9d19c58fe1ddbe155073bba872ba5668a9e3de50 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 14:58:21 +0100 Subject: [PATCH 086/100] setTrashEmpty --- .../source/class/osparc/dashboard/ResourceFilter.js | 8 ++++++-- .../client/source/class/osparc/dashboard/StudyBrowser.js | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js index 66d1b520d7b..40bce40b8b4 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js @@ -115,9 +115,13 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { return trashButton; }, - setTrashedNElements: function(nElements) { + evaluateTrashEmpty: function() { + + }, + + setTrashEmpty: function(isEmpty) { this.__trashButton.set({ - textColor: nElements ? "danger-red" : "text" + textColor: isEmpty ? "text" : "danger-red" }); }, /* /TRASH BIN */ diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 39c781bc815..5d099bb8d19 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -462,7 +462,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__reloadWorkspaces(); const msg = this.tr("Successfully moved to Trash"); osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); - this._resourceFilter.setTrashedNElements(1); + this._resourceFilter.setTrashEmpty(false); }) .catch(err => { console.error(err); @@ -625,7 +625,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__reloadFolders(); const msg = this.tr("Successfully moved to Trash"); osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); - this._resourceFilter.setTrashedNElements(1); + this._resourceFilter.setTrashEmpty(false); }) .catch(err => { console.error(err); @@ -1983,7 +1983,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__removeFromStudyList(studyData.uuid); const msg = this.tr("Successfully moved to Trash"); osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); - this._resourceFilter.setTrashedNElements(1); + this._resourceFilter.setTrashEmpty(false); }) .catch(err => { console.error(err); From dc7895e899cc7dbed0d96e2e70f379fd05448408 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 15:10:15 +0100 Subject: [PATCH 087/100] evaluateTrashEmpty --- .../class/osparc/dashboard/ResourceFilter.js | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js index 40bce40b8b4..dcda538841c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js @@ -112,11 +112,53 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { this.fireEvent("trashContext"); } }); + this.evaluateTrashEmpty(); return trashButton; }, evaluateTrashEmpty: function() { - + const studiesParams = { + url: { + offset: 0, + limit: 1, // just one + orderBy: JSON.stringify({ + field: "last_change_date", + direction: "desc" + }), + } + }; + const foldersParams = { + url: { + offset: 0, + limit: 1, // just one + orderBy: JSON.stringify({ + field: "modified_at", + direction: "desc" + }), + } + }; + const workspacesParams = { + url: { + offset: 0, + limit: 1, // just one + orderBy: JSON.stringify({ + field: "modified_at", + direction: "desc" + }), + } + }; + Promise.all([ + osparc.data.Resources.fetch("studies", "getPageTrashed", studiesParams), + osparc.data.Resources.fetch("folders", "getPageTrashed", foldersParams), + osparc.data.Resources.fetch("workspaces", "getPageTrashed", workspacesParams), + ]) + .then(values => { + const nTrashedStudies = values[0].length; + const nTrashedFolders = values[1].length; + const nTrashedWorkspaces = values[2].length; + this.setTrashEmpty((nTrashedStudies+nTrashedFolders+nTrashedWorkspaces) === 0); + }) + .catch(err => console.error(err)); }, setTrashEmpty: function(isEmpty) { From a8e3517d144f15c42b683ece8786bb74d1817935 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 26 Nov 2024 15:13:13 +0100 Subject: [PATCH 088/100] evaluate after restore --- .../client/source/class/osparc/dashboard/StudyBrowser.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 5d099bb8d19..c003dab2197 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -476,6 +476,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__reloadWorkspaces(); const msg = this.tr("Successfully restored"); osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + this._resourceFilter.evaluateTrashEmpty(); }) .catch(err => { console.error(err); @@ -639,6 +640,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__reloadFolders(); const msg = this.tr("Successfully restored"); osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + this._resourceFilter.evaluateTrashEmpty(); }) .catch(err => { console.error(err); @@ -1969,6 +1971,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__removeFromStudyList(studyData.uuid); const msg = this.tr("Successfully restored"); osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + this._resourceFilter.evaluateTrashEmpty(); }) .catch(err => { console.error(err); From 35e6feae44520fca7c8c812b12b072bb4c63d2d8 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 27 Nov 2024 10:18:50 +0100 Subject: [PATCH 089/100] minor --- .../client/source/class/osparc/data/model/IframeHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/data/model/IframeHandler.js b/services/static-webserver/client/source/class/osparc/data/model/IframeHandler.js index fa037642af4..583b31f979e 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/IframeHandler.js +++ b/services/static-webserver/client/source/class/osparc/data/model/IframeHandler.js @@ -300,7 +300,7 @@ qx.Class.define("osparc.data.model.IframeHandler", { if (response.status < 400) { this.__serviceReadyIn(srvUrl); } else { - console.log(`Connecting: ${srvUrl} is not reachable. Status: ${response.status}`); + console.error(`Connecting: ${srvUrl} is not reachable. Status: ${response.status}`); retry(); } }) From 9b9d47d62fe4965e7f6c4a171551ead699f3351d Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 27 Nov 2024 10:43:08 +0100 Subject: [PATCH 090/100] minor --- .../source/class/osparc/dashboard/StudyBrowserHeader.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index bb740ffe436..ac217b2048a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -16,7 +16,7 @@ ************************************************************************ */ /** - * Widget used for displaying a Workspace information + * Widget used for displaying a Study Browser's context information * */ @@ -77,7 +77,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { nullable: false, init: {}, event: "changeAccessRights", - apply: "__applyAccessRights" + apply: "__updateShareInfo" }, myAccessRights: { @@ -203,6 +203,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { control = new qx.ui.form.Button(this.tr("Empty Trash"), "@FontAwesome5Solid/trash/14").set({ appearance: "danger-button", allowGrowY: false, + alignY: "middle", }); control.addListener("execute", () => this.fireEvent("emptyTrashRequested")); this._addAt(control, this.self().POS.EMPTY_TRASH_BUTTON); @@ -333,7 +334,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { return shareIcon; }, - __applyAccessRights: function(accessRights) { + __updateShareInfo: function(accessRights) { const shareIcon = this.__getShareIcon(); const shareText = this.getChildControl("share-text"); if (accessRights && Object.keys(accessRights).length) { @@ -396,7 +397,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { const win = osparc.ui.window.Window.popUpInWindow(permissionsView, title, 500, 400); permissionsView.addListener("updateAccessRights", () => { win.close(); - this.__applyAccessRights(workspace.getAccessRights()); + this.__updateShareInfo(workspace.getAccessRights()); }, this); }, } From be63dd79b63f1beaa879297d20fcc539ebbcc2a1 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 27 Nov 2024 10:46:51 +0100 Subject: [PATCH 091/100] switch --- .../osparc/dashboard/StudyBrowserHeader.js | 76 ++++++++++--------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index ac217b2048a..022f9bef256 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -237,41 +237,47 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { description.resetValue(); this.getChildControl("empty-trash-button").exclude(); - const currentContext = this.getCurrentContext(); - if (currentContext === "search") { - this.__setIcon("@FontAwesome5Solid/search/24"); - title.set({ - value: this.tr("Search results"), - }); - } else if (currentContext === "trash") { - this.__setIcon("@FontAwesome5Solid/trash/20"); - const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); - title.set({ - value: this.tr("Trash:"), - cursor: "auto", - }); - description.set({ - value: this.tr(`Items in the bin will be permanently deleted after ${trashDays} days.`) - }); - } else if (currentContext === "workspaces") { - this.__setIcon(osparc.store.Workspaces.iconPath(32)); - title.set({ - value: this.tr("Shared Workspaces"), - }) - } else if (currentContext === "studiesAndFolders") { - const workspaceId = this.getCurrentWorkspaceId(); - title.setCursor("pointer"); - title.addListener("tap", this.__titleTapped, this); - const workspace = osparc.store.Workspaces.getInstance().getWorkspace(workspaceId); - if (workspace) { - const thumbnail = workspace.getThumbnail(); - this.__setIcon(thumbnail ? thumbnail : osparc.store.Workspaces.iconPath(32)); - workspace.bind("name", title, "value"); - workspace.bind("accessRights", this, "accessRights"); - workspace.bind("myAccessRights", this, "myAccessRights"); - } else { - this.__setIcon("@FontAwesome5Solid/home/30"); - title.setValue(this.tr("My Workspace")); + switch (this.getCurrentContext()) { + case "studiesAndFolders": { + const workspaceId = this.getCurrentWorkspaceId(); + title.setCursor("pointer"); + title.addListener("tap", this.__titleTapped, this); + const workspace = osparc.store.Workspaces.getInstance().getWorkspace(workspaceId); + if (workspace) { + const thumbnail = workspace.getThumbnail(); + this.__setIcon(thumbnail ? thumbnail : osparc.store.Workspaces.iconPath(32)); + workspace.bind("name", title, "value"); + workspace.bind("accessRights", this, "accessRights"); + workspace.bind("myAccessRights", this, "myAccessRights"); + } else { + this.__setIcon("@FontAwesome5Solid/home/30"); + title.setValue(this.tr("My Workspace")); + } + break; + } + case "workspaces": + this.__setIcon(osparc.store.Workspaces.iconPath(32)); + title.set({ + value: this.tr("Shared Workspaces"), + }); + break; + case "search": + this.__setIcon("@FontAwesome5Solid/search/24"); + title.set({ + value: this.tr("Search results"), + }); + break; + case "trash": { + this.__setIcon("@FontAwesome5Solid/trash/20"); + const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); + title.set({ + value: this.tr("Trash:"), + cursor: "auto", + }); + description.set({ + value: this.tr(`Items in the bin will be permanently deleted after ${trashDays} days.`) + }); + break; } } }, From e3f6ffc3361fb91e3a24681d6aa840b8b7be80f1 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 27 Nov 2024 10:52:53 +0100 Subject: [PATCH 092/100] [skip ci] StudyBrowserContext --- .../class/osparc/dashboard/ContextBreadcrumbs.js | 13 ++++--------- .../class/osparc/dashboard/StudyBrowserHeader.js | 1 - 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js b/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js index c84e6cf8a51..4358bc68848 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js @@ -24,6 +24,8 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { this._setLayout(new qx.ui.layout.HBox(5).set({ alignY: "middle" })); + + osparc.store.Store.getInstance().addListener("changeStudyBrowserContext", () => this.__rebuild(), this); }, events: { @@ -31,14 +33,6 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { }, properties: { - currentContext: { - check: ["studiesAndFolders", "workspaces", "search", "trash"], - nullable: false, - init: "studiesAndFolders", - event: "changeCurrentContext", - apply: "__rebuild" - }, - currentWorkspaceId: { check: "Number", nullable: true, @@ -60,7 +54,8 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { __rebuild: function() { this._removeAll(); - if (this.getCurrentContext() !== "studiesAndFolders") { + const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext(); + if (currentContext !== "studiesAndFolders") { return; } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 022f9bef256..45e71358588 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -130,7 +130,6 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { control = new osparc.dashboard.ContextBreadcrumbs(); this.bind("currentWorkspaceId", control, "currentWorkspaceId"); this.bind("currentFolderId", control, "currentFolderId"); - this.bind("currentContext", control, "currentContext"); control.bind("currentWorkspaceId", this, "currentWorkspaceId"); control.bind("currentFolderId", this, "currentFolderId"); control.addListener("locationChanged", e => { From 06095a23a1880feaea01b053868049185c739e2f Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 27 Nov 2024 10:56:17 +0100 Subject: [PATCH 093/100] [skip ci] browserContext --- .../source/class/osparc/dashboard/StudyBrowser.js | 1 - .../class/osparc/dashboard/StudyBrowserHeader.js | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index c003dab2197..463ad78adde 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -1151,7 +1151,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // notify header const header = this.__header; header.set({ - currentContext: context, currentWorkspaceId: workspaceId, currentFolderId: folderId, }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 45e71358588..6d42bdc56dd 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -39,6 +39,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { this.initCurrentWorkspaceId(); this.initCurrentFolderId(); + + osparc.store.Store.getInstance().addListener("changeStudyBrowserContext", () => this.__buildLayout(), this); }, events: { @@ -49,14 +51,6 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }, properties: { - currentContext: { - check: ["studiesAndFolders", "workspaces", "search", "trash"], - nullable: false, - init: "studiesAndFolders", - event: "changeCurrentContext", - apply: "__buildLayout" - }, - currentWorkspaceId: { check: "Number", nullable: true, @@ -236,7 +230,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { description.resetValue(); this.getChildControl("empty-trash-button").exclude(); - switch (this.getCurrentContext()) { + const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext(); + switch (currentContext) { case "studiesAndFolders": { const workspaceId = this.getCurrentWorkspaceId(); title.setCursor("pointer"); From ab8f63f3798040de2fc4157b900e01aefd6d0a6c Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Wed, 27 Nov 2024 12:42:06 +0100 Subject: [PATCH 094/100] clean up the header --- .../osparc/dashboard/StudyBrowserHeader.js | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 6d42bdc56dd..31ea4eadebc 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -218,24 +218,18 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }, __buildLayout: function() { + this._removeAll(); + this.getChildControl("icon"); const title = this.getChildControl("title"); - title.resetCursor(); - title.removeListener("tap", this.__titleTapped, this); - this.getChildControl("breadcrumbs"); - this.getChildControl("edit-button").exclude(); - this.resetAccessRights(); - this.resetMyAccessRights(); - const description = this.getChildControl("description"); - description.resetValue(); - this.getChildControl("empty-trash-button").exclude(); - const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext(); switch (currentContext) { case "studiesAndFolders": { const workspaceId = this.getCurrentWorkspaceId(); title.setCursor("pointer"); title.addListener("tap", this.__titleTapped, this); + this.getChildControl("breadcrumbs"); + this.getChildControl("edit-button").exclude(); const workspace = osparc.store.Workspaces.getInstance().getWorkspace(workspaceId); if (workspace) { const thumbnail = workspace.getThumbnail(); @@ -263,14 +257,14 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { break; case "trash": { this.__setIcon("@FontAwesome5Solid/trash/20"); - const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); title.set({ - value: this.tr("Trash:"), - cursor: "auto", + value: this.tr("Trash") }); - description.set({ + const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); + this.getChildControl("description").set({ value: this.tr(`Items in the bin will be permanently deleted after ${trashDays} days.`) }); + this.getChildControl("empty-trash-button").exclude(); break; } } From 277af25d2aa4ceef9070ecf5863a85799e43d34d Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 27 Nov 2024 16:44:30 +0100 Subject: [PATCH 095/100] empty trash button --- .../source/class/osparc/dashboard/StudyBrowser.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 463ad78adde..f44827b5a15 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -196,6 +196,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { request .then(workspaces => { this.__setWorkspacesToList(workspaces); + if (this.getCurrentContext() === "trash") { + if (workspaces.length) { + this.__header.getChildControl("empty-trash-button").show(); + } + } }) .catch(console.error) .finally(() => { @@ -238,6 +243,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { request .then(folders => { this.__setFoldersToList(folders); + if (this.getCurrentContext() === "trash") { + if (folders.length) { + this.__header.getChildControl("empty-trash-button").show(); + } + } }) .catch(console.error) .finally(() => { @@ -302,7 +312,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } if (this.getCurrentContext() === "trash") { - this.__header.getChildControl("empty-trash-button").setVisibility(this._resourcesList.length ? "visible" : "excluded"); + if (this._resourcesList.length) { + this.__header.getChildControl("empty-trash-button").show(); + } } // Show Quick Start if there are no studies in the root folder of the personal workspace From 6642bcf7725ca973a3f9021557f34e069f08c7e0 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Wed, 27 Nov 2024 16:49:58 +0100 Subject: [PATCH 096/100] minor --- .../osparc/dashboard/StudyBrowserHeader.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 31ea4eadebc..58debb8868f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -98,6 +98,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }, members: { + __spacers: null, + _createChildControlImpl: function(id) { let control; switch (id) { @@ -220,6 +222,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { __buildLayout: function() { this._removeAll(); + this.__spacers = []; + this.getChildControl("icon"); const title = this.getChildControl("title"); const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext(); @@ -245,25 +249,20 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { } case "workspaces": this.__setIcon(osparc.store.Workspaces.iconPath(32)); - title.set({ - value: this.tr("Shared Workspaces"), - }); + title.setValue(this.tr("Shared Workspaces")); break; case "search": this.__setIcon("@FontAwesome5Solid/search/24"); - title.set({ - value: this.tr("Search results"), - }); + title.setValue(this.tr("Search results")); break; case "trash": { this.__setIcon("@FontAwesome5Solid/trash/20"); - title.set({ - value: this.tr("Trash") - }); + title.setValue(this.tr("Trash")); const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); this.getChildControl("description").set({ value: this.tr(`Items in the bin will be permanently deleted after ${trashDays} days.`) }); + // the study browser will take care of making it visible this.getChildControl("empty-trash-button").exclude(); break; } From f777ea5d632080549e334a5a9e35c77c588dc902 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 29 Nov 2024 10:40:36 +0100 Subject: [PATCH 097/100] minor --- .../source/class/osparc/dashboard/StudyBrowserHeader.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index 58debb8868f..cb40cb1fcff 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -278,21 +278,16 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { this._add(spacer); }, - __resetIcon: function() { + __setIcon: function(source) { + // reset icon first const icon = this.getChildControl("icon"); const image = icon.getChildControl("image"); image.resetSource(); icon.getContentElement().setStyles({ "background-image": "none" }); - }, - __setIcon: function(source) { - this.__resetIcon(); - - const icon = this.getChildControl("icon"); if (source.includes("@")) { - const image = icon.getChildControl("image"); image.set({ source }); From 8f14374178771dc23121560fd42c8560ac48d065 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 29 Nov 2024 11:29:13 +0100 Subject: [PATCH 098/100] minor --- .../source/class/osparc/dashboard/StudyBrowser.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index f44827b5a15..c7ef8f916f2 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -498,7 +498,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { _deleteWorkspaceRequested: function(workspaceId) { osparc.store.Workspaces.getInstance().deleteWorkspace(workspaceId) - .then(() => this.__reloadWorkspaces()) + .then(() => { + this.__reloadWorkspaces(); + const msg = this.tr("Successfully deleted"); + osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + this._resourceFilter.evaluateTrashEmpty(); + }) .catch(err => { console.error(err); osparc.FlashMessenger.logAs(err.message, "ERROR"); @@ -662,7 +667,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { _deleteFolderRequested: function(folderId) { osparc.store.Folders.getInstance().deleteFolder(folderId, this.getCurrentWorkspaceId()) - .then(() => this.__reloadFolders()) + .then(() => { + this.__reloadFolders(); + const msg = this.tr("Successfully deleted"); + osparc.FlashMessenger.getInstance().logAs(msg, "INFO"); + this._resourceFilter.evaluateTrashEmpty(); + }) .catch(err => console.error(err)); }, // /FOLDERS From c1e0513f2904ef1e8e473dc4997663e158115f94 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 29 Nov 2024 11:30:01 +0100 Subject: [PATCH 099/100] [skip ci] no spacers --- .../osparc/dashboard/StudyBrowserHeader.js | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index cb40cb1fcff..b3d79afc887 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -35,8 +35,6 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { alignY: "middle", }); - this.__spacers = []; - this.initCurrentWorkspaceId(); this.initCurrentFolderId(); @@ -98,8 +96,6 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }, members: { - __spacers: null, - _createChildControlImpl: function(id) { let control; switch (id) { @@ -151,8 +147,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { this._addAt(control, this.self().POS.EDIT_BUTTON); break; case "share-layout": - this.__addSpacer(); control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({ + maringLeft: 10, alignY: "middle" })); this._addAt(control, this.self().POS.SHARE_LAYOUT); @@ -166,8 +162,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { break; } case "role-layout": - this.__addSpacer(); control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({ + maringLeft: 10, alignY: "middle" })); this._addAt(control, this.self().POS.ROLE_LAYOUT); @@ -269,15 +265,6 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { } }, - __addSpacer: function() { - const spacer = new qx.ui.basic.Label("-").set({ - font: "text-16", - alignY: "middle", - }); - this.__spacers.push(spacer); - this._add(spacer); - }, - __setIcon: function(source) { // reset icon first const icon = this.getChildControl("icon"); @@ -302,10 +289,6 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { } }, - __showSpacers: function(show) { - this.__spacers.forEach(spacer => spacer.setVisibility(show ? "visible" : "excluded")); - }, - __getShareIcon: function() { // reset previous const layout = this.getChildControl("share-layout"); @@ -330,11 +313,9 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { shareText.setValue(Object.keys(accessRights).length + " members"); shareIcon.show(); shareText.show(); - this.__showSpacers(true); } else { shareIcon.exclude(); shareText.exclude(); - this.__showSpacers(false); } }, @@ -358,12 +339,10 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { roleText.setValue(osparc.data.Roles.WORKSPACE[val].label); roleText.show(); roleIcon.show(); - this.__showSpacers(true); } else { editButton.exclude(); roleText.exclude(); roleIcon.exclude(); - this.__showSpacers(false); } }, From cd8d8f206db7eea14f7ce810f242291ec87aed51 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 29 Nov 2024 12:24:01 +0100 Subject: [PATCH 100/100] last fixes --- .../osparc/dashboard/StudyBrowserHeader.js | 57 +++++++++++++------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js index b3d79afc887..cb2e130cfcf 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -148,9 +148,10 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { break; case "share-layout": control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({ - maringLeft: 10, - alignY: "middle" - })); + alignY: "middle", + })).set({ + marginLeft: 10, + }); this._addAt(control, this.self().POS.SHARE_LAYOUT); break; case "share-text": { @@ -163,9 +164,10 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { } case "role-layout": control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({ - maringLeft: 10, - alignY: "middle" - })); + alignY: "middle", + })).set({ + marginLeft: 10, + }); this._addAt(control, this.self().POS.ROLE_LAYOUT); break; case "role-text": { @@ -216,25 +218,45 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }, __buildLayout: function() { - this._removeAll(); - - this.__spacers = []; - this.getChildControl("icon"); const title = this.getChildControl("title"); + + const locationBreadcrumbs = this.getChildControl("breadcrumbs").set({ + visibility: "excluded" + }); + const editWorkspace = this.getChildControl("edit-button").set({ + visibility: "excluded" + }); + const shareWorkspaceLayout = this.getChildControl("share-layout").set({ + visibility: "excluded" + }); + const roleWorkspaceLayout = this.getChildControl("role-layout").set({ + visibility: "excluded" + }); + + const description = this.getChildControl("description").set({ + visibility: "excluded" + }); + // the study browser will take care of making it visible + this.getChildControl("empty-trash-button").set({ + visibility: "excluded" + }); + const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext(); switch (currentContext) { case "studiesAndFolders": { const workspaceId = this.getCurrentWorkspaceId(); title.setCursor("pointer"); title.addListener("tap", this.__titleTapped, this); - this.getChildControl("breadcrumbs"); - this.getChildControl("edit-button").exclude(); + locationBreadcrumbs.show(); const workspace = osparc.store.Workspaces.getInstance().getWorkspace(workspaceId); if (workspace) { const thumbnail = workspace.getThumbnail(); this.__setIcon(thumbnail ? thumbnail : osparc.store.Workspaces.iconPath(32)); workspace.bind("name", title, "value"); + editWorkspace.show(); + shareWorkspaceLayout.show(); + roleWorkspaceLayout.show(); workspace.bind("accessRights", this, "accessRights"); workspace.bind("myAccessRights", this, "myAccessRights"); } else { @@ -255,11 +277,10 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { this.__setIcon("@FontAwesome5Solid/trash/20"); title.setValue(this.tr("Trash")); const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); - this.getChildControl("description").set({ - value: this.tr(`Items in the bin will be permanently deleted after ${trashDays} days.`) + description.set({ + value: this.tr(`Items in the bin will be permanently deleted after ${trashDays} days.`), + visibility: "visible", }); - // the study browser will take care of making it visible - this.getChildControl("empty-trash-button").exclude(); break; } } @@ -323,7 +344,8 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { const editButton = this.getChildControl("edit-button"); const roleText = this.getChildControl("role-text"); const roleIcon = this.getChildControl("role-icon"); - if (value && Object.keys(value).length) { + const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext(); + if (currentContext === "studiesAndFolders" && value && Object.keys(value).length) { editButton.setVisibility(value["delete"] ? "visible" : "excluded"); const menu = new qx.ui.menu.Menu().set({ position: "bottom-right" @@ -355,6 +377,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { win.close(); this.__buildLayout(); }, this); + workspaceEditor.addListener("cancel", () => win.close()); }, __openShareWith: function() {