Skip to content

Commit cfbbba9

Browse files
committed
singleton
1 parent e3e6af6 commit cfbbba9

29 files changed

+69
-68
lines changed

services/static-webserver/client/source/class/osparc/conversation/AddMessage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
193193
const newCollaborators = {
194194
[userGid]: osparc.data.Roles.STUDY["write"].accessRights
195195
};
196-
osparc.store.Study.addCollaborators(this.__studyData, newCollaborators)
196+
osparc.store.Study.getInstance().addCollaborators(this.__studyData, newCollaborators)
197197
.then(() => {
198198
this.__addNotify(userGid);
199199
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators()

services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
671671
const arCopy = osparc.utils.Utils.deepCloneObject(templateData["accessRights"]);
672672
// remove collaborator
673673
delete arCopy[myGid];
674-
operationPromise = osparc.store.Study.patchStudyData(templateData, "accessRights", arCopy);
674+
operationPromise = osparc.store.Study.getInstance().patchStudyData(templateData, "accessRights", arCopy);
675675
} else {
676676
// delete study
677-
operationPromise = osparc.store.Study.deleteStudy(templateData.uuid);
677+
operationPromise = osparc.store.Study.getInstance().deleteStudy(templateData.uuid);
678678
}
679679
operationPromise
680680
.then(() => this.__removeFromTemplateList(templateData.uuid))
@@ -754,7 +754,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
754754
};
755755
const cancelCB = () => {
756756
this._hideLoadingPage();
757-
osparc.store.Study.deleteStudy(studyId);
757+
osparc.store.Study.getInstance().deleteStudy(studyId);
758758
};
759759

760760
const promises = [];
@@ -783,7 +783,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
783783
const nodeId = nodesIdsListed[idx];
784784
const pricingPlanId = nodePricingUnits.getPricingPlanId();
785785
const selectedUnit = nodePricingUnits.getPricingUnits().getSelectedUnit();
786-
promises.push(osparc.store.Study.updateSelectedPricingUnit(studyId, nodeId, pricingPlanId, selectedUnit));
786+
promises.push(osparc.store.Study.getInstance().updateSelectedPricingUnit(studyId, nodeId, pricingPlanId, selectedUnit));
787787
}
788788
});
789789

@@ -806,7 +806,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
806806
const openCB = () => this._hideLoadingPage();
807807
const cancelCB = () => {
808808
this._hideLoadingPage();
809-
osparc.store.Study.deleteStudy(studyId);
809+
osparc.store.Study.getInstance().deleteStudy(studyId);
810810
};
811811
const isStudyCreation = true;
812812
this._startStudyById(studyId, openCB, cancelCB, isStudyCreation);
@@ -831,7 +831,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
831831
const openCB = () => this._hideLoadingPage();
832832
const cancelCB = () => {
833833
this._hideLoadingPage();
834-
osparc.store.Study.deleteStudy(studyId);
834+
osparc.store.Study.getInstance().deleteStudy(studyId);
835835
};
836836
const isStudyCreation = true;
837837
this._startStudyById(studyId, openCB, cancelCB, isStudyCreation);

