Lots of small fixes and tweaks

This commit is contained in:
Jamie.Rees 2016-12-02 14:51:14 +00:00
commit d8e7693d8d
29 changed files with 185 additions and 67 deletions

View file

@ -9,20 +9,22 @@
<input id="email" type="email" placeholder="email address" ng-model="user.email" class="form-control form-control-custom" />
</div>
<div class="row">
<h3>Permissions: </h3>
<div>
<h3 class="col-md-5">Permissions: </h3>
<h3 class="col-md-5">Features: </h3>
</div>
<div class="col-md-5">
<div class="checkbox" ng-repeat="permission in permissions">
<input id="permission_{{$id}}" class="checkbox-custom" name="permission[]"
ng-checked="permission.selected" ng-model="permission.selected" type="checkbox" value="{{permission.value}}" />
ng-checked="permission.selected" ng-model="permission.selected" type="checkbox" value="{{permission.value}}"/>
<label for="permission_{{$id}}">{{permission.name}}</label>
</div>
</div>
<h3>Features: </h3>
<div class="col-md-5">
<div class="checkbox" ng-repeat="f in features">
<input id="features_{{$id}}" class="checkbox-custom" name="f[]"
ng-checked="f.selected" ng-model="f.selected" type="checkbox" value="{{f.value}}" />
ng-checked="f.selected" ng-model="f.selected" type="checkbox" value="{{f.value}}"/>
<label for="features_{{$id}}">{{f.name}}</label>
</div>
</div>

View file

@ -18,26 +18,29 @@
<br />
<div ng-show="selectedUser">
<!--Edit-->
<div class="row" style="margin-left: 0; margin-right: 0;">
<div class="col-md-6">
<strong>Modify Permissions:</strong>
<!--Load all permissions-->
<strong>Modify Permissions:</strong>
<!--Load all permissions-->
<div class="checkbox" ng-repeat="p in selectedUser.permissions">
<input id="permissionsCheckbox_{{$id}}" class="checkbox-custom" name="permissions[]" ng-checked="p.selected" ng-model="p.selected" type="checkbox" value="{{p.value}}" />
<label for="permissionsCheckbox_{{$id}}">{{p.name}}</label>
</div>
<strong>Modify Features:</strong>
<!--Load all features-->
<div class="checkbox" ng-repeat="p in selectedUser.features">
<input id="featuresCheckbox_{{$id}}" class="checkbox-custom" name="features[]" ng-checked="p.selected" ng-model="p.selected" type="checkbox" value="{{p.value}}" />
<label for="featuresCheckbox_{{$id}}">{{p.name}}</label>
</div>
<strong>Email Address</strong>
<div class="form-group">
<input id="emailAddress" type="email" ng-model="selectedUser.emailAddress" ng-disabled="selectedUser.type === 0" class="form-control form-control-custom" />
<div class="checkbox small-checkbox" ng-repeat="p in selectedUser.permissions">
<input id="permissionsCheckbox_{{$id}}" class="checkbox-custom" name="permissions[]" ng-checked="p.selected" ng-model="p.selected" type="checkbox" value="{{p.value}}" />
<label class="small-label" for="permissionsCheckbox_{{$id}}">{{p.name}}</label>
</div>
</div>
<div class="col-md-6">
<strong>Modify Features:</strong>
<!--Load all features-->
<div class="checkbox small-checkbox" ng-repeat="p in selectedUser.features">
<input id="featuresCheckbox_{{$id}}" class="checkbox-custom" name="features[]" ng-checked="p.selected" ng-model="p.selected" type="checkbox" value="{{p.value}}" />
<label class="small-label" for="featuresCheckbox_{{$id}}">{{p.name}}</label>
</div>
</div>
</div>
<strong>Email Address</strong>
<div class="form-group">
<input id="emailAddress" type="email" ng-model="selectedUser.emailAddress" ng-disabled="selectedUser.type === 0" class="form-control form-control-custom" />
</div>
<strong>Alias</strong>
<div class="form-group">

View file

