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

From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> Changelog: v3: - rebase with master 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 | 9 +- po/kimchi.pot | 8 +- po/pt_BR.po | 9 +- po/zh_CN.po | 9 +- ui/js/src/kimchi.storagepool_add_main.js | 174 ++++++++++++++++--------------- ui/pages/i18n.html.tmpl | 5 +- ui/pages/storagepool-add.html.tmpl | 7 +- 7 files changed, 129 insertions(+), 92 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 | 174 ++++++++++++++++--------------- 1 file changed, 89 insertions(+), 85 deletions(-) diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js index 0cc5349..10833be 100644 --- a/ui/js/src/kimchi.storagepool_add_main.js +++ b/ui/js/src/kimchi.storagepool_add_main.js @@ -23,6 +23,21 @@ kimchi.storagepool_add_main = function() { }; kimchi.initStorageAddPage = function() { + kimchi.listHostPartitions(function(data) { + if (data.length > 0) { + var deviceHtml = $('#partitionTmpl').html(); + var listHtml = ''; + $.each(data, function(index, value) { + if (value.type === 'part' || value.type === 'disk') { + listHtml += kimchi.template(deviceHtml, value); + } + }); + $('.host-partition').html(listHtml); + } else { + $('.host-partition').html(i18n['KCHPOOL6011M']); + } + }); + $('#poolTypeId').selectMenu(); $('#serverComboboxId').combobox(); $('#targetFilterSelectId').filterselect(); @@ -32,105 +47,94 @@ kimchi.initStorageAddPage = function() { }, { label : "NFS", value : "netfs" - } ,{ + }, { label : "iSCSI", value : "iscsi" + }, { + label : "LOGICAL", + value : "logical" } ]; - kimchi.listHostPartitions(function(data) { + $('#poolTypeId').selectMenu("setData", options); + + kimchi.getStorageServers('netfs', function(data) { + var serverContent = []; if (data.length > 0) { - options.push({ - label : "LOGICAL", - value : "logical" - }); - var deviceHtml = $('#partitionTmpl').html(); - var listHtml = ''; $.each(data, function(index, value) { - if (value.type === 'part' || value.type === 'disk') { - listHtml += kimchi.template(deviceHtml, value); - } - }); - $('.host-partition').html(listHtml); - } - $('#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 keyup",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); + 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 keyup",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); + }); }); }); + + $('#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

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 | 9 ++++++++- po/kimchi.pot | 8 +++++++- po/pt_BR.po | 9 ++++++++- po/zh_CN.po | 9 ++++++++- ui/pages/i18n.html.tmpl | 5 +++-- ui/pages/storagepool-add.html.tmpl | 7 ++++++- 6 files changed, 40 insertions(+), 7 deletions(-) diff --git a/po/en_US.po b/po/en_US.po index 7a10fe4..d9df56d 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-03-03 16:50-0300\n" +"POT-Creation-Date: 2014-03-03 17:18-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 "" diff --git a/po/kimchi.pot b/po/kimchi.pot index d9a7292..df89712 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-03-03 16:50-0300\n" +"POT-Creation-Date: 2014-03-03 17:18-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 "" diff --git a/po/pt_BR.po b/po/pt_BR.po index b66f543..f00edd8 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-03-03 16:50-0300\n" +"POT-Creation-Date: 2014-03-03 17:18-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 "" diff --git a/po/zh_CN.po b/po/zh_CN.po index ce0c376..366c6bf 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-03-03 16:50-0300\n" +"POT-Creation-Date: 2014-03-03 17:18-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 "" diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl index 38f71d9..a7dddf4 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
participants (2)
-
Aline Manera
-
Daniel Barboza