Skip to content

Commit

Permalink
0.1.4
Browse files Browse the repository at this point in the history
Added option to enable buttons while printing
  • Loading branch information
jneilliii committed Feb 11, 2020
1 parent 57d4321 commit 8ac3bba
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
10 changes: 9 additions & 1 deletion octoprint_terminalcommandsextended/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_settings_defaults(self):
)

def get_settings_version(self):
return 2
return 3

def on_settings_migrate(self, target, current=None):
if current is None or current < 1:
Expand All @@ -39,6 +39,14 @@ def on_settings_migrate(self, target, current=None):
commands_new.append(command)
self._settings.set(["commands"],commands_new)

if current == 2:
commands_new = []
for command in self._settings.get(['commands']):
if not command.get("enabled_while_printing", False):
command["enabled_while_printing"] = False
commands_new.append(command)
self._settings.set(["commands"],commands_new)

##~~ AssetPlugin mixin

def get_assets(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ $(function() {
};

self.addCommand = function() {
self.selected_command({icon: ko.observable('fas fa-gear'), label: ko.observable(''), tooltip: ko.observable(''), command: ko.observable(''), confirmation: ko.observable(false), message: ko.observable(''), input: ko.observableArray([])});
self.selected_command({icon: ko.observable('fas fa-gear'),
label: ko.observable(''),
tooltip: ko.observable(''),
command: ko.observable(''),
confirmation: ko.observable(false),
message: ko.observable(''),
input: ko.observableArray([]),
enabled_while_printing: ko.observable(false)});
self.settingsViewModel.settings.plugins.terminalcommandsextended.commands.push(self.selected_command());
$('#terminalCommandEditor').modal('show');
};
Expand All @@ -38,7 +45,8 @@ $(function() {
command: ko.observable(data.command()),
confirmation: ko.observable(data.confirmation()),
message: ko.observable(data.message()),
input: ko.observableArray(data.input())});
input: ko.observableArray(data.input()),
enabled_while_printing: ko.observable(data.enabled_while_printing())});
};

self.removeCommand = function(data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script type="text/html" id="customTerminalControls_controlTemplate_input">
<div class="btn-group" style="display: inline-block; margin-left: 0px; margin-bottom: 5px;">
<!-- ko foreach: input -->
<button style="cursor: default" data-bind="text: label, enable: $root.controlViewModel.isOperational() && !$root.controlViewModel.isPrinting()" class="btn"></button>
<button style="cursor: default" data-bind="text: label, enable: $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting() || enabled_while_printing())" class="btn"></button>
<input type="text" class="input-mini btn active" style="cursor: text;margin-bottom: 0px;" data-bind="attr: {placeholder: label, title: value}, value: value, enable: $root.controlViewModel.isOperational() && !$root.controlViewModel.isPrinting()">
<!-- /ko -->
<!-- ko template: { name: 'customTerminalControls_controlTemplate_command', data: $data} --><!-- /ko -->
Expand All @@ -19,5 +19,5 @@

<!-- Template for button -->
<script type="text/html" id="customTerminalControls_controlTemplate_command">
<button class="btn" data-bind="click: $root.runCustomCommand, attr: {title: (tooltip() ? tooltip : command)}, enable: $root.controlViewModel.isOperational() && !$root.controlViewModel.isPrinting()"><i data-bind="css: icon"></i> <span data-bind="text: label"/></button>
<button class="btn" data-bind="click: $root.runCustomCommand, attr: {title: (tooltip() ? tooltip : command)}, enable: $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting() || enabled_while_printing())"><i data-bind="css: icon"></i> <span data-bind="text: label"/></button>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<div class="controls"><label class="control-label">{{ _('Icon') }}</label><input type="text" class="input-block-level" data-bind="value: icon, iconpicker: icon,iconpickerOptions: {hideOnSelect: true, collision: true}"/></div>
<div class="controls"><label class="control-label">{{ _('Label') }}</label><input type="text" class="input-block-level" data-bind="value: label"/></div>
<div class="controls"><label class="control-label">{{ _('Tooltip') }}</label><input type="text" class="input-block-level" data-bind="value: tooltip"/></div>
<div class="controls"><label class="checkbox">{{ _('Enabled While Printing') }}<input type="checkbox" data-bind="checked: enabled_while_printing" title="Prompt for Confirmation"/></label></div>
<div class="controls"><label class="checkbox">{{ _('Confirm') }}<input type="checkbox" data-bind="checked: confirmation" title="Prompt for Confirmation"/></label></div>
<!-- ko if: confirmation -->
<div class="controls"><label class="control-label">{{ _('Message') }}</label><input type="text" class="input-block-level" data-bind="value: message"/></div>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "Terminal Commands Extended"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.1.3"
plugin_version = "0.1.4"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 8ac3bba

Please sign in to comment.