![JAR search and dependency download from the Maven repository](/logo.png)
static.js.users.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of greeting Show documentation
Show all versions of greeting Show documentation
Server-side integration for the FormKiQ ios application
The newest version!
function saveUser(sel, url, successcallback) {
var data = sel.serialize();
$.ajax({
type : 'POST',
url : url + "?" + data,
contentType: 'application/json; charset=utf-8',
dataType : 'json',
success : function(data) {
hidemessages();
showsuccess(sel, "User Saved");
typeof successcallback === 'function' && successcallback(data);
},
error: function (data) {
hidemessages();
var text = JSON.parse(data.responseText)
showerror(sel, "Unable to Save - " + text.message);
}
});
}
function deleteUser(sel, url) {
var data = sel.serialize();
$.ajax({
type : 'POST',
url : url + "?" + data,
contentType: 'application/json; charset=utf-8',
dataType : 'json',
success : function(data) {
hidemessages();
showsuccess(sel, "User Deleted");
},
error: function (data) {
hidemessages();
var text = JSON.parse(data.responseText)
showerror(sel, "Unable to Delete - " + text.message);
}
});
}
function updateUserListTable(token) {
$.getJSON("/api/users/list?token=" + token, function() {
})
.done(function(data) {
$("#userlisttable > tbody").html("");
$("#userlisttable").append(
$.map(data.users, function (item, index) {
return ''
+ '' + item.email + ' '
+ '' + item.role + ' '
+ '' + item.status + ' '
+ ''
+ ' '
+ ' '
+ ''
+ ' ';
}).join());
if (data.prevtoken === undefined) {
$('#prev-button').hide();
} else {
$('#prev-button').show();
$('#prev-button').data('token', data.prevtoken);
}
if (data.nexttoken === undefined) {
$('#next-button').hide();
} else {
$("#next-button").data("token", data.nexttoken );
$('#next-button').show();
}
})
.fail(function(data) {
var text = JSON.parse(data.responseText)
showerror("#usereditdiv", "Unable to Get User List - " + text.data);
});
}
function updateClientList() {
$.getJSON("/api/clients/list", function(data) {
$(".clientlist").append(
$.map(data.clients, function (item, index) {
return '';
}).join());
});
}
function updateEditUserTable(email) {
$('.email').attr("value", email);
$.getJSON("/api/users/get?email=" + email, function(data) {
$('#statusedit').val(data.status);
$('#roleedit').val(data.role);
$("#userclientlisttable > tbody").html("");
$("#userclientlisttable").append(
$.map(data.clients, function (item, index) {
return ''
+ '' + item.client + ' '
+ '' + item.clientname + ' '
+ ' ';
}).join());
});
}
function backbutton() {
updateUserListTable("");
$("#userlist").slideDown( "slow", function() {
$("#userdelete").hide();
$("#useredit").hide();
$("#useradd").hide();
$("#userclientslist").hide();
$("#adduserclients").hide();
$("#useraddclient").val('');
hidemessages();
});
}
$(document).ready(function() {
updateClientList();
updateUserListTable("");
$("#useredit").hide();
$("#useradd").hide();
$("#userclientslist").hide();
$("#adduserclients").hide();
$("#userpassword").hide();
$("#userdelete").hide();
$("#userlisttable").on( "click", "button", function() {
var email = $(this).data("email");
updateEditUserTable(email);
if ($(this).text() == "Delete") {
$("#userdelete").show();
$("#userlist").slideUp( "slow", function() {
});
} else if ($(this).text() == "Reset Password") {
$("#userpassword").show();
$("#userlist").slideUp( "slow", function() {
});
} else {
$("#useredit").show();
$("#userclientslist").show();
$("#adduserclients").show();
$("#useradd").hide();
$("#userlist").slideUp( "slow", function() {
});
}
});
$("#adduserbutton").click(function() {
$("#useradd").show();
$("#userlist").slideUp( "slow", function() {
});
});
$("#next-button").click(function() {
var token = $("#next-button").data("token");
updateUserListTable(token);
});
$("#prev-button").click(function() {
var token = $("#prev-button").data("token");
updateUserListTable(token);
});
$(".backbutton").click(function(){
backbutton();
});
$(".saveuser").submit(function(event) {
saveUser($(this), "/api/users/save");
return false;
});
$(".deleteuser").submit(function(event) {
deleteUser($(this), "/api/users/delete");
return false;
});
$('#useraddclientform').submit(function(event) {
saveUser($(this), "/api/users/save", function(data) {
updateEditUserTable(data.id);
});
return false;
});
});
© 2015 - 2025 Weber Informatics LLC | Privacy Policy