you change the code of this two files.
\public\assets\javascript\og\FileManager.js
\public\assets\javascript\og\og.js
the file "FileManager.js" contains the code to generate the documents list.
line 11 define the fields or attributes of the files.
the field list must extend with the attribute "size".
this.fields =
['name', 'object_id', 'type', 'tags', 'createdBy', 'createdById',
...
'isMP3','size'];
Now we need a render function. This function generate the formated size information. I have create the function between the other render functions.
function renderSize(value, p, r) {
if (!value) {
return "";
}
return userString = String.format('{0}',og.filesizeFormat(r.data.size));
}
The 3. step is necessary to create the new column in the document list.
at the end (after action) of the column declarations you can add the new size column.
},{
id: 'actions',
header: lang("actions"),
width: 50,
renderer: renderActions,
sortable: false
},{
id: 'size',
header: lang("size"),
dataIndex: 'size',
width: 50,
renderer: renderSize, // call the renderSize function
sortable: true // i don't no why, but this column is not sortable
}]);
This are all changes in the FileManager.js
Now it works but the size is showing like 2.2.6 MB.
To change this you must change the og.filesizeFormat function in og.js file.
/* original entry
og.filesizeFormat = function(fs) {
if (fs > 1024 * 1024) {
var total = Math.round(fs / 1024 / 1024 * 10);
return total / 10 + "." + total % 10 + " MB";
} else {
var total = Math.round(fs / 1024 * 10);
return total / 10 + "." + total % 10 + " KB";
}
};
*/
// new function to calulate the filesize
og.filesizeFormat = function(fs) {
var units = new Array(' B',' KiB',' MiB',' GiB',' TiB'); // More informations http://en.wikipedia.org/wiki/Byte
var i = 0;
while (i<units.length && fs > 1024){
fs = fs / 1024;
i++;
}
if (i!=0){
fs = Math.round(fs * 100)/100;
}
return fs + units[i];
};
My english is terrible but i hope you can understand me.