From 9a8b8d86d5ed6dd2d59a5794947af1887f0fb730 Mon Sep 17 00:00:00 2001 From: electr0sheep Date: Fri, 23 Feb 2018 18:00:54 -0700 Subject: [PATCH 1/2] Extended "customControls_controlTemplate_command" --- src/octoprint/templates/tabs/control.jinja2 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/octoprint/templates/tabs/control.jinja2 b/src/octoprint/templates/tabs/control.jinja2 index a3c8cc633..0cf7e741f 100644 --- a/src/octoprint/templates/tabs/control.jinja2 +++ b/src/octoprint/templates/tabs/control.jinja2 @@ -173,6 +173,11 @@ From 88b622e28291f1ee11a1433dbaef1dbd405e03f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 7 Mar 2018 15:37:16 +0100 Subject: [PATCH 2/2] customClass => additionalClasses --- docs/features/custom_controls.rst | 4 ++++ src/octoprint/static/js/app/viewmodels/control.js | 4 ++++ src/octoprint/templates/tabs/control.jinja2 | 7 +------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/features/custom_controls.rst b/docs/features/custom_controls.rst index a953617e9..f130596c1 100644 --- a/docs/features/custom_controls.rst +++ b/docs/features/custom_controls.rst @@ -166,6 +166,10 @@ Controls clicked. This allows to override the direct sending of the command or commands to the printer with more sophisticated behaviour. The JavaScript snippet is ``eval``'d and processed in a context where the control it is part of is provided as local variable ``data`` and the ``ControlViewModel`` is available as ``self``. + * - ``additionalClasses`` + - (Optional) Additional classes to apply to the button of a ``command``, ``commands``, ``script`` or ``javascript`` + control, other than the default ``btn``. Can be used to visually style the button, e.g. set to ``btn-danger`` to + turn the button red. * - ``enabled`` - (Optional) A JavaScript snippet returning either ``true`` or ``false`` determining whether the control should be enabled or not. This allow to override the default logic for this (disabled if printer is offline diff --git a/src/octoprint/static/js/app/viewmodels/control.js b/src/octoprint/static/js/app/viewmodels/control.js index 0f38329de..072205414 100644 --- a/src/octoprint/static/js/app/viewmodels/control.js +++ b/src/octoprint/static/js/app/viewmodels/control.js @@ -226,6 +226,10 @@ $(function() { } } + if (control.hasOwnProperty("command") && !control.hasOwnProperty("additionalClasses")) { + control.additionalClasses = ""; + } + control.processed = true; return control; }; diff --git a/src/octoprint/templates/tabs/control.jinja2 b/src/octoprint/templates/tabs/control.jinja2 index 0cf7e741f..14b672508 100644 --- a/src/octoprint/templates/tabs/control.jinja2 +++ b/src/octoprint/templates/tabs/control.jinja2 @@ -173,11 +173,6 @@