Skip to content

Commit 1014740

Browse files
author
Josef-MrBeam
committed
adding the hard refresh overlay
1 parent a8bb7b1 commit 1014740

File tree

7 files changed

+83
-0
lines changed

7 files changed

+83
-0
lines changed

octoprint_mrbeam/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ def get_assets(self):
709709
"js/calibration/watterott/camera_alignment.js",
710710
"js/calibration/watterott/calibration_qa.js",
711711
"js/calibration/watterott/label_printer.js",
712+
"js/hard_refresh_overlay.js",
712713
],
713714
css=[
714715
"css/mrbeam.css",

octoprint_mrbeam/static/css/mrbeam.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,3 +3407,15 @@ button#terminal-send {
34073407
#support_overlay > div.modal-body.scrollable > table {
34083408
margin: 20px auto;
34093409
}
3410+
3411+
.hard_refresh_overlay {
3412+
width: 60%;
3413+
margin-left: -30%;
3414+
}
3415+
.hard_refresh_overlay .image_description {
3416+
padding: 40px;
3417+
}
3418+
.hard_refresh_overlay .modal-header {
3419+
padding-top: 10px;
3420+
padding-bottom: 10px;
3421+
}
9.72 KB
Loading
9.88 KB
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
$(function () {
2+
function HardRefreshOverlayViewModel(params) {
3+
let self = this;
4+
window.mrbeam.viewModels["HardRefreshOverlayViewModel"] = self;
5+
6+
self.settings = params[0];
7+
self.loginState = params[1];
8+
9+
self.onUserLoggedIn = function () {
10+
if (
11+
self.loginState.currentUser?.()?.active
12+
) {
13+
let x = document.cookie.split('; ').find((row) => row.startsWith('f.u.extra='))?.split('=')[1]; // get cookie
14+
if (x !== undefined && x === 'true') {
15+
$("#hard_refresh_overlay").modal("show");
16+
}
17+
}
18+
19+
};
20+
self.onEventplugin_softwareupdate_update_succeeded = function () {
21+
document.cookie = "f.u.extra=true"
22+
}
23+
self.onDataUpdaterPluginMessage = function (plugin, data) {
24+
console.log("hard_refresh", plugin, data);
25+
if (plugin === "softwareupdate") {
26+
if ("type" in data && (data["type"] === "success" || data["type"] === "restarting" || data["type"] === "restart_manually")) {
27+
document.cookie = "f.u.extra=true";
28+
}
29+
}
30+
}
31+
self.setUserHardRefreshed = function () {
32+
// document.cookie = "f.u.extra= ; expires = Thu, 01 Jan 1970 00:00:00 GMT"//delete cookie
33+
}
34+
}
35+
36+
// view model class, parameters for constructor, container to bind to
37+
OCTOPRINT_VIEWMODELS.push([
38+
HardRefreshOverlayViewModel,
39+
40+
// e.g. loginStateViewModel, settingsViewModel, ...
41+
["settingsViewModel", "loginStateViewModel"],
42+
43+
// e.g. #settings_plugin_mrbeam, #tab_plugin_mrbeam, ...
44+
["#hard_refresh_overlay"],
45+
]);
46+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div id="hard_refresh_overlay" class="modal hide fade hard_refresh_overlay" data-backdrop="static">
2+
<div class="modal-header">
3+
<h3><i class="icon icon-warning-sign"></i> {{ _('Refresh is needed after the last Software Update') }}</h3>
4+
</div>
5+
<div class="modal-body">
6+
<div class="row-fluid">
7+
<div class="span5 image_description">
8+
<p>{{ _("An update has been installed on this Mr Beam. To use the new functions, the user interace must be completely reloaded.") }}</p>
9+
<p> {{ _("We call this a hard refresh. To do this, press the three keys at the same time, depending on your operating system, as shown in the graphic:") }}</p>
10+
</div>
11+
<div class="span7">
12+
<b>{{ _("Windows | Strg + Shift + R") }}</b>
13+
<img src="/plugin/mrbeam/static/img/windows_refresh.png">
14+
<b>{{ _("Mac | Command + Shift + R") }}</b>
15+
<img src="/plugin/mrbeam/static/img/mac_refresh.png">
16+
</div>
17+
</div>
18+
</div>
19+
<div class="modal-footer">
20+
<button class="btn btn-primary" id="#hard_refresh_confirmed" data-dismiss="modal"
21+
aria-hidden="true" data-bind="click: $root.setUserHardRefreshed">{{ _('Yes, I will reload the page') }}</button>
22+
</div>
23+
</div>

octoprint_mrbeam/templates/mrbeam_ui_index.jinja2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
{% include 'quick_shape.jinja2' %}
178178
{% include 'conversion_dialog.jinja2' %}
179179
{% include 'laserhead_changed.jinja2' %}
180+
{% include 'hard_refresh_overlay.jinja2' %}
180181
<!-- End of dialogs -->
181182

182183
<!-- Overlays -->

0 commit comments

Comments
 (0)