Skip to content

Commit f0f8eb9

Browse files
committed
savePending
1 parent 1cc62af commit f0f8eb9

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ qx.Class.define("osparc.data.model.Study", {
249249
init: null,
250250
event: "changeTrashedBy",
251251
},
252+
253+
savePending: {
254+
check: "Boolean",
255+
nullable: true,
256+
event: "changeSavePending",
257+
init: false
258+
},
252259
// ------ ignore for serializing ------
253260
},
254261

@@ -259,6 +266,7 @@ qx.Class.define("osparc.data.model.Study", {
259266
"pipelineRunning",
260267
"readOnly",
261268
"trashedAt",
269+
"savePending",
262270
],
263271

264272
IgnoreModelizationProps: [

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
105105

106106
statics: {
107107
AUTO_SAVE_INTERVAL: 3000,
108+
DIFF_CHECK_INTERVAL: 300,
108109
READ_ONLY_TEXT: qx.locale.Manager.tr("You do not have writing permissions.<br>Your changes will not be saved."),
109110
},
110111

@@ -114,6 +115,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
114115
__workbenchView: null,
115116
__slideshowView: null,
116117
__autoSaveTimer: null,
118+
__savingTimer: null,
117119
__studyEditorIdlingTracker: null,
118120
__studyDataInBackend: null,
119121
__updatingStudy: null,
@@ -226,6 +228,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
226228

227229
if (osparc.data.model.Study.canIWrite(study.getAccessRights())) {
228230
this.__startAutoSaveTimer();
231+
this.__startSavingTimer();
229232
} else {
230233
const msg = this.self().READ_ONLY_TEXT;
231234
osparc.FlashMessenger.logAs(msg, "WARNING");
@@ -840,9 +843,30 @@ qx.Class.define("osparc.desktop.StudyEditor", {
840843
},
841844
// ------------------ AUTO SAVER ------------------
842845

846+
// ---------------- SAVING TIMER ------------------
847+
__startSavingTimer: function() {
848+
const timer = this.__savingTimer = new qx.event.Timer(this.self().DIFF_CHECK_INTERVAL);
849+
timer.addListener("interval", () => {
850+
if (!osparc.wrapper.WebSocket.getInstance().isConnected()) {
851+
return;
852+
}
853+
this.getStudy().setSavePending(this.didStudyChange());
854+
}, this);
855+
timer.start();
856+
},
857+
858+
__stopSavingTimer: function() {
859+
if (this.__savingTimer && this.__savingTimer.isEnabled()) {
860+
this.__savingTimer.stop();
861+
this.__savingTimer.setEnabled(false);
862+
}
863+
},
864+
// ---------------- SAVING TIMER ------------------
865+
843866
__stopTimers: function() {
844867
this.__stopIdlingTracker();
845868
this.__stopAutoSaveTimer();
869+
this.__stopSavingTimer();
846870
},
847871

848872
__getStudyDiffs: function() {

services/static-webserver/client/source/class/osparc/navigation/NavigationBar.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,15 @@ qx.Class.define("osparc.navigation.NavigationBar", {
114114

115115
const savingStudyIcon = this.getChildControl("saving-study-icon");
116116
this.bind("study", savingStudyIcon, "visibility", {
117-
converter: s => s ? "visible" : "excluded"
117+
converter: s => {
118+
if (s) {
119+
s.addListener("changeSavePending", e => {
120+
const isSaving = e.getData();
121+
savingStudyIcon.setVisibility(isSaving ? "visible" : "excluded");
122+
});
123+
}
124+
return "excluded";
125+
}
118126
});
119127

120128
// center-items
@@ -212,7 +220,6 @@ qx.Class.define("osparc.navigation.NavigationBar", {
212220
toolTipText: this.tr("Saving pipeline..."),
213221
source: "@FontAwesome5Solid/cloud-upload-alt/14",
214222
opacity: 0.8,
215-
// visibility: "excluded",
216223
});
217224
this.getChildControl("left-items").add(control);
218225
break;

0 commit comments

Comments
 (0)