diff --git a/services/static-webserver/client/source/class/osparc/dashboard/AppBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/AppBrowser.js index e2ed9fc5314..0cebb0bc42c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/AppBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/AppBrowser.js @@ -129,8 +129,6 @@ qx.Class.define("osparc.dashboard.AppBrowser", { this._populateCardMenu(card); }); osparc.filter.UIFilterController.dispatch("searchBarFilter"); - - this._resourcesContainer.evaluateNoResourcesFoundLabel(cards, this._resourceType); }, __itemClicked: function(card) { 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 6f335b73b3d..5573d4900ae 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -508,7 +508,7 @@ qx.Class.define("osparc.dashboard.CardBase", { 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 + (this.isResourceType("study") && (studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.TRASH)) // It could a trashed study ); }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js b/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js index 047b047e8f7..281b16bfb4b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js @@ -105,7 +105,11 @@ qx.Class.define("osparc.dashboard.CardContainer", { }, areMoreResourcesRequired: function(loadingResourcesBtn) { - if (this.nextRequest !== null && loadingResourcesBtn && osparc.utils.Utils.isWidgetOnScreen(loadingResourcesBtn)) { + if ( + this.nextRequest !== null && + loadingResourcesBtn && + osparc.utils.Utils.isWidgetOnScreen(loadingResourcesBtn) + ) { return true; } return false; 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 4358bc68848..60155dedd0a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js @@ -55,18 +55,16 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", { this._removeAll(); const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext(); - if (currentContext !== "studiesAndFolders") { - return; - } - - if (this.getCurrentFolderId()) { - const currentFolder = osparc.store.Folders.getInstance().getFolder(this.getCurrentFolderId()); - this.__createUpstreamButtons(currentFolder); - } + if (currentContext === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS) { + if (this.getCurrentFolderId()) { + const currentFolder = osparc.store.Folders.getInstance().getFolder(this.getCurrentFolderId()); + this.__createUpstreamButtons(currentFolder); + } - const currentFolderButton = this.__createCurrentFolderButton(); - if (currentFolderButton) { - this._add(currentFolderButton); + const currentFolderButton = this.__createCurrentFolderButton(); + if (currentFolderButton) { + this._add(currentFolderButton); + } } }, 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 dfd0b2453a3..48fb0effa96 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -276,19 +276,19 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); if ( - studyBrowserContext === "search" || - studyBrowserContext === "studiesAndFolders" + studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS || + studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS ) { const editButton = new qx.ui.menu.Button(this.tr("Rename..."), "@FontAwesome5Solid/pencil-alt/12"); editButton.addListener("execute", () => this.__editFolder(), this); menu.add(editButton); - if (studyBrowserContext === "search") { + if (studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS) { const openLocationButton = new qx.ui.menu.Button(this.tr("Open location"), "@FontAwesome5Solid/external-link-alt/12"); openLocationButton.addListener("execute", () => { const folder = this.getFolder(); this.fireDataEvent("changeContext", { - context: "studiesAndFolders", + context: osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS, workspaceId: folder.getWorkspaceId(), folderId: folder.getParentFolderId(), }); @@ -306,7 +306,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { const trashButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); trashButton.addListener("execute", () => this.fireDataEvent("trashFolderRequested", this.getFolderId()), this); menu.add(trashButton); - } else if (studyBrowserContext === "trash") { + } else if (studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.TRASH) { 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); @@ -325,7 +325,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { __itemSelected: function() { const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); // do not allow selecting workspace - if (studyBrowserContext !== "trash") { + if (studyBrowserContext !== osparc.dashboard.StudyBrowser.CONTEXT.TRASH) { this.fireDataEvent("folderSelected", this.getFolderId()); } }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserFilter.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserFilter.js index 3df1a134676..cd3b10b1b0c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserFilter.js @@ -35,7 +35,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", { events: { "templatesContext": "qx.event.type.Event", - "publicContext": "qx.event.type.Event", + "publicTemplatesContext": "qx.event.type.Event", "trashContext": "qx.event.type.Event", "changeTab": "qx.event.type.Data", "trashStudyRequested": "qx.event.type.Data", @@ -100,9 +100,9 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", { }); this.__workspacesAndFoldersTree.contextChanged(context); - this.__templatesButton.setValue(context === "templates"); - this.__publicProjectsButton.setValue(context === "public"); - this.__trashButton.setValue(context === "trash"); + this.__templatesButton.setValue(context === osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES); + this.__publicProjectsButton.setValue(context === osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES); + this.__trashButton.setValue(context === osparc.dashboard.StudyBrowser.CONTEXT.TRASH); }, /* WORKSPACES AND FOLDERS */ @@ -158,7 +158,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", { publicProjectsButton.addListener("changeValue", e => { const templatesEnabled = e.getData(); if (templatesEnabled) { - this.fireEvent("publicContext"); + this.fireEvent("publicTemplatesContext"); } }); return publicProjectsButton; 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 09fe9f840a5..ffa57c14175 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -31,6 +31,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this.__foldersList = []; this.__resourcesList = []; this.__groupedContainersList = []; + this.__resourceType = resourceType || "study"; if (resourceType === "study") { const workspacesContainer = this.__workspacesContainer = new osparc.dashboard.CardContainer(); @@ -135,35 +136,57 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { __groupedContainersList: null, __foldersContainer: null, __workspacesContainer: null, - __noResourcesFound: null, __nonGroupedContainer: null, __groupedContainers: null, - - evaluateNoResourcesFoundLabel: function(cards, context) { - if (this.__noResourcesFound) { - let text = null; - switch (context) { - case "studiesAndFolders": - case "search": - text = this.tr("No Projects found"); - break; - case "templates": - text = this.tr("No Templates found"); - break; - case "public": - text = this.tr("No Public Projects found"); - break; - case "template": - text = this.tr("No Tutorials found"); - break; - case "service": - text = this.tr("No Apps found"); - break; + __resourceType: null, + __noResourcesFound: null, + __noResourcesFoundTimer: null, + + __evaluateNoResourcesFoundLabel: function() { + let text = null; + switch (this.__resourceType) { + case "study": { + const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); + switch (studyBrowserContext) { + case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS: + case osparc.dashboard.StudyBrowser.CONTEXT.TRASH: + text = this.tr("No Projects found"); + break; + case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: + text = this.tr("No Templates found"); + break; + case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: + text = this.tr("No Public Projects found"); + break; + } + break; } - this.__noResourcesFound.set({ - value: text, - visibility: text && cards.length === 0 ? "visible" : "excluded", - }); + case "template": + text = this.tr("No Tutorials found"); + break; + case "service": + text = this.tr("No Apps found"); + break; + default: + text = this.tr("No Resources found"); + break; + } + + this.__noResourcesFound.exclude(); + if (this.__noResourcesFoundTimer) { + clearTimeout(this.__noResourcesFoundTimer); + } + if (text && this.__resourcesList.length === 0) { + // delay it a bit to avoid the initial flickering + this.__noResourcesFoundTimer = setTimeout(() => { + this.__noResourcesFound.set({ + value: text, + visibility: "visible", + }); + }, 2000); } }, @@ -307,6 +330,8 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { setResourcesToList: function(resourcesList) { this.__resourcesList = resourcesList; + + this.__evaluateNoResourcesFoundLabel(); }, __cleanAll: function() { 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 163be91a007..d5d0f7ea43c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -47,15 +47,30 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { "publishTemplate": "qx.event.type.Data", }, + statics: { + CONTEXT: { + PROJECTS: "studiesAndFolders", + WORKSPACES: "workspaces", + TEMPLATES: "templates", + PUBLIC_TEMPLATES: "publicTemplates", + TRASH: "trash", + SEARCH_PROJECTS: "searchProjects", + SEARCH_TEMPLATES: "searchTemplates", + SEARCH_PUBLIC_TEMPLATES: "searchPublicTemplates", + } + }, + properties: { currentContext: { check: [ "studiesAndFolders", "workspaces", - "search", "templates", - "public", + "publicTemplates", "trash", + "searchProjects", + "searchTemplates", + "searchPublicTemplates", ], nullable: false, init: "studiesAndFolders", @@ -166,7 +181,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __reloadWorkspaces: function() { if ( !osparc.auth.Manager.getInstance().isLoggedIn() || - ["studiesAndFolders", "templates", "public"].includes(this.getCurrentContext()) || + ![ + osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES, + osparc.dashboard.StudyBrowser.CONTEXT.TRASH, + osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS, + ].includes(this.getCurrentContext()) || this.__loadingWorkspaces ) { return; @@ -174,19 +193,18 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { let request = null; switch (this.getCurrentContext()) { - case "search": { + case osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES: + request = osparc.store.Workspaces.getInstance().fetchWorkspaces(); + break; + case osparc.dashboard.StudyBrowser.CONTEXT.TRASH: + request = osparc.store.Workspaces.getInstance().fetchAllTrashedWorkspaces(); + break; + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS: { const filterData = this._searchBarFilter.getFilterData(); const text = filterData.text ? encodeURIComponent(filterData.text) : ""; request = osparc.store.Workspaces.getInstance().searchWorkspaces(text, this.getOrderBy()); break; } - case "workspaces": { - request = osparc.store.Workspaces.getInstance().fetchWorkspaces(); - break; - } - case "trash": - request = osparc.store.Workspaces.getInstance().fetchAllTrashedWorkspaces(); - break; } this.__loadingWorkspaces = true; @@ -194,7 +212,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { request .then(workspaces => { this.__setWorkspacesToList(workspaces); - if (this.getCurrentContext() === "trash") { + if (this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.TRASH) { if (workspaces.length) { this.__header.getChildControl("empty-trash-button").show(); } @@ -210,7 +228,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __reloadFolders: function() { if ( !osparc.auth.Manager.getInstance().isLoggedIn() || - ["workspaces", "templates", "public"].includes(this.getCurrentContext()) || + ![ + osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS, + osparc.dashboard.StudyBrowser.CONTEXT.TRASH, + osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS, + ].includes(this.getCurrentContext()) || this.__loadingFolders ) { return; @@ -218,21 +240,21 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { let request = null; switch (this.getCurrentContext()) { - case "search": { - const filterData = this._searchBarFilter.getFilterData(); - const text = filterData.text ? encodeURIComponent(filterData.text) : ""; // name, description and uuid - request = osparc.store.Folders.getInstance().searchFolders(text, this.getOrderBy()); - break; - } - case "studiesAndFolders": { + case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS: { const workspaceId = this.getCurrentWorkspaceId(); const folderId = this.getCurrentFolderId(); request = osparc.store.Folders.getInstance().fetchFolders(folderId, workspaceId, this.getOrderBy()); break; } - case "trash": + case osparc.dashboard.StudyBrowser.CONTEXT.TRASH: request = osparc.store.Folders.getInstance().fetchAllTrashedFolders(this.getOrderBy()); break; + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS: { + const filterData = this._searchBarFilter.getFilterData(); + const text = filterData.text ? encodeURIComponent(filterData.text) : ""; // name, description and uuid + request = osparc.store.Folders.getInstance().searchFolders(text, this.getOrderBy()); + break; + } } this.__loadingFolders = true; @@ -240,7 +262,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return request .then(folders => { this.__setFoldersToList(folders); - if (this.getCurrentContext() === "trash") { + if (this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.TRASH) { if (folders.length) { this.__header.getChildControl("empty-trash-button").show(); } @@ -259,7 +281,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __reloadStudies: function() { if ( !osparc.auth.Manager.getInstance().isLoggedIn() || - this.getCurrentContext() === "workspaces" || + this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES || // all but workspaces this._loadingResourcesBtn.isFetching() ) { return; @@ -269,7 +291,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._loadingResourcesBtn.setFetching(true); this._loadingResourcesBtn.setVisibility("visible"); - this._resourcesContainer.evaluateNoResourcesFoundLabel([]); return this.__getNextStudiesRequest() .then(resp => { // Context might have been changed while waiting for the response. @@ -279,31 +300,44 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return; } - if (["templates", "public"].includes(this.getCurrentContext())) { - const templates = resp["data"]; - templates.forEach(template => template["resourceType"] = "template"); - // For now, filtered in the frontend - const groupsStore = osparc.store.Groups.getInstance(); - const everyoneGid = groupsStore.getEveryoneGroup().getGroupId(); - const productEveryoneGid = groupsStore.getEveryoneProductGroup().getGroupId(); - const filteredTemplates = templates.filter(template => { - const publicAccess = everyoneGid in template["accessRights"] || productEveryoneGid in template["accessRights"]; - if (this.getCurrentContext() === "public") { - return publicAccess; - } - return !publicAccess; - }); - this.__addResourcesToList(filteredTemplates); - } else { - const studies = resp["data"]; - studies.forEach(study => study["resourceType"] = "study"); - this.__addResourcesToList(studies); + switch (this.getCurrentContext()) { + case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS: + case osparc.dashboard.StudyBrowser.CONTEXT.TRASH: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS: { + const studies = resp["data"]; + studies.forEach(study => study["resourceType"] = "study"); + this.__addResourcesToList(studies); + break; + } + case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: { + const templates = resp["data"]; + templates.forEach(template => template["resourceType"] = "template"); + // For now, filtered in the frontend + const groupsStore = osparc.store.Groups.getInstance(); + const everyoneGid = groupsStore.getEveryoneGroup().getGroupId(); + const productEveryoneGid = groupsStore.getEveryoneProductGroup().getGroupId(); + const filteredTemplates = templates.filter(template => { + const publicAccess = everyoneGid in template["accessRights"] || productEveryoneGid in template["accessRights"]; + if ([ + osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES, + osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES, + ].includes(this.getCurrentContext())) { + return publicAccess; + } + return !publicAccess; + }); + this.__addResourcesToList(filteredTemplates); + break; + } } if (this._resourcesContainer.getFlatList()) { this._resourcesContainer.getFlatList().nextRequest = resp["_links"]["next"]; } - if (this.getCurrentContext() === "trash") { + if (this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.TRASH) { if (this._resourcesList.length) { this.__header.getChildControl("empty-trash-button").show(); } @@ -319,7 +353,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const nStudies = "_meta" in resp ? resp["_meta"]["total"] : 0; if ( nStudies === 0 && - this.getCurrentContext() === "studiesAndFolders" && + this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS && this.getCurrentWorkspaceId() === null && this.getCurrentFolderId() === null ) { @@ -419,8 +453,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._resourcesContainer.addNonResourceCard(loadMoreBtn); osparc.filter.UIFilterController.dispatch("searchBarFilter"); - - this._resourcesContainer.evaluateNoResourcesFoundLabel(cards, this.getCurrentContext()); }, __reloadNewCards: function() { @@ -429,8 +461,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.__configureStudyCards(cards); osparc.filter.UIFilterController.dispatch("searchBarFilter"); - - this._resourcesContainer.evaluateNoResourcesFoundLabel(cards, this.getCurrentContext()); }, // WORKSPACES @@ -440,7 +470,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __addNewWorkspaceButton: function() { - if (this.getCurrentContext() !== "workspaces") { + if (this.getCurrentContext() !== osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES) { return; } @@ -458,7 +488,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _workspaceSelected: function(workspaceId) { - this._changeContext("studiesAndFolders", workspaceId, null); + this._changeContext(osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS, workspaceId, null); }, _workspaceUpdated: function() { @@ -506,7 +536,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __addNewFolderButton: function() { - if (this.getCurrentContext() !== "studiesAndFolders") { + if (this.getCurrentContext() !== osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS) { return; } const currentWorkspaceId = this.getCurrentWorkspaceId(); @@ -538,7 +568,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _folderSelected: function(folderId) { - this._changeContext("studiesAndFolders", this.getCurrentWorkspaceId(), folderId); + this._changeContext(osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS, this.getCurrentWorkspaceId(), folderId); }, _folderUpdated: function() { @@ -649,7 +679,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { card.addListener("tap", e => this.__studyCardClicked(card, e.getNativeEvent().shiftKey), this); this._populateCardMenu(card); - if (["studiesAndFolders", "search"].includes(this.getCurrentContext())) { + if ([ + osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS, + osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS, + ].includes(this.getCurrentContext())) { this.__attachDragHandlers(card); } }); @@ -765,6 +798,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // loose equality: will do a Number to String conversion if necessary sameContext &= key in currentParams && currentParams[key] == value; }); + + if (!sameContext) { + console.log("not sameContext", currentParams, reqParams); + } + return !sameContext; }, @@ -783,10 +821,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // keep this until the backend implements it switch (this.getCurrentContext()) { - case "templates": + case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: urlParams.accessRights = "non-public"; break; - case "public": + case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: urlParams.accessRights = "public"; break; } @@ -811,33 +851,39 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { requestParams.orderBy = JSON.stringify(this.getOrderBy()); switch (this.getCurrentContext()) { - case "studiesAndFolders": + case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS: + requestParams.type = "user"; requestParams.workspaceId = this.getCurrentWorkspaceId(); requestParams.folderId = this.getCurrentFolderId(); - requestParams.type = "user"; break; - case "templates": + case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: requestParams.type = "template"; requestParams.templateType = osparc.data.model.StudyUI.TEMPLATE_TYPE; requestParams.accessRights = "non-public"; break; - case "public": + case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: requestParams.type = "template"; requestParams.templateType = osparc.data.model.StudyUI.TEMPLATE_TYPE; requestParams.accessRights = "public"; 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(",") : ""; - } + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS: { + requestParams.type = "user"; break; } } + if (this.getCurrentContext().includes("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(",") : ""; + } + } + return requestParams; }, @@ -864,20 +910,24 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { let request = null; switch (this.getCurrentContext()) { - case "studiesAndFolders": + case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS: request = osparc.data.Resources.fetch("studies", "getPage", params, options); break; - case "search": - request = osparc.data.Resources.fetch("studies", "getPageSearch", params, options); + case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: + // The distinction is done in the frontend + request = osparc.store.Templates.fetchTemplatesPaginated(params, options); break; - case "templates": - request = osparc.store.Templates.fetchTemplatesNonPublicPaginated(params, options); + case osparc.dashboard.StudyBrowser.CONTEXT.TRASH: + request = osparc.data.Resources.fetch("studies", "getPageTrashed", params, options); break; - case "public": - request = osparc.store.Templates.fetchTemplatesPublicPaginated(params, options); + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS: + request = osparc.data.Resources.fetch("studies", "getPageSearch", params, options); break; - case "trash": - request = osparc.data.Resources.fetch("studies", "getPageTrashed", params, options); + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: + // The distinction is done in the frontend + request = osparc.store.Templates.searchTemplatesPaginated(params, options); break; } return request; @@ -933,7 +983,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __addNewStudyButtons: function() { - if (this.getCurrentContext() !== "studiesAndFolders") { + if (this.getCurrentContext() !== osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS) { return; } const currentWorkspaceId = this.getCurrentWorkspaceId(); @@ -1059,17 +1109,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const selection = e.getData(); studiesMoveButton.set({ - visibility: selection.length && currentContext === "studiesAndFolders" ? "visible" : "excluded", + visibility: selection.length && currentContext === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS ? "visible" : "excluded", label: this.tr("Move") + (selection.length > 1 ? ` (${selection.length})` : ""), }); studiesTrashButton.set({ - visibility: selection.length && currentContext === "studiesAndFolders" ? "visible" : "excluded", + visibility: selection.length && currentContext === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS ? "visible" : "excluded", label: this.tr("Delete") + (selection.length > 1 ? ` (${selection.length})` : ""), }); studiesDeleteButton.set({ - visibility: selection.length && currentContext === "trash" ? "visible" : "excluded", + visibility: selection.length && currentContext === osparc.dashboard.StudyBrowser.CONTEXT.TRASH ? "visible" : "excluded", label: this.tr("Delete permanently") + (selection.length > 1 ? ` (${selection.length})` : ""), }); }); @@ -1084,7 +1134,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { header.addListener("locationChanged", () => { const workspaceId = header.getCurrentWorkspaceId(); const folderId = header.getCurrentFolderId(); - this._changeContext("studiesAndFolders", workspaceId, folderId); + this._changeContext(osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS, workspaceId, folderId); }, this); const workspacesAndFoldersTree = this._resourceFilter.getWorkspacesAndFoldersTree(); @@ -1092,32 +1142,57 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const context = e.getData(); const workspaceId = context["workspaceId"]; if (workspaceId === -1) { - this._changeContext("workspaces"); + this._changeContext(osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES); } else { const folderId = context["folderId"]; - this._changeContext("studiesAndFolders", workspaceId, folderId); + this._changeContext(osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS, workspaceId, folderId); } }, this); - this._resourceFilter.addListener("templatesContext", () => this._changeContext("templates")); - this._resourceFilter.addListener("publicContext", () => this._changeContext("public")); - this._resourceFilter.addListener("trashContext", () => this._changeContext("trash")); + this._resourceFilter.addListener("templatesContext", () => this._changeContext(osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES)); + this._resourceFilter.addListener("publicTemplatesContext", () => this._changeContext(osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES)); + this._resourceFilter.addListener("trashContext", () => this._changeContext(osparc.dashboard.StudyBrowser.CONTEXT.TRASH)); this._searchBarFilter.addListener("filterChanged", e => { const filterData = e.getData(); if (filterData.text) { - this._changeContext("search"); + let searchContext = null; + switch (this.getCurrentContext()) { + case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: + searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES; + break; + case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: + searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES; + break; + default: + searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS; + break; + } + this._changeContext(searchContext); } else { + let backToContext = osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS; + switch (this.getCurrentContext()) { + case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: + backToContext = osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES; + break; + case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: + backToContext = osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES; + break; + } const workspaceId = this.getCurrentWorkspaceId(); const folderId = this.getCurrentFolderId(); - this._changeContext("studiesAndFolders", workspaceId, folderId); + this._changeContext(backToContext, workspaceId, folderId); } }); }, _changeContext: function(context, workspaceId = null, folderId = null) { if ( - context !== "search" && // reload studies for a new search + !context.includes("search") && // load projects if search string changed context === this.getCurrentContext() && workspaceId === this.getCurrentWorkspaceId() && folderId === this.getCurrentFolderId() @@ -1143,20 +1218,23 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._resourcesContainer.reloadCards("studies"); switch (this.getCurrentContext()) { - case "studiesAndFolders": + case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS: this._searchBarFilter.resetFilters(); + this._searchBarFilter.getChildControl("text-field").setPlaceholder("Search in My Projects"); this._toolbar.show(); this.__reloadFolders(); this._loadingResourcesBtn.setFetching(false); this.invalidateStudies(); this.__reloadStudies(); break; - case "workspaces": + case osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES: this._searchBarFilter.resetFilters(); + this._searchBarFilter.getChildControl("text-field").setPlaceholder("Search in My Projects"); this._toolbar.exclude(); this.__reloadWorkspaces(); break; - case "search": + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS: + this._searchBarFilter.getChildControl("text-field").setPlaceholder("Search in My Projects"); this._toolbar.show(); this.__reloadWorkspaces(); this.__reloadFolders(); @@ -1164,22 +1242,31 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this.invalidateStudies(); this.__reloadStudies(); break; - case "templates": - this._searchBarFilter.resetFilters(); + case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: + if (this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES) { + this._searchBarFilter.resetFilters(); + } + this._searchBarFilter.getChildControl("text-field").setPlaceholder("Search in Templates"); this._toolbar.show(); this._loadingResourcesBtn.setFetching(false); this.invalidateStudies(); this.__reloadStudies(); break; - case "public": - this._searchBarFilter.resetFilters(); + case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: + if (this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES) { + this._searchBarFilter.resetFilters(); + } + this._searchBarFilter.getChildControl("text-field").setPlaceholder("Search in Public Projects"); this._toolbar.show(); this._loadingResourcesBtn.setFetching(false); this.invalidateStudies(); this.__reloadStudies(); break; - case "trash": + case osparc.dashboard.StudyBrowser.CONTEXT.TRASH: this._searchBarFilter.resetFilters(); + this._searchBarFilter.getChildControl("text-field").setPlaceholder("Search in My Projects"); this._toolbar.show(); this.__reloadWorkspaces(); this.__reloadFolders(); @@ -1410,7 +1497,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }); this.bind("multiSelection", selectButton, "value"); this.bind("currentContext", selectButton, "visibility", { - converter: currentContext => currentContext === "studiesAndFolders" ? "visible" : "excluded" + converter: currentContext => currentContext === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS ? "visible" : "excluded" }); return selectButton; }, @@ -1567,7 +1654,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const writeAccess = osparc.data.model.Study.canIWrite(studyData["accessRights"]); const deleteAccess = osparc.data.model.Study.canIDelete(studyData["accessRights"]); - if (this.getCurrentContext() === "trash") { + if (this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.TRASH) { const trashed = Boolean(studyData["trashedAt"]); if (trashed) { if (writeAccess) { @@ -1588,9 +1675,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { menu.add(openButton); } - if (this.getCurrentContext() === "search") { - const renameStudyButton = this.__getOpenLocationMenuButton(studyData); - menu.add(renameStudyButton); + if (this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS) { + const openLocationButton = this.__getOpenLocationMenuButton(studyData); + menu.add(openLocationButton); } if (writeAccess) { @@ -1665,7 +1752,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __getOpenLocationMenuButton: function(studyData) { const openLocationButton = new qx.ui.menu.Button(this.tr("Open location"), "@FontAwesome5Solid/external-link-alt/12"); openLocationButton.addListener("execute", () => { - this._changeContext("studiesAndFolders", studyData["workspaceId"], studyData["folderId"]); + this._changeContext(osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS, studyData["workspaceId"], studyData["folderId"]); }, this); return openLocationButton; }, @@ -1876,7 +1963,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _deleteResourceRequested: function(studyId) { - if (this.getCurrentContext() === "trash") { + if (this.getCurrentContext() === osparc.dashboard.StudyBrowser.CONTEXT.TRASH) { this.__deleteStudyRequested(this.__getStudyData(studyId)); } else { this.__trashStudyRequested(this.__getStudyData(studyId)); 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 d4c99138587..9eb45031dbb 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowserHeader.js @@ -234,7 +234,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }, __titleTapped: function() { - if (osparc.store.Store.getInstance().getStudyBrowserContext() === "studiesAndFolders") { + if (osparc.store.Store.getInstance().getStudyBrowserContext() === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS) { const workspaceId = this.getCurrentWorkspaceId(); const folderId = null; this.setCurrentFolderId(folderId); @@ -272,7 +272,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext(); switch (currentContext) { - case "studiesAndFolders": { + case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS: { const workspaceId = this.getCurrentWorkspaceId(); title.setCursor("pointer"); title.addListener("tap", this.__titleTapped, this); @@ -293,25 +293,21 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { } break; } - case "workspaces": + case osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES: this.__setIcon(osparc.store.Workspaces.iconPath(32)); title.setValue(this.tr("Shared Workspaces")); break; - case "search": - this.__setIcon("@FontAwesome5Solid/search/24"); - title.setValue(this.tr("Search results")); - break; - case "templates": { + case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: { this.__setIcon("@FontAwesome5Solid/copy/24"); title.setValue(this.tr("Templates")); break; } - case "public": { + case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: { this.__setIcon("@FontAwesome5Solid/globe/24"); title.setValue(this.tr("Public Projects")); break; } - case "trash": { + case osparc.dashboard.StudyBrowser.CONTEXT.TRASH: { this.__setIcon("@FontAwesome5Solid/trash/24"); title.setValue(this.tr("Recently Deleted")); const trashDays = osparc.store.StaticInfo.getInstance().getTrashRetentionDays(); @@ -321,6 +317,18 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { }); break; } + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS: + this.__setIcon("@FontAwesome5Solid/search/24"); + title.setValue(this.tr("Projects results")); + break; + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: + this.__setIcon("@FontAwesome5Solid/search/24"); + title.setValue(this.tr("Templates results")); + break; + case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: + this.__setIcon("@FontAwesome5Solid/search/24"); + title.setValue(this.tr("Public Projects results")); + break; } }, @@ -383,7 +391,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", { const roleText = this.getChildControl("role-text"); const roleIcon = this.getChildControl("role-icon"); const currentContext = osparc.store.Store.getInstance().getStudyBrowserContext(); - if (currentContext === "studiesAndFolders" && value && Object.keys(value).length) { + if (currentContext === osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS && value && Object.keys(value).length) { editButton.setVisibility(value["delete"] ? "visible" : "excluded"); const menu = new qx.ui.menu.Menu().set({ position: "bottom-right" diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TutorialBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TutorialBrowser.js index 73c9cb69bdb..0821e31526e 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TutorialBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TutorialBrowser.js @@ -106,7 +106,7 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", { } this._resourcesContainer.setResourcesToList(this._resourcesList); - const cards = this._resourcesContainer.reloadCards("templates"); + const cards = this._resourcesContainer.reloadCards(osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES); cards.forEach(card => { card.setMultiSelectionMode(this.getMultiSelection()); card.addListener("tap", () => this.__itemClicked(card), this); @@ -116,8 +116,6 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", { }); this.__evaluateUpdateAllButton(); osparc.filter.UIFilterController.dispatch("searchBarFilter"); - - this._resourcesContainer.evaluateNoResourcesFoundLabel(cards, this._resourceType); }, __itemClicked: function(card) { 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 7d8fb3b5a95..ddb4602e710 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js @@ -195,8 +195,8 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); if ( - studyBrowserContext === "search" || - studyBrowserContext === "workspaces" + studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS || + studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES ) { const editButton = new qx.ui.menu.Button(this.tr("Edit..."), "@FontAwesome5Solid/pencil-alt/12"); editButton.addListener("execute", () => { @@ -221,7 +221,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { const trashButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12"); trashButton.addListener("execute", () => this.__trashWorkspaceRequested(), this); menu.add(trashButton); - } else if (studyBrowserContext === "trash") { + } else if (studyBrowserContext === osparc.dashboard.StudyBrowser.CONTEXT.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); @@ -287,7 +287,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { __itemSelected: function() { const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); // do not allow selecting workspace - if (studyBrowserContext !== "trash") { + if (studyBrowserContext !== osparc.dashboard.StudyBrowser.CONTEXT.TRASH) { this.fireDataEvent("workspaceSelected", this.getWorkspaceId()); } }, 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 604d5e2e7b0..0d5301915a5 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("studiesAndFolders"); + this.contextChanged(osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS); osparc.store.Folders.getInstance().addListener("folderAdded", e => { const folder = e.getData(); @@ -323,8 +323,11 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", { if (selection) { selection.removeAll(); } - if (context === "studiesAndFolders" || context === "workspaces") { - const workspaceId = context === "workspaces" ? -1 : this.getCurrentWorkspaceId(); + if ([ + osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS, + osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES, + ].includes(context)) { + const workspaceId = context === osparc.dashboard.StudyBrowser.CONTEXT.WORKSPACES ? -1 : this.getCurrentWorkspaceId(); const folderId = this.getCurrentFolderId(); const locationModel = this.__getModel(workspaceId, folderId); if (locationModel) { 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 e4b1567da1c..6d69b0a0456 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -610,7 +610,11 @@ qx.Class.define("osparc.data.Resources", { }, getPageFilteredSorted: { method: "GET", - url: statics.API + "/projects?type=template&template_type={templateType}&offset={offset}&limit={limit}&order_by={orderBy}" + url: statics.API + "/projects?type=template&offset={offset}&limit={limit}&order_by={orderBy}&template_type={templateType}" + }, + getPageSearchFilteredSorted: { + method: "GET", + url: statics.API + "/projects:search?type=template&offset={offset}&limit={limit}&order_by={orderBy}&template_type={templateType}&text={text}" }, } }, diff --git a/services/static-webserver/client/source/class/osparc/info/ServiceUtils.js b/services/static-webserver/client/source/class/osparc/info/ServiceUtils.js index 8a1f9c659c0..55727bba3c7 100644 --- a/services/static-webserver/client/source/class/osparc/info/ServiceUtils.js +++ b/services/static-webserver/client/source/class/osparc/info/ServiceUtils.js @@ -175,11 +175,6 @@ qx.Class.define("osparc.info.ServiceUtils", { alignY: "middle" })); - const label = new qx.ui.basic.Label(qx.locale.Manager.tr("Description")).set({ - font: "text-13" - }); - descriptionLayout.add(label); - const description = new osparc.ui.markdown.Markdown(); // display markdown link content if that's the case if ( @@ -197,8 +192,10 @@ qx.Class.define("osparc.info.ServiceUtils", { console.error(err); description.setValue(serviceData["description"]); }); - } else { + } else if (serviceData["description"]) { description.setValue(serviceData["description"]); + } else { + description.setValue(this.tr("No description")); } descriptionLayout.add(description); diff --git a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js index 691011503ff..575bc7975d9 100644 --- a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js +++ b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js @@ -146,7 +146,7 @@ qx.Class.define("osparc.info.StudyLarge", { } }, "DESCRIPTION": { - view: osparc.info.StudyUtils.createDescriptionMD(this.getStudy(), 150), + view: osparc.info.StudyUtils.createDescriptionMD(this.getStudy()), action: { button: osparc.utils.Utils.getEditButton(this.__canIWrite()), callback: this.__canIWrite() ? this.__openDescriptionEditor : null, 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 d77b23a6cc1..aac3ec10c1c 100644 --- a/services/static-webserver/client/source/class/osparc/store/Store.js +++ b/services/static-webserver/client/source/class/osparc/store/Store.js @@ -79,10 +79,12 @@ qx.Class.define("osparc.store.Store", { check: [ "studiesAndFolders", "workspaces", - "search", "templates", - "public", + "publicTemplates", "trash", + "searchProjects", + "searchTemplates", + "searchPublicTemplates", ], init: "studiesAndFolders", nullable: false, diff --git a/services/static-webserver/client/source/class/osparc/store/Templates.js b/services/static-webserver/client/source/class/osparc/store/Templates.js index 33b0f8b4b9e..fa49e3f9a5a 100644 --- a/services/static-webserver/client/source/class/osparc/store/Templates.js +++ b/services/static-webserver/client/source/class/osparc/store/Templates.js @@ -24,7 +24,7 @@ qx.Class.define("osparc.store.Templates", { __hypertools: null, __hypertoolsPromiseCached: null, - __fetchTemplatesPaginated: function(params, options) { + fetchTemplatesPaginated: function(params, options) { params["url"]["templateType"] = osparc.data.model.StudyUI.TEMPLATE_TYPE; return osparc.data.Resources.fetch("templates", "getPageFilteredSorted", params, options) .then(response => { @@ -35,12 +35,15 @@ qx.Class.define("osparc.store.Templates", { .catch(err => osparc.FlashMessenger.logError(err)); }, - fetchTemplatesNonPublicPaginated: function(params, options) { - return this.__fetchTemplatesPaginated(params, options); - }, - - fetchTemplatesPublicPaginated: function(params, options) { - return this.__fetchTemplatesPaginated(params, options); + searchTemplatesPaginated: function(params, options) { + params["url"]["templateType"] = osparc.data.model.StudyUI.TEMPLATE_TYPE; + return osparc.data.Resources.fetch("templates", "getPageSearchFilteredSorted", params, options) + .then(response => { + const templates = response["data"]; + templates.forEach(template => template["resourceType"] = "template"); + return response; + }) + .catch(err => osparc.FlashMessenger.logError(err)); }, fetchTemplate: function(templateId) { diff --git a/services/static-webserver/client/source/class/osparc/theme/ColorLight.js b/services/static-webserver/client/source/class/osparc/theme/ColorLight.js index 629e75ccef5..d6e2c366b78 100644 --- a/services/static-webserver/client/source/class/osparc/theme/ColorLight.js +++ b/services/static-webserver/client/source/class/osparc/theme/ColorLight.js @@ -58,7 +58,6 @@ qx.Theme.define("osparc.theme.ColorLight", { "shadow": qx.core.Environment.get("css.rgba") ? "a-bit-transparent" : "bg-shadow", // window - // OM here "window-popup-background": "rgba(225, 225, 225, 1)", "window-caption-background": "background-main", "window-caption-background-active": "background-main-3",