[Kimchi-devel] [PATCH] [Kimchi 5/9] Issue 783: Error message hidden by the modal window

sguimaraes943 at gmail.com sguimaraes943 at gmail.com
Mon Dec 14 20:10:30 UTC 2015


From: samhenri <samuel.guimaraes at eldorado.org.br>

Added an alert container for error messages in modal windows and updated some wok.message.error calls to point to the right container.

Signed-off-by: samhenri <samuel.guimaraes at eldorado.org.br>
---
 ui/js/src/kimchi.guest_edit_main.js             | 75 ++++++++++++++-----------
 ui/js/src/kimchi.guest_storage_add.main.js      | 38 +++++++------
 ui/js/src/kimchi.storage_main.js                | 29 +++++-----
 ui/js/src/kimchi.storagepool_add_main.js        | 43 +++++++-------
 ui/js/src/kimchi.storagepool_add_volume_main.js | 27 +++++----
 ui/js/src/kimchi.template_add_main.js           | 62 ++++++++++----------
 ui/pages/guest-storage-add.html.tmpl            |  1 +
 ui/pages/storagepool-add-volume.html.tmpl       |  1 +
 ui/pages/storagepool-add.html.tmpl              |  3 +-
 ui/pages/template-add.html.tmpl                 | 10 ++--
 10 files changed, 159 insertions(+), 130 deletions(-)

diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index b358f59..3f9c3e9 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -22,8 +22,8 @@ kimchi.guest_edit_main = function() {
     var saveButton = $('#guest-edit-button-save');
 
     $('#guest-edit-window a[data-toggle="tab"]').on('show.bs.tab', function(tab) {
-        tab.target // newly activated tab
-        tab.relatedTarget // previous active tab
+        tab.target; // newly activated tab
+        tab.relatedTarget; // previous active tab
         var display_list = null;
         if (kimchi.thisVMState === "running") {
             display_list = ['form-guest-edit-permission'];
@@ -44,7 +44,7 @@ kimchi.guest_edit_main = function() {
         var submit_map = {
             0: generalSubmit,
             3: permissionSubmit
-        };        
+        };
         var currentTab = $('#guest-edit-window li.active a[data-toggle="tab"]').data('id');
         var toSubmit = parseInt($('#'+currentTab).index());
         var submitFun = submit_map[toSubmit];
@@ -120,8 +120,9 @@ kimchi.guest_edit_main = function() {
                 confirm: i18n['KCHAPI6002M'],
                 cancel: i18n['KCHAPI6003M']
             };
-            if ($(this).data('type') == "disk")
+            if ($(this).data('type') === "disk") {
                 settings['content'] = i18n['KCHVMCD6009M'];
+            }
 
             var dev = $(this).data('dev');
             wok.confirm(settings, function() {
@@ -183,10 +184,10 @@ kimchi.guest_edit_main = function() {
             $(".action-area", item).toggleClass("hide");
         };
         var addItem = function(data) {
-            if (data.id == -1) {
-                data.id = $('#form-guest-edit-interface > .body').children().size()
+            if (data.id === -1) {
+                data.id = $('#form-guest-edit-interface > .body').children().size();
             }
-            if (data.ips == "" || data.ips == null) {
+            if (data.ips === "" || data.ips === null) {
                 data.ips = i18n["KCHNET6001M"];
             } else {
                 data.ips = data.ips;
@@ -225,13 +226,13 @@ kimchi.guest_edit_main = function() {
                     $("#edit-mac-" + data.id, item).val(mac);
                     toggleEdit(item, false, data.id);
                 };
-                if (item.prop("id") == "") {
+                if (item.prop("id") === "") {
                     kimchi.createGuestInterface(kimchi.selectedGuest, interface, function(data) {
                         item.prop("id", data.mac);
                         postUpdate(data.mac);
                     });
                 } else {
-                    if (item.prop('id') == interface.mac) {
+                    if (item.prop('id') === interface.mac) {
                         toggleEdit(item, false, data.id);
                     } else {
                         kimchi.updateGuestInterface(kimchi.selectedGuest, item.prop('id'),
@@ -252,7 +253,7 @@ kimchi.guest_edit_main = function() {
         var networkOptions = "";
         kimchi.listNetworks(function(data) {
             for (var i = 0; i < data.length; i++) {
-                var isSlected = i == 0 ? " selected" : "";
+                var isSlected = i === 0 ? " selected" : "";
                 networkOptions += "<option" + isSlected + ">" + data[i].name + "</option>";
             }
             kimchi.getGuestInterfaces(kimchi.selectedGuest, function(data) {
@@ -296,7 +297,7 @@ kimchi.guest_edit_main = function() {
                 $(this).removeClass("checked");
             });
 
-            if (data.checked == true) {
+            if (data.checked === true) {
                 $(".checked", itemNode).addClass("hide");
             }
         };
@@ -308,8 +309,8 @@ kimchi.guest_edit_main = function() {
         //set up for PAM
         var userNodes = {},
             groupNodes = {};
-        authType = kimchi.capabilities['auth']
-        if (authType == 'pam') {
+        authType = kimchi.capabilities['auth'];
+        if (authType === 'pam') {
             $("#form-guest-edit-permission .ldap").hide();
             kimchi.retrieveVM(kimchi.selectedGuest, function(vm) {
                 kimchi.getUsers(function(users) {
@@ -317,7 +318,7 @@ kimchi.guest_edit_main = function() {
                         var subArray = function(a1, a2) { //a1-a2
                             for (var i = 0; i < a2.length; i++) {
                                 for (var j = 0; j < a1.length; j++) {
-                                    if (a2[i] == a1[j]) {
+                                    if (a2[i] === a1[j]) {
                                         a1.splice(j, 1);
                                         break;
                                     }
@@ -330,7 +331,7 @@ kimchi.guest_edit_main = function() {
                     });
                 });
             });
-        } else if (authType == 'ldap') {
+        } else if (authType === 'ldap') {
             $("#form-guest-edit-permission .pam").hide();
             kimchi.retrieveVM(kimchi.selectedGuest, function(vm) {
                 for (var i = 0; i < vm.users.length; i++) {
@@ -391,9 +392,9 @@ kimchi.guest_edit_main = function() {
         };
         var filterNodes = function(key, container) {
             container.children().each(function() {
-                $(this).css("display", $("label", this).text().indexOf(key) == -1 ? "none" : "");
+                $(this).css("display", $("label", this).text().indexOf(key) === -1 ? "none" : "");
             });
-        }
+        };
         $("#permission-avail-searchBox").on("keyup", function() {
             var key = $(this).val();
             filterNodes(key, $("#permission-avail-users"));
@@ -424,7 +425,7 @@ kimchi.guest_edit_main = function() {
             filterNodes("", $("#permission-avail-users"));
             filterNodes("", $("#permission-avail-groups"));
         });
-    }
+    };
 
     var filterPCINodes = function(group, text, targetName) {
         text = text.toLowerCase();
@@ -553,12 +554,17 @@ kimchi.guest_edit_main = function() {
     var setupSnapshot = function() {
         var currentSnapshot;
         var setCurrentSnapshot = function(aSnapshot) {
-            if (!aSnapshot)
+            if (!aSnapshot) {
                 kimchi.getCurrentSnapshot(kimchi.selectedGuest, function(snapshot) {
-                    if (snapshot && snapshot.name) aSnapshot = snapshot.name;
+                    if (snapshot && snapshot.name) {
+                        aSnapshot = snapshot.name;
+                    }
                 }, null, true);
+            }
             if (aSnapshot) {
-                if (currentSnapshot) $(".fa.fa-check", "#" + currentSnapshot).addClass("hide");
+                if (currentSnapshot) {
+                    $(".fa.fa-check", "#" + currentSnapshot).addClass("hide");
+                }
                 $(".fa.fa-check", "#" + aSnapshot).removeClass("hide");
                 currentSnapshot = aSnapshot;
             }
@@ -606,7 +612,7 @@ kimchi.guest_edit_main = function() {
                 listMode: "hide",
                 createMode: ""
             }, 'task');
-            if (kimchi.trackingTasks.indexOf(task.id) == -1)
+            if (kimchi.trackingTasks.indexOf(task.id) === -1) {
                 kimchi.trackTask(task.id, function(task) {
                     listGeneratingSnapshots();
                     $("button", "#form-guest-edit-snapshot").prop("disabled", false);
@@ -615,6 +621,7 @@ kimchi.guest_edit_main = function() {
                     listGeneratingSnapshots();
                     $("button", "#form-guest-edit-snapshot").prop("disabled", false);
                 });
+            }
         };
         var listGeneratingSnapshots = function() {
             kimchi.getTasksByFilter('status=running&target_uri=' + encodeURIComponent('^/plugins/kimchi/snapshots/*'), function(tasks) {
@@ -622,7 +629,9 @@ kimchi.guest_edit_main = function() {
                 for (var i = 0; i < tasks.length; i++) {
                     addOngoingItem(tasks[i]);
                 }
-                if (tasks.length == 0) listSnapshots();
+                if (tasks.length === 0) {
+                    listSnapshots();
+                }
             });
         };
         var listSnapshots = function() {
@@ -645,7 +654,9 @@ kimchi.guest_edit_main = function() {
                 addOngoingItem(task);
             });
         });
-        if (kimchi.thisVMState == "running") $("button", "#form-guest-edit-snapshot").remove();
+        if (kimchi.thisVMState === "running") {
+            $("button", "#form-guest-edit-snapshot").remove();
+        }
     };
 
     var initContent = function(guest) {
@@ -693,10 +704,10 @@ kimchi.guest_edit_main = function() {
     var generalSubmit = function(event) {
         $(saveButton).prop('disabled', true);
         var data = $('#form-guest-edit-general').serializeObject();
-        if (data['memory'] != undefined) {
+        if (data['memory'] !== undefined) {
             data['memory'] = Number(data['memory']);
         }
-        if (data['cpus'] != undefined) {
+        if (data['cpus'] !== undefined) {
             data['cpus'] = Number(data['cpus']);
         }
 
@@ -707,15 +718,15 @@ kimchi.guest_edit_main = function() {
             wok.message.error(err.responseJSON.reason, '#alert-modal-container');
             $(saveButton).prop('disabled', false);
         });
-    }
+    };
 
     var permissionSubmit = function(event) {
         var content = {
             users: [],
             groups: []
         };
-        authType = kimchi.capabilities['auth']
-        if (authType == 'pam') {
+        authType = kimchi.capabilities['auth'];
+        if (authType === 'pam') {
             $("#permission-sel-users").children().each(function() {
                 content.users.push($("label", this).text());
             });
@@ -725,7 +736,7 @@ kimchi.guest_edit_main = function() {
             kimchi.updateVM(kimchi.selectedGuest, content, function() {
                 wok.window.close();
             });
-        } else if (authType == 'ldap') {
+        } else if (authType === 'ldap') {
             $(saveButton).prop('disabled', true);
             var errors = 0;
 
@@ -743,7 +754,7 @@ kimchi.guest_edit_main = function() {
                     });
                 }
             });
-            if (errors == 0) {
+            if (errors === 0) {
                 kimchi.updateVM(kimchi.selectedGuest, content, function() {
                     wok.window.close();
                 });
@@ -751,5 +762,5 @@ kimchi.guest_edit_main = function() {
                 $(saveButton).prop('disabled', false);
             }
         }
-    }
+    };
 };
diff --git a/ui/js/src/kimchi.guest_storage_add.main.js b/ui/js/src/kimchi.guest_storage_add.main.js
index 881ff7c..0afb008 100644
--- a/ui/js/src/kimchi.guest_storage_add.main.js
+++ b/ui/js/src/kimchi.guest_storage_add.main.js
@@ -40,10 +40,10 @@ kimchi.guest_storage_add_main = function() {
     var selectStorageVolHTML  = '';
 
     typeTextbox.change(function() {
-        var pathObject = {'cdrom': ".path-section", 'disk': '.volume-section'}
+        var pathObject = {'cdrom': ".path-section", 'disk': '.volume-section'};
         selectType = $(this).val();
         $.each(pathObject, function(type, value) {
-            if(selectType == type){
+            if(selectType === type){
                 $(value).removeClass('hidden');
             } else {
                 $(value).addClass('hidden');
@@ -66,7 +66,7 @@ kimchi.guest_storage_add_main = function() {
         var options = [];
         if (result && result.length) {
             $.each(result, function(index, storagePool) {
-                if ((storagePool.state=="active") && (storagePool.type !== 'kimchi-iso')) {
+                if ((storagePool.state==="active") && (storagePool.type !== 'kimchi-iso')) {
                     options.push({
                         label: storagePool.name,
                         value: storagePool.name
@@ -90,7 +90,7 @@ kimchi.guest_storage_add_main = function() {
             if (result.length) {
                 $.each(result, function(index, value) {
                     // Only unused volume can be attached
-                    if (value.used_by.length == 0 && value.isvalid && (value.type != 'file' || validVolType[selectType].test(value.format))) {
+                    if (value.used_by.length === 0 && value.isvalid && (value.type !== 'file' || validVolType[selectType].test(value.format))) {
                         options.push({
                             label: value.name,
                             value: value.name
@@ -111,16 +111,16 @@ kimchi.guest_storage_add_main = function() {
                 }
                 volTextbox.selectpicker();
                 $('.selectpicker').selectpicker('refresh');
-            } 
+            }
         }, null, false);
     });
 
 
     typeTextbox.change(function() {
-        var pathObject = {'cdrom': ".path-section", 'disk': '.volume-section'}
+        var pathObject = {'cdrom': ".path-section", 'disk': '.volume-section'};
         var selectType = $(this).val();
         $.each(pathObject, function(type, value) {
-            if(selectType == type){
+            if(selectType === type){
                 $(value).removeClass('hidden');
             } else {
                 $(value).addClass('hidden');
@@ -143,22 +143,24 @@ kimchi.guest_storage_add_main = function() {
     typeTextbox.selectpicker();
 
     var validateCDROM = function(settings) {
-        if (/^((https|http|ftp|ftps|tftp|\/).*)+$/.test(settings['path']))
-            return true;
+        if (/^((https|http|ftp|ftps|tftp|\/).*)+$/.test(settings['path'])){
+                    return true;
+        }
         else {
-            wok.message.error.code('KCHVMSTOR0001E');
+            wok.message.error(i18n['KCHVMSTOR0001E'],'#alert-modal-container2');
             return false;
         }
-    }
+    };
 
     var validateDisk = function(settings) {
-        if (settings['pool'] && settings['vol'])
-            return true;
+        if (settings['pool'] && settings['vol']){
+                    return true;
+        }
         else {
-            wok.message.error.code('KCHVMSTOR0002E');
+            wok.message.error(i18n['KCHVMSTOR0002E'],'#alert-modal-container2');
             return false;
         }
-    }
+    };
 
     validator = {cdrom: validateCDROM, disk: validateDisk};
     var submitForm = function(event) {
@@ -175,8 +177,8 @@ kimchi.guest_storage_add_main = function() {
         $(submitButton).prop('disabled', true);
         $.each([pathTextbox, poolTextbox, volTextbox], function(i, c) {
             $(c).prop('disabled', true);
-            val = $(c).val()
-            if (val && val != '') {
+            val = $(c).val();
+            if (val && val !== '') {
                 settings[$(c).attr('name')] = $(c).val();
             }
         });
@@ -199,7 +201,7 @@ kimchi.guest_storage_add_main = function() {
         }, function(result) {
             var errText = result['reason'] ||
                 result['responseJSON']['reason'];
-            wok.message.error(errText);
+            wok.message.error(errText, '#alert-modal-container2');
 
             $.each([submitButton, pathTextbox, poolTextbox, volTextbox], function(i, c) {
                 $(c).prop('disabled', false);
diff --git a/ui/js/src/kimchi.storage_main.js b/ui/js/src/kimchi.storage_main.js
index 1a711ce..1b97307 100644
--- a/ui/js/src/kimchi.storage_main.js
+++ b/ui/js/src/kimchi.storage_main.js
@@ -28,7 +28,7 @@ kimchi.doListStoragePools = function() {
                     value.icon = 'icon-med';
                 } else {
                     value.icon = 'icon-low';
-                }                
+                }
                 value.capacity = wok.changetoProperUnit(value.capacity,1);
                 value.allocated = wok.changetoProperUnit(value.allocated,1);
                 value.enableExt = value.type==="logical" ? "" : "hide-content";
@@ -36,8 +36,9 @@ kimchi.doListStoragePools = function() {
                     listHtml += wok.substitute(storageHtml, value);
                 }
             });
-            if($('#storageGrid').hasClass('wok-datagrid'))
+            if($('#storageGrid').hasClass('wok-datagrid')) {
                 $('#storageGrid').dataGrid('destroy');
+            }
             $('#storagepoolsList').html(listHtml);
             if(wok.tabMode['storage'] === 'admin') {
                 $('.storage-button').attr('style','display');
@@ -55,7 +56,7 @@ kimchi.doListStoragePools = function() {
     }, function(err) {
         wok.message.error(err.responseJSON.reason);
     });
-}
+};
 
 kimchi.storageBindClick = function() {
 
@@ -212,7 +213,7 @@ kimchi.storageBindClick = function() {
             }
         }
     });
-}
+};
 
 kimchi._generateVolumeHTML = function(volume) {
     if(volume['type'] === 'kimchi-iso') {
@@ -236,11 +237,11 @@ kimchi._generateVolumeHTML = function(volume) {
 };
 
 kimchi.doListVolumes = function(poolObj) {
-    var poolName = poolObj.data('name')
+    var poolName = poolObj.data('name');
 
     var getOngoingVolumes = function() {
-        var result = {}
-        var filter = 'status=running&target_uri=' + encodeURIComponent('^/plugins/kimchi/storagepools/' + poolName + '/*')
+        var result = {};
+        var filter = 'status=running&target_uri=' + encodeURIComponent('^/plugins/kimchi/storagepools/' + poolName + '/*');
         kimchi.getTasksByFilter(filter, function(tasks) {
             for(var i = 0; i < tasks.length; i++) {
                 var volumeName = tasks[i].target_uri.split('/').pop();
@@ -272,7 +273,7 @@ kimchi.doListVolumes = function(poolObj) {
         var ongoingVolumes = [];
         var ongoingVolumesMap = getOngoingVolumes();
         $.each(ongoingVolumesMap, function(volumeName, task) {
-            ongoingVolumes.push(volumeName)
+            ongoingVolumes.push(volumeName);
             var volume = {
                 poolName: poolName,
                 used_by: [],
@@ -292,7 +293,7 @@ kimchi.doListVolumes = function(poolObj) {
         });
 
         $.each(result, function(index, value) {
-            if (ongoingVolumes.indexOf(value.name) == -1) {
+            if (ongoingVolumes.indexOf(value.name) === -1) {
                 value.poolname = poolName;
                 listHtml += kimchi._generateVolumeHTML(value);
             }
@@ -314,7 +315,7 @@ kimchi.doListVolumes = function(poolObj) {
     }, function(err) {
         wok.message.error(err.responseJSON.reason);
     }, false);
-}
+};
 
     kimchi.initLogicalPoolExtend = function() {
 
@@ -367,7 +368,7 @@ kimchi.doListVolumes = function(poolObj) {
 
     $('#logicalPoolExtend').on('hidden.bs.modal', function () {
         $('.host-partition', '#logicalPoolExtend').empty();
-    })
+    });
 
     $('#logicalPoolExtend').on('show.bs.modal', function() {
         //$('#logicalPoolExtend2').find('.modal-content').html();
@@ -394,7 +395,7 @@ kimchi.doListVolumes = function(poolObj) {
             var devicePaths = [];
             $("input[type='checkbox']:checked", "#logicalPoolExtend").each(function() {
                 devicePaths.push($(this).prop('value'));
-            })
+            });
             kimchi.updateStoragePool($("#logicalPoolExtend"), {
                 disks: devicePaths
             }, function(partitions) {
@@ -411,7 +412,7 @@ kimchi.doListVolumes = function(poolObj) {
 
     });
 
-}
+};
 
 kimchi.storage_main = function() {
     if(wok.tabMode['storage'] === 'admin') {
@@ -504,4 +505,4 @@ kimchi.changeArrow = function(obj) {
     } else {
         $(obj).removeClass('arrow-up').addClass('arrow-down');
     }
-}
+};
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js
index 39b2cb7..0e9654a 100644
--- a/ui/js/src/kimchi.storagepool_add_main.js
+++ b/ui/js/src/kimchi.storagepool_add_main.js
@@ -26,10 +26,12 @@ kimchi.storagepool_add_main = function() {
     // 'pool-doAdd' button if all the visible form
     // fields are filled, disables it otherwise.
     $('#form-pool-add').on('input change propertychange', function() {
-        if (!kimchi.inputsNotBlank())
-            $("#pool-doAdd").attr("disabled", true);
-        else
+        if (!kimchi.inputsNotBlank()){
+                    $("#pool-doAdd").attr("disabled", true);
+        }
+        else {
            $("#pool-doAdd").attr("disabled", false);
+        }
     });
 };
 
@@ -38,7 +40,7 @@ kimchi.storageFilterSelect = function(id, isUpdate) {
     var options = $(".option", '#'+id);
     var filter = function(container, key){
         container.children().each(function(){
-            $(this).css("display", $(this).text().indexOf(key)==-1 ? "none" : "");
+            $(this).css("display", $(this).text().indexOf(key)===-1 ? "none" : "");
         });
     };
     if(!isUpdate){
@@ -63,7 +65,7 @@ kimchi.setupISCSI = function(){
         $(".option", "#iSCSITarget").empty();
         $('input', "#iSCSITarget").attr("placeholder", i18n['KCHPOOL6006M']);
         kimchi.getISCSITargets(server, port, function(data){
-            if(data.length==0){
+            if(data.length===0){
                 $('input', "#iSCSITarget").attr("placeholder", i18n['KCHPOOL6007M']);
             }else{
                 for(var i=0; i<data.length; i++){
@@ -79,14 +81,14 @@ kimchi.setupISCSI = function(){
         }, function(data){
             $('input', "#iSCSITarget").attr("placeholder", i18n['KCHPOOL6008M']);
             callback();
-            wok.message.error(data.responseJSON.reason);
+            wok.message.error(data.responseJSON.reason,'#alert-modal-container');
         });
     };
     var triggerLoadTarget = function(){
         $('input', "#iSCSITarget").val("");
         var server = $("#iscsiserverId").val().trim();
         var port = $("#iscsiportId").val().trim();
-        if(server!="" && !$("#iscsiserverId").hasClass("invalid-field") && !$("#iscsiportId").hasClass("invalid-field")){
+        if(server!=="" && !$("#iscsiserverId").hasClass("invalid-field") && !$("#iscsiportId").hasClass("invalid-field")){
             $("#iscsiserverId").attr("disabled", true);
             $("#iscsiportId").attr("disabled", true);
             loadTargets(server, port, function(){
@@ -127,7 +129,7 @@ kimchi.initStorageAddPage = function() {
             var listHtml = '';
             valid_types = ['part', 'disk', 'mpath'];
             $.each(data, function(index, value) {
-                if (valid_types.indexOf(value.type) != -1) {
+                if (valid_types.indexOf(value.type) !== -1) {
                     listHtml += wok.substitute(deviceHtml, value);
                 }
             });
@@ -238,10 +240,10 @@ kimchi.initStorageAddPage = function() {
     $('#poolTypeInputId').change(function() {
         var poolObject = {'dir': ".path-section", 'netfs': '.nfs-section',
                           'iscsi': '.iscsi-section', 'scsi': '.scsi-section',
-                          'logical': '.logical-section'}
+                          'logical': '.logical-section'};
         var selectType = $(this).val();
         $.each(poolObject, function(type, value) {
-            if(selectType == type){
+            if(selectType === type){
                 $(value).removeClass('hidden');
             } else {
                 $(value).addClass('hidden');
@@ -275,19 +277,20 @@ kimchi.initStorageAddPage = function() {
  * already.
  */
 kimchi.inputsNotBlank = function() {
-    if (!$('#poolId').val()) return false;
+    if (!$('#poolId').val()) { return false; }
     var poolType = $("#poolTypeInputId").val();
     if (poolType === "dir") {
-        if (!$('#pathId').val()) return false;
+        if (!$('#pathId').val()) { return false; }
     } else if (poolType === "netfs") {
-        if (!$('#nfspathId').val()) return false;
-        if (!$('#nfsserverId').val()) return false;
+        if (!$('#nfspathId').val()) { return false; }
+        if (!$('#nfsserverId').val()) { return false; }
     } else if (poolType === "iscsi") {
-        if (!$('#iscsiserverId').val()) return false;
-        if (!$('#iscsiTargetId').val()) return false;
+        if (!$('#iscsiserverId').val()) { return false; }
+        if (!$('#iscsiTargetId').val()) { return false; }
     } else if (poolType === "logical") {
-        if ($("input[name=devices]:checked").length === 0)
-            return false;
+        if ($("input[name=devices]:checked").length === 0){
+                    return false;
+            }
     }
     return true;
 };
@@ -393,7 +396,7 @@ kimchi.addPool = function(event) {
             }
             formData.source = source;
         } else if (poolType === 'scsi'){
-            formData.source = { adapter_name: $('#scsiAdapter').selectMenu('value') };
+            formData.source = { adapter_name: $('#scsiAdapter').val() };
         }
         var storagePoolAddingFunc = function() {
             $('input', '#form-pool-add').attr('disabled','disabled');
@@ -403,7 +406,7 @@ kimchi.addPool = function(event) {
                     kimchi.doListStoragePools();
                     wok.window.close();
                 }, function(err) {
-                    wok.message.error(err.responseJSON.reason);
+                    wok.message.error(err.responseJSON.reason,'#alert-modal-container');
                     $('input', '#form-pool-add').removeAttr('disabled');
                     $('#pool-loading').hide();
                     $('#pool-doAdd').show();
diff --git a/ui/js/src/kimchi.storagepool_add_volume_main.js b/ui/js/src/kimchi.storagepool_add_volume_main.js
index a1a8306..51fc43f 100644
--- a/ui/js/src/kimchi.storagepool_add_volume_main.js
+++ b/ui/js/src/kimchi.storagepool_add_volume_main.js
@@ -38,7 +38,7 @@ kimchi.sp_add_volume_main = function() {
         $('.volume-input').prop('disabled', true);
         $('.volume-input.' + this.value).prop('disabled', false);
         type = this.value;
-        if(type == 'download') {
+        if(type === 'download') {
             $(addButton).prop('disabled', !isValidURL());
         }
         else {
@@ -104,11 +104,12 @@ kimchi.sp_add_volume_main = function() {
             kimchi.uploadVolumeToSP(kimchi.selectedSP, blobFile.name, {
                 formData: fd
             }, function(result) {
-                if (uploaded < blobFile.size)
-                    setTimeout(doUpload, 500);
+                if (uploaded < blobFile.size){
+                                    setTimeout(doUpload, 500);
+                }
             }, onError);
 
-            uploaded += blob.size
+            uploaded += blob.size;
         };
 
         // Check file exists and has read permission
@@ -116,10 +117,12 @@ kimchi.sp_add_volume_main = function() {
             var blob = blobFile.slice(0, 20);
             var reader = new FileReader();
             reader.onloadend = function(e) {
-                if (e.loaded == 0)
+                if (e.loaded === 0){
                     wok.message.error.code('KCHAPI6008E');
-                else
+                }
+                else{
                     createUploadVol();
+                }
             };
 
             reader.readAsBinaryString(blob);
@@ -133,10 +136,12 @@ kimchi.sp_add_volume_main = function() {
                 var blob = blobFile.slice(uploaded, uploaded + chunkSize);
                 var reader = new FileReader();
                 reader.onloadend = function(e) {
-                    if (e.loaded == 0)
+                    if (e.loaded === 0) {
                         wok.message.error.code('KCHAPI6009E');
-                    else
+                    }
+                    else {
                         uploadRequest(blob);
+                    }
                 };
 
                 reader.readAsBinaryString(blob);
@@ -144,14 +149,14 @@ kimchi.sp_add_volume_main = function() {
                 wok.message.error.code('KCHAPI6009E');
                 return;
             }
-        }
+        };
 
         var trackVolCreation = function(taskid) {
             var onTaskResponse = function(result) {
                 var taskStatus = result['status'];
                 var taskMsg = result['message'];
-                if (taskStatus == 'running') {
-                    if (taskMsg != 'ready for upload') {
+                if (taskStatus === 'running') {
+                    if (taskMsg !== 'ready for upload') {
                         setTimeout(function() {
                             trackVolCreation(taskid);
                         }, 2000);
diff --git a/ui/js/src/kimchi.template_add_main.js b/ui/js/src/kimchi.template_add_main.js
index 2478eec..fd50251 100644
--- a/ui/js/src/kimchi.template_add_main.js
+++ b/ui/js/src/kimchi.template_add_main.js
@@ -62,7 +62,7 @@ kimchi.template_add_main = function() {
                 showLocalIsoField(isos);
             } else {
                 if (isFinished) {
-                    wok.message.warn(i18n['KCHTMPL6001W']);
+                    wok.message.warn(i18n['KCHTMPL6001W'], '#local-iso-warning-container');
                 }
             }
             if (isFinished) {
@@ -70,7 +70,7 @@ kimchi.template_add_main = function() {
                 $(button).show();
             }
         }, function(err) {
-            wok.message.error(err.responseJSON.reason, '.alert-modal-container');
+            wok.message.error(err.responseJSON.reason, '#local-iso-error-container');
             $(button + '-loading').hide();
             $(button).show();
         });
@@ -170,7 +170,7 @@ kimchi.template_add_main = function() {
             $('#iso-search').show();
         }
     }, function(err) {
-        wok.message.error(err.responseJSON.reason, '.alert-modal-container');
+        wok.message.error(err.responseJSON.reason, '#local-iso-error-container');
     });
     $('#template-add-window .modal-body .template-pager').animate({
         height: "689px"
@@ -209,7 +209,7 @@ kimchi.template_add_main = function() {
                     $('#iso-search').show();
                 }
             }, function(err) {
-                wok.message.error(err.responseJSON.reason, '.alert-modal-container');
+                wok.message.error(err.responseJSON.reason, '#local-iso-error-container');
             });
         }
     });
@@ -293,7 +293,7 @@ kimchi.template_add_main = function() {
         if (checkedLength) {
             $('#btn-template-local-iso-create').removeAttr('disabled');
             var length = $('#list-local-iso [type="checkbox"]').length;
-            $('#select-all-local-iso').prop('checked', length == checkedLength);
+            $('#select-all-local-iso').prop('checked', length === checkedLength);
             $('#btn-template-local-iso-create').removeAttr('disabled');
         } else {
             $('#select-all-local-iso').prop('checked', false);
@@ -309,8 +309,7 @@ kimchi.template_add_main = function() {
         var isoFile = $('#iso-file').val();
         $('vm-image-local-text').val('');
         if (!kimchi.template_check_path(isoFile)) {
-            wok.message.error(err.responseJSON.reason, '.alert-modal-container');
-            wok.message.error.code('KCHAPI6003E');
+            wok.message.error(i18n['KCHAPI6003E'],'#local-iso-error-container');
             return;
         }
         var data = {
@@ -323,12 +322,12 @@ kimchi.template_add_main = function() {
     $('#iso-remote').attr("disabled", true).css('cursor', 'not-allowed');
 
     var enabledRemoteIso = function() {
-        if (kimchi.capabilities == undefined) {
+        if (kimchi.capabilities === undefined) {
             setTimeout(enabledRemoteIso, 2000);
             return;
         }
 
-        if (kimchi.capabilities.qemu_stream != true) {
+        if (kimchi.capabilities.qemu_stream !== true) {
             return;
         }
 
@@ -396,13 +395,13 @@ kimchi.template_add_main = function() {
                 }
             });
             $('#list-remote-iso').html(html);
-            $('#load-remote-iso').hide()
+            $('#load-remote-iso').hide();
             $('#remote-iso-field').show();
             $('#iso-url-field').show();
         } else {
-            $('#load-remote-iso').hide()
+            $('#load-remote-iso').hide();
             $('#iso-url-field').show();
-            wok.message.warn(i18n['KCHTMPL6001W']);
+            wok.message.warn(i18n['KCHTMPL6001W'],"#remote-iso-warning-container");
         }
     };
 
@@ -436,7 +435,7 @@ kimchi.template_add_main = function() {
         if (checkedLength) {
             $('#btn-template-remote-iso-create').removeAttr('disabled');
             var length = $('#list-remote-iso [type="checkbox"]').length;
-            $('#select-all-remote-iso').prop('checked', length == checkedLength);
+            $('#select-all-remote-iso').prop('checked', length === checkedLength);
 
             $('#iso-file').val('');
             $('vm-image-local-text').val('');
@@ -479,7 +478,7 @@ kimchi.template_add_main = function() {
 
         $('#btn-template-remote-iso-create').attr('disabled', 'disabled').css('display', 'none'); // 5 - Remote selected isos
 
-    }
+    };
 
     $('#iso-url').on('input propertychange keyup focus cut paste click', function() {
         $('#select-all-local-iso, #select-all-remote-iso').prop('checked', false);
@@ -520,24 +519,25 @@ kimchi.template_add_main = function() {
             $('#vm-image-local-box-button').attr('disabled', (isValid ? false : true));
         }, 0);
     });
-    $('button', $('#vm-image-local-box')).button({
-        disabled: true
-    }).click(function() {
+    $('input', '#vm-image-local-box').on('input propertychange keyup focus cut paste click', function() {
+        setTimeout(function() {
+            var isValid = kimchi.template_check_path($('input', '#vm-image-local-box').val());
+            $('input', '#vm-image-local-box').parent().toggleClass('has-error', !isValid);
+            $('#vm-image-local-box-button').attr('disabled', (isValid ? false : true));
+        }, 0);
+    });
+    $('#vm-image-local-box-button').on('click', function(){
         $('input', '#vm-image-local-box').prop('disabled', true);
-        $(this).button('option', {
-            label: i18n['KCHAPI6008M'],
-            disabled: true
-        });
+        $('#vm-image-local-box-button').text(i18n['KCHAPI6008M']);
+        $('#vm-image-local-box-button').prop('disabled', true);
         addTemplate({
             disks: [{
                 base: $('input', '#vm-image-local-box').val()
             }]
         }, function() {
             $('input', '#vm-image-local-box').prop('disabled', false);
-            $('button', $('.body', '#vm-image-local-box')).button('option', {
-                label: i18n['KCHAPI6005M'],
-                disabled: false
-            });
+            $('#vm-image-local-box-button').text(i18n['KCHAPI6005M']);
+            $('#vm-image-local-box-button').prop('disabled', false);
         });
     });
 
@@ -556,13 +556,17 @@ kimchi.template_add_main = function() {
     //do create
     var addTemplate = function(data, callback) {
         kimchi.createTemplate(data, function() {
-            if (callback) callback();
+            if (callback) {
+                callback();
+            }
             kimchi.doListTemplates();
             wok.window.close();
             wok.topic('templateCreated').publish();
         }, function(err) {
-            if (callback) callback();
-            wok.message.error(err.responseJSON.reason, '.alert-modal-container');
+            if (callback) {
+                callback();
+            }
+            wok.message.error(err.responseJSON.reason, '#alert-modal-container');
         });
     };
 
@@ -587,7 +591,7 @@ kimchi.template_add_main = function() {
                         wok.window.close();
                     }
                 }, function(err) {
-                    wok.message.error(err.responseJSON.reason, '.alert-modal-container');
+                    wok.message.error(err.responseJSON.reason, '#alert-modal-container');
                 });
             };
             if (formData.iso instanceof Array) {
diff --git a/ui/pages/guest-storage-add.html.tmpl b/ui/pages/guest-storage-add.html.tmpl
index 43cfd48..1137f69 100644
--- a/ui/pages/guest-storage-add.html.tmpl
+++ b/ui/pages/guest-storage-add.html.tmpl
@@ -28,6 +28,7 @@
             <h4 class="modal-title">$_("Add a Storage Device to VM")</h4>
         </div>
         <div class="modal-body">
+            <span id="alert-modal-container2"></span>
             <form id="form-guest-storage-add">
                 <div class="form-group">
                     <label>$_("Device Type")</label>
diff --git a/ui/pages/storagepool-add-volume.html.tmpl b/ui/pages/storagepool-add-volume.html.tmpl
index 735b0c8..392785f 100644
--- a/ui/pages/storagepool-add-volume.html.tmpl
+++ b/ui/pages/storagepool-add-volume.html.tmpl
@@ -27,6 +27,7 @@
             <h4 class="modal-title">$_("Add a Volume to Storage Pool")</h4>
         </div>
         <div class="modal-body">
+            <span id="alert-modal-container"></span>
             <div class="form-group">
                 <input type="radio" id="volume-type-download" class="volume-type wok-radio" name="volumeType" value="download" checked="checked" />
                 <label for="volume-type-download"> $_("Fetch from remote URL")</label>
diff --git a/ui/pages/storagepool-add.html.tmpl b/ui/pages/storagepool-add.html.tmpl
index 1771e4a..9d8d104 100644
--- a/ui/pages/storagepool-add.html.tmpl
+++ b/ui/pages/storagepool-add.html.tmpl
@@ -29,6 +29,7 @@
         </div>
         <div class="modal-body">
             <form id="form-pool-add">
+                    <span id="alert-modal-container"></span>
                     <div class="form-group">
                         <label for="poolId">$_("Storage Pool Name")</label>
                         <input id="poolId" required="required" type="text" class="form-control" name="name">
@@ -38,7 +39,7 @@
                     </div>
                     <div class="form-group">
                         <label for="poolId">$_("Storage Pool Type")</label>
-                        <select id="poolTypeInputId" class="selectpicker col-md-12 col-lg-12"></select>    
+                        <select id="poolTypeInputId" class="selectpicker col-md-12 col-lg-12"></select>
                     </div>
                     <div class="path-section row">
                         <div class="form-group">
diff --git a/ui/pages/template-add.html.tmpl b/ui/pages/template-add.html.tmpl
index 46df4dc..5fe93b2 100644
--- a/ui/pages/template-add.html.tmpl
+++ b/ui/pages/template-add.html.tmpl
@@ -31,6 +31,7 @@
             <div class="modal-body">
                 <div class="template-modal-container">
                     <div>
+                        <span id="alert-modal-container"></span>
                         <h5>$_("Where is the source media for this template? ")</h5>
                         <input type="radio" checked="checked" name="iso-source" id="iso-local" value="iso-local" class="wok-radio">
                         <label for="iso-local">$_("Local ISO Image")</label>
@@ -43,7 +44,6 @@
                 <div class="template-pager">
                     <div class="page-list">
                         <div class="page" id="iso-local-box">
-                                <span class="alert-modal-container"></span>
                                 <!-- 1-1-2 -->
                                 <div id="iso-file-field">
                                     <div id="iso-file-box" class="custom-iso-field">
@@ -53,6 +53,8 @@
                                         </div>
                                     </div>
                                 </div>
+                                <span id="local-iso-warning-container"></span>
+                                <span id="local-iso-error-container"></span>
                                 <button class="btn btn-primary" id="iso-search" style="display: none">$_("Search ISOs")</button>
                                 <button class="btn btn-primary" id="iso-search-loading" style="display: none"><span class="wok-loading-icon"></span> $_("Please, wait...")</button>
                                 <!-- 1-1-1 -->
@@ -101,7 +103,6 @@
                         </div>
 
                         <div class="page" id="vm-image-local-box">
-                            <span class="alert-modal-container"></span>
                             <div class="from-group">
                                 <label for="vm-image-local-text">$_("File Path:")</label>
                                 <input type="text" class="form-control" id="vm-image-local-text" />
@@ -110,7 +111,6 @@
 
                         <!-- 1-2 -->
                         <div class="page" id="iso-remote-box">
-                            <span class="alert-modal-container"></span>
                             <!-- 1-2-2 -->
                             <div id="iso-url-field" style="display: none;">
                                 <div id="iso-url-box" class="form-group">
@@ -118,12 +118,12 @@
                                     <input type="text" class="form-control" id="iso-url" name="iso-url">
                                 </div>
                             </div>
-
                             <!-- 1-2-0 -->
                             <div id="load-remote-iso">
                                 <p><span class="wok-loading-icon"></span> $_("Loading default remote ISOs ...")</p>
                             </div>
-
+                            <span id="remote-iso-warning-container"></span>
+                            <span id="remote-iso-error-container"></span>
                             <!-- 1-2-1 -->
                             <div id="remote-iso-field" class="iso-field" style="display: none;">
                                 <div class="row">
-- 
1.9.3




More information about the Kimchi-devel mailing list