Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Fix to bugreport #752
Browse files Browse the repository at this point in the history
Fixes #752: Retention/Expiration column not sorted by number
  • Loading branch information
fbergkemper committed Jan 30, 2017
1 parent 539d89f commit 837d6a2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
12 changes: 11 additions & 1 deletion module/Media/view/media/media/index.phtml
Expand Up @@ -163,7 +163,8 @@ $(document).ready(function() {
{ "data": null },
{ "type": "file-size", "data": "maxvolbytes" },
{ "type": "file-size", "data": "volbytes" },
{ "data": "lastwritten" }
{ "data": "lastwritten" },
{ "data": null }
],
"columnDefs": [
{
Expand All @@ -181,6 +182,7 @@ $(document).ready(function() {
},
{
"targets": 6,
"orderData": 10,
"render": function(data, type, full, meta) {
return formatExpiration(data.volstatus, data.lastwritten, data.volretention);
}
Expand All @@ -201,6 +203,14 @@ $(document).ready(function() {
"targets": 9,
"visible": false,
"searchable": false
},
{
"targets": 10,
"visible": false,
"searchable": false,
"render": function(data, type, full, meta) {
return formatHiddenRetExp(data.volstatus, data.lastwritten, data.volretention);
}
}
],
"buttons": [
Expand Down
25 changes: 25 additions & 0 deletions public/js/datatables.functions.js
Expand Up @@ -190,6 +190,31 @@ function formatExpiration(volstatus, lastwritten, volretention) {
}
}

function formatHiddenRetExp(volstatus, lastwritten, volretention) {
if(volstatus == iJS._("Used") || volstatus == iJS._("Full")) {
if(lastwritten == null || lastwritten == "") {
return 100000000000;
}
else {
var d = Date.now() / 1000;
var a = lastwritten.split(" ");
var b = new Date(a[0]).getTime() / 1000;
var interval = (d - b) / (3600 * 24);
var retention = Math.round(volretention / 60 / 60 / 24);
var expiration = (retention - interval).toFixed(2);
return Math.ceil(expiration);
}
}
else {
// This is kind of ugly but expiration can also be a negativ value, but somehow we need to sort numerical.
// As a workaround we move the area of unused volumes with a retention way down into the negativ by
// prepending a large negativ number out of the scope of the usual rentention times commonly used
// to avoid further problems.
// TODO: Find a better sorting solution for the Retention/Expiration column.
return Math.ceil('-1000000000000'+(volretention / 60 / 60 / 24));
}
}

function formatLastWritten(data) {
if(data == null || data == '' || data == 0) {
return iJS._('never');
Expand Down

0 comments on commit 837d6a2

Please sign in to comment.