@ -21,12 +21,6 @@
$scope.hideColumns = false;
$scope.error = {
error: false,
errorMessage: ""
};
var ReadOnlyPermission = "Read Only User";
var open = false;
@ -64,24 +58,18 @@
// Create a user, do some validation too
$scope.addUser = function () {
if (!$scope.user.username || !$scope.user.password) {
$scope.error.error = true;
$scope.error.errorMessage = "Please provide a correct username and password";
generateNotify($scope.error.errorMessage, 'warning');
generateNotify("Please provide a username and password", 'warning');
return;
}
if ($scope.selectedPermissions.length === 0) {
$scope.error.error = true;
$scope.error.errorMessage = "Please select a permission";
generateNotify($scope.error.errorMessage, 'warning');
generateNotify("Please select a permission", 'warning');
return;
}
var hasReadOnly = $scope.selectedPermissions.indexOf(ReadOnlyPermission) !== -1;
if (hasReadOnly) {
if ($scope.selectedPermissions.length > 1) {
$scope.error.error = true;
$scope.error.errorMessage = "Cannot have the " + ReadOnlyPermission + " permission with other permissions.";
generateNotify($scope.error.errorMessage, 'danger');
generateNotify("Cannot have the " + ReadOnlyPermission + " permission with other permissions.", 'danger');
return;
}
}
@ -89,8 +77,7 @@
userManagementService.addUser($scope.user, $scope.selectedPermissions, $scope.selectedFeatures)
.then(function (data) {
if (data.message) {
$scope.error.error = true;
$scope.error.errorMessage = data.message;
generateNotify(data.message, 'warning');
} else {
$scope.users.push(data.data); // Push the new user into the array to update the DOM
$scope.user = {};

View file

@ -16,6 +16,13 @@
return null;
}
if (!isArray(permissions)) {
permissions = [];
}
if (!isArray(features)) {
features = [];
}
var url = createBaseUrl(getBaseUrl(), '/usermanagement/createuser');
return $http({
@ -38,6 +45,14 @@
var updateUser = function (id, permissions, features, alias, email) {
if (!isArray(permissions)) {
permissions = [];
}
if (!isArray(features)) {
features = [];
}
var url = createBaseUrl(getBaseUrl(), '/usermanagement/updateUser');
return $http({
url: url,
@ -69,6 +84,10 @@
return $('#baseUrl').text();
}
function isArray(obj) {
return !!obj && Array === obj.constructor;
}
angular.module('PlexRequests').factory('userManagementService', ["$http", userManagementService]);
}());

View file

@ -56,6 +56,17 @@ label {
margin-bottom: 0.5rem !important;
font-size: 16px !important; }
.small-label {
display: inline-block !important;
margin-bottom: 0.5rem !important;
font-size: 11px !important; }
.small-checkbox {
min-height: 0 !important; }
.round-checkbox {
border-radius: 8px; }
.nav-tabs > li {
font-size: 13px;
line-height: 21px; }
@ -294,6 +305,45 @@ label {
text-align: center;
line-height: 13px; }
.small-checkbox label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
margin-bottom: 10px; }
.small-checkbox label:before {
content: "";
display: inline-block;
width: 18px;
height: 18px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
border: 2px solid #eee;
border-radius: 8px;
min-height: 0px !important; }
.small-checkbox input[type=checkbox] {
display: none; }
.small-checkbox input[type=checkbox]:checked + label:before {
content: "\2713";
font-size: 13px;
color: #fafafa;
text-align: center;
line-height: 13px; }
.small-checkbox label {
min-height: 0 !important;
padding-left: 20px;
margin-bottom: 0;
font-weight: normal;
cursor: pointer; }
.input-group-sm {
padding-top: 2px;
padding-bottom: 2px; }

File diff suppressed because one or more lines are too long

View file

@ -86,6 +86,21 @@ label {
margin-bottom: .5rem $i;
font-size: 16px $i;
}
.small-label {
display: inline-block $i;
margin-bottom: .5rem $i;
font-size: 11px $i;
}
.small-checkbox{
min-height:0 $i;
}
.round-checkbox {
border-radius:8px;
}
.nav-tabs > li {
font-size: 13px;
@ -369,6 +384,50 @@ $border-radius: 10px;
line-height: 13px;
}
.small-checkbox label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
margin-bottom: 10px;
}
.small-checkbox label:before {
content: "";
display: inline-block;
width: 18px;
height: 18px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
border: 2px solid #eee;
border-radius: 8px;
min-height:0px $i;
}
.small-checkbox input[type=checkbox] {
display: none;
}
.small-checkbox input[type=checkbox]:checked + label:before {
content: "\2713";
font-size: 13px;
color: #fafafa;
text-align: center;
line-height: 13px;
}
.small-checkbox label {
min-height: 0 $i;
padding-left: 20px;
margin-bottom: 0;
font-weight: normal;
cursor: pointer;
}
.input-group-sm {
padding-top: 2px;
padding-bottom: 2px;