static.js.workflows.js Maven / Gradle / Ivy
function updateClientList() {
$.getJSON("/api/clients/list", function(data) {
$(".clientlist").append(
$.map(data.clients, function (item, index) {
return '';
}).join());
clientListOnChange();
});
}
function clientListOnChange() {
var client = $("#workflowsclient");
updateWorkflowsTable(client.val());
}
function updateWorkflowsTable(client) {
$.getJSON("/api/workflows/list?client=" + client, function(data) {
var count = 0;
$("#workflowlisttable > tbody").html("");
$("#workflowlisttable").append(
$.map(data.workflows, function (item, index) {
count++;
return ''
+ '' + item.name + ' '
+ '' + item.uuid + ' '
+ '' + item.updated_date + ' '
+ ' '
+ ' ';
}).join());
if (count == 0) {
$("#workflowlisttable").append("No Workflow(s) ");
}
});
}
function updateWorkflowsTable2(workflowname, workflowuuid) {
var client = $("#workflowsclient").val();
$("#workflowlisttitle2").html(workflowname + " Workflow(s)");
$.getJSON("/api/workflows/list?client=" + client + "&workflow=" + workflowuuid, function(data) {
var count = 0;
$("#workflowlisttable2 > tbody").html("");
$("#workflowlisttable2").append(
$.map(data.workflows, function (item, index) {
count++;
return ''
+ '' + item.name + ' '
+ '' + item.uuid + ' '
+ '' + item.updated_date + ' '
+ ' ';
}).join());
if (count == 0) {
$("#workflowlisttable2").append("No Workflows ");
}
});
}
function backbutton() {
updateClientList();
$("#workflowlist").slideDown( "slow", function() {
$("#uploadworkflow").hide();
hidemessages();
});
}
$(document).ready(function() {
$("#uploadworkflow").hide();
$("#workflowlist2").hide();
updateClientList();
$(".clientlist").change(function() {
clientListOnChange();
});
$(".backbutton").click(function(){
backbutton();
});
$("#workflowlisttable").on( "click", "button", function() {
var list = $(this).closest('tr').children('td')
var name = list[0].innerHTML;
var uuid = list[1].innerHTML;
updateWorkflowsTable2(name, uuid);
$("#workflowlist2").slideDown( "fast", function() {
});
});
$("#uploadworkflowbutton").click(function() {
$("#uploadworkflow").show();
$("#workflowlist2").hide();
$("#workflowlist").slideUp( "slow", function() {
});
});
$('#uploadworkflowworkflow').submit(function(e) {
$.ajax( {
url: '/api/workflows/save',
type: 'POST',
contentType: false,
data: new FormData(this),
processData: false
}).done(function() {
hidemessages();
showsuccess("#uploadworkflowworkflow", "Workflow Uploaded");
document.getElementById("uploadworkflowworkflow").reset();
}).fail(function(data) {
hidemessages();
var text = JSON.parse(data.responseText)
showerror("#uploadworkflowworkflow", "Unable to Upload - " + text.message);
});
e.preventDefault();
});
});