diff --git a/services/static-webserver/client/source/class/osparc/conversation/AddMessage.js b/services/static-webserver/client/source/class/osparc/conversation/AddMessage.js index d061753b80c1..104f0f515049 100644 --- a/services/static-webserver/client/source/class/osparc/conversation/AddMessage.js +++ b/services/static-webserver/client/source/class/osparc/conversation/AddMessage.js @@ -193,7 +193,7 @@ qx.Class.define("osparc.conversation.AddMessage", { const newCollaborators = { [userGid]: osparc.data.Roles.STUDY["write"].accessRights }; - osparc.store.Study.addCollaborators(this.__studyData, newCollaborators) + osparc.store.Study.getInstance().addCollaborators(this.__studyData, newCollaborators) .then(() => { this.__addNotify(userGid); const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators() 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 eb58ca7fed86..271981b06bf7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -121,12 +121,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { const walletsEnabled = osparc.desktop.credits.Utils.areWalletsEnabled(); if (walletsEnabled) { - const params = { - url: { - studyId - } - }; - osparc.data.Resources.fetch("studies", "getWallet", params) + osparc.store.Study.getInstance().getWallet(studyId) .then(wallet => { if ( isStudyCreation || @@ -164,8 +159,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { } else { openStudy(); } - }) - .catch(err => osparc.FlashMessenger.logError(err)); + }); } else { openStudy(); } @@ -671,10 +665,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { const arCopy = osparc.utils.Utils.deepCloneObject(templateData["accessRights"]); // remove collaborator delete arCopy[myGid]; - operationPromise = osparc.store.Study.patchStudyData(templateData, "accessRights", arCopy); + operationPromise = osparc.store.Study.getInstance().patchStudyData(templateData, "accessRights", arCopy); } else { // delete study - operationPromise = osparc.store.Store.getInstance().deleteStudy(templateData.uuid); + operationPromise = osparc.store.Study.getInstance().deleteStudy(templateData.uuid); } operationPromise .then(() => this.__removeFromTemplateList(templateData.uuid)) @@ -754,12 +748,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { }; const cancelCB = () => { this._hideLoadingPage(); - const params = { - url: { - studyId - } - }; - osparc.data.Resources.fetch("studies", "delete", params); + osparc.store.Study.getInstance().deleteStudy(studyId); }; const promises = []; @@ -788,7 +777,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { const nodeId = nodesIdsListed[idx]; const pricingPlanId = nodePricingUnits.getPricingPlanId(); const selectedUnit = nodePricingUnits.getPricingUnits().getSelectedUnit(); - promises.push(osparc.store.Study.updateSelectedPricingUnit(studyId, nodeId, pricingPlanId, selectedUnit)); + promises.push(osparc.store.Study.getInstance().updateSelectedPricingUnit(studyId, nodeId, pricingPlanId, selectedUnit)); } }); @@ -811,12 +800,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { const openCB = () => this._hideLoadingPage(); const cancelCB = () => { this._hideLoadingPage(); - const params = { - url: { - studyId - } - }; - osparc.data.Resources.fetch("studies", "delete", params); + osparc.store.Study.getInstance().deleteStudy(studyId); }; const isStudyCreation = true; this._startStudyById(studyId, openCB, cancelCB, isStudyCreation); @@ -841,12 +825,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { const openCB = () => this._hideLoadingPage(); const cancelCB = () => { this._hideLoadingPage(); - const params = { - url: { - studyId - } - }; - osparc.data.Resources.fetch("studies", "delete", params); + osparc.store.Study.getInstance().deleteStudy(studyId); }; const isStudyCreation = true; this._startStudyById(studyId, openCB, cancelCB, isStudyCreation); 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 cd3b10b1b0c7..0cb9a6a55cb4 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserFilter.js @@ -247,7 +247,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", { } }; Promise.all([ - osparc.data.Resources.fetch("studies", "getPageTrashed", studiesParams), + osparc.store.Study.getInstance().getPageTrashed(studiesParams), osparc.data.Resources.fetch("folders", "getPageTrashed", foldersParams), osparc.data.Resources.fetch("workspaces", "getPageTrashed", workspacesParams), ]) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js index 8291e6912f59..6c1b9fa31d2f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js @@ -30,12 +30,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", { case "template": case "tutorial": case "hypertool": { - const params = { - url: { - "studyId": resourceData["uuid"] - } - }; - latestPromise = osparc.data.Resources.fetch("studies", "getOne", params); + latestPromise = osparc.store.Study.getInstance().getOne(resourceData["uuid"]); break; } case "function": { @@ -231,13 +226,8 @@ qx.Class.define("osparc.dashboard.ResourceDetails", { return; } openButton.setFetching(true); - const params = { - url: { - "studyId": this.__resourceData["uuid"] - } - }; Promise.all([ - osparc.data.Resources.fetch("studies", "getOne", params), + osparc.store.Study.getInstance().getOne(this.__resourceData["uuid"]), osparc.store.Services.getStudyServices(this.__resourceData["uuid"]), ]) .then(values => { 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 d5d0f7ea43c3..01a666d26243 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -144,12 +144,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __getActiveStudy: function() { - const params = { - url: { - tabId: osparc.utils.Utils.getClientSessionID() - } - }; - return osparc.data.Resources.fetch("studies", "getActive", params) + return osparc.store.Study.getInstance().getActive(osparc.utils.Utils.getClientSessionID()) .then(studyData => { if (studyData) { osparc.store.Store.getInstance().setCurrentStudyId(studyData["uuid"]); @@ -406,12 +401,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const delay = 2000; const studyId = study["uuid"]; setTimeout(() => { - const params = { - url: { - studyId - } - }; - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(studyId) .then(studyData => { this.__studyStateReceived(study["uuid"], studyData["state"]); }); @@ -911,7 +901,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { let request = null; switch (this.getCurrentContext()) { case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS: - request = osparc.data.Resources.fetch("studies", "getPage", params, options); + request = osparc.store.Study.getInstance().getPage(params, options); break; case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES: case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES: @@ -919,10 +909,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { request = osparc.store.Templates.fetchTemplatesPaginated(params, options); break; case osparc.dashboard.StudyBrowser.CONTEXT.TRASH: - request = osparc.data.Resources.fetch("studies", "getPageTrashed", params, options); + request = osparc.store.Study.getInstance().getPageTrashed(params, options); break; case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS: - request = osparc.data.Resources.fetch("studies", "getPageSearch", params, options); + request = osparc.store.Study.getInstance().getPageSearch(params, options); break; case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES: case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES: @@ -1600,12 +1590,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const openCB = () => this._hideLoadingPage(); const cancelCB = () => { this._hideLoadingPage(); - const params = { - url: { - studyId - } - }; - osparc.data.Resources.fetch("studies", "delete", params); + osparc.store.Study.getInstance().deleteStudy(studyId); }; const isStudyCreation = true; this._startStudyById(studyId, openCB, cancelCB, isStudyCreation); @@ -1794,13 +1779,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __updateName: function(studyData, name) { - osparc.store.Study.patchStudyData(studyData, "name", name) + osparc.store.Study.getInstance().patchStudyData(studyData, "name", name) .then(() => this._updateStudyData(studyData)) .catch(err => osparc.FlashMessenger.logError(err, this.tr("Something went wrong while renaming"))); }, __updateThumbnail: function(studyData, url) { - osparc.store.Study.patchStudyData(studyData, "thumbnail", url) + osparc.store.Study.getInstance().patchStudyData(studyData, "thumbnail", url) .then(() => this._updateStudyData(studyData)) .catch(err => osparc.FlashMessenger.logError(err, this.tr("Something went wrong while updating the thumbnail"))); }, @@ -1867,13 +1852,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // resolve right away return new Promise(resolve => resolve()); } - const params = { - url: { - studyId: studyData["uuid"], - workspaceId: destWorkspaceId, - } - }; - return osparc.data.Resources.fetch("studies", "moveToWorkspace", params) + return osparc.store.Study.getInstance().moveStudyToWorkspace(studyData["uuid"], destWorkspaceId) .then(() => studyData["workspaceId"] = destWorkspaceId); }, @@ -1882,13 +1861,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // resolve right away return new Promise(resolve => resolve()); } - const params = { - url: { - studyId: studyData["uuid"], - folderId: destFolderId, - } - }; - return osparc.data.Resources.fetch("studies", "moveToFolder", params) + return osparc.store.Study.getInstance().moveStudyToFolder(studyData["uuid"], destFolderId) .then(() => studyData["folderId"] = destFolderId); }, @@ -1949,7 +1922,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __updateUIMode: function(studyData, uiMode) { const studyUI = osparc.utils.Utils.deepCloneObject(studyData["ui"]); studyUI["mode"] = uiMode; - return osparc.store.Study.patchStudyData(studyData, "ui", studyUI) + return osparc.store.Study.getInstance().patchStudyData(studyData, "ui", studyUI) .then(() => this._updateStudyData(studyData)) }, @@ -2114,12 +2087,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { importTaskUI.setSubtitle(processingLabel); importingStudyCard.getChildControl("progress-bar").exclude(); const data = JSON.parse(req.responseText); - const params = { - url: { - "studyId": data["data"]["uuid"] - } - }; - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(data["data"]["uuid"]) .then(studyData => this._updateStudyData(studyData)) .catch(err => osparc.FlashMessenger.logError(err, this.tr("Something went wrong while fetching the study"))) .finally(() => { @@ -2148,7 +2116,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __untrashStudy: function(studyData) { - osparc.store.Store.getInstance().untrashStudy(studyData.uuid) + osparc.store.Study.getInstance().untrashStudy(studyData.uuid) .then(() => { this.__removeFromStudyList(studyData.uuid); const msg = this.tr("Successfully restored"); @@ -2160,7 +2128,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __trashStudy: function(studyData) { - osparc.store.Store.getInstance().trashStudy(studyData.uuid) + osparc.store.Study.getInstance().trashStudy(studyData.uuid) .then(() => { this.__removeFromStudyList(studyData.uuid); const msg = this.tr("Successfully deleted"); @@ -2188,7 +2156,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { // remove me from collaborators const myGid = osparc.auth.Data.getInstance().getGroupId(); delete arCopy[myGid]; - return osparc.store.Study.patchStudyData(studyData, "accessRights", arCopy); + return osparc.store.Study.getInstance().patchStudyData(studyData, "accessRights", arCopy); }, __doDeleteStudy: function(studyData) { @@ -2197,7 +2165,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { operationPromise = this.__removeMeFromCollaborators(studyData); } else { // delete study - operationPromise = osparc.store.Store.getInstance().deleteStudy(studyData.uuid); + operationPromise = osparc.store.Study.getInstance().deleteStudy(studyData.uuid); } operationPromise .then(() => this.__removeFromStudyList(studyData.uuid)) 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 0821e31526ea..d54097606b5a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TutorialBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TutorialBrowser.js @@ -218,7 +218,7 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", { if (node["version"] !== latestCompatible["version"]) { patchData["version"] = latestCompatible["version"]; } - templatePromises.push(osparc.store.Study.patchNodeData(uniqueTemplateData, nodeId, patchData)); + templatePromises.push(osparc.store.Study.getInstance().patchNodeData(uniqueTemplateData, nodeId, patchData)); } } Promise.all(templatePromises) 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 cf29de3ed00b..1469e15569f3 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 @@ -680,13 +680,7 @@ qx.Class.define("osparc.data.model.Study", { } return new Promise((resolve, reject) => { - const params = { - url: { - "studyId": this.getUuid() - }, - data: studyChanges - }; - osparc.data.Resources.fetch("studies", "patch", params) + osparc.store.Study.getInstance().patchStudy(this.getUuid(), studyChanges) .then(() => { Object.keys(studyChanges).forEach(fieldKey => { const upKey = qx.lang.String.firstUp(fieldKey); @@ -717,14 +711,9 @@ qx.Class.define("osparc.data.model.Study", { } const fieldKeys = Object.keys(studyDiffs); if (fieldKeys.length) { - const patchData = {}; - const params = { - url: { - "studyId": this.getUuid() - }, - data: patchData - }; fieldKeys.forEach(fieldKey => { + // OM: can this be called all together? + const patchData = {}; if (fieldKey === "ui") { patchData[fieldKey] = this.getUi().serialize(); } else { @@ -732,7 +721,7 @@ qx.Class.define("osparc.data.model.Study", { const getter = "get" + upKey; patchData[fieldKey] = this[getter](studyDiffs[fieldKey]); } - promises.push(osparc.data.Resources.fetch("studies", "patch", params)) + promises.push(osparc.store.Study.getInstance().patchStudy(this.getUuid(), patchData)) }); } return Promise.all(promises) diff --git a/services/static-webserver/client/source/class/osparc/desktop/MainPage.js b/services/static-webserver/client/source/class/osparc/desktop/MainPage.js index c04da057ecad..f969a3915332 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/MainPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/MainPage.js @@ -264,9 +264,9 @@ qx.Class.define("osparc.desktop.MainPage", { task.addListener("resultReceived", e => { const templateData = e.getData(); // these operations need to be done after template creation - osparc.store.Study.addCollaborators(templateData, templateAccessRights); + osparc.store.Study.getInstance().addCollaborators(templateData, templateAccessRights); if (templateType) { - osparc.store.Study.patchTemplateType(templateData["uuid"], templateType) + osparc.store.Study.getInstance().patchTemplateType(templateData["uuid"], templateType) .then(() => { if (tutorialBrowser && templateType === osparc.data.model.StudyUI.TUTORIAL_TYPE) { tutorialBrowser.reloadResources(false); @@ -274,7 +274,8 @@ qx.Class.define("osparc.desktop.MainPage", { if (appBrowser && templateType === osparc.data.model.StudyUI.HYPERTOOL_TYPE) { appBrowser.reloadResources(false); } - }); + }) + .catch(err => osparc.FlashMessenger.logError(err)); } }); }) @@ -336,12 +337,7 @@ qx.Class.define("osparc.desktop.MainPage", { const msg = this.tr("No snapshot found"); throw new Error(msg); } - const params2 = { - url: { - "studyId": studyId - } - }; - osparc.data.Resources.fetch("studies", "getOne", params2) + osparc.store.Study.getInstance().getOne(studyId) .then(studyData => { if (!studyData) { const msg = this.tr("Project not found"); @@ -375,13 +371,7 @@ qx.Class.define("osparc.desktop.MainPage", { }, __openIteration: function(iterationUuid) { - const params = { - url: { - "studyId": iterationUuid - } - }; - // OM TODO. DO NOT ADD ITERATIONS TO STUDIES CACHE - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(iterationUuid) .then(studyData => { if (!studyData) { const msg = this.tr("Iteration not found"); diff --git a/services/static-webserver/client/source/class/osparc/desktop/MainPageHandler.js b/services/static-webserver/client/source/class/osparc/desktop/MainPageHandler.js index 506fa829ea54..4f43bffa01a1 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/MainPageHandler.js +++ b/services/static-webserver/client/source/class/osparc/desktop/MainPageHandler.js @@ -64,12 +64,7 @@ qx.Class.define("osparc.desktop.MainPageHandler", { this.setLoadingPageHeader(qx.locale.Manager.tr("Loading ") + osparc.product.Utils.getStudyAlias()); this.showLoadingPage(); - const params = { - url: { - "studyId": studyId - } - }; - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(studyId) .then(studyData => { if (!studyData) { const msg = qx.locale.Manager.tr("Project not found"); 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 c220a2a43723..81c1e85b0707 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js +++ b/services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js @@ -131,12 +131,7 @@ qx.Class.define("osparc.desktop.StudyEditor", { this._showLoadingPage(this.tr("Starting") + " " + studyData.name); // Before starting a study, make sure the latest version is fetched - const params = { - url: { - "studyId": studyData.uuid - } - }; - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(studyData.uuid) .then(latestStudyData => { const study = new osparc.data.model.Study(latestStudyData); this.setStudy(study); diff --git a/services/static-webserver/client/source/class/osparc/editor/AnnotationEditor.js b/services/static-webserver/client/source/class/osparc/editor/AnnotationEditor.js index d26d6296d89b..08eedabdd1e4 100644 --- a/services/static-webserver/client/source/class/osparc/editor/AnnotationEditor.js +++ b/services/static-webserver/client/source/class/osparc/editor/AnnotationEditor.js @@ -164,8 +164,8 @@ qx.Class.define("osparc.editor.AnnotationEditor", { } const colorPicker = this.getChildControl("color-picker"); - marker.bind("color", colorPicker, "color"); - colorPicker.bind("color", marker, "color"); + marker.bind("color", colorPicker, "value"); + colorPicker.bind("value", marker, "color"); }, addDeleteButton: function() { diff --git a/services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js b/services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js index a1d69c4b2f07..da44144e674a 100644 --- a/services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js +++ b/services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js @@ -169,7 +169,7 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", { [userGid]: osparc.data.Roles.STUDY["write"].accessRights }; const currentStudyData = osparc.store.Store.getInstance().getCurrentStudy().serialize(); - osparc.store.Study.addCollaborators(currentStudyData, newCollaborators) + osparc.store.Study.getInstance().addCollaborators(currentStudyData, newCollaborators) .then(() => { this.__setRecipientGid(userGid); const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators() diff --git a/services/static-webserver/client/source/class/osparc/form/tag/TagManager.js b/services/static-webserver/client/source/class/osparc/form/tag/TagManager.js index 10db2579bee3..b0f9bb5e272d 100644 --- a/services/static-webserver/client/source/class/osparc/form/tag/TagManager.js +++ b/services/static-webserver/client/source/class/osparc/form/tag/TagManager.js @@ -155,43 +155,17 @@ qx.Class.define("osparc.form.tag.TagManager", { return tagButton; }, - __getAddTagPromise: function(tagId) { - const params = { - url: { - tagId, - studyId: this.__resourceId - } - }; - return osparc.data.Resources.fetch("studies", "addTag", params); - }, - - __getRemoveTagPromise: function(tagId) { - const params = { - url: { - tagId, - studyId: this.__resourceId - } - }; - return osparc.data.Resources.fetch("studies", "removeTag", params); - }, - __saveAddTag: function(tagId, tagButton) { - this.__getAddTagPromise(tagId) + osparc.store.Study.getInstance().addTag(this.__resourceId, tagId) .then(() => this.__selectedTags.push(tagId)) - .catch(err => { - console.error(err); - tagButton.setValue(false); - }) + .catch(() => tagButton.setValue(false)) .finally(() => tagButton.setFetching(false)); }, __saveRemoveTag: function(tagId, tagButton) { - this.__getRemoveTagPromise(tagId) + osparc.store.Study.getInstance().removeTag(this.__resourceId, tagId) .then(() => this.__selectedTags.remove(tagId)) - .catch(err => { - console.error(err); - tagButton.setValue(true); - }) + .catch(() => tagButton.setValue(true)) .finally(() => tagButton.setFetching(false)); }, @@ -203,14 +177,14 @@ qx.Class.define("osparc.form.tag.TagManager", { for (let i=0; i updatedData); } } for (let i=0; i updatedData); } } diff --git a/services/static-webserver/client/source/class/osparc/info/MergedLarge.js b/services/static-webserver/client/source/class/osparc/info/MergedLarge.js index e2c4bf6e9e0b..baefb1a75140 100644 --- a/services/static-webserver/client/source/class/osparc/info/MergedLarge.js +++ b/services/static-webserver/client/source/class/osparc/info/MergedLarge.js @@ -317,7 +317,7 @@ qx.Class.define("osparc.info.MergedLarge", { resourcesLayout.exclude(); let promise = null; if (this.getNode().getNodeId()) { - promise = osparc.store.Study.getNodeResources(this.getStudy().getUuid(), this.getNode().getNodeId()); + promise = osparc.store.Study.getInstance().getNodeResources(this.getStudy().getUuid(), this.getNode().getNodeId()); } else { promise = osparc.store.Services.getResources(this.getNode().getKey(), this.getNode().getVersion()) } diff --git a/services/static-webserver/client/source/class/osparc/info/ServiceLarge.js b/services/static-webserver/client/source/class/osparc/info/ServiceLarge.js index b79d34c491ff..a9515e3a79ff 100644 --- a/services/static-webserver/client/source/class/osparc/info/ServiceLarge.js +++ b/services/static-webserver/client/source/class/osparc/info/ServiceLarge.js @@ -395,7 +395,7 @@ qx.Class.define("osparc.info.ServiceLarge", { resourcesLayout.exclude(); let promise = null; if (this.getNodeId()) { - promise = osparc.store.Study.getNodeResources(this.getStudyId(), this.getNodeId()); + promise = osparc.store.Study.getInstance().getNodeResources(this.getStudyId(), this.getNodeId()); } else { promise = osparc.store.Services.getResources(this.getService()["key"], this.getService()["version"]) } 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 fad851d77447..3b6c2c88b619 100644 --- a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js +++ b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js @@ -95,8 +95,9 @@ qx.Class.define("osparc.info.StudyLarge", { if (selected) { saveBtn.setFetching(true); const templateType = selected.getModel(); - osparc.store.Study.patchTemplateType(this.getStudy().getUuid(), templateType) + osparc.store.Study.getInstance().patchTemplateType(this.getStudy().getUuid(), templateType) .then(() => osparc.FlashMessenger.logAs(this.tr("Template type updated, please reload"), "INFO")) + .catch(err => osparc.FlashMessenger.logError(err)) .finally(() => saveBtn.setFetching(false)); } }, this); diff --git a/services/static-webserver/client/source/class/osparc/metadata/ClassifiersEditor.js b/services/static-webserver/client/source/class/osparc/metadata/ClassifiersEditor.js index e1337f16f38d..e717d1e07c1c 100644 --- a/services/static-webserver/client/source/class/osparc/metadata/ClassifiersEditor.js +++ b/services/static-webserver/client/source/class/osparc/metadata/ClassifiersEditor.js @@ -146,7 +146,7 @@ qx.Class.define("osparc.metadata.ClassifiersEditor", { const newClassifiers = this.__classifiersTree.getCheckedClassifierIDs(); if (osparc.utils.Resources.isStudy(this.__resourceData) || osparc.utils.Resources.isTemplate(this.__resourceData)) { - osparc.store.Study.patchStudyData(this.__resourceData, "classifiers", newClassifiers) + osparc.store.Study.getInstance().patchStudyData(this.__resourceData, "classifiers", newClassifiers) .then(() => { osparc.FlashMessenger.logAs(this.tr("Classifiers successfully edited")); saveBtn.setFetching(false); diff --git a/services/static-webserver/client/source/class/osparc/metadata/QualityEditor.js b/services/static-webserver/client/source/class/osparc/metadata/QualityEditor.js index 2178057ae2d9..7573f82c110c 100644 --- a/services/static-webserver/client/source/class/osparc/metadata/QualityEditor.js +++ b/services/static-webserver/client/source/class/osparc/metadata/QualityEditor.js @@ -469,7 +469,7 @@ qx.Class.define("osparc.metadata.QualityEditor", { .catch(err => osparc.FlashMessenger.logError(err, this.tr("There was an issue while updating the Quality Assessment."))) .finally(() => btn.setFetching(false)); } else { - osparc.store.Study.patchStudyData(this.__resourceData, "quality", newQuality) + osparc.store.Study.getInstance().patchStudyData(this.__resourceData, "quality", newQuality) .then(() => { this.__initResourceData(this.__resourceData); this.fireDataEvent("updateQuality", this.__resourceData); diff --git a/services/static-webserver/client/source/class/osparc/metadata/ServicesInStudy.js b/services/static-webserver/client/source/class/osparc/metadata/ServicesInStudy.js index bf1cc7a2773c..cec837790089 100644 --- a/services/static-webserver/client/source/class/osparc/metadata/ServicesInStudy.js +++ b/services/static-webserver/client/source/class/osparc/metadata/ServicesInStudy.js @@ -77,7 +77,7 @@ qx.Class.define("osparc.metadata.ServicesInStudy", { } this.setEnabled(false); - osparc.store.Study.patchNodeData(this._studyData, nodeId, patchData) + osparc.store.Study.getInstance().patchNodeData(this._studyData, nodeId, patchData) .then(() => { this.fireDataEvent("updateService", this._studyData); this._populateLayout(); diff --git a/services/static-webserver/client/source/class/osparc/node/TierSelectionView.js b/services/static-webserver/client/source/class/osparc/node/TierSelectionView.js index cb7350a6328d..944abc528b24 100644 --- a/services/static-webserver/client/source/class/osparc/node/TierSelectionView.js +++ b/services/static-webserver/client/source/class/osparc/node/TierSelectionView.js @@ -59,7 +59,7 @@ qx.Class.define("osparc.node.TierSelectionView", { }); const studyId = node.getStudy().getUuid(); const nodeId = node.getNodeId(); - osparc.store.Study.getSelectedPricingUnit(studyId, nodeId) + osparc.store.Study.getInstance().getSelectedPricingUnit(studyId, nodeId) .then(selectedPricingUnit => { if (selectedPricingUnit && selectedPricingUnit["pricingUnitId"]) { const tierFound = tierBox.getSelectables().find(t => t.getModel() === selectedPricingUnit["pricingUnitId"]); @@ -97,7 +97,7 @@ qx.Class.define("osparc.node.TierSelectionView", { tierBox.setEnabled(false); const selectedUnitId = selection[0].getModel(); const selectedUnit = pricingUnits.find(pUnit => pUnit.getPricingUnitId() === selectedUnitId) - osparc.store.Study.updateSelectedPricingUnit(studyId, nodeId, pricingPlans["pricingPlanId"], selectedUnit) + osparc.store.Study.getInstance().updateSelectedPricingUnit(studyId, nodeId, pricingPlans["pricingPlanId"], selectedUnit) .finally(() => { tierBox.setEnabled(true); showSelectedTier(selectedUnitId); diff --git a/services/static-webserver/client/source/class/osparc/node/UpdateResourceLimitsView.js b/services/static-webserver/client/source/class/osparc/node/UpdateResourceLimitsView.js index d6c10f70bc8a..6226cbca4bea 100644 --- a/services/static-webserver/client/source/class/osparc/node/UpdateResourceLimitsView.js +++ b/services/static-webserver/client/source/class/osparc/node/UpdateResourceLimitsView.js @@ -43,7 +43,7 @@ qx.Class.define("osparc.node.UpdateResourceLimitsView", { this._add(resourcesLayout); const node = this.getNode(); - osparc.store.Study.getNodeResources(node.getStudy().getUuid(), node.getNodeId()) + osparc.store.Study.getInstance().getNodeResources(node.getStudy().getUuid(), node.getNodeId()) .then(serviceResources => { resourcesLayout.show(); const gridLayout = resourcesLayout.getChildren()[1]; @@ -139,7 +139,7 @@ qx.Class.define("osparc.node.UpdateResourceLimitsView", { } }); const node = this.getNode(); - osparc.store.Study.updateNodeResources(node.getStudy().getUuid(), node.getNodeId(), updatedResources) + osparc.store.Study.getInstance().updateNodeResources(node.getStudy().getUuid(), node.getNodeId(), updatedResources) .then(() => osparc.FlashMessenger.logAs(this.tr("Limits have been successfully updated"))) .catch(err => osparc.FlashMessenger.logError(err, this.tr("Something went wrong while updating the limits"))) .finally(() => { 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 6e5233ffa8b2..731b632db3a4 100644 --- a/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js +++ b/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js @@ -194,12 +194,7 @@ qx.Class.define("osparc.notification.NotificationUI", { break; case "STUDY_SHARED": if (resourceId) { - const params = { - url: { - "studyId": resourceId - } - }; - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(resourceId) .then(study => { const studyAlias = osparc.product.Utils.getStudyAlias({ firstUpperCase: true @@ -234,12 +229,7 @@ qx.Class.define("osparc.notification.NotificationUI", { break; case "CONVERSATION_NOTIFICATION": if (resourceId) { - const params = { - url: { - "studyId": resourceId - } - }; - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(resourceId) .then(study => titleLabel.setValue(`You were notified in '${study["name"]}'`)) .catch(() => this.setEnabled(false)); } @@ -252,12 +242,7 @@ qx.Class.define("osparc.notification.NotificationUI", { break; case "ANNOTATION_NOTE": if (resourceId) { - const params = { - url: { - "studyId": resourceId - } - }; - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(resourceId) .then(study => titleLabel.setValue(`Note added in '${study["name"]}'`)) .catch(() => this.setEnabled(false)); } @@ -322,12 +307,7 @@ qx.Class.define("osparc.notification.NotificationUI", { }, __openStudyDetails: function(studyId, notification) { - const params = { - url: { - "studyId": studyId - } - }; - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(studyId) .then(studyData => { if (studyData) { const studyDataCopy = osparc.data.model.Study.deepCloneStudyObject(studyData); diff --git a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js index 8f21a4e1958c..1099aa6c1cbd 100644 --- a/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/AddCollaborators.js @@ -107,7 +107,7 @@ qx.Class.define("osparc.share.AddCollaborators", { message, } = e.getData(); collaboratorsManager.close(); - osparc.store.Study.sendShareEmails(this.__serializedDataCopy, selectedEmails, newAccessRights, message) + osparc.store.Study.getInstance().sendShareEmails(this.__serializedDataCopy, selectedEmails, newAccessRights, message) .then(() => osparc.FlashMessenger.logAs(this.tr("Emails sent"), "INFO")) .catch(err => osparc.FlashMessenger.logError(err)); }, this); 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 6be3a6b98842..9abb5dbb8660 100644 --- a/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js +++ b/services/static-webserver/client/source/class/osparc/share/CollaboratorsStudy.js @@ -93,7 +93,7 @@ qx.Class.define("osparc.share.CollaboratorsStudy", { gids.forEach(gid => { newCollaborators[gid] = newAccessRights; }); - osparc.store.Study.addCollaborators(this._serializedDataCopy, newCollaborators) + osparc.store.Study.getInstance().addCollaborators(this._serializedDataCopy, newCollaborators) .then(() => { const text = resourceAlias + this.tr(" successfully shared"); osparc.FlashMessenger.logAs(text); @@ -111,7 +111,7 @@ qx.Class.define("osparc.share.CollaboratorsStudy", { item.setEnabled(false); } - return osparc.store.Study.removeCollaborator(this._serializedDataCopy, collaborator["gid"]) + return osparc.store.Study.getInstance().removeCollaborator(this._serializedDataCopy, collaborator["gid"]) .then(() => { this.fireDataEvent("updateAccessRights", this._serializedDataCopy); osparc.FlashMessenger.logAs(collaborator["name"] + this.tr(" successfully removed")); @@ -128,7 +128,7 @@ qx.Class.define("osparc.share.CollaboratorsStudy", { __make: function(collaboratorGId, newAccessRights, successMsg, failureMsg, item) { item.setEnabled(false); - osparc.store.Study.updateCollaborator(this._serializedDataCopy, collaboratorGId, newAccessRights) + osparc.store.Study.getInstance().updateCollaborator(this._serializedDataCopy, collaboratorGId, newAccessRights) .then(() => { this.fireDataEvent("updateAccessRights", this._serializedDataCopy); osparc.FlashMessenger.logAs(successMsg); diff --git a/services/static-webserver/client/source/class/osparc/snapshots/IterationsView.js b/services/static-webserver/client/source/class/osparc/snapshots/IterationsView.js index fd2c8eaa384e..5f3a3866bad5 100644 --- a/services/static-webserver/client/source/class/osparc/snapshots/IterationsView.js +++ b/services/static-webserver/client/source/class/osparc/snapshots/IterationsView.js @@ -71,12 +71,7 @@ qx.Class.define("osparc.snapshots.IterationsView", { if (iterations.length) { const iterationPromises = []; iterations.forEach(iteration => { - const params = { - url: { - "studyId": iteration["workcopy_project_id"] - } - }; - iterationPromises.push(osparc.data.Resources.fetch("studies", "getOne", params)); + iterationPromises.push(osparc.store.Study.getInstance().getOne(iteration["workcopy_project_id"])); }); Promise.all(iterationPromises) .then(values => { @@ -199,12 +194,7 @@ qx.Class.define("osparc.snapshots.IterationsView", { }, __reloadIteration: function(iterationId) { - const params = { - url: { - "studyId": iterationId - } - }; - osparc.data.Resources.fetch("studies", "getOne", params) + osparc.store.Study.getInstance().getOne(iterationId) .then(data => { const studyData = this.__study.serialize(); studyData["workbench"] = data["workbench"]; 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 aac3ec10c1cb..f614c470822d 100644 --- a/services/static-webserver/client/source/class/osparc/store/Store.js +++ b/services/static-webserver/client/source/class/osparc/store/Store.js @@ -503,62 +503,6 @@ qx.Class.define("osparc.store.Store", { return Boolean(this.getStudyDebt(studyId)); }, - 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: { - studyId - } - }; - return new Promise((resolve, reject) => { - osparc.data.Resources.fetch("studies", "delete", params) - .then(() => { - this.remove("studies", "uuid", studyId); - resolve(); - }) - .catch(err => { - console.error(err); - reject(err); - }); - }); - }, - reloadCreditPrice: function() { const store = osparc.store.Store.getInstance(); store.setCreditPrice(null); diff --git a/services/static-webserver/client/source/class/osparc/store/Study.js b/services/static-webserver/client/source/class/osparc/store/Study.js index 59d210614666..bf656ad2b365 100644 --- a/services/static-webserver/client/source/class/osparc/store/Study.js +++ b/services/static-webserver/client/source/class/osparc/store/Study.js @@ -16,12 +16,69 @@ ************************************************************************ */ qx.Class.define("osparc.store.Study", { - type: "static", + extend: qx.core.Object, + type: "singleton", - statics: { + members: { __nodeResources: null, __nodePricingUnit: null, + getPage: function(params, options) { + return osparc.data.Resources.fetch("studies", "getPage", params, options) + }, + + getPageTrashed: function(params, options) { + return osparc.data.Resources.fetch("studies", "getPageTrashed", params, options) + }, + + getPageSearch: function(params, options) { + return osparc.data.Resources.fetch("studies", "getPageSearch", params, options); + }, + + getActive: function(clientSessionID) { + const params = { + url: { + tabId: clientSessionID, + } + }; + return osparc.data.Resources.fetch("studies", "getActive", params) + }, + + getOne: function(studyId) { + const params = { + url: { + studyId + } + }; + return osparc.data.Resources.fetch("studies", "getOne", params) + }, + + deleteStudy: function(studyId) { + const params = { + url: { + studyId + } + }; + return osparc.data.Resources.fetch("studies", "delete", params) + .then(() => { + osparc.store.Store.getInstance().remove("studies", "uuid", studyId); + }) + .catch(err => { + console.error(err); + throw err; + }); + }, + + patchStudy: function(studyId, patchData) { + const params = { + url: { + studyId, + }, + data: patchData + }; + return osparc.data.Resources.fetch("studies", "patch", params); + }, + patchStudyData: function(studyData, fieldKey, value) { if (osparc.data.model.Study.OwnPatch.includes(fieldKey)) { console.error(fieldKey, "has it's own PATCH path"); @@ -30,13 +87,7 @@ qx.Class.define("osparc.store.Study", { const patchData = {}; patchData[fieldKey] = value; - const params = { - url: { - "studyId": studyData["uuid"] - }, - data: patchData - }; - return osparc.data.Resources.fetch("studies", "patch", params) + return this.patchStudy(studyData["uuid"], patchData) .then(() => { studyData[fieldKey] = value; // A bit hacky, but it's not sent back to the backend @@ -45,16 +96,69 @@ qx.Class.define("osparc.store.Study", { }, patchTemplateType: function(templateId, templateType) { + const patchData = { + "templateType": templateType, + }; + return this.patchStudy(templateId, patchData); + }, + + updateMetadata: function(studyId, metadata) { const params = { url: { - "studyId": templateId + studyId, }, - data: { - "templateType": templateType, + data: metadata + }; + return osparc.data.Resources.fetch("studies", "updateMetadata", params); + }, + + trashStudy: function(studyId) { + const params = { + url: { + studyId } }; - return osparc.data.Resources.fetch("studies", "patch", params) - .catch(err => osparc.FlashMessenger.logError(err)); + return osparc.data.Resources.fetch("studies", "trash", params) + .then(() => { + osparc.store.Store.getInstance().remove("studies", "uuid", studyId); + }) + .catch(err => { + console.error(err); + throw err; + }); + }, + + untrashStudy: function(studyId) { + const params = { + url: { + studyId + } + }; + return osparc.data.Resources.fetch("studies", "untrash", params) + .catch(err => { + console.error(err); + throw err; + }); + }, + + moveStudyToWorkspace: function(studyId, destWorkspaceId) { + const params = { + url: { + studyId, + workspaceId: destWorkspaceId, + } + }; + return osparc.data.Resources.fetch("studies", "moveToWorkspace", params); + }, + + moveStudyToFolder: function(studyId, destFolderId) { + const params = { + url: { + studyId, + folderId: destFolderId, + } + }; + return osparc.data.Resources.fetch("studies", "moveToFolder", params); }, patchNodeData: function(studyData, nodeId, patchData) { @@ -75,6 +179,61 @@ qx.Class.define("osparc.store.Study", { }); }, + getWallet: function(studyId) { + const params = { + url: { + studyId + } + }; + return osparc.data.Resources.fetch("studies", "getWallet", params) + .catch(err => { + osparc.FlashMessenger.logError(err); + throw err; + }); + }, + + selectWallet: function(studyId, walletId) { + const params = { + url: { + studyId, + walletId, + } + }; + return osparc.data.Resources.fetch("studies", "selectWallet", params) + .catch(err => { + osparc.FlashMessenger.logError(err); + throw err; + }); + }, + + addTag: function(studyId, tagId) { + const params = { + url: { + tagId, + studyId, + } + }; + return osparc.data.Resources.fetch("studies", "addTag", params) + .catch(err => { + console.error(err); + throw err; + }); + }, + + removeTag: function(studyId, tagId) { + const params = { + url: { + tagId, + studyId, + } + }; + return osparc.data.Resources.fetch("studies", "removeTag", params) + .catch(err => { + console.error(err); + throw err; + }); + }, + addCollaborators: function(studyData, newCollaborators) { const promises = []; Object.keys(newCollaborators).forEach(gid => { @@ -94,7 +253,10 @@ qx.Class.define("osparc.store.Study", { }); studyData["lastChangeDate"] = new Date().toISOString(); }) - .catch(err => osparc.FlashMessenger.logError(err)); + .catch(err => { + osparc.FlashMessenger.logError(err); + throw err; + }); }, removeCollaborator: function(studyData, gid) { @@ -109,7 +271,10 @@ qx.Class.define("osparc.store.Study", { delete studyData["accessRights"][gid]; studyData["lastChangeDate"] = new Date().toISOString(); }) - .catch(err => osparc.FlashMessenger.logError(err)); + .catch(err => { + osparc.FlashMessenger.logError(err); + throw err; + }); }, updateCollaborator: function(studyData, gid, newPermissions) { @@ -125,7 +290,10 @@ qx.Class.define("osparc.store.Study", { studyData["accessRights"][gid] = newPermissions; studyData["lastChangeDate"] = new Date().toISOString(); }) - .catch(err => osparc.FlashMessenger.logError(err)); + .catch(err => { + osparc.FlashMessenger.logError(err); + throw err; + }); }, sendShareEmails: function(studyData, selectedEmails, newAccessRights, message) { 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 fa49e3f9a5a5..b07e916b21a7 100644 --- a/services/static-webserver/client/source/class/osparc/store/Templates.js +++ b/services/static-webserver/client/source/class/osparc/store/Templates.js @@ -47,12 +47,7 @@ qx.Class.define("osparc.store.Templates", { }, fetchTemplate: function(templateId) { - const params = { - url: { - "studyId": templateId, - } - }; - return osparc.data.Resources.fetch("studies", "getOne", params) + return osparc.store.Study.getInstance().getOne(templateId) .catch(err => console.error(err)); }, diff --git a/services/static-webserver/client/source/class/osparc/study/BillingSettings.js b/services/static-webserver/client/source/class/osparc/study/BillingSettings.js index 20edebea9f5d..0964bf07de4d 100644 --- a/services/static-webserver/client/source/class/osparc/study/BillingSettings.js +++ b/services/static-webserver/client/source/class/osparc/study/BillingSettings.js @@ -119,12 +119,7 @@ qx.Class.define("osparc.study.BillingSettings", { const walletSelector = this.getChildControl("wallet-selector"); - const paramsGet = { - url: { - studyId: this.__studyData["uuid"] - } - }; - osparc.data.Resources.fetch("studies", "getWallet", paramsGet) + osparc.store.Study.getInstance().getWallet(this.__studyData["uuid"]) .then(wallet => { if (wallet) { this.__studyWalletId = wallet["walletId"]; @@ -275,13 +270,7 @@ qx.Class.define("osparc.study.BillingSettings", { __switchWallet: function(walletId) { const creditAccountBox = this.getChildControl("credit-account-box"); creditAccountBox.setEnabled(false); - const paramsPut = { - url: { - studyId: this.__studyData["uuid"], - walletId - } - }; - osparc.data.Resources.fetch("studies", "selectWallet", paramsPut) + osparc.store.Study.getInstance().selectWallet(this.__studyData["uuid"], walletId) .then(() => { this.__studyWalletId = walletId; const msg = this.tr("Credit Account saved"); @@ -291,7 +280,6 @@ qx.Class.define("osparc.study.BillingSettings", { if ("status" in err && err["status"] == 402) { osparc.study.Utils.extractDebtFromError(this.__studyData["uuid"], err); } - osparc.FlashMessenger.logError(err); this.fireEvent("closeWindow"); }) .finally(() => { diff --git a/services/static-webserver/client/source/class/osparc/study/CreateFunction.js b/services/static-webserver/client/source/class/osparc/study/CreateFunction.js index 4b28bf0b5dce..7dee8e3593f0 100644 --- a/services/static-webserver/client/source/class/osparc/study/CreateFunction.js +++ b/services/static-webserver/client/source/class/osparc/study/CreateFunction.js @@ -330,18 +330,12 @@ qx.Class.define("osparc.study.CreateFunction", { }, __updateTemplateMetadata: function(templateData) { - const patchData = { + const metadata = { "custom" : { "hidden": "Base template for function", } }; - const params = { - url: { - "studyId": templateData["uuid"], - }, - data: patchData - }; - osparc.data.Resources.fetch("studies", "updateMetadata", params) + osparc.store.Study.getInstance().updateMetadata(templateData["uuid"], metadata) .catch(err => console.error(err)); }, diff --git a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js index 04099e84cab0..d10d3916c6c0 100644 --- a/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js +++ b/services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js @@ -92,7 +92,7 @@ qx.Class.define("osparc.study.NodePricingUnits", { this.set({ pricingPlanId: pricingPlanData["pricingPlanId"] }); - osparc.store.Study.getSelectedPricingUnit(studyId, nodeId) + osparc.store.Study.getInstance().getSelectedPricingUnit(studyId, nodeId) .then(selectedPricingUnit => { if (pricingPlanData && "pricingUnits" in pricingPlanData && pricingPlanData["pricingUnits"].length) { const pricingUnitsData = pricingPlanData["pricingUnits"]; @@ -109,7 +109,7 @@ qx.Class.define("osparc.study.NodePricingUnits", { if (this.isPatchNode()) { pricingUnitTiers.setEnabled(false); const pricingPlanId = this.getPricingPlanId(); - osparc.store.Study.updateSelectedPricingUnit(studyId, nodeId, pricingPlanId, newSelectedPricingUnit) + osparc.store.Study.getInstance().updateSelectedPricingUnit(studyId, nodeId, pricingPlanId, newSelectedPricingUnit) .then(() => pricingUnitTiers.setSelectedUnitId(newSelectedPricingUnit.getPricingUnitId())) .catch(err => osparc.FlashMessenger.logError(err, this.tr("Cannot change Tier"))) .finally(() => pricingUnitTiers.setEnabled(true)); diff --git a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js index 37cd905c33c5..0569a23295d1 100644 --- a/services/static-webserver/client/source/class/osparc/study/StudyOptions.js +++ b/services/static-webserver/client/source/class/osparc/study/StudyOptions.js @@ -91,19 +91,12 @@ qx.Class.define("osparc.study.StudyOptions", { }, updateName: function(studyData, name) { - return osparc.store.Study.patchStudyData(studyData, "name", name) + return osparc.store.Study.getInstance().patchStudyData(studyData, "name", name) .catch(err => osparc.FlashMessenger.logError(err, qx.locale.Manager.tr("Something went wrong while renaming"))); }, updateWallet: function(studyId, walletId) { - const params = { - url: { - studyId, - walletId, - } - }; - return osparc.data.Resources.fetch("studies", "selectWallet", params) - .catch(err => osparc.FlashMessenger.logError(err, qx.locale.Manager.tr("An issue occurred while selecting Credit Account"))); + return osparc.store.Study.getInstance().selectWallet(studyId, walletId); }, }, @@ -231,14 +224,9 @@ qx.Class.define("osparc.study.StudyOptions", { }, __fetchStudy: function(studyId) { - const params = { - url: { - studyId - } - }; Promise.all([ - osparc.data.Resources.fetch("studies", "getOne", params), - osparc.data.Resources.fetch("studies", "getWallet", params) + osparc.store.Study.getInstance().getOne(studyId), + osparc.store.Study.getInstance().getWallet(studyId), ]) .then(values => { const studyData = values[0];