From bc6302e967a44a372402bc904d041edbc9830353 Mon Sep 17 00:00:00 2001 From: thelastWallE <12502210+thelastWallE@users.noreply.github.com> Date: Tue, 16 Mar 2021 19:06:16 +0100 Subject: [PATCH] *prepare workspace *bugfixes *testing --- .editorconfig | 15 +++++++--- .gitignore | 3 +- octoprint_klipper/__init__.py | 25 ++++++++++++---- octoprint_klipper/static/css/klipper.css | 16 +++++----- octoprint_klipper/static/js/klipper.js | 30 ++++++++----------- octoprint_klipper/static/less/klipper.less | 5 ---- .../templates/klipper_sidebar.jinja2 | 9 ++---- 7 files changed, 54 insertions(+), 49 deletions(-) delete mode 100644 octoprint_klipper/static/less/klipper.less diff --git a/.editorconfig b/.editorconfig index 82c8e05..540df65 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,10 +8,17 @@ end_of_line = lf charset = utf-8 insert_final_newline = true trim_trailing_whitespace = true +indent_style = space +max_line_length = 90 [**.py] -indent_style = tab +indent_size = 3 -[**.js] -indent_style = space -indent_size = 4 +[**.yaml] +indent_size = 2 + +[/static/less/**.less] +indent_size = 2 + +[**.jinja2] +indent_size = 3 diff --git a/.gitignore b/.gitignore index 5d59104..b46a89f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ dist .DS_Store *.zip -*.bak \ No newline at end of file +*.bak +.vscode diff --git a/octoprint_klipper/__init__.py b/octoprint_klipper/__init__.py index 4b50863..5d9692c 100644 --- a/octoprint_klipper/__init__.py +++ b/octoprint_klipper/__init__.py @@ -59,7 +59,7 @@ class KlipperPlugin( "description": gettext("Allows to config klipper"), "default_groups": [ADMIN_GROUP], "dangerous": True, - "roles": ["admin"], + "roles": ["admin"] }, { "key": "MACRO", @@ -67,10 +67,10 @@ class KlipperPlugin( "description": gettext("Allows to use klipper macros"), "default_groups": [ADMIN_GROUP], "dangerous": True, - "roles": ["admin"], + "roles": ["admin"] }, ] - + def get_settings_defaults(self): return dict( connection = dict( @@ -118,6 +118,20 @@ class KlipperPlugin( ) return data + def reloadConfigfile(self): + data = octoprint.plugin.SettingsPlugin.on_settings_load(self) + + filepath = os.path.expanduser( + self._settings.get(["configuration", "configpath"])) + try: + f = open(filepath, "r", encoding="utf-8") + data["config"] = f.read() + f.close() + except IOError: + self._logger.error( + "Error: Klipper config file not found at: {}".format(filepath)) + return data + def on_settings_save(self, data): if "config" in data: try: @@ -346,8 +360,8 @@ class KlipperPlugin( repo="OctoprintKlipperPlugin", pip="https://github.com/thelastWallE/OctoprintKlipperPlugin/archive/{target_version}.zip", stable_branch=dict( - name="Stable", - branch="master", + name="Stable", + branch="master", comittish=["master"] ), prerelease_branches=[ @@ -396,4 +410,3 @@ def __plugin_load__(): "octoprint.comm.protocol.gcode.received": __plugin_implementation__.on_parse_gcode, "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information } - diff --git a/octoprint_klipper/static/css/klipper.css b/octoprint_klipper/static/css/klipper.css index 841c7d4..df1a37f 100644 --- a/octoprint_klipper/static/css/klipper.css +++ b/octoprint_klipper/static/css/klipper.css @@ -38,10 +38,6 @@ margin-bottom: 6px; } -#level .add-on { - padding: 5px; -} - #level .controls { padding: 1px; } @@ -80,7 +76,7 @@ ul#klipper-settings { #tab_plugin_klipper_main .span4 { flex-grow: 0; flex-shrink: 1; - max-width: 13%; + /* max-width: 13%; */ float: left; box-sizing: border-box; } @@ -109,15 +105,17 @@ ul#klipper-settings { } #macros #item.control-group { - margin-bottom: 5px; - border: 1px solid #ddd; + margin-bottom: 2px; + border: 2px solid #ccc; border-radius: 3px; - background-color: #eeeeef; + background-color: #eeeeee; color: #333; + padding-bottom: 2px; + padding-top: 2px; } #klipper_graph_dialog form { - margin: 0; + margin: 0; } #klipper_graph_dialog .graph-footer { diff --git a/octoprint_klipper/static/js/klipper.js b/octoprint_klipper/static/js/klipper.js index 1bb68c5..e899629 100644 --- a/octoprint_klipper/static/js/klipper.js +++ b/octoprint_klipper/static/js/klipper.js @@ -31,7 +31,7 @@ $(function () { dialog.modal({ show: "true", backdrop: "static", - keyboard: false, + keyboard: false }); self.levelingViewModel.initView(); }; @@ -41,7 +41,7 @@ $(function () { dialog.modal({ show: "true", backdrop: "static", - keyboard: false, + keyboard: false }); }; @@ -49,7 +49,7 @@ $(function () { var dialog = $("#klipper_offset_dialog"); dialog.modal({ show: "true", - backdrop: "static", + backdrop: "static" }); }; @@ -58,7 +58,7 @@ $(function () { dialog.modal({ show: "true", minHeight: "500px", - maxHeight: "600px", + maxHeight: "600px" }); }; @@ -79,7 +79,7 @@ $(function () { var dialog = $("#klipper_macro_dialog"); dialog.modal({ show: "true", - backdrop: "static", + backdrop: "static" }); } }; @@ -124,7 +124,7 @@ $(function () { self.logMessages.push({ time: timestamp, type: type, - msg: message.replace(/\n/gi, "
"), + msg: message.replace(/\n/gi, "
") }); }; @@ -137,14 +137,12 @@ $(function () { }; self.hasRight = function (right_role, type) { - var arg = eval( - "self.access.permissions.PLUGIN_KLIPPER_" + right_role - ); + var arg = eval("self.access.permissions.PLUGIN_KLIPPER_" + right_role); if (type == "Ko") { return self.loginState.hasPermissionKo(arg); - } - return self.loginState.hasPermission(arg); + } + return self.loginState.hasPermission(arg); }; // OctoKlipper settings link @@ -155,9 +153,7 @@ $(function () { $("li#settings_plugin_klipper_link a").click(); if (profile_type) { var query = - "#klipper-settings a[data-profile-type='" + - profile_type + - "']"; + "#klipper-settings a[data-profile-type='" + profile_type + "']"; $(query).click(); } }; @@ -171,12 +167,12 @@ $(function () { "connectionViewModel", "klipperLevelingViewModel", "klipperMacroDialogViewModel", - "accessViewModel", + "accessViewModel" ], elements: [ "#tab_plugin_klipper_main", "#sidebar_plugin_klipper", - "#navbar_plugin_klipper", - ], + "#navbar_plugin_klipper" + ] }); }); diff --git a/octoprint_klipper/static/less/klipper.less b/octoprint_klipper/static/less/klipper.less deleted file mode 100644 index 602468b..0000000 --- a/octoprint_klipper/static/less/klipper.less +++ /dev/null @@ -1,5 +0,0 @@ -#tab_plugin_klipper iframe { - width: 100%; - height: 600px; - border: 1px solid #808080; -} \ No newline at end of file diff --git a/octoprint_klipper/templates/klipper_sidebar.jinja2 b/octoprint_klipper/templates/klipper_sidebar.jinja2 index f61e193..d132e8d 100644 --- a/octoprint_klipper/templates/klipper_sidebar.jinja2 +++ b/octoprint_klipper/templates/klipper_sidebar.jinja2 @@ -7,17 +7,12 @@
-
- -
-
-
- +
-
\ No newline at end of file +