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

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

There is a newer version: 0.6.1
Show newest version
function saveClient(sel, url) {

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

function updateClientListTable() {
	$.getJSON("/api/clients/list", function() {
	})
	.done(function(data) {
		
		$("#clientlisttable > tbody").html("");
		$("#clientlisttable").append(
			    $.map(data.clients, function (item, index) {
			    	return '' + item.client + '' 
			    		+ '' + item.clientname + '' 
			    		+ '';
		}).join());
	})
	.fail(function(data) {
		
		var text = JSON.parse(data.responseText)
		showerror("#clienteditdiv", "Unable to Save Client - " + text.data);
	});
}

function backbutton() {
	updateClientListTable();
	$("#clientlist").slideDown( "slow", function() {    				
		$("#clientadd").hide();
	});
}

$(document).ready(function() {

	$("#clientadd").hide();
	
	updateClientListTable();
	
	$("#generatetokens").click(function() {
		$('#client').attr("value", makeid(5));
		$('#clientsecret').attr("value", makeid(10));
	});
	
	$('#clientaddform').submit(function(event) {
		saveClient($(this), "/api/clients/create")
		return false;
	});
	
	$("#addclientbutton").click(function() {
		$("#clientadd").show();
		$("#clientlist").slideUp( "slow", function() {
		});
	});
	
	$(".backbutton").click(function(){
		 backbutton();
	});
});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy