Skip to content

Commit f2b1287

Browse files
committed
minor
1 parent 326458e commit f2b1287

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

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

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,24 @@ qx.Class.define("osparc.MaintenanceTracker", {
4242
statics: {
4343
CHECK_INTERVAL: 15*60*1000, // Check every 15'
4444
CLOSABLE_WARN_IN_ADVANCE: 4*24*60*60*1000, // Show Closable Ribbon Message 4 days in advance
45-
PERMANENT_WARN_IN_ADVANCE: 60*60*1000 // Show Permanent Ribbon Message 60' in advance
45+
PERMANENT_WARN_IN_ADVANCE: 60*60*1000, // Show Permanent Ribbon Message 60' in advance
46+
47+
dataToText: function(start, end, reason) {
48+
let text = osparc.utils.Utils.formatDateAndTime(start);
49+
if (end) {
50+
if (start.getDate() === end.getDate()) {
51+
// do not print the same day twice
52+
text += " - " + osparc.utils.Utils.formatTime(end);
53+
} else {
54+
text += " - " + osparc.utils.Utils.formatDateAndTime(end);
55+
}
56+
}
57+
text += " (local time)";
58+
if (reason) {
59+
text += ": " + reason;
60+
}
61+
return text;
62+
},
4663
},
4764

4865
members: {
@@ -78,20 +95,7 @@ qx.Class.define("osparc.MaintenanceTracker", {
7895
return null;
7996
}
8097

81-
let text = osparc.utils.Utils.formatDateAndTime(this.getStart());
82-
if (this.getEnd()) {
83-
if (this.getStart().getDate() === this.getEnd().getDate()) {
84-
// do not print the same day twice
85-
text += " - " + osparc.utils.Utils.formatTime(this.getEnd());
86-
} else {
87-
text += " - " + osparc.utils.Utils.formatDateAndTime(this.getEnd());
88-
}
89-
}
90-
text += " (local time)";
91-
if (this.getReason()) {
92-
text += ": " + this.getReason();
93-
}
94-
return text;
98+
return this.self().dataToText(this.getStart(), this.getEnd(), this.getReason());
9599
},
96100

97101
__setMaintenance: function(maintenanceData) {
@@ -129,9 +133,9 @@ qx.Class.define("osparc.MaintenanceTracker", {
129133
}
130134
},
131135

132-
__messageToRibbon: function(closable) {
136+
messageToRibbon: function(closable, message = null) {
133137
this.__removeRibbonMessage();
134-
const text = this.__getText();
138+
const text = message || this.__getText();
135139
const notification = new osparc.notification.RibbonNotification(text, "maintenance", closable);
136140
osparc.notification.RibbonNotifications.getInstance().addNotification(notification);
137141
this.__lastRibbonMessage = notification;
@@ -143,14 +147,14 @@ qx.Class.define("osparc.MaintenanceTracker", {
143147
const diffPermanent = this.getStart().getTime() - now.getTime() - this.self().PERMANENT_WARN_IN_ADVANCE;
144148

145149
if (diffClosable < 0) {
146-
this.__messageToRibbon(true);
150+
this.messageToRibbon(true);
147151
} else {
148-
setTimeout(() => this.__messageToRibbon(true), diffClosable);
152+
setTimeout(() => this.messageToRibbon(true), diffClosable);
149153
}
150154
if (diffPermanent < 0) {
151-
this.__messageToRibbon(false);
155+
this.messageToRibbon(false);
152156
} else {
153-
setTimeout(() => this.__messageToRibbon(false), diffPermanent);
157+
setTimeout(() => this.messageToRibbon(false), diffPermanent);
154158
}
155159
},
156160

services/static-webserver/client/source/class/osparc/admin/Maintenance.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,17 @@ qx.Class.define("osparc.admin.Maintenance", {
5050
vBox.removeAll();
5151

5252
if (data) {
53+
const displayMaintenanceBtn = new qx.ui.form.Button(this.tr("Test Maintenance message")).set({
54+
appearance: "strong-button",
55+
allowGrowX: false,
56+
});
57+
const message = osparc.MaintenanceTracker.dataToText(new Date(data["start"]), new Date(data["end"]), data["reason"]);
58+
displayMaintenanceBtn.addListener("execute", () => osparc.MaintenanceTracker.getInstance().messageToRibbon(true), message);
59+
vBox.add(displayMaintenanceBtn);
60+
5361
const respLabel = new qx.ui.basic.Label(this.tr("Start and End dates go in UTC time zone"));
5462
vBox.add(respLabel);
5563

56-
const displayMaintenanceBtn = new qx.ui.form.Button(this.tr("Display Maintenance message"));
57-
// eslint-disable-next-line no-underscore-dangle
58-
displayMaintenanceBtn.addListener("execute", () => osparc.MaintenanceTracker.getInstance().__messageToRibbon(true));
59-
vBox.add(displayMaintenanceBtn);
60-
6164
const invitationRespViewer = new osparc.ui.basic.JsonTreeWidget(data, "maintenance-data");
6265
const container = new qx.ui.container.Scroll();
6366
container.add(invitationRespViewer);

0 commit comments

Comments
 (0)