diff --git a/src/sunstone/public/js/plugins/datastores-tab.js b/src/sunstone/public/js/plugins/datastores-tab.js
index e6c497d3dd..55771177c6 100644
--- a/src/sunstone/public/js/plugins/datastores-tab.js
+++ b/src/sunstone/public/js/plugins/datastores-tab.js
@@ -610,6 +610,25 @@ Sunstone.addMainTab('datastores-tab',datastores_tab);
Sunstone.addInfoPanel('datastore_info_panel',datastore_info_panel);
+function generate_datastore_capacity_bar(ds, ds_type) {
+ var total = parseInt(ds.TOTAL_MB);
+
+ var used = total - parseInt(ds.FREE_MB);
+
+ if (total > 0) {
+ var ratio = Math.round((used / total) * 100);
+ info_str = humanize_size_from_mb(used) + ' / ' + humanize_size_from_mb(total) + ' (' + ratio + '%)';
+ } else {
+ if(ds_type == 1) {
+ info_str = '- / -';
+ } else {
+ info_str = humanize_size(used) + ' / -';
+ }
+ }
+
+ return quotaBarHtml(used, total, info_str);
+}
+
function datastoreElements() {
return getSelectedNodes(dataTable_datastores);
}
@@ -617,29 +636,14 @@ function datastoreElements() {
function datastoreElementArray(element_json){
var element = element_json.DATASTORE;
- var type = "IMAGE_DS";
+ var ds_type_str = "IMAGE_DS";
if (typeof element.TEMPLATE.TYPE != "undefined")
{
- type = element.TEMPLATE.TYPE;
+ ds_type_str = element.TEMPLATE.TYPE;
}
- var total = parseInt(element.TOTAL_MB);
-
- var used = total - parseInt(element.FREE_MB);
-
- if (total > 0) {
- var ratio = Math.round((used / total) * 100);
- info_str = humanize_size_from_mb(used) + ' / ' + humanize_size_from_mb(total) + ' (' + ratio + '%)';
- } else {
- if(element.TYPE == 1) {
- info_str = '- / -';
- } else {
- info_str = humanize_size(used) + ' / -';
- }
- }
-
- var pb_capacity = quotaBarHtml(used, total, info_str);
+ var pb_capacity = generate_datastore_capacity_bar(element, element.TYPE);
return [
'\
+ \
+ \
+ \
+ \
+ ' + tr("Datastore ID") + ' \
+ ' + tr("Capacity") + ' \
+