diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js
index 66f486de6..ffaad4923 100644
--- a/xCAT-UI/js/custom/zvmUtils.js
+++ b/xCAT-UI/js/custom/zvmUtils.js
@@ -1896,10 +1896,10 @@ function loadDiskPoolTable(data) {
});
// Delete disk from pool
- var deleteLnk = $('Delete');
- deleteLnk.bind('click', function(event){
+ var removeLnk = $('Remove');
+ removeLnk.bind('click', function(event){
var disks = getNodesChecked(tableId);
- openDeleteDiskFromPoolDialog(disks);
+ openRemoveDiskFromPoolDialog(disks);
});
// Refresh table
@@ -1936,7 +1936,7 @@ function loadDiskPoolTable(data) {
var actionBar = $('
');
// Create an action menu
- var actionsMenu = createMenu([addLnk, deleteLnk, refreshLnk]);
+ var actionsMenu = createMenu([addLnk, removeLnk, refreshLnk]);
actionsMenu.superfish();
actionsMenu.css('display', 'inline-block');
actionBar.append(actionsMenu);
@@ -1964,13 +1964,13 @@ function loadDiskPoolTable(data) {
}
/**
- * Open dialog to delete disk from pool
+ * Open dialog to remove disk from pool
*
- * @param disks2delete
+ * @param disks2remove
* Disks selected in table
* @return Nothing
*/
-function openDeleteDiskFromPoolDialog(disks2delete) {
+function openRemoveDiskFromPoolDialog(disks2remove) {
// Create form to delete disk to pool
var dialogId = 'zvmDeleteDiskFromPool';
var deleteDiskForm = $('');
@@ -1992,7 +1992,7 @@ function openDeleteDiskFromPoolDialog(disks2delete) {
hcp.append(hcpSelect);
// Set region input based on those selected on table (if any)
- var region = $('');
+ var region = $('');
var group = $('');
deleteDiskForm.append(action, hcp, region, group);
diff --git a/xCAT-UI/js/provision/images.js b/xCAT-UI/js/provision/images.js
index e58edf1ec..19162a96e 100644
--- a/xCAT-UI/js/provision/images.js
+++ b/xCAT-UI/js/provision/images.js
@@ -129,7 +129,7 @@ function loadImages(data) {
$('#imagesTab').children().remove();
// Create info bar for images tab
- var info = createInfoBar('Click on a cell to edit. Click outside the table to save changes. Hit the Escape key to ignore changes.');
+ var info = createInfoBar('Double click on a cell to edit. Click outside the table to save changes. Hit the Escape key to ignore changes.');
$('#imagesTab').append(info);
/**
@@ -137,27 +137,62 @@ function loadImages(data) {
* copy Linux distribution and edit image properties
*/
- // Create copy CD link
+ // Copy CD into install directory
var copyCDLnk = $('Copy CD');
copyCDLnk.click(function() {
loadCopyCdPage();
});
- // Create image link
- var newLnk = $('Create image');
- newLnk.click(function() {
+ // Generate stateless or statelite image
+ var generateLnk = $('Generate image');
+ generateLnk.click(function() {
loadCreateImage();
});
- // Create edit link
- var editBtn = $('Edit');
- editBtn.click(function() {
+ // Edit image attributes
+ var editLnk = $('Edit');
+ editLnk.click(function() {
var tgtImages = getNodesChecked(imgTableId).split(',');
- for (var i in tgtImages) {
- loadEditImagePage(tgtImages[i]);
+ if (tgtImages) {
+ for (var i in tgtImages) {
+ loadEditImagePage(tgtImages[i]);
+ }
}
});
+ // Add a row
+ var addLnk = $('Add');
+ addLnk.click(function() {
+ loadAddImageDialog();
+ });
+
+ // Remove a row
+ var removeLnk = $('Remove');
+ removeLnk.click(function() {
+ var images = getNodesChecked(imgTableId);
+ if (images) {
+ confirmImageDeleteDialog(images);
+ }
+ });
+
+ // Refresh image table
+ var refreshLnk = $('Refresh');
+ refreshLnk.click(function() {
+ // Get images within the database
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'lsdef',
+ tgt : '',
+ args : '-t;osimage;-l',
+ msg : ''
+ },
+
+ success : loadImages
+ });
+ });
+
// Insert table
$('#imagesTab').append(dTable.object());
@@ -179,11 +214,11 @@ function loadImages(data) {
// Actions
var actionBar = $('');
- var actionsLnk = 'Actions';
- var actsMenu = createMenu([copyCDLnk, newLnk, editBtn]);
+ var advancedLnk = 'Advanced';
+ var advancedMenu = createMenu([copyCDLnk, generateLnk]);
// Create an action menu
- var actionsMenu = createMenu([ [ actionsLnk, actsMenu ] ]);
+ var actionsMenu = createMenu([refreshLnk, addLnk, editLnk, removeLnk, [advancedLnk, advancedMenu]]);
actionsMenu.superfish();
actionsMenu.css('display', 'inline-block');
actionBar.append(actionsMenu);
@@ -205,8 +240,8 @@ function loadImages(data) {
* Enable editable columns
*/
- // Do not make 1st, 2nd, 3rd, 4th, or 5th column editable
- $('#' + imgTableId + ' td:not(td:nth-child(1),td:nth-child(2))').editable(
+ // Do not make 1st column editable
+ $('#' + imgTableId + ' td:not(td:nth-child(1))').editable(
function(value, settings) {
// Get column index
var colPos = this.cellIndex;
@@ -250,6 +285,7 @@ function loadImages(data) {
onblur : 'submit', // Clicking outside editable area submits changes
type : 'textarea', // Input type to use
placeholder: ' ',
+ event : "dblclick", // Double click and edit
height : '30px' // The height of the text area
});
@@ -268,6 +304,308 @@ function loadImages(data) {
});
}
+/**
+ * Open dialog to confirm deleting image
+ *
+ * @param images
+ * Comma delimited image names
+ * @return Nothing
+ */
+function confirmImageDeleteDialog(images) {
+ // Make images list more readable
+ var dialogId = 'confirmImageRemove';
+ var tmp = images.replace(new RegExp(',', 'g'), ', ');
+ var confirmDialog = $('
'
+ + '
Are you sure you want to remove ' + tmp + '?
'
+ + '
');
+
+ // Open dialog to confirm delete
+ confirmDialog.dialog({
+ modal: true,
+ title: 'Confirm',
+ width: 500,
+ buttons: {
+ "Ok": function(){
+ // Change dialog buttons
+ $(this).dialog('option', 'buttons', {
+ 'Close': function() {$(this).dialog("close");}
+ });
+
+ // Add image to xCAT
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'rmdef',
+ tgt : '',
+ args : '-t;osimage;-o;' + images,
+ msg : dialogId
+ },
+
+ success : updateImageDialog
+ });
+ },
+ "Cancel": function(){
+ $(this).dialog("close");
+ }
+ }
+ });
+}
+
+/**
+ * Open a dialog to add an image
+ *
+ * @return Nothing
+ */
+function loadAddImageDialog() {
+ // Create dialog to add image
+ var dialogId = 'addImage';
+ var addImageForm = $('');
+
+ // Create info bar
+ var info = createInfoBar('Provide the following attributes for the image. The image name will be generated based on the attributes you will give.');
+ addImageForm.append(info);
+
+ // Create inputs for image attributes
+ var imageName = $('');
+ var imageType = $('');
+ var architecture = $('');
+ var osName = $('');
+ var osVersion = $('');
+ var profile = $('');
+ var provisionMethod = $('');
+ var provisionSelect = $('');
+ provisionMethod.append(provisionSelect);
+
+ // Create inputs for optional attributes
+ var otherpkgDirectory = $('');
+ var otherpkgDirectoryInput = $('');
+ otherpkgDirectory.append(otherpkgDirectoryInput);
+ otherpkgDirectoryInput.serverBrowser({
+ onSelect : function(path) {
+ $('#addImage input[name="otherpkgdir"]').val(path);
+ },
+ onLoad : function() {
+ return $('#addImage input[name="otherpkgdir"]').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 packageDirectory = $('');
+ var packageDirectoryInput = $('');
+ packageDirectory.append(packageDirectoryInput);
+ packageDirectoryInput.serverBrowser({
+ onSelect : function(path) {
+ $('#addImage input[name="pkgdir"]').val(path);
+ },
+ onLoad : function() {
+ return $('#addImage input[name="pkgdir"]').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 packageList = $('');
+ var packageListInput = $('');
+ packageList.append(packageListInput);
+ packageListInput.serverBrowser({
+ onSelect : function(path) {
+ $('#addImage input[name="pkglist"]').val(path);
+ },
+ onLoad : function() {
+ return $('#addImage input[name="pkglist"]').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);
+ templateInput.serverBrowser({
+ onSelect : function(path) {
+ $('#addImage input[name="template"]').val(path);
+ },
+ onLoad : function() {
+ return $('#addImage input[name="template"]').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
+ });
+
+ addImageForm.append(imageName, imageType, architecture, osName, osVersion, profile, provisionMethod,
+ otherpkgDirectory, packageDirectory, packageList, template);
+
+ // Open dialog to add image
+ addImageForm.dialog({
+ title:'Add image',
+ modal: true,
+ width: 500,
+ 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();
+
+ // 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();
+
+ // Override image name
+ $(this).find('input[name="imagename"]').val(osVersion + '-' + architecture + '-' + provisionMethod + '-' + profile);
+ var imageName = $(this).find('input[name="imagename"]').val();
+
+ // If inputs are not complete, show warning message
+ if (!imageType || !architecture || !osName || !osVersion || !profile || !provisionMethod) {
+ var warn = createWarnBar('Please provide a value for each missing field.');
+ warn.prependTo($(this));
+ } else {
+ // 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;
+
+ if (otherpkgDirectory)
+ args += ';otherpkgdir=' + otherpkgDirectory;
+ if (pkgDirectory)
+ args += ';pkgdir=' + pkgDirectory;
+ if (pkgList)
+ args += ';pkglist=' + pkgList;
+ if (template)
+ args += ';template=' + template;
+
+ // Add image to xCAT
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'chdef',
+ tgt : '',
+ args : args,
+ msg : dialogId
+ },
+
+ success : updateImageDialog
+ });
+ }
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
+}
+
+/**
+ * Update image dialog
+ *
+ * @param data
+ * HTTP request data
+ * @return Nothing
+ */
+function updateImageDialog(data) {
+ var dialogId = data.msg;
+ var infoMsg;
+
+ // Create info message
+ if (jQuery.isArray(data.rsp)) {
+ infoMsg = '';
+ for (var i in data.rsp) {
+ infoMsg += data.rsp[i] + '';
+ }
+ } else {
+ infoMsg = data.rsp;
+ }
+
+ // Create info bar with close button
+ var infoBar = $('').css('margin', '5px 0px');
+ var icon = $('').css({
+ 'display': 'inline-block',
+ 'margin': '10px 5px'
+ });
+
+ // Create close button to close info bar
+ var close = $('').css({
+ 'display': 'inline-block',
+ 'float': 'right'
+ }).click(function() {
+ $(this).parent().remove();
+ });
+
+ var msg = $('