1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

Bug #4605, #4590: Show image size with unit suffix, fix column sorting

This commit is contained in:
Carlos Martín 2016-07-04 15:33:34 +02:00
parent d24dfa91cf
commit 35f9b6a4c9
3 changed files with 28 additions and 4 deletions

View File

@ -25,6 +25,8 @@ define(function(require) {
Foundation.DropdownMenu.defaults.clickOpen = true;
Foundation.Reveal.defaults.closeOnClick = false;
_setupDataTableSearch();
var DASHBOARD_TAB_ID = require('tabs/dashboard-tab/tabId');
var SETTINGS_TAB_ID = require('tabs/settings-tab/tabId');
var PROVISION_TAB_ID = require('tabs/provision-tab/tabId');
@ -175,4 +177,25 @@ define(function(require) {
Sunstone.showTab(SETTINGS_TAB_ID);
});
}
function _setupDataTableSearch() {
$.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
var matches = data.match( /^(\d+(?:\.\d+)?)\s*([a-z]+)/i );
var multipliers = {
B: 1,
KB: 1024,
MB: 1048576,
GB: 1073741824,
TB: 1099511627776,
PB: 1125899906842624
};
if (matches) {
var multiplier = multipliers[matches[2]];
return parseFloat( matches[1] ) * multiplier;
} else {
return -1;
}
}
}
});

View File

@ -54,7 +54,8 @@ define(function(require) {
{"bSortable": false, "aTargets": ["check"]},
{"sWidth": "35px", "aTargets": [0]},
{"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(tabId)},
{"bVisible": false, "aTargets": ['_all']}
{"bVisible": false, "aTargets": ['_all']},
{"sType": "file-size", "aTargets": [ 6 ] }
]
}
@ -99,7 +100,7 @@ define(function(require) {
element.GNAME,
element.NAME,
element.DATASTORE,
element.SIZE,
Humanize.sizeFromMB(element.SIZE),
OpenNebulaImage.typeStr(element.TYPE),
Humanize.prettyTime(element.REGTIME),
parseInt(element.PERSISTENT) ? "yes" : "no",

View File

@ -71,9 +71,9 @@ define(function(require) {
"aoColumnDefs": [
{"bSortable": false, "aTargets": ["check"]},
{"sWidth": "35px", "aTargets": [0]},
{"sWidth": "250px", "aTargets": [5]},
{"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(TAB_NAME)},
{"bVisible": false, "aTargets": ['_all']}
{"bVisible": false, "aTargets": ['_all']},
{"sType": "file-size", "aTargets": [ 6 ] }
]
}