[PATCH v2 0/2] Github bug #307: Add storage pool list

From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> Changelog: v2: - Fixing message ID These patches fixes the bug where the list of storage pool types can take a long time to appear. The solution used here is to detach the view of such list with the return of the JSON that loads the partition data. To test this patch I recomend doing the following change in src/kimchi/model/hosts.py: + import time class PartitionsModel(object): def __init__(self, **kargs): pass def get_list(self): + time.sleep(10) result = disks.get_partitions_names() return result The sleep(10) call will ensure that get_list (which returns the partition data) will take at least 10 seconds to execute. It is enough time to select the LOGICAL type and see how the UI is working before and after the JSON call. Daniel Henrique Barboza (2): Github bug #307: add storage pool type list - JS changes Github bug #307: storage pool type list - html and string changes po/en_US.po | 21 +++- po/kimchi.pot | 20 +++- po/pt_BR.po | 21 +++- po/zh_CN.po | 21 +++- ui/js/src/kimchi.storagepool_add_main.js | 177 ++++++++++++++++--------------- ui/pages/i18n.html.tmpl | 5 +- ui/pages/storagepool-add.html.tmpl | 7 +- 7 files changed, 177 insertions(+), 95 deletions(-) -- 1.8.3.1

From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> The changes in ui/js/src/kimchi.storagepool_add_main.js were made to relieve the storage pool type dropbox from the return of the ajax call to retrieve the available partitions of the host. The dropbox will always have all the options displayed. In case of the LOGICAL pool type the user won't be able to proceed with the creation of the pool if no partitions are found. A message is being displayed to warn the user. Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- ui/js/src/kimchi.storagepool_add_main.js | 177 ++++++++++++++++--------------- 1 file changed, 89 insertions(+), 88 deletions(-) diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index 5960c8d..1332051 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -23,25 +23,8 @@ kimchi.storagepool_add_main = function() { }; kimchi.initStorageAddPage = function() { - $('#poolTypeId').selectMenu(); - $('#serverComboboxId').combobox(); - $('#targetFilterSelectId').filterselect(); - var options = [ { - label : "DIR", - value : "dir" - }, { - label : "NFS", - value : "netfs" - } ,{ - label : "iSCSI", - value : "iscsi" - } ]; kimchi.listHostPartitions(function(data) { if (data.length > 0) { - options.push({ - label : "LOGICAL", - value : "logical" - }); var deviceHtml = $('#partitionTmpl').html(); var listHtml = ''; $.each(data, function(index, value) { @@ -50,87 +33,105 @@ kimchi.initStorageAddPage = function() { } }); $('.host-partition').html(listHtml); + } else { + $('.host-partition').html(i18n['KCHPOOL6011E']); } - $('#poolTypeId').selectMenu("setData", options); - kimchi.getStorageServers('netfs', function(data) { - var serverContent = []; - if (data.length > 0) { - $.each(data, function(index, value) { - serverContent.push({ - label : value.host, - value : value.host - }); - }); - } - $('#serverComboboxId').combobox("setData", serverContent); - $('input[name=nfsServerType]').change(function() { - if ($(this).val() === 'input') { - $('#nfsServerInputDiv').removeClass('tmpl-html'); - $('#nfsServerChooseDiv').addClass('tmpl-html'); - } else { - $('#nfsServerInputDiv').addClass('tmpl-html'); - $('#nfsServerChooseDiv').removeClass('tmpl-html'); - } - }); - $('#nfsserverId').on("change",function() { - if ($(this).val() !== '' && kimchi.isServer($(this).val())) { - $('#nfspathId').prop('disabled',false); - $(this).removeClass("invalid-field"); - } else { - $(this).addClass("invalid-field"); - $('#nfspathId').prop( "disabled",true); - } - $('#targetFilterSelectId').filterselect('clear'); - }); - $('#nfspathId').focus(function() { - var targetContent = []; - kimchi.getStorageTargets($('#nfsserverId').val(), 'netfs', function(data) { - if (data.length > 0) { - $.each(data, function(index, value) { - targetContent.push({ - label : value.target, - value : value.target - }); - }); - } - $('#targetFilterSelectId').filterselect("setData", targetContent); + }); + kimchi.getStorageServers('netfs', function(data) { + var serverContent = []; + if (data.length > 0) { + $.each(data, function(index, value) { + serverContent.push({ + label : value.host, + value : value.host }); }); - }); - $('#poolTypeInputId').change(function() { - if ($(this).val() === 'dir') { - $('.path-section').removeClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); - } else if ($(this).val() === 'netfs') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').removeClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); - } else if ($(this).val() === 'iscsi') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').removeClass('tmpl-html'); - } else if ($(this).val() === 'logical') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').removeClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); + } + $('#serverComboboxId').combobox("setData", serverContent); + $('input[name=nfsServerType]').change(function() { + if ($(this).val() === 'input') { + $('#nfsServerInputDiv').removeClass('tmpl-html'); + $('#nfsServerChooseDiv').addClass('tmpl-html'); + } else { + $('#nfsServerInputDiv').addClass('tmpl-html'); + $('#nfsServerChooseDiv').removeClass('tmpl-html'); } }); - $('#authId').click(function() { - if ($(this).prop("checked")) { - $('.authenticationfield').removeClass('tmpl-html'); + $('#nfsserverId').on("change",function() { + if ($(this).val() !== '' && kimchi.isServer($(this).val())) { + $('#nfspathId').prop('disabled',false); + $(this).removeClass("invalid-field"); } else { - $('.authenticationfield').addClass('tmpl-html'); + $(this).addClass("invalid-field"); + $('#nfspathId').prop( "disabled",true); } + $('#targetFilterSelectId').filterselect('clear'); }); - $('#iscsiportId').keyup(function(event) { - $(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val())); + $('#nfspathId').focus(function() { + var targetContent = []; + kimchi.getStorageTargets($('#nfsserverId').val(), 'netfs', function(data) { + if (data.length > 0) { + $.each(data, function(index, value) { + targetContent.push({ + label : value.target, + value : value.target + }); + }); + } + $('#targetFilterSelectId').filterselect("setData", targetContent); + }); }); }); + $('#poolTypeId').selectMenu(); + $('#serverComboboxId').combobox(); + $('#targetFilterSelectId').filterselect(); + var options = [ { + label : "DIR", + value : "dir" + }, { + label : "NFS", + value : "netfs" + } ,{ + label : "iSCSI", + value : "iscsi" + } ,{ + label : "LOGICAL", + value : "logical" + } ]; + $('#poolTypeId').selectMenu("setData", options); + $('#poolTypeInputId').change(function() { + if ($(this).val() === 'dir') { + $('.path-section').removeClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } else if ($(this).val() === 'netfs') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').removeClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } else if ($(this).val() === 'iscsi') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').removeClass('tmpl-html'); + } else if ($(this).val() === 'logical') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').removeClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } + }); + $('#authId').click(function() { + if ($(this).prop("checked")) { + $('.authenticationfield').removeClass('tmpl-html'); + } else { + $('.authenticationfield').addClass('tmpl-html'); + } + }); + $('#iscsiportId').keyup(function(event) { + $(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val())); + }); }; kimchi.validateForm = function() { -- 1.8.3.1

