macro: Add setting to config macro btn slot

This commit is contained in:
mfm 2018-01-24 23:07:55 +01:00
parent 57c617f1a1
commit e722718984
6 changed files with 30 additions and 8 deletions

View File

@ -21,7 +21,7 @@ class KlipperPlugin(
return dict(
serialport="/tmp/printer",
replace_connection_panel=True,
macros=[{'name':"Echo", 'macro':"ECHO"}],
macros=[{'name':"Echo", 'macro':"ECHO", 'sidebar':True, 'tab':True}],
probeHeight=0,
probeLift=5,
probeSpeedXy=1500,

View File

@ -48,7 +48,6 @@ $(function() {
self.onAfterBinding = function() {
self.connectionState.selectedPort(self.settings.settings.plugins.klipper.serialport());
console.log(self.connectionState.selectedPort());
self.shortStatus("Idle");
}

View File

@ -4,7 +4,12 @@ $(function() {
self.settings = parameters[0];
self.addMacro = function() {
self.settings.settings.plugins.klipper.macros.push({name: 'Macro', macro: ''});
self.settings.settings.plugins.klipper.macros.push({
name: 'Macro',
macro: '',
sidebar: true,
tab: true
});
}
self.removeMacro = function(macro) {

View File

@ -14,13 +14,28 @@
<div class="control-group">
<h4>{{ _('Macros') }}<h4>
</div>
<div class="control-group">
<div class="controls">
<div class="row-fluid">
<div class="span8" style="text-align: right"><small>Add macro button to:</small></div>
<div class="span1"><small>Klipper Tab</small></div>
<div class="span2"><small>Sidebar</small></div>
</div>
</div>
</div>
<div data-bind="foreach: settings.settings.plugins.klipper.macros">
<div class="control-group">
<label class="control-label">{{ _('Name') }}</label>
<div class="controls">
<div class="row-fluid">
<div class="span9">
<input type="text" class="input-block-level" data-bind="value: name">
<div class="span8">
<input type="text" class="input-block-level" data-bind="value: name"/>
</div>
<div class="span1">
<input type="checkbox" class="input-block-level" data-bind="checked: tab"/>
</div>
<div class="span1">
<input type="checkbox" class="input-block-level" data-bind="checked: sidebar"/>
</div>
<div class="span2">
<a href='#' data-bind='click: $parent.moveMacroUp' class="fa fa-chevron-up"></a>
@ -28,12 +43,11 @@
<a href='#' data-bind='click: $parent.removeMacro' class="fa fa-trash-o"></a>
</div>
</div>
</div>
<label class="control-label">{{ _('GCODE') }}</label>
<div class="controls">
<div class="row-fluid">
<div class="span9">
<div class="span8">
<textarea rows="4" class="block" data-bind="value: macro">
</textarea>
</div>

View File

@ -14,6 +14,8 @@
<div>
<label>Macros</label>
<div data-bind="foreach: settings.settings.plugins.klipper.macros">
<!-- ko if: sidebar -->
<button class="btn btn-block" data-bind="text: name, click: $parent.executeMacro, enable: $parent.isActive()"></button>
<!-- /ko -->
</div>
</div>

View File

@ -25,10 +25,12 @@
<button class="btn btn-block" data-bind="click: showPidTuningDialog, enable: isActive()">PID Tuning</button>
</div>
<div class="controls">
<hr>
<hr>
<label class="control-label">Macros</label>
<div data-bind="foreach: settings.settings.plugins.klipper.macros">
<!-- ko if: tab -->
<button class="btn btn-block" data-bind="text: name, click: $parent.executeMacro, enable: $parent.isActive()"></button>
<!-- /ko -->
</div>
</div>
</div>