Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -164,8 +159,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
} else {
openStudy();
}
})
.catch(err => osparc.FlashMessenger.logError(err));
});
} else {
openStudy();
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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));
}
});

Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Expand Down Expand Up @@ -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"]);
});
Expand Down Expand Up @@ -911,18 +901,18 @@ 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:
// The distinction is done in the frontend
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:
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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")));
},
Expand Down Expand Up @@ -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);
},

Expand All @@ -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);
},

Expand Down Expand Up @@ -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))
},

Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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) {
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -717,22 +711,17 @@ 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 {
const upKey = qx.lang.String.firstUp(fieldKey);
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -336,12 +336,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");
Expand Down Expand Up @@ -375,13 +370,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");
Expand Down
Loading
Loading