mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-11 11:51:27 +00:00
format size when admin set user quota
This commit is contained in:
@@ -761,3 +761,31 @@ function userInputOPtionsForSelect2(user_search_url) {
|
|||||||
escapeMarkup: function(m) { return m; }
|
escapeMarkup: function(m) { return m; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function quotaSizeFormat(bytes, precision) {
|
||||||
|
var kilobyte = 1000;
|
||||||
|
var megabyte = kilobyte * 1000;
|
||||||
|
var gigabyte = megabyte * 1000;
|
||||||
|
var terabyte = gigabyte * 1000;
|
||||||
|
|
||||||
|
var precision = precision || 0;
|
||||||
|
|
||||||
|
if ((bytes >= 0) && (bytes < kilobyte)) {
|
||||||
|
return bytes + ' B';
|
||||||
|
|
||||||
|
} else if ((bytes >= kilobyte) && (bytes < megabyte)) {
|
||||||
|
return (bytes / kilobyte).toFixed(precision) + ' KB';
|
||||||
|
|
||||||
|
} else if ((bytes >= megabyte) && (bytes < gigabyte)) {
|
||||||
|
return (bytes / megabyte).toFixed(precision) + ' MB';
|
||||||
|
|
||||||
|
} else if ((bytes >= gigabyte) && (bytes < terabyte)) {
|
||||||
|
return (bytes / gigabyte).toFixed(precision) + ' GB';
|
||||||
|
|
||||||
|
} else if (bytes >= terabyte) {
|
||||||
|
return (bytes / terabyte).toFixed(precision) + ' TB';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return bytes + ' B';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -114,7 +114,7 @@ $('#set-quota-form').submit(function() {
|
|||||||
if (space_quota == 0) {
|
if (space_quota == 0) {
|
||||||
$spaceQuota.html('--');
|
$spaceQuota.html('--');
|
||||||
} else {
|
} else {
|
||||||
$spaceQuota.html(parseInt(data['total'])/1000000 + ' MB');
|
$spaceQuota.html(quotaSizeFormat(parseInt(data['total']), 1));
|
||||||
}
|
}
|
||||||
$.modal.close();
|
$.modal.close();
|
||||||
},
|
},
|
||||||
|
@@ -410,7 +410,7 @@ $('#set-quota-form').submit(function() {
|
|||||||
if (space_quota == 0) {
|
if (space_quota == 0) {
|
||||||
$quota.html('--');
|
$quota.html('--');
|
||||||
} else {
|
} else {
|
||||||
$quota.html(parseInt(data['total'])/1000000 + ' MB');
|
$quota.html(quotaSizeFormat(parseInt(data['total']), 1));
|
||||||
}
|
}
|
||||||
$.modal.close();
|
$.modal.close();
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user