On 02/28/2014 04:50 PM, Daniel Barboza wrote:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
The changes in ui/js/src/kimchi.storagepool_add_main.js were made to relieve the storage pool type dropbox from the return of the ajax call to retrieve the available partitions of the host.
The dropbox will always have all the options displayed. In case of the LOGICAL pool type the user won't be able to proceed with the creation of the pool if no partitions are found. A message is being displayed to warn the user.
As all the options will be always shown to user I suggest to put them on tmpl.html file
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- ui/js/src/kimchi.storagepool_add_main.js | 177 ++++++++++++++++--------------- 1 file changed, 89 insertions(+), 88 deletions(-)
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index 5960c8d..1332051 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -23,25 +23,8 @@ kimchi.storagepool_add_main = function() { };
kimchi.initStorageAddPage = function() { - $('#poolTypeId').selectMenu(); - $('#serverComboboxId').combobox(); - $('#targetFilterSelectId').filterselect(); - var options = [ { - label : "DIR", - value : "dir" - }, { - label : "NFS", - value : "netfs" - } ,{ - label : "iSCSI", - value : "iscsi" - } ]; kimchi.listHostPartitions(function(data) { if (data.length > 0) { - options.push({ - label : "LOGICAL", - value : "logical" - }); var deviceHtml = $('#partitionTmpl').html(); var listHtml = ''; $.each(data, function(index, value) { @@ -50,87 +33,105 @@ kimchi.initStorageAddPage = function() { } }); $('.host-partition').html(listHtml); + } else { + $('.host-partition').html(i18n['KCHPOOL6011E']); } - $('#poolTypeId').selectMenu("setData", options); - kimchi.getStorageServers('netfs', function(data) { - var serverContent = []; - if (data.length > 0) { - $.each(data, function(index, value) { - serverContent.push({ - label : value.host, - value : value.host - }); - }); - } - $('#serverComboboxId').combobox("setData", serverContent); - $('input[name=nfsServerType]').change(function() { - if ($(this).val() === 'input') { - $('#nfsServerInputDiv').removeClass('tmpl-html'); - $('#nfsServerChooseDiv').addClass('tmpl-html'); - } else { - $('#nfsServerInputDiv').addClass('tmpl-html'); - $('#nfsServerChooseDiv').removeClass('tmpl-html'); - } - }); - $('#nfsserverId').on("change",function() { - if ($(this).val() !== '' && kimchi.isServer($(this).val())) { - $('#nfspathId').prop('disabled',false); - $(this).removeClass("invalid-field"); - } else { - $(this).addClass("invalid-field"); - $('#nfspathId').prop( "disabled",true); - } - $('#targetFilterSelectId').filterselect('clear'); - }); - $('#nfspathId').focus(function() { - var targetContent = []; - kimchi.getStorageTargets($('#nfsserverId').val(), 'netfs', function(data) { - if (data.length > 0) { - $.each(data, function(index, value) { - targetContent.push({ - label : value.target, - value : value.target - }); - }); - } - $('#targetFilterSelectId').filterselect("setData", targetContent); + }); + kimchi.getStorageServers('netfs', function(data) { + var serverContent = []; + if (data.length > 0) { + $.each(data, function(index, value) { + serverContent.push({ + label : value.host, + value : value.host }); }); - }); - $('#poolTypeInputId').change(function() { - if ($(this).val() === 'dir') { - $('.path-section').removeClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); - } else if ($(this).val() === 'netfs') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').removeClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); - } else if ($(this).val() === 'iscsi') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').removeClass('tmpl-html'); - } else if ($(this).val() === 'logical') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').removeClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); + } + $('#serverComboboxId').combobox("setData", serverContent); + $('input[name=nfsServerType]').change(function() { + if ($(this).val() === 'input') { + $('#nfsServerInputDiv').removeClass('tmpl-html'); + $('#nfsServerChooseDiv').addClass('tmpl-html'); + } else { + $('#nfsServerInputDiv').addClass('tmpl-html'); + $('#nfsServerChooseDiv').removeClass('tmpl-html'); } }); - $('#authId').click(function() { - if ($(this).prop("checked")) { - $('.authenticationfield').removeClass('tmpl-html'); + $('#nfsserverId').on("change",function() { + if ($(this).val() !== '' && kimchi.isServer($(this).val())) { + $('#nfspathId').prop('disabled',false); + $(this).removeClass("invalid-field"); } else { - $('.authenticationfield').addClass('tmpl-html'); + $(this).addClass("invalid-field"); + $('#nfspathId').prop( "disabled",true); } + $('#targetFilterSelectId').filterselect('clear'); }); - $('#iscsiportId').keyup(function(event) { - $(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val())); + $('#nfspathId').focus(function() { + var targetContent = []; + kimchi.getStorageTargets($('#nfsserverId').val(), 'netfs', function(data) { + if (data.length > 0) { + $.each(data, function(index, value) { + targetContent.push({ + label : value.target, + value : value.target + }); + }); + } + $('#targetFilterSelectId').filterselect("setData", targetContent); + }); }); }); + $('#poolTypeId').selectMenu(); + $('#serverComboboxId').combobox(); + $('#targetFilterSelectId').filterselect(); + var options = [ { + label : "DIR", + value : "dir" + }, { + label : "NFS", + value : "netfs" + } ,{ + label : "iSCSI", + value : "iscsi" + } ,{ + label : "LOGICAL", + value : "logical" + } ]; + $('#poolTypeId').selectMenu("setData", options); + $('#poolTypeInputId').change(function() { + if ($(this).val() === 'dir') { + $('.path-section').removeClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } else if ($(this).val() === 'netfs') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').removeClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } else if ($(this).val() === 'iscsi') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').removeClass('tmpl-html'); + } else if ($(this).val() === 'logical') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').removeClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } + }); + $('#authId').click(function() { + if ($(this).prop("checked")) { + $('.authenticationfield').removeClass('tmpl-html'); + } else { + $('.authenticationfield').addClass('tmpl-html'); + } + }); + $('#iscsiportId').keyup(function(event) { + $(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val())); + }); };
kimchi.validateForm = function() {

On 03/03/2014 03:09 PM, Aline Manera wrote:
On 02/28/2014 04:50 PM, Daniel Barboza wrote:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
The changes in ui/js/src/kimchi.storagepool_add_main.js were made to relieve the storage pool type dropbox from the return of the ajax call to retrieve the available partitions of the host.
The dropbox will always have all the options displayed. In case of the LOGICAL pool type the user won't be able to proceed with the creation of the pool if no partitions are found. A message is being displayed to warn the user.
As all the options will be always shown to user I suggest to put them on tmpl.html file
I tried to do that but failed miserably :( If you see in the JS you'll notice that this select is created using this call $('#poolTypeId').selectMenu("setData", options); This call is declared in the widgets/select-menu.js and it is a rather complex JQuery call, which I wasn't able to put it "hardcoded" in the template.
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- ui/js/src/kimchi.storagepool_add_main.js | 177 ++++++++++++++++--------------- 1 file changed, 89 insertions(+), 88 deletions(-)
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index 5960c8d..1332051 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -23,25 +23,8 @@ kimchi.storagepool_add_main = function() { };
kimchi.initStorageAddPage = function() { - $('#poolTypeId').selectMenu(); - $('#serverComboboxId').combobox(); - $('#targetFilterSelectId').filterselect(); - var options = [ { - label : "DIR", - value : "dir" - }, { - label : "NFS", - value : "netfs" - } ,{ - label : "iSCSI", - value : "iscsi" - } ]; kimchi.listHostPartitions(function(data) { if (data.length > 0) { - options.push({ - label : "LOGICAL", - value : "logical" - }); var deviceHtml = $('#partitionTmpl').html(); var listHtml = ''; $.each(data, function(index, value) { @@ -50,87 +33,105 @@ kimchi.initStorageAddPage = function() { } }); $('.host-partition').html(listHtml); + } else { + $('.host-partition').html(i18n['KCHPOOL6011E']); } - $('#poolTypeId').selectMenu("setData", options); - kimchi.getStorageServers('netfs', function(data) { - var serverContent = []; - if (data.length > 0) { - $.each(data, function(index, value) { - serverContent.push({ - label : value.host, - value : value.host - }); - }); - } - $('#serverComboboxId').combobox("setData", serverContent); - $('input[name=nfsServerType]').change(function() { - if ($(this).val() === 'input') { - $('#nfsServerInputDiv').removeClass('tmpl-html'); - $('#nfsServerChooseDiv').addClass('tmpl-html'); - } else { - $('#nfsServerInputDiv').addClass('tmpl-html'); - $('#nfsServerChooseDiv').removeClass('tmpl-html'); - } - }); - $('#nfsserverId').on("change",function() { - if ($(this).val() !== '' && kimchi.isServer($(this).val())) { - $('#nfspathId').prop('disabled',false); - $(this).removeClass("invalid-field"); - } else { - $(this).addClass("invalid-field"); - $('#nfspathId').prop( "disabled",true); - } - $('#targetFilterSelectId').filterselect('clear'); - }); - $('#nfspathId').focus(function() { - var targetContent = []; - kimchi.getStorageTargets($('#nfsserverId').val(), 'netfs', function(data) { - if (data.length > 0) { - $.each(data, function(index, value) { - targetContent.push({ - label : value.target, - value : value.target - }); - }); - } - $('#targetFilterSelectId').filterselect("setData", targetContent); + }); + kimchi.getStorageServers('netfs', function(data) { + var serverContent = []; + if (data.length > 0) { + $.each(data, function(index, value) { + serverContent.push({ + label : value.host, + value : value.host }); }); - }); - $('#poolTypeInputId').change(function() { - if ($(this).val() === 'dir') { - $('.path-section').removeClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); - } else if ($(this).val() === 'netfs') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').removeClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); - } else if ($(this).val() === 'iscsi') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').removeClass('tmpl-html'); - } else if ($(this).val() === 'logical') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').removeClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); + } + $('#serverComboboxId').combobox("setData", serverContent); + $('input[name=nfsServerType]').change(function() { + if ($(this).val() === 'input') { + $('#nfsServerInputDiv').removeClass('tmpl-html'); + $('#nfsServerChooseDiv').addClass('tmpl-html'); + } else { + $('#nfsServerInputDiv').addClass('tmpl-html'); + $('#nfsServerChooseDiv').removeClass('tmpl-html'); } }); - $('#authId').click(function() { - if ($(this).prop("checked")) { - $('.authenticationfield').removeClass('tmpl-html'); + $('#nfsserverId').on("change",function() { + if ($(this).val() !== '' && kimchi.isServer($(this).val())) { + $('#nfspathId').prop('disabled',false); + $(this).removeClass("invalid-field"); } else { - $('.authenticationfield').addClass('tmpl-html'); + $(this).addClass("invalid-field"); + $('#nfspathId').prop( "disabled",true); } + $('#targetFilterSelectId').filterselect('clear'); }); - $('#iscsiportId').keyup(function(event) { - $(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val())); + $('#nfspathId').focus(function() { + var targetContent = []; + kimchi.getStorageTargets($('#nfsserverId').val(), 'netfs', function(data) { + if (data.length > 0) { + $.each(data, function(index, value) { + targetContent.push({ + label : value.target, + value : value.target + }); + }); + } + $('#targetFilterSelectId').filterselect("setData", targetContent); + }); }); }); + $('#poolTypeId').selectMenu(); + $('#serverComboboxId').combobox(); + $('#targetFilterSelectId').filterselect(); + var options = [ { + label : "DIR", + value : "dir" + }, { + label : "NFS", + value : "netfs" + } ,{ + label : "iSCSI", + value : "iscsi" + } ,{ + label : "LOGICAL", + value : "logical" + } ]; + $('#poolTypeId').selectMenu("setData", options); + $('#poolTypeInputId').change(function() { + if ($(this).val() === 'dir') { + $('.path-section').removeClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } else if ($(this).val() === 'netfs') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').removeClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } else if ($(this).val() === 'iscsi') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').removeClass('tmpl-html'); + } else if ($(this).val() === 'logical') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').removeClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } + }); + $('#authId').click(function() { + if ($(this).prop("checked")) { + $('.authenticationfield').removeClass('tmpl-html'); + } else { + $('.authenticationfield').addClass('tmpl-html'); + } + }); + $('#iscsiportId').keyup(function(event) { + $(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val())); + }); };
kimchi.validateForm = function() {

On 03/03/2014 05:13 PM, Daniel H Barboza wrote:
On 03/03/2014 03:09 PM, Aline Manera wrote:
On 02/28/2014 04:50 PM, Daniel Barboza wrote:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
The changes in ui/js/src/kimchi.storagepool_add_main.js were made to relieve the storage pool type dropbox from the return of the ajax call to retrieve the available partitions of the host.
The dropbox will always have all the options displayed. In case of the LOGICAL pool type the user won't be able to proceed with the creation of the pool if no partitions are found. A message is being displayed to warn the user.
As all the options will be always shown to user I suggest to put them on tmpl.html file
I tried to do that but failed miserably :(
If you see in the JS you'll notice that this select is created using this call
$('#poolTypeId').selectMenu("setData", options);
This call is declared in the widgets/select-menu.js and it is a rather complex JQuery call, which I wasn't able to put it "hardcoded" in the template.
Got it. Thanks for the explanation
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- ui/js/src/kimchi.storagepool_add_main.js | 177 ++++++++++++++++--------------- 1 file changed, 89 insertions(+), 88 deletions(-)
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index 5960c8d..1332051 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -23,25 +23,8 @@ kimchi.storagepool_add_main = function() { };
kimchi.initStorageAddPage = function() { - $('#poolTypeId').selectMenu(); - $('#serverComboboxId').combobox(); - $('#targetFilterSelectId').filterselect(); - var options = [ { - label : "DIR", - value : "dir" - }, { - label : "NFS", - value : "netfs" - } ,{ - label : "iSCSI", - value : "iscsi" - } ]; kimchi.listHostPartitions(function(data) { if (data.length > 0) { - options.push({ - label : "LOGICAL", - value : "logical" - }); var deviceHtml = $('#partitionTmpl').html(); var listHtml = ''; $.each(data, function(index, value) { @@ -50,87 +33,105 @@ kimchi.initStorageAddPage = function() { } }); $('.host-partition').html(listHtml); + } else { + $('.host-partition').html(i18n['KCHPOOL6011E']); } - $('#poolTypeId').selectMenu("setData", options); - kimchi.getStorageServers('netfs', function(data) { - var serverContent = []; - if (data.length > 0) { - $.each(data, function(index, value) { - serverContent.push({ - label : value.host, - value : value.host - }); - }); - } - $('#serverComboboxId').combobox("setData", serverContent); - $('input[name=nfsServerType]').change(function() { - if ($(this).val() === 'input') { - $('#nfsServerInputDiv').removeClass('tmpl-html'); - $('#nfsServerChooseDiv').addClass('tmpl-html'); - } else { - $('#nfsServerInputDiv').addClass('tmpl-html'); - $('#nfsServerChooseDiv').removeClass('tmpl-html'); - } - }); - $('#nfsserverId').on("change",function() { - if ($(this).val() !== '' && kimchi.isServer($(this).val())) { - $('#nfspathId').prop('disabled',false); - $(this).removeClass("invalid-field"); - } else { - $(this).addClass("invalid-field"); - $('#nfspathId').prop( "disabled",true); - } - $('#targetFilterSelectId').filterselect('clear'); - }); - $('#nfspathId').focus(function() { - var targetContent = []; - kimchi.getStorageTargets($('#nfsserverId').val(), 'netfs', function(data) { - if (data.length > 0) { - $.each(data, function(index, value) { - targetContent.push({ - label : value.target, - value : value.target - }); - }); - } - $('#targetFilterSelectId').filterselect("setData", targetContent); + }); + kimchi.getStorageServers('netfs', function(data) { + var serverContent = []; + if (data.length > 0) { + $.each(data, function(index, value) { + serverContent.push({ + label : value.host, + value : value.host }); }); - }); - $('#poolTypeInputId').change(function() { - if ($(this).val() === 'dir') { - $('.path-section').removeClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); - } else if ($(this).val() === 'netfs') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').removeClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); - } else if ($(this).val() === 'iscsi') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').addClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').removeClass('tmpl-html'); - } else if ($(this).val() === 'logical') { - $('.path-section').addClass('tmpl-html'); - $('.logical-section').removeClass('tmpl-html'); - $('.nfs-section').addClass('tmpl-html'); - $('.iscsi-section').addClass('tmpl-html'); + } + $('#serverComboboxId').combobox("setData", serverContent); + $('input[name=nfsServerType]').change(function() { + if ($(this).val() === 'input') { + $('#nfsServerInputDiv').removeClass('tmpl-html'); + $('#nfsServerChooseDiv').addClass('tmpl-html'); + } else { + $('#nfsServerInputDiv').addClass('tmpl-html'); + $('#nfsServerChooseDiv').removeClass('tmpl-html'); } }); - $('#authId').click(function() { - if ($(this).prop("checked")) { - $('.authenticationfield').removeClass('tmpl-html'); + $('#nfsserverId').on("change",function() { + if ($(this).val() !== '' && kimchi.isServer($(this).val())) { + $('#nfspathId').prop('disabled',false); + $(this).removeClass("invalid-field"); } else { - $('.authenticationfield').addClass('tmpl-html'); + $(this).addClass("invalid-field"); + $('#nfspathId').prop( "disabled",true); } + $('#targetFilterSelectId').filterselect('clear'); }); - $('#iscsiportId').keyup(function(event) { - $(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val())); + $('#nfspathId').focus(function() { + var targetContent = []; + kimchi.getStorageTargets($('#nfsserverId').val(), 'netfs', function(data) { + if (data.length > 0) { + $.each(data, function(index, value) { + targetContent.push({ + label : value.target, + value : value.target + }); + }); + } + $('#targetFilterSelectId').filterselect("setData", targetContent); + }); }); }); + $('#poolTypeId').selectMenu(); + $('#serverComboboxId').combobox(); + $('#targetFilterSelectId').filterselect(); + var options = [ { + label : "DIR", + value : "dir" + }, { + label : "NFS", + value : "netfs" + } ,{ + label : "iSCSI", + value : "iscsi" + } ,{ + label : "LOGICAL", + value : "logical" + } ]; + $('#poolTypeId').selectMenu("setData", options); + $('#poolTypeInputId').change(function() { + if ($(this).val() === 'dir') { + $('.path-section').removeClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } else if ($(this).val() === 'netfs') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').removeClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } else if ($(this).val() === 'iscsi') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').addClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').removeClass('tmpl-html'); + } else if ($(this).val() === 'logical') { + $('.path-section').addClass('tmpl-html'); + $('.logical-section').removeClass('tmpl-html'); + $('.nfs-section').addClass('tmpl-html'); + $('.iscsi-section').addClass('tmpl-html'); + } + }); + $('#authId').click(function() { + if ($(this).prop("checked")) { + $('.authenticationfield').removeClass('tmpl-html'); + } else { + $('.authenticationfield').addClass('tmpl-html'); + } + }); + $('#iscsiportId').keyup(function(event) { + $(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val())); + }); };
kimchi.validateForm = function() {

From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> This patch contains changes in ui/pages/storagepool-add.html.tmpl to reflect the new behavior of the page. A message saying "Loading ..." with the loading.gif picture is now displayed in the LOGICAL frame when there are no partition data yet. When partition data arrives, the view is displayed normally. If no partition data is available a warning message is displayed instead. The new strings were added in ui/pages/i18n.html.tmpl and the .po files were update by using 'make -C po update-po'. Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- po/en_US.po | 21 ++++++++++++++++++++- po/kimchi.pot | 20 +++++++++++++++++++- po/pt_BR.po | 21 ++++++++++++++++++++- po/zh_CN.po | 21 ++++++++++++++++++++- ui/pages/i18n.html.tmpl | 5 +++-- ui/pages/storagepool-add.html.tmpl | 7 ++++++- 6 files changed, 88 insertions(+), 7 deletions(-) diff --git a/po/en_US.po b/po/en_US.po index aeff16e..0d19ef4 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: kimchi 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-25 15:23-0300\n" +"POT-Creation-Date: 2014-02-28 10:34-0300\n" "PO-Revision-Date: 2013-07-11 17:32-0400\n" "Last-Translator: Crístian Viana <vianac@linux.vnet.ibm.com>\n" "Language-Team: English\n" @@ -305,6 +305,13 @@ msgstr "Server name can not be blank." msgid "This is not a valid Server Name or IP. please, modify it." msgstr "This is not a valid Server Name or IP. please, modify it." +msgid "Looking for available partitions ..." +msgstr "" + +#, fuzzy +msgid "No available partitions found." +msgstr "No templates found." + msgid "Help" msgstr "" @@ -947,6 +954,18 @@ msgstr "" #, python-format msgid "" +"Unable to activate NFS storage pool %(name)s. NFS server %(server)s is " +"unreachable." +msgstr "" + +#, python-format +msgid "" +"Unable to deactivate NFS storage pool %(name)s. NFS server %(server)s is " +"unreachable." +msgstr "" + +#, python-format +msgid "" "Unable to deactivate pool %(name)s as it is associated with some templates" msgstr "" diff --git a/po/kimchi.pot b/po/kimchi.pot index abb7219..b4f8bd8 100755 --- a/po/kimchi.pot +++ b/po/kimchi.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-25 15:23-0300\n" +"POT-Creation-Date: 2014-02-28 10:34-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -297,6 +297,12 @@ msgstr "" msgid "This is not a valid Server Name or IP. please, modify it." msgstr "" +msgid "Looking for available partitions ..." +msgstr "" + +msgid "No available partitions found." +msgstr "" + msgid "Help" msgstr "" @@ -935,6 +941,18 @@ msgstr "" #, python-format msgid "" +"Unable to activate NFS storage pool %(name)s. NFS server %(server)s is " +"unreachable." +msgstr "" + +#, python-format +msgid "" +"Unable to deactivate NFS storage pool %(name)s. NFS server %(server)s is " +"unreachable." +msgstr "" + +#, python-format +msgid "" "Unable to deactivate pool %(name)s as it is associated with some templates" msgstr "" diff --git a/po/pt_BR.po b/po/pt_BR.po index db7c579..11eb039 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: kimchi 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-25 15:23-0300\n" +"POT-Creation-Date: 2014-02-28 10:34-0300\n" "PO-Revision-Date: 2013-06-27 10:48+0000\n" "Last-Translator: Crístian Viana <vianac@linux.vnet.ibm.com>\n" "Language-Team: Aline Manera <alinefm@br.ibm.com>\n" @@ -323,6 +323,13 @@ msgstr "" msgid "This is not a valid Server Name or IP. please, modify it." msgstr "" +msgid "Looking for available partitions ..." +msgstr "" + +#, fuzzy +msgid "No available partitions found." +msgstr "Nenhum modelo encontrado." + msgid "Help" msgstr "" @@ -962,6 +969,18 @@ msgstr "" #, python-format msgid "" +"Unable to activate NFS storage pool %(name)s. NFS server %(server)s is " +"unreachable." +msgstr "" + +#, python-format +msgid "" +"Unable to deactivate NFS storage pool %(name)s. NFS server %(server)s is " +"unreachable." +msgstr "" + +#, python-format +msgid "" "Unable to deactivate pool %(name)s as it is associated with some templates" msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po index 0439b04..bf118e2 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: kimchi 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-25 15:23-0300\n" +"POT-Creation-Date: 2014-02-28 10:34-0300\n" "PO-Revision-Date: 2013-06-27 10:48+0000\n" "Last-Translator: ShaoHe Feng <shaohef@linux.vnet.ibm.com>\n" "Language-Team: ShaoHe Feng <shaohef@linux.vnet.ibm.com>\n" @@ -313,6 +313,13 @@ msgstr "服务器不能为空" msgid "This is not a valid Server Name or IP. please, modify it." msgstr "这不是一个有效的服务器名或IP,请修改" +msgid "Looking for available partitions ..." +msgstr "" + +#, fuzzy +msgid "No available partitions found." +msgstr "没有发现模板" + msgid "Help" msgstr "" @@ -951,6 +958,18 @@ msgstr "" #, python-format msgid "" +"Unable to activate NFS storage pool %(name)s. NFS server %(server)s is " +"unreachable." +msgstr "" + +#, python-format +msgid "" +"Unable to deactivate NFS storage pool %(name)s. NFS server %(server)s is " +"unreachable." +msgstr "" + +#, python-format +msgid "" "Unable to deactivate pool %(name)s as it is associated with some templates" msgstr "" diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl index db6166e..fff7ceb 100644 --- a/ui/pages/i18n.html.tmpl +++ b/ui/pages/i18n.html.tmpl @@ -90,7 +90,6 @@ var i18n = { 'KCHDR6011M': "$_("Report name should contain only letters, digits and/or hyphen ('-').")", 'KCHVM6001M': "$_("This will delete the virtual machine and its virtual disks. This operation cannot be undone. Would you like to continue?")", - 'KCHVM6002M': "$_("Delete Confirmation")", 'KCHNET6001E': "$_("The VLAN id must be between 1 and 4094.")", @@ -110,7 +109,9 @@ var i18n = { 'KCHPOOL6006E': "$_("No logical device selected.")", 'KCHPOOL6007E': "$_("The iSCSI target can not be blank.")", 'KCHPOOL6008E': "$_("Server name can not be blank.")", - 'KCHPOOL6009E': "$_("This is not a valid Server Name or IP. please, modify it.")" + 'KCHPOOL6009E': "$_("This is not a valid Server Name or IP. please, modify it.")", + 'KCHPOOL6010M': "$_("Looking for available partitions ...")", + 'KCHPOOL6011M': "$_("No available partitions found.")" }; </script> </body> diff --git a/ui/pages/storagepool-add.html.tmpl b/ui/pages/storagepool-add.html.tmpl index 0a622db..222788f 100644 --- a/ui/pages/storagepool-add.html.tmpl +++ b/ui/pages/storagepool-add.html.tmpl @@ -97,7 +97,12 @@ <div class="logical-section tmpl-html"> <section class="form-section storageType"> <h2>3. $_("Device path")</h2> - <div class="host-partition"></div> + <div class="host-partition"> + <p class="text-help"> + $_("Looking for available partitions ...") + <img src = "../images/theme-default/loading.gif" /> + </p> + </div> </section> </div> <div class="iscsi-section tmpl-html"> -- 1.8.3.1

Reviewed-by: Crístian Viana <vianac@linux.vnet.ibm.com> Am 28-02-2014 16:50, schrieb Daniel Barboza:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Changelog: v2: - Fixing message ID
These patches fixes the bug where the list of storage pool types can take a long time to appear. The solution used here is to detach the view of such list with the return of the JSON that loads the partition data.
To test this patch I recomend doing the following change in src/kimchi/model/hosts.py:
+ import time
class PartitionsModel(object): def __init__(self, **kargs): pass
def get_list(self): + time.sleep(10) result = disks.get_partitions_names() return result
The sleep(10) call will ensure that get_list (which returns the partition data) will take at least 10 seconds to execute. It is enough time to select the LOGICAL type and see how the UI is working before and after the JSON call.
Daniel Henrique Barboza (2): Github bug #307: add storage pool type list - JS changes Github bug #307: storage pool type list - html and string changes
po/en_US.po | 21 +++- po/kimchi.pot | 20 +++- po/pt_BR.po | 21 +++- po/zh_CN.po | 21 +++- ui/js/src/kimchi.storagepool_add_main.js | 177 ++++++++++++++++--------------- ui/pages/i18n.html.tmpl | 5 +- ui/pages/storagepool-add.html.tmpl | 7 +- 7 files changed, 177 insertions(+), 95 deletions(-)
participants (4)
-
Aline Manera
-
Crístian Viana
-
Daniel Barboza
-
Daniel H Barboza