From 8243622ba332e0b84ca1e5137fa54c0cf4975af4 Mon Sep 17 00:00:00 2001 From: Arie Boven Date: Sat, 23 Mar 2024 14:27:22 +0100 Subject: [PATCH] Adds the possibility to add margin to button --- octoprint_simpleemergencystop/__init__.py | 4 +- .../static/js/simpleemergencystop.js | 24 +++++++-- .../simpleemergencystop_navbar.jinja2 | 52 ++++++++++--------- .../simpleemergencystop_settings.jinja2 | 21 ++++++-- 4 files changed, 69 insertions(+), 32 deletions(-) diff --git a/octoprint_simpleemergencystop/__init__.py b/octoprint_simpleemergencystop/__init__.py index 58b3ae5..930f734 100644 --- a/octoprint_simpleemergencystop/__init__.py +++ b/octoprint_simpleemergencystop/__init__.py @@ -16,7 +16,9 @@ class SimpleemergencystopPlugin(octoprint.plugin.StartupPlugin, return dict( emergencyGCODE="M112", confirmationDialog=False, - big_button=False + big_button=False, + enableMargin=False, + marginValue=0, ) def on_settings_save(self, data): diff --git a/octoprint_simpleemergencystop/static/js/simpleemergencystop.js b/octoprint_simpleemergencystop/static/js/simpleemergencystop.js index c9b18c4..ba31ad0 100644 --- a/octoprint_simpleemergencystop/static/js/simpleemergencystop.js +++ b/octoprint_simpleemergencystop/static/js/simpleemergencystop.js @@ -49,15 +49,33 @@ $(function () { return user.permissions.includes("control") || user.needs.role.includes("control"); } else return true; - + } + this.ses_margin_css = function () { + if (this.settings.enableMargin()) { + $('#ses_wrapper').css({ + 'margin-left':`${this.settings.marginValue()}px`, + 'margin-right':`${this.settings.marginValue()}px` + }); + } else { + $('#ses_wrapper').css({ + 'margin-left':'0px', + 'margin-right':'0px' + }); + } + }; + + this.ses_visible = function () { + return this.loginState.isUser() && this.hasControlPermition(); + }; + this.big_button_visible = function () { - return this.loginState.isUser() && this.settings.big_button() && this.hasControlPermition(); + return this.settings.big_button(); }; this.little_button_visible = function () { - return this.loginState.isUser() && !this.settings.big_button() && this.hasControlPermition(); + return !this.settings.big_button(); }; this.can_send_command = function () { diff --git a/octoprint_simpleemergencystop/templates/simpleemergencystop_navbar.jinja2 b/octoprint_simpleemergencystop/templates/simpleemergencystop_navbar.jinja2 index b9340e8..beadd8c 100644 --- a/octoprint_simpleemergencystop/templates/simpleemergencystop_navbar.jinja2 +++ b/octoprint_simpleemergencystop/templates/simpleemergencystop_navbar.jinja2 @@ -1,28 +1,30 @@ -
- - - - - - -
+
+
+ + + + + + +
-
- -
- - - - -
{{ _("Emergency Stop") }}
- - - - -
-
+
+ +
+ + + + +
{{ _("Emergency Stop") }}
+ + + + +
+
+
-
\ No newline at end of file + diff --git a/octoprint_simpleemergencystop/templates/simpleemergencystop_settings.jinja2 b/octoprint_simpleemergencystop/templates/simpleemergencystop_settings.jinja2 index 3345927..963851b 100644 --- a/octoprint_simpleemergencystop/templates/simpleemergencystop_settings.jinja2 +++ b/octoprint_simpleemergencystop/templates/simpleemergencystop_settings.jinja2 @@ -3,7 +3,7 @@
-
@@ -19,6 +19,21 @@ - - +
+ +
+ +
+
+
+ +
+
+ + px +
+
+