aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/assets/js/admin/dialogs/user-add.js17
-rw-r--r--src/views/admin-page.ecr100
2 files changed, 85 insertions, 32 deletions
diff --git a/data/assets/js/admin/dialogs/user-add.js b/data/assets/js/admin/dialogs/user-add.js
index 692d8a4..16757bb 100644
--- a/data/assets/js/admin/dialogs/user-add.js
+++ b/data/assets/js/admin/dialogs/user-add.js
@@ -6,6 +6,7 @@ jQuery(function($) {
$('#user-add-' + id).val('');
});
$('#user-add-role').val('viewer');
+ $('#user-add-active').val('inactive');
});
$('#user-add-dialog').on('shown.bs.modal', function() {
@@ -32,19 +33,27 @@ jQuery(function($) {
// toggle loading
me.toggleClass('disabled').find('.loading').toggleClass('hidden');
- send('test/add_user', {
+ send('user/add', {
name: $('#user-add-name').val(),
email: $('#user-add-email').val(),
password: $('#user-add-password').val(),
role: $('#user-add-role').val(),
- active: 't',
+ active: ($('#user-add-active').val() == 'active') ? 't' : 'f',
}).always(function() {
// toggle loading
me.toggleClass('disabled').find('.loading').toggleClass('hidden');
}).fail(function(r) {
- alert('Error ' + r.responseText);
+ var error = r.responseText;
+
+ try {
+ var data = $.parseJSON(r.responseText);
+
+ if (data.error)
+ error = data.error;
+ } catch (e) {}
+
+ alert('Error: ' + error);
}).done(function(r) {
- console.log(r);
$('#users-reload').click();
$('#user-add-dialog').modal('hide');
});
diff --git a/src/views/admin-page.ecr b/src/views/admin-page.ecr
index 7845682..89a75d0 100644
--- a/src/views/admin-page.ecr
+++ b/src/views/admin-page.ecr
@@ -440,21 +440,7 @@
</h4><!-- modal-title -->
</div><!-- modal-header -->
- <div class='modal-body loading-text'>
- <p>
- <i class='fa fa-spinner fa-spin'></i>
- Loading...
- </p>
- </div><!-- modal-body -->
-
- <div class='modal-body loading-error'>
- <div class='well'>
- <i class='fa fa-exclamation-triangle'></i>
- Error: <span class='error-text'></span>
- </div><!-- well -->
- </div><!-- modal-body -->
-
- <div class='modal-body loading-done'>
+ <div class='modal-body'>
<div class='form-group'>
<label for='user-add-name'>
Name
@@ -466,7 +452,12 @@
class='form-control'
title='Enter name of user.'
placeholder='John Doe'
+ aria-describedby='user-add-name-help'
/>
+
+ <p id='user-add-name-help' class='help-block'>
+ Visible name of user.
+ </p>
</div><!-- form-group -->
<div class='form-group'>
@@ -480,7 +471,12 @@
class='form-control'
title='Enter user email.'
placeholder='johndoe@example.com'
+ aria-describedby='user-add-email-help'
/>
+
+ <p id='user-add-email-help' class='help-block'>
+ Email address (and login) of user.
+ </p>
</div><!-- form-group -->
<div class='form-group'>
@@ -493,29 +489,77 @@
id='user-add-password'
class='form-control'
title='Enter password.'
+ aria-describedby='user-add-password-help'
/>
+
+ <p id='user-add-password-help' class='help-block'>
+ User password.
+ </p>
</div><!-- form-group -->
- <div class='form-group'>
- <label for='user-add-role'>
- Role
- </label>
+ <div class='row'>
+ <div class='col-md-6'>
+ <div class='form-group'>
+ <label for='user-add-role'>
+ Role
+ </label>
- <select
- id='user-add-role'
- class='form-control'
- title='Choose role of user.'
- ><%=
- role_options
- %></select>
- </div><!-- form-group -->
+ <select
+ id='user-add-role'
+ class='form-control'
+ title='Choose role of user.'
+ aria-describedby='user-add-role-help'
+ ><%=
+ role_options
+ %></select>
+
+ <p id='user-add-role-help' class='help-block'>
+ User role.
+ </p>
+ </div><!-- form-group -->
+ </div><!-- col-md-6 -->
+
+ <div class='col-md-6'>
+ <div class='form-group'>
+ <label for='user-add-active'>
+ Active
+ </label>
+
+ <select
+ id='user-add-active'
+ class='form-control'
+ title='Choose active state of user.'
+ aria-describedby='user-add-active-help'
+ >
+ <option
+ value='inactive'
+ selected='selected'
+ title='Inactive: user cannot log in.'
+ >
+ Inactive
+ </option>
+
+ <option
+ value='active'
+ title='Active: user can log in.'
+ >
+ Active
+ </option>
+ </select>
+
+ <p id='user-add-active-help' class='help-block'>
+ Is this user active?
+ </p>
+ </div><!-- form-group -->
+ </div><!-- col-md-6 -->
+ </div><!-- row -->
</div><!-- modal-body -->
<div class='modal-footer'>
<button
id='user-add-confirm'
class='btn btn-primary'
- title='Create new user.'
+ title='Create user.'
>
<span class='hidden loading'>
<i class='fa fa-spinner fa-spin'></i>