From: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
Signed-off-by: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.api.js | 12 +++++++++
ui/js/src/kimchi.storage_main.js | 38 ++++++++++++++++++++++++++++++
ui/js/src/kimchi.storagepool_add_main.js | 2 +-
ui/pages/i18n.html.tmpl | 1 +
ui/pages/tabs/storage.html.tmpl | 10 ++++++++
5 files changed, 62 insertions(+), 1 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 686141b..ee7f0d8 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -745,5 +745,17 @@ var kimchi = {
kimchi.message.error(data.responseJSON.reason);
}
});
+ },
+
+ updateStoragePool : function(name, content, suc, err) {
+ $.ajax({
+ url : kimchi.url + "storagepools/" + encodeURIComponent(name),
+ type : 'PUT',
+ contentType : 'application/json',
+ dataType : 'json',
+ data : JSON.stringify(content)
+ }).done(suc).fail(err ? err : function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ });
}
};
diff --git a/ui/js/src/kimchi.storage_main.js b/ui/js/src/kimchi.storage_main.js
index d65da0b..40aceb7 100644
--- a/ui/js/src/kimchi.storage_main.js
+++ b/ui/js/src/kimchi.storage_main.js
@@ -27,6 +27,7 @@ kimchi.doListStoragePools = function() {
value.usage = parseInt(value.allocated / value.capacity * 100) || 0;
value.capacity = kimchi.changetoProperUnit(value.capacity,1);
value.allocated = kimchi.changetoProperUnit(value.allocated,1);
+ value.enableExt = value.type==="logical" ? "" :
"hide-content";
if ('kimchi-iso' !== value.type) {
listHtml += kimchi.template(storageHtml, value);
}
@@ -140,6 +141,10 @@ kimchi.storageBindClick = function() {
}
}
});
+ $('.pool-extend').on('click', function() {
+ $("#logicalPoolExtend").dialog("option",
"poolName", $(this).data('name'));
+ $("#logicalPoolExtend").dialog("open");
+ });
}
kimchi.doListVolumes = function(poolObj) {
@@ -170,11 +175,44 @@ kimchi.doListVolumes = function(poolObj) {
});
}
+kimchi.initLogicalPoolExtend = function() {
+ $("#logicalPoolExtend").dialog({
+ autoOpen : false,
+ modal : true,
+ width : 600,
+ resizable : false,
+ closeText: "X",
+ open : function(){
+ $(".ui-dialog-titlebar-close",
$("#logicalPoolExtend").parent()).removeAttr("title");
+ kimchi.listHostPartitions(function(data) {
+ for(var i=0;i<data.length;i++){
+ if (data[i].type === 'part' || data[i].type ===
'disk') {
+ $('.host-partition',
'#logicalPoolExtend').append(kimchi.template($('#logicalPoolExtendTmpl').html(),
data[i]));
+ }
+ }
+ });
+ },
+ beforeClose : function() { $('.host-partition',
'#logicalPoolExtend').empty(); },
+ buttons : [{
+ class: "ui-button-primary",
+ text: i18n.KCHAPI6007M,
+ click: function(){
+ var devicePaths = [];
+ $("input[type='checkbox']:checked",
"#logicalPoolExtend").each(function(){
+ devicePaths.push($(this).prop('value'));
+ })
+
kimchi.updateStoragePool($("#logicalPoolExtend").dialog("option",
"poolName"),{disks: devicePaths});
+ }
+ }]
+ });
+}
+
kimchi.storage_main = function() {
$('#storage-pool-add').on('click', function() {
kimchi.window.open('storagepool-add.html');
});
kimchi.doListStoragePools();
+ kimchi.initLogicalPoolExtend();
}
kimchi.changeArrow = function(obj) {
diff --git a/ui/js/src/kimchi.storagepool_add_main.js
b/ui/js/src/kimchi.storagepool_add_main.js
index 43ff31a..beb59ed 100644
--- a/ui/js/src/kimchi.storagepool_add_main.js
+++ b/ui/js/src/kimchi.storagepool_add_main.js
@@ -53,7 +53,7 @@ kimchi.initStorageAddPage = function() {
listHtml += kimchi.template(deviceHtml, value);
}
});
- $('.host-partition').html(listHtml);
+ $('.host-partition', '#form-pool-add').html(listHtml);
}
kimchi.getStorageServers('netfs', function(data) {
var serverContent = [];
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
index fe8ed5b..26ac47b 100644
--- a/ui/pages/i18n.html.tmpl
+++ b/ui/pages/i18n.html.tmpl
@@ -62,6 +62,7 @@ var i18n = {
'KCHAPI6004M': "$_("Confirm")",
'KCHAPI6005M': "$_("Create")",
'KCHAPI6006M': "$_("Warning")",
+ 'KCHAPI6007M': "$_("Save")",
'KCHTMPL6001W': "$_("No iso found")",
diff --git a/ui/pages/tabs/storage.html.tmpl b/ui/pages/tabs/storage.html.tmpl
index 6930c22..d36c90e 100644
--- a/ui/pages/tabs/storage.html.tmpl
+++ b/ui/pages/tabs/storage.html.tmpl
@@ -44,6 +44,9 @@
</div>
<ul id="storagepoolsList" class="list-storage"></ul>
</div>
+<div id="logicalPoolExtend" title="$_("Device
path")">
+ <div class="host-partition"></div>
+</div>
<script id="storageTmpl" type="html/text">
<li id="{name}">
<div class="storage-li in" data-name="{name}"
data-stat="{state}">
@@ -78,6 +81,7 @@
<button class="button-big pool-deactivate"
data-stat="{state}" data-name="{name}"><span
class="text">$_("Deactivate")</span></button>
<button class="button-big pool-activate"
data-stat="{state}" data-name="{name}"><span
class="text">$_("Activate")</span></button>
<button class="button-big red pool-delete"
data-stat="{state}" data-name="{name}"><span
class="text">$_("Undefine")</span></button>
+ <button class="button-big pool-extend {enableExt}"
data-stat="{state}" data-name="{name}"><span
class="text">$_("Extend")</span></button>
</div>
</div>
</div>
@@ -110,6 +114,12 @@
</div>
</div>
</script>
+<script id="logicalPoolExtendTmpl" type="html/text">
+ <div>
+ <input type="checkbox" value="{path}"
name="devices">
+ <label for="{name}">{path}</label>
+ </div>
+</script>
<script>
kimchi.storage_main();
</script>
--
1.7.1