All Downloads are FREE. Search and download functionalities are using the official Maven repository.

static.js.clients.js Maven / Gradle / Ivy

function saveClient(sel, url, type) {

	var data = sel.serialize();
	
	$.ajax({
		type : 'POST',
		url  : url + "?" + data,
		contentType: 'application/json; charset=utf-8',
		dataType    : 'json',		
		success :  function(data) {
			hidemessages();			
			showsuccess(sel, "Client " + type);
		},
		error: function (data) {
			hidemessages();
			var text = JSON.parse(data.responseText)
			showerror(sel, "Unable to " + type + " Client - " + text.message);
		}
	});
}		

function updateClient(client) {
	
	$.getJSON("/api/clients/get?client=" + client, function(data) {	
		$(".clientname").attr("value", data.clientname);
		$(".client").attr("value", data.client);
	});
}

function updateClientListTable(token) {
	$.getJSON("/api/clients/list?token=" + token, function() {
	})
	.done(function(data) {
		
		$("#clientlisttable > tbody").html("");
		$("#clientlisttable").append(
			    $.map(data.clients, function (item, index) {
			    	return ''
		    			+ '' + item.clientname + '' 			    	
			    		+ '' + item.client + '' 
			    		+ '' 
			    		+ '
' + ' Edit' + ' Reset Secret' + ' Delete' + '
' + '' + ''; }).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("#clienteditdiv", "Unable to Save Client - " + text.data); }); } $(document).ready(function() { updateClientListTable(""); $("#generatetokens").click(function() { $('#client').attr("value", guid()); $('#clientsecret').attr("value", guid()); }); $("#next-button").click(function() { var token = $("#next-button").data("token"); updateClientListTable(token); }); $("#prev-button").click(function() { var token = $("#prev-button").data("token"); updateClientListTable(token); }); });




© 2015 - 2024 Weber Informatics LLC | Privacy Policy