aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/stuff/test/auth.js36
1 files changed, 25 insertions, 11 deletions
diff --git a/data/stuff/test/auth.js b/data/stuff/test/auth.js
index 6f10fbf..5876a41 100644
--- a/data/stuff/test/auth.js
+++ b/data/stuff/test/auth.js
@@ -60,6 +60,16 @@ jQuery(function($) {
return false;
}
+ function set_user(user_id) {
+ return send('test/set_user', {
+ user_id: user_id,
+ }).fail(function(r) {
+ alert('Error ' + r.responseText);
+ }).done(function(r) {
+ // do nothing
+ });
+ }
+
$('#users').on('click', 'a.list-group-item', function() {
var me = $(this);
@@ -70,25 +80,27 @@ jQuery(function($) {
// show spinner
me.addClass('disabled').find('.loading').toggleClass('hidden');
- send('test/set_user', {
- user_id: me.data('user_id'),
- }).always(function() {
+ set_user(me.data('user_id')).always(function() {
// hide spinner
me.removeClass('disabled').find('.loading').toggleClass('hidden');
}).fail(function(r) {
- alert('Error ' + r.responseText);
// restore old highlight
me.removeClass('active');
last.addClass('active');
- }).done(function(r) {
- // do nothing
});
// stop event
return false;
});
- $('#create-user').click(function() {
+ $('#add-dialog').on('show.bs.modal', function() {
+ $.each(['name', 'email', 'password'], function(i, id) {
+ $('#add-' + id).val('');
+ });
+ $('#add-role').val('guest');
+ });
+
+ $('#add-confirm').click(function() {
var me = $(this);
if (me.hasClass('disabled'))
@@ -98,11 +110,11 @@ jQuery(function($) {
me.toggleClass('disabled').find('.loading').toggleClass('hidden');
send('test/add_user', {
- name: $('#user-name').val(),
+ name: $('#add-name').val(),
+ email: $('#add-email').val(),
+ password: $('#add-password').val(),
+ role: $('#add-role').val(),
active: 't',
- email: $('#user-email').val(),
- password: $('#user-password').val(),
- role: $('#user-role').val(),
}).always(function() {
// toggle loading
me.toggleClass('disabled').find('.loading').toggleClass('hidden');
@@ -110,6 +122,8 @@ jQuery(function($) {
alert('Error ' + r.responseText);
}).done(function(r) {
console.log(r);
+ reload();
+ $('#add-dialog').modal('hide');
});
// stop event