diff options
Diffstat (limited to 'public/js/pbs.js')
-rw-r--r-- | public/js/pbs.js | 504 |
1 files changed, 504 insertions, 0 deletions
diff --git a/public/js/pbs.js b/public/js/pbs.js new file mode 100644 index 0000000..f216602 --- /dev/null +++ b/public/js/pbs.js @@ -0,0 +1,504 @@ + +var bootmedia = function () { + $("#action-menu").load("/ui/subpage/get/bootmedia/actionmenu", function () { + $("#bootmedia-create-button").click(function () {bootmediaAdd();}); + }); + + $("#main").load("/ui/subpage/get/bootmedia/list", function () { + $("#bootmedia-list-content").load("/backend/bootmedia/list"); + }); +}; + +var bootmediaAdd = function () { + $("#dialog-bootmedia-create").remove(); + $("#dialog-anchor").load("/ui/dialog/get/bootmedia/create",null,function() { + /* load dropdown content */ + $.getJSON("/backend/json/kernel", + function (data) { + $.each(data, function(i, item) { + $("<option></option>").attr("value", item.kernel) + .html(item.kernel) + .appendTo("#kernel"); + }); + } + ); + + $("#dialog-bootmedia-create").dialog({ + bgiframe: true, + autoOpen: true, + minHeight: 340, + minWidth: 460, + width: 460, + modal: true, + buttons: { + 'Create ISO': function() { + var bValid = true; + + if (bValid) { + $(this).dialog('close'); + bootmediaBuild($("#kernel").val(), $("#name").val(), $("#description").val()); + } + }, + Cancel: function() { + $(this).dialog('close'); + } + }, + close: function() { + $(this).dialog('destroy'); + $("#dialog-anchor").empty(); + } + }); + + }); +}; + +var bootmediaBuild = function (kernel, name, description) { + $("#dialog-bootmedia-progress").remove(); + $("#dialog-anchor").load("/ui/dialog/get/bootmedia/progress",null,function() { + /* init progress bar */ + $("#progressbar").progressbar({ + value: 0 + }); + + $("#dialog-bootmedia-progress").dialog({ + bgiframe: true, + autoOpen: true, + minHeight: 140, + minWidth: 460, + width: 460, + modal: true, + open: function() { + $.post("/backend/mkiso/prepare", + {kernel : kernel, name : name, description : description}, + bootmediaBuildCreateiso, + "json" + ); + }, + close: function(event, ui) { + $(this).dialog('destroy'); + $("#dialog-anchor").empty(); + }, + beforeclose: function(event, ui) { + if ($("#progressbar").progressbar('option', 'value') < 100) + return false; + else + return true; + + } + + }); + + }); + + +}; + +var bootmediaBuildCreateiso = function (data) { + $("#progressbar").progressbar('value', data.progress); + $("#progress-text").text(data.progressmsg); + $.post("/backend/mkiso/createiso", + { kernel : data.kernel, + name : data.name, + description : data.description, + identifier: data.identifier }, + bootmediaBuildCleanup, + "json" + ); +}; + +var bootmediaBuildCleanup = function (data) { + $("#progressbar").progressbar('value', data.progress); + $("#progress-text").text(data.progressmsg); + $.post("/backend/mkiso/cleanup", + { kernel : data.kernel, + name : data.name, + description : data.description, + identifier: data.identifier }, + bootmediaBuildDb, + "json" + ); +}; + +var bootmediaBuildDb = function (data) { + $("#progressbar").progressbar('value', data.progress); + $("#progress-text").text(data.progressmsg); + $.post("/backend/mkiso/db", + { kernel : data.kernel, + name : data.name, + description : data.description, + identifier: data.identifier }, + function (data) { + $("#progressbar").progressbar('value', data.progress); + $("#progress-text").text(data.progressmsg); + $("#dialog-bootmedia-progress-exit").removeAttr("disabled"); + $("#bootmedia-list-content").load("/backend/bootmedia/list"); + $("#dialog-bootmedia-progress-exit").click(function () { + $("#dialog-bootmedia-progress").dialog('close'); + }); + }, + "json" + ); +}; + + +var bootmediaEdit = function (id) { + alert("not yet implemented"); +}; + +var bootmediaDelete = function (id) { + $.post("/backend/bootmedia/del", { + id : id + }, + function () { + $("#bootmedia-list-content").load("/backend/bootmedia/list"); + } + ); +}; + + +var menu = function () { + $("#action-menu").load("/ui/subpage/get/menu/actionmenu", function () { + $("#menu-create-button").click(function () {menuAdd();}); + }); + + menuMain(); +}; + +var menuMain = function () { + $("#main").load("/ui/subpage/get/menu/list", function () { + $("#menu-list-content").load("/backend/menu/list"); + }); +}; + +var menuAdd = function () { + $("#dialog-menu-create").remove(); + $("#dialog-anchor").load("/ui/dialog/get/menu/create",null,function() { + /* load dropdown content */ + + $("#dialog-menu-create").dialog({ + bgiframe: true, + autoOpen: true, + minHeight: 340, + minWidth: 460, + width: 460, + modal: true, + buttons: { + 'Create Menu': function() { + var bValid = true; + + if (bValid) { + $(this).dialog('close'); + menuBuild( + $("#dialog-menu-create-name").val(), + $("#dialog-menu-create-description").val() + ); + } + }, + Cancel: function() { + $(this).dialog('close'); + } + }, + close: function() { + $(this).dialog('destroy'); + $("#dialog-anchor").empty(); + } + }); + + }); +}; + +var menuBuild = function (name, description) { + $.post("/backend/menu/add", + {name : name, description : description}, + function () { + $("#menu-list-content").load("/backend/menu/list"); + } + ); +}; + + +var curMenuPointer = null; + +var menuEditentries = function (id) { + curMenuPointer = id; + $("#action-menu").load("/ui/subpage/get/menu/actionmenu-entries", function () { + $("#menu-createentry-button").click(function () {menuCreateentry();}); + $("#menu-arrangeentries-button").click(function () {menuArrangeentries();}); + $("#menu-list-button").click(function () {menu();}); + }); + $("#main").load("/ui/subpage/get/menu/entrylist/id/"+id+"/", function () { + $("#menuentries-list-content").load("/backend/menu/listentries/id/"+id+"/"); + $("#menuentries-list-content").sortable({ + placeholder: 'ui-state-highlight', + handle: '.sortHandle' + }); + }); +}; + + +var menuEdit = function () { + alert("not yet implemented: "+curMenuPointer); +}; + +var menuDelete = function (id) { + $.post("/backend/menu/del", { + id : id + }, + function () { + $("#menu-list-content").load("/backend/menu/list"); + } + ); +}; + +var menuCreateentry = function (id) { + $("#dialog-menu-createentry").remove(); + $("#dialog-anchor").load("/ui/dialog/get/menu/createentry",null,function() { + /* load dropdown content */ + $.getJSON("/backend/json/sources/", + function (data) { + $.each(data, function(i, item) { + $("<option></option>").attr("value", item.ip) + .html("["+item.ip+"] OpenSLX "+ item.version) + .appendTo("#dialog-menu-createentry-source"); + }); + $("#dialog-menu-createentry-source").removeAttr("disabled"); + $("#dialog-menu-createentry-source").change(function () { + if ($("#dialog-menu-createentry-source").val() != 'none'){ + $(".source-defaultentry").remove(); + $(".system-defaultentry").html("loading.."); + + $.getJSON("/backend/json/systems/ip/"+$("#dialog-menu-createentry-source").val()+"/", + function (data) { + $(".system-defaultentry").remove(); + $("#dialog-menu-createentry-system").removeAttr("disabled"); + $.each(data, function(i, item) { + $("<option></option>").attr("value", item.id) + .html(item.name) + .appendTo("#dialog-menu-createentry-system"); + }); + } + ); + } + + }); + $("#dialog-menu-createentry-system").change(function () { + if ($("#dialog-menu-createentry-system").val() != 'none'){ + $(".system-defaultentry").remove(); + } + }); + } + ); + $("#dialog-menu-createentry").dialog({ + bgiframe: true, + autoOpen: true, + minHeight: 140, + minWidth: 460, + width: 460, + modal: true, + buttons: { + 'Next': function() { + var bValid = true; + + if (bValid) { + $(this).dialog('close'); + menuCreateEntryStep2( + $("#dialog-menu-createentry-source").val(), + $("#dialog-menu-createentry-system").val() + ); + } + }, + Cancel: function() { + $(this).dialog('close'); + } + }, + close: function(event, ui) { + $(this).dialog('destroy'); + $("#dialog-anchor").empty(); + } + }); + + }); +}; + +var menuCreateEntryStep2 = function (source, system) { + $("#dialog-menu-createentry2").remove(); + $("#dialog-anchor").load("/ui/dialog/get/menu/createentry2/",null,function() { + $("#dialog-menu-createentry2-system").attr({value:system}); + $("#dialog-menu-createentry2").dialog({ + bgiframe: true, + autoOpen: true, + minHeight: 140, + minWidth: 460, + width: 460, + modal: true, + buttons: { + 'Finish': function() { + var bValid = true; + + if (bValid) { + $(this).dialog('close'); + menuCreateEntryStep3( + $("#dialog-menu-createentry2-system").val(), + $("input[name=alternative-caption]:checked").val(), + $("#dialog-menu-createentry2-caption").val(), + $("input[name=alternative-append]:checked").val(), + $("#dialog-menu-createentry2-append").val() + ); + + } + }, + Cancel: function() { + $(this).dialog('close'); + } + }, + close: function(event, ui) { + $(this).dialog('destroy'); + $("#dialog-anchor").empty(); + } + }); + }); +}; + +var menuCreateEntryStep3 = function (system, altCaptionSet, altCaption, altAppendSet, altAppend) { + $.post("/backend/menu/addentry", { + menu : curMenuPointer, + system : system, + altCaptionSet : altCaptionSet, + altCaption : altCaption, + altAppendSet : altAppendSet, + altAppend : altAppend + }, + function () { + $("#menuentries-list-content").load("/backend/menu/listentries/id/"+curMenuPointer+"/"); + $("#menuentries-list-content").sortable({ + placeholder: 'ui-state-highlight', + handle: '.sortHandle' + }); + $("#menuentries-list-content").disableSelection(); + + } + ); + +}; + +var menuEntryDelete = function (id) { + $.post("/backend/menu/delentry", { + id : id + }, + function () { + $("#menuentries-list-content").load("/backend/menu/listentries/id/"+curMenuPointer+"/"); + $("#menuentries-list-content").sortable({ + placeholder: 'ui-state-highlight', + handle: '.sortHandle' + }); + $("#menuentries-list-content").disableSelection(); + + } + ); +}; + +var menuEntryEdit = function (id) { + alert("not yet implemented"); +}; + +var menuArrangeentries = function () { + var data = ''; + $("#menuentries-list-content .menuentries-item-id-value").each(function (i, el) { + data = data + $(el).html()+':'+ i +';'; + }); + $.post("/backend/menu/saveentryorder", { + data : data + }, + function () {} + ); +}; + + + +var menuAssignment = function () { + $("#action-menu").load("/ui/subpage/get/menu/actionmenu-menuassignment", function () { + $("#menuassignment-create-button").click(function () {menuCreateAssignment();}); + }); + $("#main").load("/ui/subpage/get/menu/assignmentlist/", function () { + $("#menuassignment-list-content").load("/backend/menu/listassignments/"); + }); +}; + +var menuCreateAssignment = function (id) { + $("#dialog-menu-createassignment").remove(); + $("#dialog-anchor").load("/ui/dialog/get/menu/createassignment",null,function() { + /* load dropdown content */ + $.getJSON("/backend/json/menu/", + function (data) { + $.each(data, function(i, item) { + $("<option></option>").attr("value", item.id) + .html(item.name) + .appendTo("#dialog-menu-createassignment-menu"); + }); + $("#dialog-menu-createassignment-menu").removeAttr("disabled"); + $("#dialog-menu-createassignment-menu").change(function () { + if ($("#dialog-menu-createassignment-menu").val() != 'none'){ + $(".menu-defaultentry").remove(); + } + + }); + } + ); + + $.getJSON("/backend/json/bootmedia/", + function (data) { + $.each(data, function(i, item) { + $("<option></option>").attr("value", item.id) + .html(item.name) + .appendTo("#dialog-menu-createassignment-bootmedia"); + }); + $("#dialog-menu-createassignment-bootmedia").removeAttr("disabled"); + } + ); + + $("#dialog-menu-createassignment").dialog({ + bgiframe: true, + autoOpen: true, + minHeight: 140, + minWidth: 460, + width: 460, + modal: true, + buttons: { + 'Save': function() { + var bValid = true; + + if (bValid) { + $(this).dialog('close'); + menuCreateAssignmentStep2( + $("#dialog-menu-createassignment-name").val(), + $("#dialog-menu-createassignment-menu").val(), + $("#dialog-menu-createassignment-bootmedia").val(), + $("#dialog-menu-createassignment-ip").val() + ); + } + }, + Cancel: function() { + $(this).dialog('close'); + } + }, + close: function(event, ui) { + $(this).dialog('destroy'); + $("#dialog-anchor").empty(); + } + }); + + }); +}; + +var menuCreateAssignmentStep2 = function (name, menu, bootmedia, ip) { + $.post("/backend/menu/addassignment", { + name : name, + menu : menu, + bootmedia : bootmedia, + ip : ip + }, + function () { + $("#menuassignments-list-content").load("/backend/menu/listassignments/"); + }); +}; + |