You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/Old/Ombi.UI/Content/app/userManagement/userManagementService.js

93 lines
2.6 KiB

9 years ago
(function () {
var userManagementService = function ($http) {
$http.defaults.headers.common['Content-Type'] = 'application/json'; // Set default headers
8 years ago
9 years ago
var getUsers = function () {
8 years ago
var url = createBaseUrl(getBaseUrl(), '/usermanagement/users');
return $http.get(url);
9 years ago
};
8 years ago
var addUser = function (user, permissions, features) {
if (!user || permissions.length === 0) {
return null;
}
9 years ago
if (!isArray(permissions)) {
permissions = [];
}
if (!isArray(features)) {
features = [];
}
8 years ago
var url = createBaseUrl(getBaseUrl(), '/usermanagement/createuser');
return $http({
8 years ago
url: url,
9 years ago
method: "POST",
8 years ago
data: { username: user.username, password: user.password, permissions: permissions, features : features, email: user.email }
9 years ago
});
}
8 years ago
var getFeatures = function () {
8 years ago
var url = createBaseUrl(getBaseUrl(), '/usermanagement/features');
return $http.get(url);
8 years ago
}
8 years ago
var getPermissions = function () {
8 years ago
var url = createBaseUrl(getBaseUrl(), '/usermanagement/permissions');
return $http.get(url);
8 years ago
}
var updateUser = function (id, permissions, features, alias, email) {
8 years ago
if (!isArray(permissions)) {
permissions = [];
}
if (!isArray(features)) {
features = [];
}
8 years ago
var url = createBaseUrl(getBaseUrl(), '/usermanagement/updateUser');
return $http({
8 years ago
url: url,
method: "POST",
data: { id: id, permissions: permissions, features: features, alias: alias, emailAddress: email },
});
}
var deleteUser = function (id) {
8 years ago
var url = createBaseUrl(getBaseUrl(), '/usermanagement/deleteUser');
return $http({
8 years ago
url: url,
method: "POST",
data: { id: id }
});
}
9 years ago
return {
getUsers: getUsers,
8 years ago
addUser: addUser,
8 years ago
getFeatures: getFeatures,
getPermissions: getPermissions,
updateUser: updateUser,
deleteUser: deleteUser
9 years ago
};
}
8 years ago
function getBaseUrl() {
return $('#baseUrl').text();
}
9 years ago
function isArray(obj) {
return !!obj && Array === obj.constructor;
}
9 years ago
angular.module('PlexRequests').factory('userManagementService', ["$http", userManagementService]);
}());