diff --git a/xCAT-UI/js/custom/esx.js b/xCAT-UI/js/custom/esx.js index 8ffa72b5c..430a45a83 100644 --- a/xCAT-UI/js/custom/esx.js +++ b/xCAT-UI/js/custom/esx.js @@ -22,7 +22,7 @@ var esxPlugin = function() { * @return Nothing */ esxPlugin.prototype.serviceClone = function(node) { - + openDialog('info', 'Not yet supported'); }; /** @@ -33,7 +33,7 @@ esxPlugin.prototype.serviceClone = function(node) { * @return Nothing */ esxPlugin.prototype.loadServiceProvisionPage = function(tabId) { - + $('#' + tabId).append(createInfoBar('Not yet supported')); }; /** diff --git a/xCAT-UI/js/custom/kvm.js b/xCAT-UI/js/custom/kvm.js index 90c5d9318..25a745fe2 100644 --- a/xCAT-UI/js/custom/kvm.js +++ b/xCAT-UI/js/custom/kvm.js @@ -22,7 +22,7 @@ var kvmPlugin = function() { * @return Nothing */ kvmPlugin.prototype.serviceClone = function(node) { - + openDialog('info', 'Not yet supported'); }; /** @@ -33,7 +33,7 @@ kvmPlugin.prototype.serviceClone = function(node) { * @return Nothing */ kvmPlugin.prototype.loadServiceProvisionPage = function(tabId) { - + $('#' + tabId).append(createInfoBar('Not yet supported')); }; /** diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js index e7d92a566..dff145741 100644 --- a/xCAT-UI/js/nodes/nodes.js +++ b/xCAT-UI/js/nodes/nodes.js @@ -2030,7 +2030,7 @@ function updateStatusBar(data) { $('#' + statBarId).find('img').hide(); // Write ajax response to status bar - var prg = writeRsp(rsp, ''); + var prg = writeRsp(rsp, ''); $('#' + statBarId).find('div').append(prg); // If there was an error, do not continue @@ -2047,9 +2047,6 @@ function updateStatusBar(data) { dTable.fnDeleteRow(rowPos); } } - - // Adjust column size - adjustColumnSize(nodesTableId); } else if (cmd == 'xdsh') { // Hide loader $('#' + statBarId).find('img').hide(); @@ -2316,12 +2313,10 @@ function setGroupsCookies(data) { * Column to find string under * @return The row index containing the search string */ -function findRow(str, table, col){ - var dTable, rows, cols; - +function findRow(str, table, col){ // Get datatable - dTable = $(table).dataTable(); - rows = dTable.fnGetData(); + var dTable = $(table).dataTable(); + var rows = dTable.fnGetData(); // Loop through each row for (var i in rows) { diff --git a/xCAT-UI/js/provision/images.js b/xCAT-UI/js/provision/images.js index 19162a96e..9f7476aa7 100644 --- a/xCAT-UI/js/provision/images.js +++ b/xCAT-UI/js/provision/images.js @@ -140,7 +140,7 @@ function loadImages(data) { // Copy CD into install directory var copyCDLnk = $('Copy CD'); copyCDLnk.click(function() { - loadCopyCdPage(); + openCopyCdDialog(); }); // Generate stateless or statelite image @@ -155,7 +155,7 @@ function loadImages(data) { var tgtImages = getNodesChecked(imgTableId).split(','); if (tgtImages) { for (var i in tgtImages) { - loadEditImagePage(tgtImages[i]); + openEditImagePage(tgtImages[i]); } } }); @@ -163,7 +163,7 @@ function loadImages(data) { // Add a row var addLnk = $('Add'); addLnk.click(function() { - loadAddImageDialog(); + openAddImageDialog(); }); // Remove a row @@ -354,10 +354,8 @@ function confirmImageDeleteDialog(images) { /** * Open a dialog to add an image - * - * @return Nothing */ -function loadAddImageDialog() { +function openAddImageDialog() { // Create dialog to add image var dialogId = 'addImage'; var addImageForm = $('
'); @@ -383,6 +381,30 @@ function loadAddImageDialog() { provisionMethod.append(provisionSelect); // Create inputs for optional attributes + var exList = $('
'); + var exListInput = $(''); + exList.append(exListInput); + exListInput.serverBrowser({ + onSelect : function(path) { + $('#addImage input[name="exlist"]').val(path); + }, + onLoad : function() { + return $('#addImage input[name="exlist"]').val(); + }, + knownPaths : [{ + text : 'Install', + image : 'desktop.png', + path : '/install' + }], + imageUrl : 'images/serverbrowser/', + systemImageUrl : 'images/serverbrowser/', + handlerUrl : 'lib/getpath.php', + title : 'Browse', + requestMethod : 'POST', + width : '500', + height : '300', + basePath : '/install' // Limit user to only install directory + }); var otherpkgDirectory = $('
'); var otherpkgDirectoryInput = $(''); otherpkgDirectory.append(otherpkgDirectoryInput); @@ -455,6 +477,30 @@ function loadAddImageDialog() { height : '300', basePath : '/install' // Limit user to only install directory }); + var postInstall = $('
'); + var postInstallInput = $(''); + postInstall.append(postInstallInput); + postInstallInput.serverBrowser({ + onSelect : function(path) { + $('#addImage input[name="postinstall"]').val(path); + }, + onLoad : function() { + return $('#addImage input[name="postinstall"]').val(); + }, + knownPaths : [{ + text : 'Install', + image : 'desktop.png', + path : '/install' + }], + imageUrl : 'images/serverbrowser/', + systemImageUrl : 'images/serverbrowser/', + handlerUrl : 'lib/getpath.php', + title : 'Browse', + requestMethod : 'POST', + width : '500', + height : '300', + basePath : '/install' // Limit user to only install directory + }); var template = $('
'); var templateInput = $(''); template.append(templateInput); @@ -481,63 +527,81 @@ function loadAddImageDialog() { }); addImageForm.append(imageName, imageType, architecture, osName, osVersion, profile, provisionMethod, - otherpkgDirectory, packageDirectory, packageList, template); + exList, otherpkgDirectory, packageDirectory, packageList, postInstall, template); // Open dialog to add image addImageForm.dialog({ title:'Add image', modal: true, - width: 500, + width: 400, buttons: { "Ok": function(){ // Remove any warning messages $(this).find('.ui-state-error').remove(); // Get image attributes - var imageType = $(this).find('input[name="imagetype"]').val(); - var architecture = $(this).find('input[name="osarch"]').val(); - var osName = $(this).find('input[name="osname"]').val(); - var osVersion = $(this).find('input[name="osvers"]').val(); - var profile = $(this).find('input[name="profile"]').val(); - var provisionMethod = $(this).find('select[name="provmethod"]').val(); + var imageType = $(this).find('input[name="imagetype"]'); + var architecture = $(this).find('input[name="osarch"]'); + var osName = $(this).find('input[name="osname"]'); + var osVersion = $(this).find('input[name="osvers"]'); + var profile = $(this).find('input[name="profile"]'); + var provisionMethod = $(this).find('select[name="provmethod"]'); // Get optional image attributes - var otherpkgDirectory = $(this).find('input[name="otherpkgdir"]').val(); - var pkgDirectory = $(this).find('input[name="pkgdir"]').val(); - var pkgList = $(this).find('input[name="pkglist"]').val(); - var template = $(this).find('input[name="template"]').val(); + var exList = $(this).find('input[name="exlist"]'); + var otherpkgDirectory = $(this).find('input[name="otherpkgdir"]'); + var pkgDirectory = $(this).find('input[name="pkgdir"]'); + var pkgList = $(this).find('input[name="pkglist"]'); + var postInstall = $(this).find('input[name="postinstall"]'); + var template = $(this).find('input[name="template"]'); - // Override image name - $(this).find('input[name="imagename"]').val(osVersion + '-' + architecture + '-' + provisionMethod + '-' + profile); - var imageName = $(this).find('input[name="imagename"]').val(); + // Check that image attributes are provided before continuing + var ready = 1; + var inputs = new Array(imageType, architecture, osName, osVersion, profile, provisionMethod); + for (var i in inputs) { + if (!inputs[i].val()) { + inputs[i].css('border-color', 'red'); + ready = 0; + } else + inputs[i].css('border-color', ''); + } // If inputs are not complete, show warning message - if (!imageType || !architecture || !osName || !osVersion || !profile || !provisionMethod) { + if (!ready) { var warn = createWarnBar('Please provide a value for each missing field.'); warn.prependTo($(this)); } else { + // Override image name + $(this).find('input[name="imagename"]').val(osVersion.val() + '-' + architecture.val() + '-' + provisionMethod.val() + '-' + profile.val()); + var imageName = $(this).find('input[name="imagename"]'); + // Change dialog buttons $(this).dialog('option', 'buttons', { 'Close': function() {$(this).dialog("close");} }); // Create arguments to send via AJAX - var args = '-t;osimage;-o;' + imageName + ';' + - 'imagetype=' + imageType + ';' + - 'osarch=' + architecture + ';' + - 'osname=' + osName + ';' + - 'osvers=' + osVersion + ';' + - 'profile=' + profile + ';' + - 'provmethod=' + provisionMethod; + var args = '-t;osimage;-o;' + imageName.val() + ';' + + 'imagetype=' + imageType.val() + ';' + + 'osarch=' + architecture.val() + ';' + + 'osname=' + osName.val() + ';' + + 'osvers=' + osVersion.val() + ';' + + 'profile=' + profile.val() + ';' + + 'provmethod=' + provisionMethod.val(); - if (otherpkgDirectory) - args += ';otherpkgdir=' + otherpkgDirectory; - if (pkgDirectory) - args += ';pkgdir=' + pkgDirectory; - if (pkgList) - args += ';pkglist=' + pkgList; - if (template) - args += ';template=' + template; + // Get optional attributes + if (exList.val()) + args += ';exlist=' + exList.val(); + if (otherpkgDirectory.val()) + args += ';otherpkgdir=' + otherpkgDirectory.val(); + if (pkgDirectory.val()) + args += ';pkgdir=' + pkgDirectory.val(); + if (pkgList.val()) + args += ';pkglist=' + pkgList.val(); + if (postInstall.val()) + args += ';postinstall=' + postInstall.val(); + if (template.val()) + args += ';template=' + template.val(); // Add image to xCAT $.ajax( { @@ -571,13 +635,23 @@ function loadAddImageDialog() { function updateImageDialog(data) { var dialogId = data.msg; var infoMsg; + + // Delete loader if one does exist + $('.ui-dialog #' + dialogId + ' img[src="images/loader.gif"]').remove(); // Create info message if (jQuery.isArray(data.rsp)) { infoMsg = ''; - for (var i in data.rsp) { + + // If the data returned is more than 10 lines, get only the last line + var i, start; + if (data.rsp.length > 10) + start = data.rsp.length - 1; + else + start = 0; + + for (i = start; i < data.rsp.length; i++) infoMsg += data.rsp[i] + '
'; - } } else { infoMsg = data.rsp; } @@ -956,7 +1030,7 @@ function hpcShow() { * Target image to set properties * @return Nothing */ -function loadEditImagePage(tgtImage) { +function openEditImagePage(tgtImage) { // Get nodes tab var tab = getProvisionTab(); @@ -1223,31 +1297,11 @@ function loadEditImagePage(tgtImage) { * * @return Nothing */ -function loadCopyCdPage() { - // Get provision tab - var tab = getProvisionTab(); - - // Generate new tab ID - var inst = 0; - newTabId = 'copyLinuxTab' + inst; - while ($('#' + newTabId).length) { - // If one already exists, generate another one - inst = inst + 1; - newTabId = 'copyLinuxTab' + inst; - } - +function openCopyCdDialog() { // Create copy Linux form - var copyLinuxForm = $('
'); - - // Create status bar, hide on load - var statBarId = 'copyLinuxStatusBar' + inst; - var statBar = createStatusBar(statBarId).hide(); - copyLinuxForm.append(statBar); - - // Create loader - var loader = createLoader(''); - statBar.find('div').append(loader); - + var dialogId = 'imageCopyCd'; + var copyLinuxForm = $('
'); + // Create info bar var infoBar = createInfoBar('Copy Linux distributions and service levels from CDs or DVDs to the install directory.'); copyLinuxForm.append(infoBar); @@ -1261,26 +1315,10 @@ function loadCopyCdPage() { copyLinuxForm.append(iso); // Create architecture input - copyLinuxForm.append('
'); + copyLinuxForm.append('
'); // Create distribution input - copyLinuxForm.append('
'); - - // Generate tooltips - copyLinuxForm.find('div input[title]').tooltip({ - position: "center right", - offset: [-2, 10], - effect: "fade", - opacity: 0.7, - delay: 500, - predelay: 800, - events: { - def: "mouseover,mouseout", - input: "mouseover,mouseout", - widget: "focus mouseover,blur mouseout", - tooltip: "mouseover,mouseout" - } - }); - + copyLinuxForm.append('
'); + /** * Browse */ @@ -1289,10 +1327,10 @@ function loadCopyCdPage() { // Browse server directory and files browseBtn.serverBrowser({ onSelect : function(path) { - $('#iso').val(path); + $('#imageCopyCd #iso').val(path); }, onLoad : function() { - return $('#iso').val(); + return $('#imageCopyCd #iso').val(); }, knownExt : [ 'exe', 'js', 'txt' ], knownPaths : [ { @@ -1310,90 +1348,49 @@ function loadCopyCdPage() { basePath : '/install' // Limit user to only install directory }); - /** - * Copy - */ - var copyBtn = createButton('Copy'); - copyLinuxForm.append(copyBtn); - copyBtn.bind('click', function(event) { - // Disable all inputs and buttons - $('#' + newTabId + ' input').attr('disabled', 'true'); - $('#' + newTabId + ' button').attr('disabled', 'true'); - // Show status bar and loader - $('#' + statBarId).show(); - $('#' + statBarId).find('img').show(); - - // Get Linux ISO - var iso = $('#' + newTabId + ' input[name=iso]').val(); - // Get architecture - var arch = $('#' + newTabId + ' input[name=arch]').val(); - // Get distribution - var distro = $('#' + newTabId + ' input[name=distro]').val(); + // Open dialog to copy CD + copyLinuxForm.dialog({ + title:'Copy CD', + modal: true, + width: 600, + buttons: { + "Copy": function() { + // Show loader + $('.ui-dialog #imageCopyCd').append(createLoader('')); + + // Change dialog buttons + $(this).dialog('option', 'buttons', { + 'Close': function() {$(this).dialog("close");} + }); + + // Get image attributes + var iso = $(this).find('input[name="iso"]'); + var arch = $(this).find('input[name="arch"]'); + var distro = $(this).find('input[name="distro"]'); - // Send ajax request to copy ISO - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'copycds', - tgt : '', - args : '-n;' + distro + ';-a;' + arch + ';' + iso, - msg : 'out=' + statBarId + // Send ajax request to copy ISO + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'copycds', + tgt : '', + args : '-n;' + distro.val() + ';-a;' + arch.val() + ';' + iso.val(), + msg : dialogId + }, + + success : updateImageDialog + }); }, - - /** - * Show output - * - * @param data - * Data returned from HTTP request - * @return Nothing - */ - success : function(data) { - // Get output - var out = data.rsp; - // Get status bar ID - var statBarId = data.msg.replace('out=', ''); - // Get tab ID - var tabId = statBarId.replace('copyLinuxStatusBar', 'copyLinuxTab'); - - // Go through output and append to paragraph - var prg = $('
');
-				for (var i in out) {
-					if (out[i].length > 6) {
-						prg.append(out[i] + '
'); - } - } - $('#' + statBarId).find('div').append(prg); - - // Hide loader - $('#' + statBarId).find('img').hide(); - // Enable inputs and buttons - $('#' + tabId + ' input').attr('disabled', ''); - $('#' + tabId + ' button').attr('disabled', ''); - } - }); + "Cancel": function() { + $(this).dialog( "close" ); + } + } }); - - /** - * Cancel - */ - var cancelBtn = createButton('Cancel'); - copyLinuxForm.append(cancelBtn); - cancelBtn.bind('click', function(event) { - // Close the tab - tab.remove($(this).parent().parent().attr('id')); - }); - - tab.add(newTabId, 'Copy', copyLinuxForm, true); - tab.select(newTabId); } /** * use users' input or select to create image - * - * @param - * - * @return Nothing */ function createImage() { var osvers = $("#createImageTab #osvers").val(); diff --git a/xCAT-UI/js/service/service.js b/xCAT-UI/js/service/service.js index 0a71e82da..4534556e4 100644 --- a/xCAT-UI/js/service/service.js +++ b/xCAT-UI/js/service/service.js @@ -58,10 +58,9 @@ function initServicePage() { includeJs("js/jquery/jqplot.dateAxisRenderer.min.js"); // Custom plugins - includeJs("js/custom/blade.js"); - includeJs("js/custom/ipmi.js"); + includeJs("js/custom/esx.js"); + includeJs("js/custom/kvm.js"); includeJs("js/custom/zvm.js"); - includeJs("js/custom/hmc.js"); // Enable settings link $('#xcat_settings').click(function() { diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js index dabf71a90..550260799 100644 --- a/xCAT-UI/js/ui.js +++ b/xCAT-UI/js/ui.js @@ -46,6 +46,16 @@ Tab.prototype.init = function() { } $.cookie('tabindex_history', order); + + // Find any datatable within the tab + var dTables = $(ui.panel).find('.dataTables_wrapper'); + if(dTables.length) { + // Adjust column sizes for each datatable found + for (var i = 0; i < dTables.length; i++) { + var tableId = dTables.eq(i).attr('id').replace('_wrapper', ''); + adjustColumnSize(tableId); + } + } }); // Remove dummy tab @@ -849,10 +859,6 @@ function changeTheme() { dialog.append(info); // Create select drop down for themes - var themeFS = $('
'); - dialog.append(themeFS); - var legend = $('Theme'); - themeFS.append(legend); var oList = $('
    '); oList.append($('
  1. Cupertino
  2. ')); oList.append($('
  3. Dark Hive
  4. ')); @@ -860,7 +866,7 @@ function changeTheme() { oList.append($('
  5. Start (default)
  6. ')); oList.append($('
  7. Sunny
  8. ')); oList.append($('
  9. UI Darkness
  10. ')); - themeFS.append(oList); + dialog.append(oList); if ($.cookie('xcat_theme')) { // Select theme @@ -995,16 +1001,13 @@ function changePassword() { */ function adjustColumnSize(tableId) { var cols = $('#' + tableId).find('tbody tr:eq(0) td'); - // If the column size is zero, wait until table is initialized - if (!cols.eq(1).outerWidth()) { - adjustColumnSize(tableId); - } else { + if (cols.eq(1).outerWidth()) { for (var i in cols) { var headers = $('#' + tableId + '_wrapper .dataTables_scrollHead .datatable thead tr th').eq(i); headers.css('width', cols.eq(i).outerWidth()); - } - } + } + } } /**