React to permission changes & fix timelapse permissions
This commit is contained in:
1 parent
b6f71eeb3b
commit
df62f08ec3
8 files changed
+25
-23
No files matched your search
@@ -355,10 +355,10 @@ class Permissions(object):
|
||||
gettext("Allows to download timelapse videos"),
|
||||
RoleNeed("timelapse_download"))
|
||||
TIMELAPSE_DELETE = OctoPrintPermission("Timelapse Delete",
|
||||
gettext("TODO"),
|
||||
gettext("Allows to delete timelapse videos and unrendered timelapses"),
|
||||
RoleNeed("timelapse_delete"))
|
||||
TIMELAPSE_ADMIN = OctoPrintPermission("Timelapse Admin",
|
||||
gettext("Allows to change the timelapse settings and"
|
||||
gettext("Allows to change the timelapse settings and delete or "
|
||||
"render unrendered timelapses. Includes the \"Timelapse List\","
|
||||
"\"Timelapse Delete\" and \"Timelapse Download\" permissions"),
|
||||
RoleNeed("timelapse_admin"), TIMELAPSE_LIST, TIMELAPSE_DOWNLOAD)
|
||||
|
||||
@@ -549,7 +549,7 @@ def _process_templates():
|
||||
control=(gettext("Control"), dict(template="tabs/control.jinja2", _div="control", styles=["display: none;"], data_bind="visible: loginState.hasAnyPermissionKo(access.permissions.WEBCAM, access.permissions.CONTROL)")),
|
||||
gcodeviewer=(gettext("GCode Viewer"), dict(template="tabs/gcodeviewer.jinja2", _div="gcode", styles=["display: none;"], data_bind="visible: loginState.hasPermissionKo(access.permissions.GCODE_VIEWER)")),
|
||||
terminal=(gettext("Terminal"), dict(template="tabs/terminal.jinja2", _div="term", styles=["display: none;"], data_bind="visible: loginState.hasPermissionKo(access.permissions.MONITOR_TERMINAL)")),
|
||||
timelapse=(gettext("Timelapse"), dict(template="tabs/timelapse.jinja2", _div="timelapse", styles=["display: none;"], data_bind="visible: loginState.hasPermissionKo(access.permissions.TIMELAPSE)"))
|
||||
timelapse=(gettext("Timelapse"), dict(template="tabs/timelapse.jinja2", _div="timelapse", styles=["display: none;"], data_bind="visible: loginState.hasPermissionKo(access.permissions.TIMELAPSE_LIST)"))
|
||||
)
|
||||
|
||||
# settings dialog
|
||||
|
||||
@@ -358,7 +358,7 @@ $(function() {
|
||||
return span + " " + offset;
|
||||
};
|
||||
|
||||
self.onStartup = function () {
|
||||
self.onUserPermissionsChanged = self.onUserLoggedIn = self.onUserLoggedOut = function() {
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
|
||||
@@ -896,8 +896,6 @@ $(function() {
|
||||
self.printerState.isSdReady.subscribe(evaluateDropzones);
|
||||
self.isPrinting.subscribe(evaluateDropzones);
|
||||
evaluateDropzones();
|
||||
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
self.onEventUpdatedFiles = function(payload) {
|
||||
|
||||
@@ -601,7 +601,6 @@ $(function() {
|
||||
};
|
||||
|
||||
self.onSettingsShown = self.requestData;
|
||||
self.onStartup = self.requestData;
|
||||
|
||||
self.onUserPermissionsChanged = self.onUserLoggedIn = self.onUserLoggedOut = function() {
|
||||
self.requestData();
|
||||
|
||||
@@ -5,6 +5,7 @@ $(function() {
|
||||
self.loginState = parameters[0];
|
||||
self.printerProfiles = parameters[1];
|
||||
self.printerState = parameters[2];
|
||||
self.access = parameters[3];
|
||||
|
||||
self.file = ko.observable(undefined);
|
||||
self.target = undefined;
|
||||
@@ -193,6 +194,10 @@ $(function() {
|
||||
});
|
||||
|
||||
self.requestData = function() {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.SLICING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return OctoPrint.slicing.listAllSlicersAndProfiles()
|
||||
.done(function(data) {
|
||||
self.fromResponse(data);
|
||||
@@ -300,7 +305,7 @@ $(function() {
|
||||
return name.replace(/[^a-zA-Z0-9\-_\.\(\) ]/g, "").replace(/ /g, "_");
|
||||
};
|
||||
|
||||
self.onStartup = function() {
|
||||
self.onUserPermissionsChanged = self.onUserLoggedIn = self.onUserLoggedOut = function() {
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
@@ -315,7 +320,7 @@ $(function() {
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: SlicingViewModel,
|
||||
dependencies: ["loginStateViewModel", "printerProfilesViewModel", "printerStateViewModel"],
|
||||
dependencies: ["loginStateViewModel", "printerProfilesViewModel", "printerStateViewModel", "accessViewModel"],
|
||||
elements: ["#slicing_configuration_dialog"]
|
||||
});
|
||||
});
|
||||
@@ -142,7 +142,7 @@ $(function() {
|
||||
);
|
||||
|
||||
self.requestData = function() {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE))
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE_LIST))
|
||||
return;
|
||||
|
||||
OctoPrint.timelapse.get(true)
|
||||
@@ -234,7 +234,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.removeFile = function(filename) {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE_ADMIN))
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE_DELETE))
|
||||
return;
|
||||
|
||||
var perform = function() {
|
||||
@@ -260,7 +260,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.removeMarkedFiles = function() {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE_ADMIN))
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE_DELETE))
|
||||
return;
|
||||
|
||||
var perform = function() {
|
||||
@@ -287,7 +287,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.removeUnrendered = function(name) {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE_ADMIN))
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE_DELETE))
|
||||
return;
|
||||
|
||||
var perform = function() {
|
||||
@@ -303,7 +303,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.removeMarkedUnrendered = function() {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE_ADMIN))
|
||||
if (!self.loginState.hasPermission(self.access.permissions.TIMELAPSE_DELETE))
|
||||
return;
|
||||
|
||||
var perform = function() {
|
||||
@@ -538,9 +538,9 @@ $(function() {
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
self.onStartup = function() {
|
||||
self.onUserPermissionsChanged = self.onUserLoggedIn = self.onUserLoggedOut = function() {
|
||||
self.requestData();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pull-left">
|
||||
<div class="pull-left" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_DELETE)">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-square-o"></i> <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
@@ -125,10 +125,10 @@
|
||||
</thead>
|
||||
<tbody data-bind="foreach: listHelper.paginatedItems">
|
||||
<tr data-bind="attr: {title: name}">
|
||||
<td class="timelapse_files_checkbox"><input type="checkbox" data-bind="value: name, checked: $root.markedForFileDeletion"></td>
|
||||
<td class="timelapse_files_checkbox"><input type="checkbox" data-bind="value: name, checked: $root.markedForFileDeletion, invisible: !$root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_DELETE)()"></td>
|
||||
<td class="timelapse_files_name" data-bind="text: name"></td>
|
||||
<td class="timelapse_files_size" data-bind="text: size"></td>
|
||||
<td class="timelapse_files_action"><a href="javascript:void(0)" class="fa fa-trash-o" data-bind="click: function() { if ($root.loginState.hasPermission($root.access.permissions.TIMELAPSE_ADMIN)) { $parent.removeFile($data.name); } else { return; } }, css: {disabled: !$root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_ADMIN)()}"></a> | <a href="javascript:void(0)" class="fa fa-download" data-bind="attr: {href: url}"></a></td>
|
||||
<td class="timelapse_files_action"><a href="javascript:void(0)" class="fa fa-trash-o" data-bind="click: function() { $parent.removeFile($data.name); }, css: {disabled: !$root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_DELETE)() }"></a> | <a href="javascript:void(0)" class="fa fa-download" data-bind="css: {disabled: !$root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_DOWNLOAD)()}, attr: { href: ($root.loginState.hasPermission($root.access.permissions.TIMELAPSE_DOWNLOAD)) ? $data.url : 'javascript:void(0)' }"></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -145,10 +145,10 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_ADMIN)() && unrenderedListHelper.allSize">
|
||||
<div data-bind="unrenderedListHelper.allSize">
|
||||
<div><small><a href="javascript:void(0)" class="muted" onclick="$(this).children().toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="fa fa-caret-right"></i> {{ _('Unrendered Timelapses') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<div class="pull-left">
|
||||
<div class="pull-left" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_DELETE)">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-square-o"></i> <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
@@ -172,13 +172,13 @@
|
||||
</thead>
|
||||
<tbody data-bind="foreach: unrenderedListHelper.paginatedItems">
|
||||
<tr data-bind="attr: {title: name}">
|
||||
<td class="timelapse_unrendered_checkbox"><input type="checkbox" data-bind="value: name, checked: $root.markedForUnrenderedDeletion"></td>
|
||||
<td class="timelapse_unrendered_checkbox"><input type="checkbox" data-bind="value: name, checked: $root.markedForUnrenderedDeletion, invisible: !$root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_DELETE)()"></td>
|
||||
<td class="timelapse_unrendered_name" data-bind="text: name"></td>
|
||||
<td class="timelapse_unrendered_count" data-bind="text: count"></td>
|
||||
<td class="timelapse_unrendered_size" data-bind="text: size"></td>
|
||||
<td class="timelapse_unrendered_action">
|
||||
<span data-bind="visible: processing"><i class="fa fa-refresh fa-spin"></i></span>
|
||||
<span data-bind="visible: !processing"><a href="javascript:void(0)" title="{{ _('Delete unrendered timelapse') }}" class="fa fa-trash-o" data-bind="click: function() { $parent.removeUnrendered($data.name); }"></a> | <a href="javascript:void(0)" title="{{ _('Render timelapse') }}" class="fa fa-video-camera" data-bind="click: function() { if (!$root.isBusy()) { $parent.renderUnrendered($data.name); } else { return; } }, css: {disabled: $root.isBusy()}"></a></span>
|
||||
<span data-bind="visible: !processing"><a href="javascript:void(0)" title="{{ _('Delete unrendered timelapse') }}" class="fa fa-trash-o" data-bind="click: function() { $parent.removeUnrendered($data.name); }, css: {disabled: !$root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_DELETE)()}"></a> | <a href="javascript:void(0)" title="{{ _('Render timelapse') }}" class="fa fa-video-camera" data-bind="click: function() { if (!$root.isBusy()) { $parent.renderUnrendered($data.name); } else { return; } }, css: {disabled: $root.isBusy() || !$root.loginState.hasPermissionKo($root.access.permissions.TIMELAPSE_ADMIN)()}"></a></span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in new issue
Block a user