Fixed a few missing thing, Added a few Comments to some functions to explain their functionality

This commit is contained in:
Marc Hannappel committed 2017-05-05 14:53:07 +02:00
1 parent 63938c6fd3
commit 43e3648ba7
6 files changed
+87 -73

No files matched your search

+15 -15
View File
@@ -6,51 +6,51 @@
}
})(this, function(OctoPrintClient) {
var deprecatedUserClient = function (deprecatedFct, newFct, fn) {
return OctoPrintClient.deprecated("OctoPrint.users." + deprecatedFct, "OctoPrint.access." + newFct, fn);
return OctoPrintClient.deprecated("OctoPrint.users." + deprecatedFct, "OctoPrint.access.users." + newFct, fn);
};
var OctoPrintUserClient = function(base) {
this.base = base;
};
OctoPrintUserClient.prototype.list = deprecatedUserClient("list", "listUsers", function (opts) {
return this.base.access.listUsers(opts);
OctoPrintUserClient.prototype.list = deprecatedUserClient("list", "list", function (opts) {
return this.base.access.users.list(opts);
});
OctoPrintUserClient.prototype.add = deprecatedUserClient("add", "addUser", function (user, opts) {
return this.base.access.addUser(user, opts);
OctoPrintUserClient.prototype.add = deprecatedUserClient("add", "add", function (user, opts) {
return this.base.access.users.add(user, opts);
});
OctoPrintUserClient.prototype.get = deprecatedUserClient("get", "getUser", function (name, opts) {
return this.base.access.getUser(name, opts);
OctoPrintUserClient.prototype.get = deprecatedUserClient("get", "get", function (name, opts) {
return this.base.access.users.get(name, opts);
});
OctoPrintUserClient.prototype.update = deprecatedUserClient("update", "updateUser", function (name, active, admin, permissions, groups, opts) {
return this.base.access.updateUser(name, active, admin, permissions, groups, opts);
OctoPrintUserClient.prototype.update = deprecatedUserClient("update", "update", function (name, active, admin, permissions, groups, opts) {
return this.base.access.users.update(name, active, admin, permissions, groups, opts);
});
OctoPrintUserClient.prototype.delete = deprecatedUserClient("delete", "delete", function (name, opts) {
return this.base.access.deleteUser(name, opts);
return this.base.access.users.delete(name, opts);
});
OctoPrintUserClient.prototype.changePassword = deprecatedUserClient("changePassword", "changePassword", function (name, password, opts) {
return this.base.access.changeUserPassword(name, password, opts);
return this.base.access.users.changePassword(name, password, opts);
});
OctoPrintUserClient.prototype.generateApiKey = deprecatedUserClient("generateApiKey", "generateApiKey", function (name, opts) {
return this.base.access.generateUserApiKey(name, opts);
return this.base.access.users.generateApiKey(name, opts);
});
OctoPrintUserClient.prototype.resetApiKey = deprecatedUserClient("resetApiKey", "resetApiKey", function (name, opts) {
return this.base.access.resetUserApiKey(name, opts);
return this.base.access.users.resetApiKey(name, opts);
});
OctoPrintUserClient.prototype.getSettings = deprecatedUserClient("getSettings", "getSettings", function (name, opts) {
return this.base.access.getUserSettings(name, opts);
return this.base.access.users.getSettings(name, opts);
});
OctoPrintUserClient.prototype.saveSettings = deprecatedUserClient("saveSettings", "saveSettings", function (name, settings, opts) {
return this.base.access.saveUserSettings(name, settings, opts);
return this.base.access.users.saveSettings(name, settings, opts);
});
OctoPrintClient.registerComponent("users", OctoPrintUserClient);
@@ -445,6 +445,17 @@ $(function() {
})();
//~~ Shared Functions across the submenus
/////////////////////////////////////////////////////////////////
// //
// Rereference functions are taking e.g. the groups data //
// delivered with the user data and replacing with //
// the groups data delivered by the groups submenu. //
// //
// This is necessary for the editor to automatically check the //
// groups the user belongs to. //
// //
/////////////////////////////////////////////////////////////////
access.rereferenceGroupsList = function(list) {
return _.filter(access.groups.groupsList(), function(group) {
return _.findWhere(list, { name: group.name }) != undefined;
@@ -457,12 +468,15 @@ $(function() {
});
};
// Maps the group names into a comma seperated list
access.groupList = function(data) {
if (data.groups === undefined)
return "";
return _.map(data.groups, function(p) { return p.name; }).join(", ");
};
// Maps the permission names into a comma seperated list
access.permissionList = function(data) {
if (data.permissions === undefined)
return "";
@@ -5,7 +5,7 @@ $(function() {
self.loginState = parameters[0];
self.settings = parameters[1];
self.printerProfiles = parameters[2];
self.permissions = parameters[3];
self.access = parameters[3];
self.printerProfiles.profiles.items.subscribe(function() {
var allProfiles = self.printerProfiles.profiles.items();
@@ -148,7 +148,7 @@ $(function() {
OCTOPRINT_VIEWMODELS.push([
ConnectionViewModel,
["loginStateViewModel", "settingsViewModel", "printerProfilesViewModel", "permissionsViewModel"],
["loginStateViewModel", "settingsViewModel", "printerProfilesViewModel", "accessViewModel"],
"#connection_wrapper"
]);
});
+31 -31
View File
@@ -3,96 +3,96 @@ $(function() {
var self = this;
self.deprecatedUsers = function (deprecatedFct, newFct, fn) {
return OctoPrintClient.deprecated("UsersViewModel." + deprecatedFct, "AccessViewModel." + newFct, fn);
return OctoPrintClient.deprecated("UsersViewModel." + deprecatedFct, "AccessViewModel.users." + newFct, fn);
};
self.access = parameters[0];
// initialize list helper
self.listHelper = self.access.listHelper;
self.listHelper = self.access.users.listHelper;
self.emptyUser = self.access.emptyUser;
self.emptyUser = self.access.users.emptyUser;
self.currentUser = self.access.currentUser;
self.currentUser = self.access.users.currentUser;
self.editorUsername = self.access.editorUsername;
self.editorGroups = self.access.editorGroups;
self.editorPermissions = self.access.editorPermissions;
self.editorPassword = self.access.editorPassword;
self.editorRepeatedPassword = self.access.editorRepeatedPassword;
self.editorApikey = self.access.editorApikey;
self.editorActive = self.access.editorActive;
self.editorUsername = self.access.users.editorUsername;
self.editorGroups = self.access.users.editorGroups;
self.editorPermissions = self.access.users.editorPermissions;
self.editorPassword = self.access.users.editorPassword;
self.editorRepeatedPassword = self.access.users.editorRepeatedPassword;
self.editorApikey = self.access.users.editorApikey;
self.editorActive = self.access.users.editorActive;
self.editorPasswordMismatch = self.access.editorPasswordMismatch;
self.editorPasswordMismatch = self.access.users.editorPasswordMismatch;
self.requestData = self.deprecatedUsers("requestData", "requestUserData", function() {
self.access.requestData();
self.requestData = self.deprecatedUsers("requestData", "requestData", function() {
self.access.users.requestData();
});
self.fromResponse = self.deprecatedUsers("fromResponse", "fromResponseUserData", function(response) {
self.access.fromResponse(response);
self.fromResponse = self.deprecatedUsers("fromResponse", "fromResponse", function(response) {
self.access.users.fromResponse(response);
});
self.showAddUserDialog = self.deprecatedUsers("showAddUserDialog", "showAddUserDialog", function() {
self.access.showAddUserDialog();
self.access.users.showAddUserDialog();
});
self.confirmAddUser = self.deprecatedUsers("confirmAddUser", "confirmAddUser", function() {
self.access.confirmAddUser();
self.access.users.confirmAddUser();
});
self.showEditUserDialog = self.deprecatedUsers("showEditUserDialog", "showEditUserDialog", function(user) {
self.access.showEditUserDialog(ser);
self.access.users.showEditUserDialog(ser);
});
self.confirmEditUser = self.deprecatedUsers("confirmEditUser", "confirmEditUser", function() {
self.access.confirmEditUser();
self.access.users.confirmEditUser();
});
self.showChangePasswordDialog = self.deprecatedUsers("showChangePasswordDialog", "showChangePasswordDialog", function(user) {
self.access.showChangePasswordDialog(user);
self.access.users.showChangePasswordDialog(user);
});
self.confirmChangePassword = self.deprecatedUsers("confirmChangePassword", "confirmChangePassword", function() {
self.access.confirmChangePassword();
self.access.users.confirmChangePassword();
});
self.confirmGenerateApikey = self.deprecatedUsers("confirmGenerateApikey", "confirmGenerateApikey", function() {
self.access.confirmGenerateApikey();
self.access.users.confirmGenerateApikey();
});
self.confirmDeleteApikey = self.deprecatedUsers("confirmDeleteApikey", "confirmDeleteApikey", function() {
self.access.confirmDeleteApikey();
self.access.users.confirmDeleteApikey();
});
self._updateApikey = self.deprecatedUsers("_updateApikey", "_updateApikey", function(apikey) {
self.access._updateApikey(apikey);
self.access.users._updateApikey(apikey);
});
//~~ API calls
self.addUser = self.deprecatedUsers("addUser", "addUser", function(user) {
self.access.addUser(user);
self.access.users.addUser(user);
});
self.removeUser = self.deprecatedUsers("removeUser", "removeUser", function(user) {
self.access.removeUser(user);
self.access.users.removeUser(user);
});
self.updateUser = self.deprecatedUsers("updateUser", "updateUser", function(user) {
self.access.updateUser(user);
self.access.users.updateUser(user);
});
self.updatePassword = self.deprecatedUsers("updatePassword", "updatePassword", function(username, password) {
self.access.updatePassword(username, password);
self.access.users.updatePassword(username, password);
});
self.generateApikey = self.deprecatedUsers("generateApikey", "generateApikey", function(username) {
self.access.generateApikey(username);
self.access.users.generateApikey(username);
});
self.deleteApikey = self.deprecatedUsers("deleteApikey", "deleteApikey", function(username) {
self.access.deleteApikey(username);
self.access.users.deleteApikey(username);
});
}
+23 -23
View File
@@ -24,33 +24,33 @@
</div>
{% endif %}
<div class="jog-panel" style="display: none;" data-bind="visible: loginState.hasPermission(Permissions.CONTROL)">
<div class="jog-panel" style="display: none;" data-bind="visible: loginState.hasPermission(access.permissions.CONTROL)">
<!-- XY jogging control panel -->
<div id="control-jog-xy" class="jog-panel">
<h1>X/Y</h1>
<div>
<button id="control-yinc" class="btn box" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendJogCommand('y',1) }"><i class="icon-arrow-up"></i></button>
<button id="control-yinc" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('y',1) }"><i class="icon-arrow-up"></i></button>
</div>
<div>
<button id="control-xdec" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendJogCommand('x',-1) }"><i class="icon-arrow-left"></i></button>
<button id="control-xyhome" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendHomeCommand(['x', 'y']) }"><i class="icon-home"></i></button>
<button id="control-xinc" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendJogCommand('x',1) }"><i class="icon-arrow-right"></i></button>
<button id="control-xdec" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('x',-1) }"><i class="icon-arrow-left"></i></button>
<button id="control-xyhome" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() , click: function() { $root.sendHomeCommand(['x', 'y']) }"><i class="icon-home"></i></button>
<button id="control-xinc" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('x',1) }"><i class="icon-arrow-right"></i></button>
</div>
<div>
<button id="control-ydec" class="btn box" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendJogCommand('y',-1) }"><i class="icon-arrow-down"></i></button>
<button id="control-ydec" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('y',-1) }"><i class="icon-arrow-down"></i></button>
</div>
</div>
<!-- Z jogging control panel -->
<div id="control-jog-z" class="jog-panel">
<h1>Z</h1>
<div>
<button id="control-zinc" class="btn box" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendJogCommand('z',1) }"><i class="icon-arrow-up"></i></button>
<button id="control-zinc" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('z',1) }"><i class="icon-arrow-up"></i></button>
</div>
<div>
<button id="control-zhome" class="btn box" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendHomeCommand(['z']) }"><i class="icon-home"></i></button>
<button id="control-zhome" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendHomeCommand(['z']) }"><i class="icon-home"></i></button>
</div>
<div>
<button id="control-zdec" class="btn box" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendJogCommand('z',-1) }"><i class="icon-arrow-down"></i></button>
<button id="control-zdec" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('z',-1) }"><i class="icon-arrow-down"></i></button>
</div>
</div>
@@ -58,7 +58,7 @@
<div class="distance">
<div class="btn-group" data-toggle="buttons-radio" id="jog_distance">
<!-- ko foreach: distances -->
<button type="button" class="btn distance" data-bind="enable: $root.loginState.hasPermission(Permissions.CONTROL)(), text: $data, click: function() { $root.distance($data) }, css: { active: $root.distance() === $data }, attr: { id: 'control-distance' + $root.stripDistanceDecimal($data) }"></button>
<button type="button" class="btn distance" data-bind="text: $data, click: function() { $root.distance($data) }, css: { active: $root.distance() === $data }, attr: { id: 'control-distance' + $root.stripDistanceDecimal($data) }"></button>
<!-- /ko -->
</div>
</div>
@@ -66,46 +66,46 @@
<!-- Feed rate -->
<div id="control-jog-feedrate" class="jog-panel">
<input type="number" style="width: 153px" data-bind="slider: {min: 50, max: 150, step: 1, value: feedRate, tooltip: 'hide'}">
<button class="btn btn-block" style="width: 169px" data-bind="enable: isOperational() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendFeedRateCommand() }">{{ _('Feed rate:') }}<span data-bind="text: feedRate() + '%'"></span></button>
<button class="btn btn-block" style="width: 169px" data-bind="enable: isOperational(), click: function() { $root.sendFeedRateCommand() }">{{ _('Feed rate:') }}<span data-bind="text: feedRate() + '%'"></span></button>
</div>
</div>
<!-- Extrusion control panel -->
<div id="control-jog-extrusion" class="jog-panel" style="display: none;" data-bind="visible: loginState.hasPermission(Permissions.CONTROL)">
<div id="control-jog-extrusion" class="jog-panel" style="display: none;" data-bind="visible: loginState.hasPermission(access.permissions.CONTROL)">
<h1>Tool (E)</h1>
<div>
<div class="btn-group control-box">
<button class="btn dropdown-toggle" data-toggle="dropdown" data-bind="enable: isOperational() && !isPrinting() && !isPaused() && loginState.hasPermission(Permissions.CONTROL)()">
<button class="btn dropdown-toggle" data-toggle="dropdown" data-bind="enable: isOperational() && !isPrinting() && !isPaused()">
{{ _('Select Tool...') }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" data-bind="foreach: tools">
<li><a href="#" data-bind="click: $root.sendSelectToolCommand, text: name(), enable: $root.isOperational() && !$root.isPrinting() && !$root.isPaused() && $root.loginState.hasPermission(Permissions.CONTROL)()"></a></li>
<li><a href="#" data-bind="click: $root.sendSelectToolCommand, text: name(), enable: $root.isOperational() && !$root.isPrinting() && !$root.isPaused()"></a></li>
</ul>
</div>
<div class="input-append control-box">
<input type="text" class="input-mini text-right" data-bind="value: extrusionAmount, enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), attr: {placeholder: settings.printer_defaultExtrusionLength}">
<input type="text" class="input-mini text-right" data-bind="value: extrusionAmount, enable: isOperational() && !isPrinting(), attr: {placeholder: settings.printer_defaultExtrusionLength}">
<span class="add-on">mm</span>
</div>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendExtrudeCommand() }">{{ _('Extrude') }}</button>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendRetractCommand() }">{{ _('Retract') }}</button>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendExtrudeCommand() }">{{ _('Extrude') }}</button>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendRetractCommand() }">{{ _('Retract') }}</button>
<!-- Flow rate -->
<input style="width: 100px" type="number" data-bind="slider: {min: 75, max: 125, step: 1, value: flowRate, tooltip: 'hide'}">
<button class="btn btn-block control-box" data-bind="enable: isOperational() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendFlowRateCommand() }">{{ _('Flow rate:') }}<span data-bind="text: flowRate() + '%'"></span></button>
<button class="btn btn-block control-box" data-bind="enable: isOperational(), click: function() { $root.sendFlowRateCommand() }">{{ _('Flow rate:') }}<span data-bind="text: flowRate() + '%'"></span></button>
</div>
</div>
<!-- General control panel -->
<div id="control-jog-general" class="jog-panel" style="display: none;" data-bind="visible: loginState.hasPermission(Permissions.CONTROL)">
<div id="control-jog-general" class="jog-panel" style="display: none;" data-bind="visible: loginState.hasPermission(access.permissions.CONTROL)">
<h1>{{ _('General') }}</h1>
<div>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && !isPrinting() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendCustomCommand({type:'command',command:'M18'}) }">{{ _('Motors off') }}</button>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendCustomCommand({type:'command',command:'M106 S255'}) }">{{ _('Fan on') }}</button>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && loginState.hasPermission(Permissions.CONTROL)(), click: function() { $root.sendCustomCommand({type:'command',command:'M106 S0'}) }">{{ _('Fan off') }}</button>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendCustomCommand({type:'command',command:'M18'}) }">{{ _('Motors off') }}</button>
<button class="btn btn-block control-box" data-bind="enable: isOperational(), click: function() { $root.sendCustomCommand({type:'command',command:'M106 S255'}) }">{{ _('Fan on') }}</button>
<button class="btn btn-block control-box" data-bind="enable: isOperational(), click: function() { $root.sendCustomCommand({type:'command',command:'M106 S0'}) }">{{ _('Fan off') }}</button>
</div>
</div>
<!-- Container for custom controls -->
<div id="control-jog-custom" style="clear: both; display: none;" data-bind="visible: loginState.hasPermission(Permissions.CONTROL), template: { name: $root.displayMode, foreach: controls }"></div>
<div id="control-jog-custom" style="clear: both; display: none;" data-bind="visible: loginState.hasPermission(access.permissions.CONTROL), template: { name: $root.displayMode, foreach: controls }"></div>
<!-- Templates for custom controls -->
<script type="text/html" id="customControls_containerTemplate_nameless">
+2 -2
View File
@@ -674,12 +674,12 @@ class User(UserMixin):
return FlaskLoginMethodReplacedByBooleanProperty("is_active", lambda: self._active)
@property
@deprecated("is_user is deprecated please use has_permissions", since="now")
@deprecated("is_user is deprecated, please use has_permissions", since="now")
def is_user(self):
return not self.is_admin()
@property
@deprecated("is_admin is deprecated please use has_permissions", since="now")
@deprecated("is_admin is deprecated, please use has_permissions", since="now")
def is_admin(self):
return OctoPrintUserMethodReplacedByBooleanProperty("is_admin", lambda: self.has_permission(Permissions.ADMIN))