services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserFilter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
247247
}
248248
};
249249
Promise.all([
250-
osparc.store.Study.getPageTrashed(studiesParams),
250+
osparc.store.Study.getInstance().getPageTrashed(studiesParams),
251251
osparc.data.Resources.fetch("folders", "getPageTrashed", foldersParams),
252252
osparc.data.Resources.fetch("workspaces", "getPageTrashed", workspacesParams),
253253
])

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
3030
case "template":
3131
case "tutorial":
3232
case "hypertool": {
33-
latestPromise = osparc.store.Study.getOne(resourceData["uuid"]);
33+
latestPromise = osparc.store.Study.getInstance().getOne(resourceData["uuid"]);
3434
break;
3535
}
3636
case "function": {
@@ -227,7 +227,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
227227
}
228228
openButton.setFetching(true);
229229
Promise.all([
230-
osparc.store.Study.getOne(this.__resourceData["uuid"]),
230+
osparc.store.Study.getInstance().getOne(this.__resourceData["uuid"]),
231231
osparc.store.Services.getStudyServices(this.__resourceData["uuid"]),
232232
])
233233
.then(values => {

services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
144144
},
145145

146146
__getActiveStudy: function() {
147-
return osparc.store.Study.getActive(osparc.utils.Utils.getClientSessionID())
147+
return osparc.store.Study.getInstance().getActive(osparc.utils.Utils.getClientSessionID())
148148
.then(studyData => {
149149
if (studyData) {
150150
osparc.store.Store.getInstance().setCurrentStudyId(studyData["uuid"]);
@@ -401,7 +401,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
401401
const delay = 2000;
402402
const studyId = study["uuid"];
403403
setTimeout(() => {
404-
osparc.store.Study.getOne(studyId)
404+
osparc.store.Study.getInstance().getOne(studyId)
405405
.then(studyData => {
406406
this.__studyStateReceived(study["uuid"], studyData["state"]);
407407
});
@@ -901,18 +901,18 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
901901
let request = null;
902902
switch (this.getCurrentContext()) {
903903
case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS:
904-
request = osparc.store.Study.getPage(params, options);
904+
request = osparc.store.Study.getInstance().getPage(params, options);
905905
break;
906906
case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES:
907907
case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES:
908908
// The distinction is done in the frontend
909909
request = osparc.store.Templates.fetchTemplatesPaginated(params, options);
910910
break;
911911
case osparc.dashboard.StudyBrowser.CONTEXT.TRASH:
912-
request = osparc.store.Study.getPageTrashed(params, options);
912+
request = osparc.store.Study.getInstance().getPageTrashed(params, options);
913913
break;
914914
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS:
915-
request = osparc.store.Study.getPageSearch(params, options);
915+
request = osparc.store.Study.getInstance().getPageSearch(params, options);
916916
break;
917917
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES:
918918
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES:
@@ -1590,7 +1590,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
15901590
const openCB = () => this._hideLoadingPage();
15911591
const cancelCB = () => {
15921592
this._hideLoadingPage();
1593-
osparc.store.Study.deleteStudy(studyId);
1593+
osparc.store.Study.getInstance().deleteStudy(studyId);
15941594
};
15951595
const isStudyCreation = true;
15961596
this._startStudyById(studyId, openCB, cancelCB, isStudyCreation);
@@ -1779,13 +1779,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
17791779
},
17801780

17811781
__updateName: function(studyData, name) {
1782-
osparc.store.Study.patchStudyData(studyData, "name", name)
1782+
osparc.store.Study.getInstance().patchStudyData(studyData, "name", name)
17831783
.then(() => this._updateStudyData(studyData))
17841784
.catch(err => osparc.FlashMessenger.logError(err, this.tr("Something went wrong while renaming")));
17851785
},
17861786

17871787
__updateThumbnail: function(studyData, url) {
1788-
osparc.store.Study.patchStudyData(studyData, "thumbnail", url)
1788+
osparc.store.Study.getInstance().patchStudyData(studyData, "thumbnail", url)
17891789
.then(() => this._updateStudyData(studyData))
17901790
.catch(err => osparc.FlashMessenger.logError(err, this.tr("Something went wrong while updating the thumbnail")));
17911791
},
@@ -1852,7 +1852,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
18521852
// resolve right away
18531853
return new Promise(resolve => resolve());
18541854
}
1855-
return osparc.store.Study.moveStudyToWorkspace(studyData["uuid"], destWorkspaceId)
1855+
return osparc.store.Study.getInstance().moveStudyToWorkspace(studyData["uuid"], destWorkspaceId)
18561856
.then(() => studyData["workspaceId"] = destWorkspaceId);
18571857
},
18581858

@@ -1861,7 +1861,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
18611861
// resolve right away
18621862
return new Promise(resolve => resolve());
18631863
}
1864-
return osparc.store.Study.moveStudyToFolder(studyData["uuid"], destFolderId)
1864+
return osparc.store.Study.getInstance().moveStudyToFolder(studyData["uuid"], destFolderId)
18651865
.then(() => studyData["folderId"] = destFolderId);
18661866
},
18671867

@@ -1922,7 +1922,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19221922
__updateUIMode: function(studyData, uiMode) {
19231923
const studyUI = osparc.utils.Utils.deepCloneObject(studyData["ui"]);
19241924
studyUI["mode"] = uiMode;
1925-
return osparc.store.Study.patchStudyData(studyData, "ui", studyUI)
1925+
return osparc.store.Study.getInstance().patchStudyData(studyData, "ui", studyUI)
19261926
.then(() => this._updateStudyData(studyData))
19271927
},
19281928

@@ -2087,7 +2087,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
20872087
importTaskUI.setSubtitle(processingLabel);
20882088
importingStudyCard.getChildControl("progress-bar").exclude();
20892089
const data = JSON.parse(req.responseText);
2090-
osparc.store.Study.getOne(data["data"]["uuid"])
2090+
osparc.store.Study.getInstance().getOne(data["data"]["uuid"])
20912091
.then(studyData => this._updateStudyData(studyData))
20922092
.catch(err => osparc.FlashMessenger.logError(err, this.tr("Something went wrong while fetching the study")))
20932093
.finally(() => {
@@ -2116,7 +2116,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
21162116
},
21172117

21182118
__untrashStudy: function(studyData) {
2119-
osparc.store.Study.untrashStudy(studyData.uuid)
2119+
osparc.store.Study.getInstance().untrashStudy(studyData.uuid)
21202120
.then(() => {
21212121
this.__removeFromStudyList(studyData.uuid);
21222122
const msg = this.tr("Successfully restored");
@@ -2128,7 +2128,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
21282128
},
21292129

21302130
__trashStudy: function(studyData) {
2131-
osparc.store.Study.trashStudy(studyData.uuid)
2131+
osparc.store.Study.getInstance().trashStudy(studyData.uuid)
21322132
.then(() => {
21332133
this.__removeFromStudyList(studyData.uuid);
21342134
const msg = this.tr("Successfully deleted");
@@ -2156,7 +2156,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
21562156
// remove me from collaborators
21572157
const myGid = osparc.auth.Data.getInstance().getGroupId();
21582158
delete arCopy[myGid];
2159-
return osparc.store.Study.patchStudyData(studyData, "accessRights", arCopy);
2159+
return osparc.store.Study.getInstance().patchStudyData(studyData, "accessRights", arCopy);
21602160
},
21612161

21622162
__doDeleteStudy: function(studyData) {
@@ -2165,7 +2165,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
21652165
operationPromise = this.__removeMeFromCollaborators(studyData);
21662166
} else {
21672167
// delete study
2168-
operationPromise = osparc.store.Study.deleteStudy(studyData.uuid);
2168+
operationPromise = osparc.store.Study.getInstance().deleteStudy(studyData.uuid);
21692169
}
21702170
operationPromise
21712171
.then(() => this.__removeFromStudyList(studyData.uuid))

services/static-webserver/client/source/class/osparc/dashboard/TutorialBrowser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", {
218218
if (node["version"] !== latestCompatible["version"]) {
219219
patchData["version"] = latestCompatible["version"];
220220
}
221-
templatePromises.push(osparc.store.Study.patchNodeData(uniqueTemplateData, nodeId, patchData));
221+
templatePromises.push(osparc.store.Study.getInstance().patchNodeData(uniqueTemplateData, nodeId, patchData));
222222
}
223223
}
224224
Promise.all(templatePromises)

services/static-webserver/client/source/class/osparc/data/model/Study.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ qx.Class.define("osparc.data.model.Study", {
680680
}
681681

682682
return new Promise((resolve, reject) => {
683-
osparc.store.Study.patchStudy(this.getUuid(), studyChanges)
683+
osparc.store.Study.getInstance().patchStudy(this.getUuid(), studyChanges)
684684
.then(() => {
685685
Object.keys(studyChanges).forEach(fieldKey => {
686686
const upKey = qx.lang.String.firstUp(fieldKey);
@@ -721,7 +721,7 @@ qx.Class.define("osparc.data.model.Study", {
721721
const getter = "get" + upKey;
722722
patchData[fieldKey] = this[getter](studyDiffs[fieldKey]);
723723
}
724-
promises.push(osparc.store.Study.patchStudy(this.getUuid(), patchData))
724+
promises.push(osparc.store.Study.getInstance().patchStudy(this.getUuid(), patchData))
725725
});
726726
}
727727
return Promise.all(promises)

services/static-webserver/client/source/class/osparc/desktop/MainPage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ qx.Class.define("osparc.desktop.MainPage", {
264264
task.addListener("resultReceived", e => {
265265
const templateData = e.getData();
266266
// these operations need to be done after template creation
267-
osparc.store.Study.addCollaborators(templateData, templateAccessRights);
267+
osparc.store.Study.getInstance().addCollaborators(templateData, templateAccessRights);
268268
if (templateType) {
269-
osparc.store.Study.patchTemplateType(templateData["uuid"], templateType)
269+
osparc.store.Study.getInstance().patchTemplateType(templateData["uuid"], templateType)
270270
.then(() => {
271271
if (tutorialBrowser && templateType === osparc.data.model.StudyUI.TUTORIAL_TYPE) {
272272
tutorialBrowser.reloadResources(false);
@@ -336,7 +336,7 @@ qx.Class.define("osparc.desktop.MainPage", {
336336
const msg = this.tr("No snapshot found");
337337
throw new Error(msg);
338338
}
339-
osparc.store.Study.getOne(studyId)
339+
osparc.store.Study.getInstance().getOne(studyId)
340340
.then(studyData => {
341341
if (!studyData) {
342342
const msg = this.tr("Project not found");
@@ -370,7 +370,7 @@ qx.Class.define("osparc.desktop.MainPage", {
370370
},
371371

372372
__openIteration: function(iterationUuid) {
373-
osparc.store.Study.getOne(iterationUuid)
373+
osparc.store.Study.getInstance().getOne(iterationUuid)
374374
.then(studyData => {
375375
if (!studyData) {
376376
const msg = this.tr("Iteration not found");

services/static-webserver/client/source/class/osparc/desktop/MainPageHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ qx.Class.define("osparc.desktop.MainPageHandler", {
6464
this.setLoadingPageHeader(qx.locale.Manager.tr("Loading ") + osparc.product.Utils.getStudyAlias());
6565
this.showLoadingPage();
6666

67-
osparc.store.Study.getOne(studyId)
67+
osparc.store.Study.getInstance().getOne(studyId)
6868
.then(studyData => {
6969
if (!studyData) {
7070
const msg = qx.locale.Manager.tr("Project not found");

services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
131131
this._showLoadingPage(this.tr("Starting") + " " + studyData.name);
132132

133133
// Before starting a study, make sure the latest version is fetched
134-
osparc.store.Study.getOne(studyData.uuid)
134+
osparc.store.Study.getInstance().getOne(studyData.uuid)
135135
.then(latestStudyData => {
136136
const study = new osparc.data.model.Study(latestStudyData);
137137
this.setStudy(study);

0 commit comments

Comments
 (0)