From 901e63aef9ba80001ac1cf409f37b4edba63bb8b Mon Sep 17 00:00:00 2001 From: Teja Date: Mon, 26 Jan 2015 14:24:31 +0100 Subject: [PATCH] working area fix. edit fix of default profiles --- .../plugins/lasercutterprofiles/profile.py | 16 ++++------------ .../static/js/lasercutterprofiles.js | 5 +++++ .../lasercutterprofiles_settings.jinja2 | 2 +- .../plugins/svgtogcode/static/js/working_area.js | 4 ++-- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/octoprint/plugins/lasercutterprofiles/profile.py b/src/octoprint/plugins/lasercutterprofiles/profile.py index 5fd7ed71..a8109be6 100644 --- a/src/octoprint/plugins/lasercutterprofiles/profile.py +++ b/src/octoprint/plugins/lasercutterprofiles/profile.py @@ -135,7 +135,7 @@ class LaserCutterProfileManager(object): def exists(self, identifier): if identifier is None: return False - elif identifier == "_default": + elif identifier == "_mrbeam_junior" or identifier == "_mrbeam_senior": return True else: path = self._get_profile_path(identifier) @@ -155,10 +155,8 @@ class LaserCutterProfileManager(object): results[identifier] = dict_merge(self._load_default("_mrbeam_junior"), profile) - if(not results.has_key("_mrbeam_junior")): - results["_mrbeam_junior"] = self._load_default("_mrbeam_junior") - if(not results.has_key("_mrbeam_senior")): - results["_mrbeam_senior"] = self._load_default("_mrbeam_senior") + results["_mrbeam_junior"] = self._load_default("_mrbeam_junior") + results["_mrbeam_senior"] = self._load_default("_mrbeam_senior") return results def _load_all_identifiers(self): @@ -211,7 +209,6 @@ class LaserCutterProfileManager(object): return False def _load_default(self, defaultModel = None): - default_overrides = self.settings.get([defaultModel]) default = copy.deepcopy(self.__class__.default) if(defaultModel is not None and defaultModel == "_mrbeam_senior"): default['volume']['width'] *= 2 @@ -219,12 +216,7 @@ class LaserCutterProfileManager(object): default['model'] = "Senior" default['id'] = "_mrbeam_senior" - if(default_overrides is None): - merge = default - else: - merge = dict_merge(default, default_overrides) - - profile = self._ensure_valid_profile(merge) + profile = self._ensure_valid_profile(default) if not profile: self._logger.warn("Invalid default profile after applying overrides") raise InvalidProfileError() diff --git a/src/octoprint/plugins/lasercutterprofiles/static/js/lasercutterprofiles.js b/src/octoprint/plugins/lasercutterprofiles/static/js/lasercutterprofiles.js index 9a819214..17efbc44 100644 --- a/src/octoprint/plugins/lasercutterprofiles/static/js/lasercutterprofiles.js +++ b/src/octoprint/plugins/lasercutterprofiles/static/js/lasercutterprofiles.js @@ -89,6 +89,7 @@ $(function() { var defaultProfile = undefined; var currentProfile = undefined; var currentProfileData = undefined; + console.log("lasercutterprofiles", data.profiles); _.each(data.profiles, function(entry) { if (entry.default) { defaultProfile = entry.id; @@ -207,6 +208,10 @@ $(function() { self.updateProfile(undefined, callback); } }; + + self.isReadOnly = function (data){ + return (data.id === "_mrbeam_senior" || data.id === "_mrbeam_junior"); + }; self._editorData = function() { var profile = { diff --git a/src/octoprint/plugins/lasercutterprofiles/templates/lasercutterprofiles_settings.jinja2 b/src/octoprint/plugins/lasercutterprofiles/templates/lasercutterprofiles_settings.jinja2 index 9d95654b..497667e8 100644 --- a/src/octoprint/plugins/lasercutterprofiles/templates/lasercutterprofiles_settings.jinja2 +++ b/src/octoprint/plugins/lasercutterprofiles/templates/lasercutterprofiles_settings.jinja2 @@ -14,7 +14,7 @@ -  |  |  +  |  |  diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 6824ac77..5e462b85 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -25,8 +25,8 @@ function WorkingAreaViewModel(params) { self.workingAreaHeightMM = ko.observable(undefined); self.hwRatio = ko.computed(function(){ // y/x = 297/216 respectively 594/432 - var h = self.workingAreaWidthMM(); - var w = self.workingAreaHeightMM(); + var w = self.workingAreaWidthMM(); + var h = self.workingAreaHeightMM(); // var h = self.settings.printerProfiles.currentProfileData().volume.depth(); // var w = self.settings.printerProfiles.currentProfileData().volume.width(); var ratio = h / w;