Skip to content

Commit b44eb75

Browse files
odeimaizmrnicegyu11
authored andcommitted
✨ [Frontend] Force reload no-cache (ITISFoundation#6397)
1 parent 77e54ce commit b44eb75

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

services/static-webserver/client/source/class/osparc/NewUITracker.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ qx.Class.define("osparc.NewUITracker", {
3333
let msg = "";
3434
msg += qx.locale.Manager.tr("A new version of the application is now available.");
3535
msg += "<br>";
36-
msg += qx.locale.Manager.tr("Reload to get the latest features.");
36+
msg += qx.locale.Manager.tr("Click the Reload button to get the latest features.");
3737
// permanent message
38-
osparc.FlashMessenger.getInstance().logAs(msg, "INFO", 0);
38+
const flashMessage = osparc.FlashMessenger.getInstance().logAs(msg, "INFO", 0).set({
39+
maxWidth: 500
40+
});
41+
const reloadButton = osparc.utils.Utils.reloadNoCacheButton();
42+
flashMessage.addWidget(reloadButton);
3943
this.stopTracker();
4044
}
4145
};

services/static-webserver/client/source/class/osparc/ui/message/FlashMessage.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ qx.Class.define("osparc.ui.message.FlashMessage", {
3131
*/
3232
construct: function(message, level, duration) {
3333
this.base(arguments);
34-
this._setLayout(new qx.ui.layout.HBox(15));
34+
this._setLayout(new qx.ui.layout.VBox(15));
3535

3636
this.set({
3737
padding: 18,
@@ -112,31 +112,34 @@ qx.Class.define("osparc.ui.message.FlashMessage", {
112112
},
113113

114114
members: {
115-
__closeCb: null,
116115
_createChildControlImpl: function(id) {
117116
let control;
118117
switch (id) {
118+
case "message-layout":
119+
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(15));
120+
this._add(control);
121+
break;
119122
case "badge":
120123
control = new qx.ui.basic.Image().set({
121124
alignY: "middle"
122125
});
123-
this._add(control);
126+
this.getChildControl("message-layout").add(control);
124127
break;
125128
case "message":
126129
control = new qx.ui.basic.Label().set({
127130
font: "text-16",
128131
selectable: true,
129132
rich: true
130133
});
131-
this._add(control, {
134+
this.getChildControl("message-layout").add(control, {
132135
flex: 1
133136
});
134137
break;
135138
case "closebutton":
136139
control = new osparc.ui.basic.IconButton("@MaterialIcons/close/16", () => this.fireEvent("closeMessage")).set({
137140
alignY: "middle"
138141
});
139-
this._add(control);
142+
this.getChildControl("message-layout").add(control);
140143
break;
141144
}
142145
return control || this.base(arguments, id);
@@ -147,6 +150,10 @@ qx.Class.define("osparc.ui.message.FlashMessage", {
147150
if (label) {
148151
label.setValue(value);
149152
}
150-
}
153+
},
154+
155+
addWidget: function(widget) {
156+
this._add(widget);
157+
},
151158
}
152159
});

services/static-webserver/client/source/class/osparc/utils/Utils.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,27 @@ qx.Class.define("osparc.utils.Utils", {
249249
// window.location.href = window.location.href.replace(/#.*$/, "");
250250
},
251251

252+
reloadNoCacheButton: function() {
253+
const reloadButton = new qx.ui.form.Button().set({
254+
label: qx.locale.Manager.tr("Reload"),
255+
icon: "@FontAwesome5Solid/redo/16",
256+
font: "text-16",
257+
gap: 10,
258+
appearance: "strong-button",
259+
allowGrowX: false,
260+
center: true,
261+
alignX: "center",
262+
});
263+
reloadButton.addListener("execute", () => {
264+
// this argument, which is passed and consumed by the boot.js init file,
265+
// adds a `nocache=rand()` query argument to the js resource calls.
266+
// This forces a hard reload
267+
const noCacheUrl = window.location.href + "?qooxdoo:add-no-cache=true";
268+
window.location.href = noCacheUrl;
269+
});
270+
return reloadButton;
271+
},
272+
252273
getUniqueStudyName: function(preferredName, list) {
253274
let title = preferredName;
254275
const existingTitles = list.map(study => study.name);

0 commit comments

Comments
 (0)