-Wrapping rest api in try catch

-Tuning css for numeric fields
-Clean-up
This commit is contained in:
sergiuToporjinschi
2022-02-05 14:25:26 +02:00
parent d294fa5724
commit aadc8a92c6
8 changed files with 51 additions and 38 deletions
+3 -3
View File
@@ -16,9 +16,9 @@ defaultSettings = {
}, },
"XYZSteps": { "XYZSteps": {
"gCodeCubeSize": { "gCodeCubeSize": {
"X":20, "X":20.000,
"Y":20, "Y":20.000,
"Z":20 "Z":20.000
} }
}, },
"pid": { "pid": {
+6 -2
View File
@@ -2,7 +2,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals from __future__ import absolute_import, division, print_function, unicode_literals
import traceback import traceback
from ast import Try
import flask import flask
@@ -27,13 +26,18 @@ class API(EStepsApi.API, PIDAutoTune.API):
return result return result
def on_api_get(self, request): def on_api_get(self, request):
# request.args.get('x') try:
self._logger.debug("api.on_api_get") self._logger.debug("api.on_api_get")
return flask.jsonify( return flask.jsonify(
{ {
"data": self.data["steps"] "data": self.data["steps"]
} }
) )
except Exception as e:
self._logger.error(traceback.format_exc())
return flask.abort(500, {
"msg": "An error curred"
})
def on_api_command(self, command, data): def on_api_command(self, command, data):
try: try:
@@ -69,6 +69,11 @@
text-align: left; text-align: left;
} }
#tab_plugin_CalibrationTools input.numberDisplay {
text-align: left;
max-width: 65px;
}
/* /*
@@ -59,7 +59,11 @@ $(function () {
"newYSteps": self.eStepsXYZ.newSteps.Y(), "newYSteps": self.eStepsXYZ.newSteps.Y(),
"newZSteps": self.eStepsXYZ.newSteps.Z() "newZSteps": self.eStepsXYZ.newSteps.Z()
}).done(function (response) { }).done(function (response) {
new PNotify({
title: "Saved",
text: "X: " + self.eStepsXYZ.newSteps.X() + "steps/mm<br>Y: " + self.eStepsXYZ.newSteps.Y() + "steps/mm<br>Z: " + self.eStepsXYZ.newSteps.Z() + " steps/mm<br> had been set for X/Y/Z axes",
type: "info"
});
}).always(function (response) { }).always(function (response) {
self.saveEStepsXYZActive(true); self.saveEStepsXYZActive(true);
}) })
@@ -24,9 +24,9 @@
"number", "settings.plugins.CalibrationTools.eSteps.markLength", "true", "mm", 50) }} "number", "settings.plugins.CalibrationTools.eSteps.markLength", "true", "mm", 50) }}
{{ snipped.subSection("X-Y-Z-Steps default values") }} {{ snipped.subSection("X-Y-Z-Steps default values") }}
{{ snipped.field("gCode cube size of X", "", "number", "settings.plugins.CalibrationTools.XYZSteps.gCodeCubeSize.X", "true", "mm", 0.01, 10.00, "") }} {{ snipped.field("gCode cube size of X", "", "number", "settings.plugins.CalibrationTools.XYZSteps.gCodeCubeSize.X", "true", "mm", 0.001, 10.000, "") }}
{{ snipped.field("gCode cube size of Y", "", "number", "settings.plugins.CalibrationTools.XYZSteps.gCodeCubeSize.Y", "true", "mm", 0.01, 10.00, "") }} {{ snipped.field("gCode cube size of Y", "", "number", "settings.plugins.CalibrationTools.XYZSteps.gCodeCubeSize.Y", "true", "mm", 0.001, 10.000, "") }}
{{ snipped.field("gCode cube size of Z", "", "number", "settings.plugins.CalibrationTools.XYZSteps.gCodeCubeSize.Z", "true", "mm", 0.01, 10.00, "") }} {{ snipped.field("gCode cube size of Z", "", "number", "settings.plugins.CalibrationTools.XYZSteps.gCodeCubeSize.Z", "true", "mm", 0.001, 10.000, "") }}
{{ snipped.subSection("Hot-end PID default values") }} {{ snipped.subSection("Hot-end PID default values") }}
@@ -1,22 +1,22 @@
<div class="octo-tab-content"> <div class="octo-tab-content">
<div class="row-fluid header" id="toolBar"> <div class="row-fluid header" id="toolBar">
<div class="span3 title"> <div class="span11 title">
<p>Calibration</p> <p>Calibration</p>
</div> </div>
<div class="span8 title"> <!-- <div class="span8 title">
<div class="row-fluid"> <div class="row-fluid">
<div class="span6"></div> <div class="span6"></div>
<div class="span6"> <div class="span6">
<button class="btn" data-bind="click: $root.restart, visible: true"> <button class="btn" data-bind="click: $root.restart, visible: false">
RESTART RESTART
</button> </button>
<button class="btn btn-primary" data-bind="click: $root.test, visible: true" title="BTN for testing"> <button class="btn btn-primary" data-bind="click: $root.test, visible: false" title="BTN for testing">
<i class="fas fa-save" data-color="#000000"></i>&nbsp&nbsp <i class="fas fa-save" data-color="#000000"></i>&nbsp&nbsp
TEST TEST
</button> </button>
</div> </div>
</div> </div>
</div> </div> -->
<div class="span1 icon"> <div class="span1 icon">
<a data-bind="click: $root.onSettingsClick"> <a data-bind="click: $root.onSettingsClick">
<i class="fas fa-cog fa-lg" data-color="#ddd"></i> <i class="fas fa-cog fa-lg" data-color="#ddd"></i>
@@ -26,14 +26,14 @@
<div class="main row-fluid"> <div class="main row-fluid">
<div class="span3"> <div class="span3">
<ul class="nav nav-list"> <ul class="nav nav-list">
<li> <li class="active">
<a data-toggle="tab" href="#calibration_documentation">Documentation</a> <a data-toggle="tab" href="#calibration_documentation">Documentation</a>
</li> </li>
<li> <li>
<a data-toggle="tab" href="#calibration_eSteps">E-Steps</a> <a data-toggle="tab" href="#calibration_eSteps">E-Steps</a>
</li> </li>
<li class="active"> <li>
<a data-toggle="tab" href="#calibration_x-y-z">X-Y-Z-Steps</a> <a data-toggle="tab" href="#calibration_x-y-z">X-Y-Z Steps</a>
</li> </li>
<li> <li>
<a data-toggle="tab" href="#calibration_pid">PID Autotune</a> <a data-toggle="tab" href="#calibration_pid">PID Autotune</a>
@@ -1,8 +1,8 @@
<div class="tab-content"> <div class="tab-content">
<div id="calibration_documentation" class="tab-pane "> <div id="calibration_documentation" class="tab-pane active">
{% include "tabs/tab-doc.jinja2" %} {% include "tabs/tab-doc.jinja2" %}
</div> </div>
<div id="calibration_x-y-z" visible="false" class="tab-pane active"> <div id="calibration_x-y-z" visible="false" class="tab-pane">
{% include "tabs/tab-xyz.jinja2" %} {% include "tabs/tab-xyz.jinja2" %}
</div> </div>
<div id="calibration_eSteps" visible="false" class="tab-pane"> <div id="calibration_eSteps" visible="false" class="tab-pane">
@@ -1,6 +1,6 @@
{% import "macros.jinja2" as snipped %} {% import "macros.jinja2" as snipped %}
{{ snipped.subSection("Current PID values", true) }} {{ snipped.subSection("X-Y-Z Steps", true) }}
<div class="row-fluid"> <div class="row-fluid">
<div class="span3"> <div class="span3">
<label for="tunningPIDNoCycles" class="pull-right" style="margin-top: 5px;" title="x"> <label for="tunningPIDNoCycles" class="pull-right" style="margin-top: 5px;" title="x">
@@ -11,11 +11,11 @@
<div class="input-prepend input-append"> <div class="input-prepend input-append">
{{ snipped.linkToMarlin("M092", "Marlin website") }} {{ snipped.linkToMarlin("M092", "Marlin website") }}
<span class="add-on" title="">M92&nbsp;&nbsp;&nbsp;X</span> <span class="add-on" title="">M92&nbsp;&nbsp;&nbsp;X</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.currentSteps.X, enable: false"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.currentSteps.X, enable: false">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;Y</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;Y</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.currentSteps.Y, enable: false"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.currentSteps.Y, enable: false">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;Z</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;Z</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.currentSteps.Z, enable: false"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.currentSteps.Z, enable: false">
<button class="btn" data-bind="click: $root.loadESteps, enable: $root.loadEStepsActive() && $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting())" <button class="btn" data-bind="click: $root.loadESteps, enable: $root.loadEStepsActive() && $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting())"
title="Loads current value from EEPROM by calling M92"> title="Loads current value from EEPROM by calling M92">
<i class="fas fa-sync-alt" style="color:false" data-color="false"></i> <i class="fas fa-sync-alt" style="color:false" data-color="false"></i>
@@ -32,11 +32,11 @@
<div class="span9"> <div class="span9">
<div class="input-prepend input-append"> <div class="input-prepend input-append">
<span class="add-on" title="">X</span> <span class="add-on" title="">X</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.gCodeCubeSize.X"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.gCodeCubeSize.X">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;Y</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;Y</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.gCodeCubeSize.Y"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.gCodeCubeSize.Y">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;Z</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;Z</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.gCodeCubeSize.Z"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.gCodeCubeSize.Z">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;mm</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;mm</span>
</div> </div>
</div> </div>
@@ -50,11 +50,11 @@
<div class="span9"> <div class="span9">
<div class="input-prepend input-append"> <div class="input-prepend input-append">
<span class="add-on" title="">X</span> <span class="add-on" title="">X</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.printedCubeSize.X"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.printedCubeSize.X">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;Y</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;Y</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.printedCubeSize.Y"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.printedCubeSize.Y">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;Z</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;Z</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.printedCubeSize.Z"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.printedCubeSize.Z">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;mm</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;mm</span>
</div> </div>
</div> </div>
@@ -69,11 +69,11 @@
<div class="input-prepend input-append"> <div class="input-prepend input-append">
{{ snipped.linkToMarlin("M092", "Marlin website") }} {{ snipped.linkToMarlin("M092", "Marlin website") }}
<span class="add-on" title="">M92&nbsp;&nbsp;&nbsp;X</span> <span class="add-on" title="">M92&nbsp;&nbsp;&nbsp;X</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.newSteps.X"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.newSteps.X">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;Y</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;Y</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.newSteps.Y"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.newSteps.Y">
<span class="add-on" title="">&nbsp;&nbsp;&nbsp;Z</span> <span class="add-on" title="">&nbsp;&nbsp;&nbsp;Z</span>
<input type="number" id="" class="input-small" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.newSteps.Z"> <input type="number" id="" class="input-small numberDisplay" step="0.001" min="0" max="100" title="" data-bind="value: $root.eStepsXYZ.newSteps.Z">
{{ snipped.m500Icon() }} {{ snipped.m500Icon() }}
</div> </div>
</div> </div>