Small Fixes, and a README
This commit is contained in:
parent
6227e12dcd
commit
c2f6afcb5e
22
README.md
Normal file
22
README.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Plugin for OctoPrint - makes Custom Controls editable via settings
|
||||||
|
==================================================================
|
||||||
|
|
||||||
|
### ATTENTION
|
||||||
|
Plugin still in development!
|
||||||
|
|
||||||
|
|
||||||
|
This plugin helps you create, edit and delete your custom controls.
|
||||||
|
You can easly access all the options in the settings under customControl.
|
||||||
|
|
||||||
|
Right-Click on a Control or the Green box to open a context menu.
|
||||||
|
|
||||||
|
By using the container elements you can easly position the controls where you want.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Install the plugin like you would install any regular Python package from source:
|
||||||
|
|
||||||
|
pip install https://github.com/Salandora/octoprint-customControl/archive/master.zip
|
||||||
|
|
||||||
|
Make sure you use the same Python environment that you installed OctoPrint under, otherwise the plugin
|
||||||
|
won't be able to satisfy its dependencies.
|
@ -73,7 +73,7 @@
|
|||||||
var input = {
|
var input = {
|
||||||
name: ko.observable(list[i].name),
|
name: ko.observable(list[i].name),
|
||||||
parameter: ko.observable(list[i].parameter),
|
parameter: ko.observable(list[i].parameter),
|
||||||
defaultValue: ko.observable(list[i].defaultValue || "0")
|
defaultValue: ko.observable(list[i].defaultValue != "" ? list[i].defaultValue : undefined),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (list[i].hasOwnProperty("slider") && typeof list[i].slider == "object") {
|
if (list[i].hasOwnProperty("slider") && typeof list[i].slider == "object") {
|
||||||
@ -82,9 +82,25 @@
|
|||||||
max: ko.observable(list[i].slider.max),
|
max: ko.observable(list[i].slider.max),
|
||||||
step: ko.observable(list[i].slider.step),
|
step: ko.observable(list[i].slider.step),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var param = list[i].hasOwnProperty("defaultValue") && !isNaN(list[i].defaultValue) && list[i].defaultValue != undefined && list[i].defaultValue != "" ? list[i].defaultValue : (list[i].slider.hasOwnProperty("min") && !isNaN(list[i].slider.min) && list[i].slider.min != undefined && list[i].slider.min != "" ? list[i].slider.min : 0);
|
||||||
|
if (typeof param == "string")
|
||||||
|
param = parseInt(param);
|
||||||
|
|
||||||
|
if (list[i].slider.hasOwnProperty("min") && param < list[i].slider.min)
|
||||||
|
param = list[i].slider.min;
|
||||||
|
|
||||||
|
if (list[i].slider.hasOwnProperty("max") && param > list[i].slider.max)
|
||||||
|
param = list[i].slider.max;
|
||||||
|
|
||||||
|
if (typeof param == "string")
|
||||||
|
param = parseInt(param);
|
||||||
|
|
||||||
|
input.value = ko.observable(param);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
input.slider = false;
|
input.slider = false;
|
||||||
|
input.value = ko.observable(!isNaN(list[i].defaultValue) ? list[i].defaultValue : undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs.push(input);
|
inputs.push(input);
|
||||||
@ -385,6 +401,22 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "script": {
|
||||||
|
element.name(ret.name);
|
||||||
|
element.script = ret.script;
|
||||||
|
|
||||||
|
if (ret.confirm != "") {
|
||||||
|
element.confirm = ret.confirm;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.input != undefined) {
|
||||||
|
element.input(self._processInput(ret.input));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
delete element.input;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "output": {
|
case "output": {
|
||||||
element.template(ret.template);
|
element.template(ret.template);
|
||||||
element.regex(ret.regex);
|
element.regex(ret.regex);
|
||||||
|
@ -120,12 +120,14 @@
|
|||||||
var input = {
|
var input = {
|
||||||
name: element.name,
|
name: element.name,
|
||||||
parameter: element.parameter,
|
parameter: element.parameter,
|
||||||
defaultValue: element.defaultValue
|
defaultValue: !isNaN(element.defaultValue) ? element.defaultValue : undefined
|
||||||
};
|
};
|
||||||
if (element.hasOwnProperty("slider") && element.slider != false) {
|
if (element.hasOwnProperty("slider") && element.slider != false) {
|
||||||
input["slider"] = {
|
input["slider"] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
input.defaultValue = !isNaN(element.defaultValue) && element.defaultValue != undefined && element.defaultValue != "" ? parseInt(element.defaultValue) : undefined;
|
||||||
|
|
||||||
if (element.slider.hasOwnProperty("min") && element.slider.min != "")
|
if (element.slider.hasOwnProperty("min") && element.slider.min != "")
|
||||||
input.slider.min = element.slider.min;
|
input.slider.min = element.slider.min;
|
||||||
if (element.slider.hasOwnProperty("max") && element.slider.max != "")
|
if (element.slider.hasOwnProperty("max") && element.slider.max != "")
|
||||||
@ -160,18 +162,20 @@
|
|||||||
var input = {
|
var input = {
|
||||||
name: element.name,
|
name: element.name,
|
||||||
parameter: element.parameter,
|
parameter: element.parameter,
|
||||||
defaultValue: element.defaultValue
|
defaultValue: !isNaN(element.defaultValue) ? element.defaultValue : undefined
|
||||||
};
|
};
|
||||||
if (element.hasOwnProperty("slider") && element.slider != false) {
|
if (element.hasOwnProperty("slider") && element.slider != false) {
|
||||||
input["slider"] = {
|
input["slider"] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (element.slider.hasOwnProperty("min") && element.slider.min != "")
|
input.defaultValue = !isNaN(element.defaultValue) && element.defaultValue != undefined && element.defaultValue != "" ? parseInt(element.defaultValue) : undefined;
|
||||||
input.slider.min = element.slider.min;
|
|
||||||
if (element.slider.hasOwnProperty("max") && element.slider.max != "")
|
if (element.slider.min != "")
|
||||||
input.slider.max = element.slider.max;
|
input.slider.min = parseInt(element.slider.min);
|
||||||
if (element.slider.hasOwnProperty("step") && element.slider.step != "")
|
if (element.slider.max != "")
|
||||||
input.slider.step = element.slider.step;
|
input.slider.max = parseInt(element.slider.max);
|
||||||
|
if (element.slider.step != "")
|
||||||
|
input.slider.step = parseInt(element.slider.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
el.input.push(input);
|
el.input.push(input);
|
||||||
@ -217,11 +221,11 @@
|
|||||||
var obj = {
|
var obj = {
|
||||||
name: ko.observable(""),
|
name: ko.observable(""),
|
||||||
parameter: ko.observable(""),
|
parameter: ko.observable(""),
|
||||||
defaultValue: ko.observable(""),
|
defaultValue: ko.observable(),
|
||||||
slider: {
|
slider: {
|
||||||
min: ko.observable(""),
|
min: ko.observable(),
|
||||||
max: ko.observable(""),
|
max: ko.observable(),
|
||||||
step: ko.observable("")
|
step: ko.observable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
<!-- ko foreach: input -->
|
<!-- ko foreach: input -->
|
||||||
<label style="cursor: default" data-bind="text: name"></label>
|
<label style="cursor: default" data-bind="text: name"></label>
|
||||||
<!-- ko if: slider -->
|
<!-- ko if: slider -->
|
||||||
<input type="number" style="width: 100px" data-bind="slider: {value: defaultValue, min: slider.min(), max: slider.max(), step: slider.step(), enabled: false }">
|
<input type="number" style="width: 100px" data-bind="slider: {value: value, min: slider.min(), max: slider.max(), step: slider.step(), enabled: false }">
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
<!-- ko ifnot: slider -->
|
<!-- ko ifnot: slider -->
|
||||||
<input type="text" class="input-small" data-bind="attr: {placeholder: name}, value: defaultValue, disable: true">
|
<input type="text" class="input-small" data-bind="attr: {placeholder: name}, value: defaultValue, disable: true">
|
||||||
|
4
setup.py
4
setup.py
@ -21,7 +21,7 @@ plugin_version = "0.1"
|
|||||||
|
|
||||||
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
||||||
# module
|
# module
|
||||||
plugin_description = ""
|
plugin_description = "Makes Custom Controls editable via settings"
|
||||||
|
|
||||||
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module
|
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module
|
||||||
plugin_author = "Marc Hannappel (Salandora)"
|
plugin_author = "Marc Hannappel (Salandora)"
|
||||||
@ -30,7 +30,7 @@ plugin_author = "Marc Hannappel (Salandora)"
|
|||||||
plugin_author_email = "sunpack@web.de"
|
plugin_author_email = "sunpack@web.de"
|
||||||
|
|
||||||
# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module
|
# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module
|
||||||
plugin_url = ""
|
plugin_url = "https://github.com/Salandora/octoprint-customControl"
|
||||||
|
|
||||||
# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module
|
# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module
|
||||||
plugin_license = "AGPLv3"
|
plugin_license = "AGPLv3"
|
||||||
|
Loading…
Reference in New Issue
Block a user