mirror of
https://github.com/cydrobolt/polr.git
synced 2024-09-19 15:11:40 +02:00
Clean up code & remove inline styles
This commit is contained in:
parent
d52e78f475
commit
a025848eb7
@ -39,3 +39,20 @@ input.api-quota {
|
||||
table-layout: fixed;
|
||||
}
|
||||
}
|
||||
|
||||
/* User Management Styles */
|
||||
select.new-user-role {
|
||||
|
||||
}
|
||||
|
||||
a.new-user-add {
|
||||
padding-left: 0.5em
|
||||
}
|
||||
|
||||
.new-user-fields {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.new-user-fields .form-input {
|
||||
/*width: 1.5em;*/
|
||||
}
|
||||
|
@ -87,6 +87,9 @@ polr.controller('AdminCtrl', function($scope, $compile) {
|
||||
el.parent().parent().slideUp();
|
||||
};
|
||||
|
||||
/*
|
||||
User Management
|
||||
*/
|
||||
$scope.toggleUserActiveStatus = function($event) {
|
||||
var el = $($event.target);
|
||||
var user_id = el.data('user-id');
|
||||
@ -107,34 +110,30 @@ polr.controller('AdminCtrl', function($scope, $compile) {
|
||||
|
||||
$scope.toggleNewUserBox = function($event) {
|
||||
var el = $($event.target);
|
||||
$('#add_user_box').toggle();
|
||||
if (el.text() == 'Add New User') {
|
||||
$('.new-user-fields').toggle();
|
||||
|
||||
if ($('.new-user-fields').css('display') == 'block') {
|
||||
el.text('Cancel');
|
||||
$('#new_user_name').focus();
|
||||
}
|
||||
else {
|
||||
el.text('Add New User');
|
||||
$scope.resetNewUserFields();
|
||||
el.text('New');
|
||||
$('.new-user-fields input').each(function () {
|
||||
$(this).val('');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$scope.resetNewUserFields = function() {
|
||||
$('#new_user_name').val('');
|
||||
$('#new_user_password').val('');
|
||||
$('#new_user_email').val('');
|
||||
$("#new_user_role").val($("#new_user_role option:first").val());
|
||||
$('#new_user_status').text('');
|
||||
$('#new_user_status').css('color', '#000');
|
||||
};
|
||||
$scope.checkNewUserFields = function() {
|
||||
var response = true;
|
||||
|
||||
$scope.checkNewUserFiels = function() {
|
||||
var user_name = $('#new_user_name').val();
|
||||
var user_password = $('#new_user_password').val();
|
||||
var user_email = $('#new_user_email').val();
|
||||
$('.new-user-fields input').each(function () {
|
||||
console.log($(this).attr('id'));
|
||||
if ($(this).val().trim() == '' || response == false) {
|
||||
response = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (user_name.trim() == '' || user_password.trim() == '' || user_email.trim() == '') return false;
|
||||
|
||||
return true;
|
||||
return response;
|
||||
}
|
||||
|
||||
$scope.addNewUser = function($event) {
|
||||
@ -147,10 +146,10 @@ polr.controller('AdminCtrl', function($scope, $compile) {
|
||||
var user_email = $('#new_user_email').val();
|
||||
var user_role = $('#new_user_role').val();
|
||||
|
||||
if (!$scope.checkNewUserFiels()) {
|
||||
$('#new_user_status').text(status_error1);
|
||||
$('#new_user_status').css('color', '#f00');
|
||||
|
||||
if (!$scope.checkNewUserFields()) {
|
||||
$('#new-user-status').text(status_error1);
|
||||
$('#new-user-status').css('color', '#f00');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -194,17 +193,6 @@ polr.controller('AdminCtrl', function($scope, $compile) {
|
||||
});
|
||||
};
|
||||
|
||||
// Delete link
|
||||
$scope.deleteLink = function($event, link_ending) {
|
||||
var el = $($event.target);
|
||||
|
||||
apiCall('admin/delete_link', {
|
||||
'link_ending': link_ending,
|
||||
}, function(new_status) {
|
||||
$scope.hideRow(el, 'Deleted!');
|
||||
});
|
||||
};
|
||||
|
||||
// Generate new API key for user_id
|
||||
$scope.generateNewAPIKey = function($event, user_id, is_dev_tab) {
|
||||
var el = $($event.target);
|
||||
@ -240,27 +228,6 @@ polr.controller('AdminCtrl', function($scope, $compile) {
|
||||
});
|
||||
};
|
||||
|
||||
// Disable and enable links
|
||||
$scope.toggleLink = function($event, link_ending) {
|
||||
var el = $($event.target);
|
||||
var curr_action = el.text();
|
||||
|
||||
apiCall('admin/toggle_link', {
|
||||
'link_ending': link_ending,
|
||||
}, function(next_action) {
|
||||
toastr.success(curr_action + " was successful.", "Success");
|
||||
if (next_action == 'Disable') {
|
||||
el.removeClass('btn-success');
|
||||
el.addClass('btn-danger');
|
||||
} else {
|
||||
el.removeClass('btn-danger');
|
||||
el.addClass('btn-success');
|
||||
}
|
||||
|
||||
el.text(next_action);
|
||||
});
|
||||
};
|
||||
|
||||
// Update user API quotas
|
||||
$scope.updateAPIQuota = function($event, user_id) {
|
||||
var el = $($event.target);
|
||||
@ -278,7 +245,7 @@ polr.controller('AdminCtrl', function($scope, $compile) {
|
||||
// Open user API settings menu
|
||||
$scope.openAPIModal = function($event, username, user_id) {
|
||||
var el = $($event.target);
|
||||
|
||||
|
||||
api_active = $('a#api_info_btn_' + user_id).attr('data-api-active');
|
||||
api_key = $('a#api_info_btn_' + user_id).attr('data-api-key');
|
||||
api_quota = $('a#api_info_btn_' + user_id).attr('data-api-quota');
|
||||
@ -301,6 +268,46 @@ polr.controller('AdminCtrl', function($scope, $compile) {
|
||||
$scope.appendModal(mt_html, modal_id);
|
||||
};
|
||||
|
||||
/*
|
||||
Link Management
|
||||
*/
|
||||
|
||||
// Delete link
|
||||
$scope.deleteLink = function($event, link_ending) {
|
||||
var el = $($event.target);
|
||||
|
||||
apiCall('admin/delete_link', {
|
||||
'link_ending': link_ending,
|
||||
}, function(new_status) {
|
||||
$scope.hideRow(el, 'Deleted!');
|
||||
});
|
||||
};
|
||||
|
||||
// Disable and enable links
|
||||
$scope.toggleLink = function($event, link_ending) {
|
||||
var el = $($event.target);
|
||||
var curr_action = el.text();
|
||||
|
||||
apiCall('admin/toggle_link', {
|
||||
'link_ending': link_ending,
|
||||
}, function(next_action) {
|
||||
toastr.success(curr_action + " was successful.", "Success");
|
||||
if (next_action == 'Disable') {
|
||||
el.removeClass('btn-success');
|
||||
el.addClass('btn-danger');
|
||||
} else {
|
||||
el.removeClass('btn-danger');
|
||||
el.addClass('btn-success');
|
||||
}
|
||||
|
||||
el.text(next_action);
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Initialisation
|
||||
*/
|
||||
|
||||
// Initialise AdminCtrl
|
||||
$scope.init = function() {
|
||||
var modal_source = $("#modal-template").html();
|
||||
@ -340,7 +347,7 @@ function changeUserRole(what) {
|
||||
parent_td.append(add);
|
||||
$('#role_changed_' + user_id).fadeIn('normal', function() {
|
||||
$(this).delay(1000).fadeOut('slow', function() {
|
||||
$('#role_changed_' + user_id).remove();
|
||||
$('#role_changed_' + user_id).remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1,31 +1,32 @@
|
||||
<div style="margin-bottom: 30px;">
|
||||
<a ng-click="toggleNewUserBox($event)" id="add_user_btn" class='btn btn-primary btn-sm status-display'>Add New User</a>
|
||||
<div id="add_user_box" style="display: none; margin-top: 10px;">
|
||||
<div>
|
||||
<a ng-click="toggleNewUserBox($event)" class="btn btn-primary btn-sm status-display">New</a>
|
||||
<div class="new-user-fields">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th width="20%">Username</th>
|
||||
<th width="20%">Password</th>
|
||||
<th width="20%">Email</th>
|
||||
<th width="10%">Role</th>
|
||||
<th width="10%"></th>
|
||||
<th>Username</th>
|
||||
<th>Password</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="new_user_name" /></td>
|
||||
<td><input id="new_user_password" /></td>
|
||||
<td><input id="new_user_email" /></td>
|
||||
<td><input class="form-control" id="new-user-name"></td>
|
||||
<td><input class="form-control" id="new-user-password"></td>
|
||||
<td><input class="form-control" id="new-user-email"></td>
|
||||
<td>
|
||||
<select id="new_user_role" style="width: 100%; height: 85%;">
|
||||
<select class="form-control new-user-role" id="new-user-role">
|
||||
@foreach ($roles as $role_text => $role_val)
|
||||
<option value="{{$role_val}}">{{$role_text}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</td>
|
||||
<td><a ng-click="addNewUser($event)" class='btn btn-primary btn-sm status-display' style="padding-left: 15px; padding-right: 15px;">Add</a></td>
|
||||
<td><a ng-click="addNewUser($event)" class="btn btn-primary btn-sm status-display new-user-add">Add</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="new_user_status" style="text-align: center;"></div>
|
||||
<div id="new-user-status"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="{{$table_id}}" class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user