update
Tested with python3 +borders around macro +macro permission role +hide macros then one has no permission
This commit is contained in:
parent
2984f072ba
commit
297554536c
|
@ -53,13 +53,22 @@ class KlipperPlugin(
|
|||
|
||||
def get_additional_permissions(self, *args, **kwargs):
|
||||
return [
|
||||
dict(key="CONFIG",
|
||||
name="Config Klipper",
|
||||
description=gettext("Allows to config klipper"),
|
||||
default_groups=[ADMIN_GROUP],
|
||||
dangerous=True,
|
||||
roles=["admin"]
|
||||
)
|
||||
{
|
||||
"key": "CONFIG",
|
||||
"name": "Config Klipper",
|
||||
"description": gettext("Allows to config klipper"),
|
||||
"default_groups": [ADMIN_GROUP],
|
||||
"dangerous": True,
|
||||
"roles": ["admin"],
|
||||
},
|
||||
{
|
||||
"key": "MACRO",
|
||||
"name": "Use Klipper Macros",
|
||||
"description": gettext("Allows to use klipper macros"),
|
||||
"default_groups": [ADMIN_GROUP],
|
||||
"dangerous": True,
|
||||
"roles": ["admin"],
|
||||
},
|
||||
]
|
||||
|
||||
def get_settings_defaults(self):
|
||||
|
@ -100,7 +109,7 @@ class KlipperPlugin(
|
|||
self._settings.get(["configuration", "configpath"])
|
||||
)
|
||||
try:
|
||||
f = open(filepath, "r")
|
||||
f = open(filepath, "r", encoding="utf-8")
|
||||
data["config"] = f.read()
|
||||
f.close()
|
||||
except IOError:
|
||||
|
@ -116,9 +125,9 @@ class KlipperPlugin(
|
|||
self._settings.get(["configuration", "configpath"])
|
||||
)
|
||||
if sys.version_info[0] < 3:
|
||||
data["config"] = data["config"].encode('utf-8')
|
||||
data["config"] = data["config"].encode('utf-8')
|
||||
|
||||
f = open(filepath, "w")
|
||||
f = open(filepath, "w", encoding="utf-8")
|
||||
f.write(data["config"])
|
||||
f.close()
|
||||
self._logger.info(
|
||||
|
|
|
@ -80,6 +80,14 @@ ul#klipper-settings {
|
|||
height: 99%;
|
||||
}
|
||||
|
||||
#macros #item.control-group {
|
||||
margin-bottom: 5px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
background-color: #eeeeef;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#klipper_graph_dialog form {
|
||||
margin: 0;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ $(function() {
|
|||
|
||||
self.shortStatus = ko.observable();
|
||||
self.logMessages = ko.observableArray();
|
||||
self.hasRight = ko.observable(false);
|
||||
|
||||
self.showLevelingDialog = function() {
|
||||
var dialog = $("#klipper_leveling_dialog");
|
||||
|
@ -126,7 +127,12 @@ $(function() {
|
|||
};
|
||||
|
||||
self.isActive = function() {
|
||||
return self.connectionState.isOperational() && self.loginState.isUser();
|
||||
return self.connectionState.isOperational() && self.loginState.hasPermission(self.access.permissions.PLUGIN_KLIPPER_CONFIG); //was: && self.loginState.isUser();
|
||||
}
|
||||
|
||||
self.hasRight = function (right_role) {
|
||||
var arg = eval("access.permissions.PLUGIN_KLIPPER_"+right_role);
|
||||
return self.loginState.hasPermissionKo(arg);
|
||||
}
|
||||
|
||||
// OctoKlipper settings link
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div data-bind="foreach: settings.settings.plugins.klipper.macros">
|
||||
<div class="control-group">
|
||||
<div class="control-group" id="item">
|
||||
<label class="control-label">{{ _('Name') }}</label>
|
||||
<div class="controls">
|
||||
<div class="row-fluid">
|
||||
|
|
Loading…
Reference in New Issue