Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WEBUI: DVR tabs - improvde filesize renderer
  • Loading branch information
perexg committed Nov 12, 2014
1 parent e296f3c commit 1a97e86
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions src/webui/static/app/dvr.js
Expand Up @@ -114,6 +114,21 @@ tvheadend.weekdaysRenderer = function(st) {
}
}

tvheadend.filesizeRenderer = function(st) {
return function() {
return function(v) {
if (v == null)
return '';
if (!v || v < 0)
return '---';
if (v > 1000000)
return parseInt(v / 1000000) + ' MB';
if (v > 1000)
return parseInt(v / 1000) + ' KB';
return parseInt(v) + ' B';
}
}
}

/**
*
Expand Down Expand Up @@ -235,8 +250,9 @@ tvheadend.dvr_finished = function(panel, index) {
};

function selected(s, abuttons) {
var count = s.getCount();
abuttons.download.setDisabled(count < 1);
var r = s.getSelections();
var b = r.length > 0 && r[0].data.filesize > 0;
abuttons.download.setDisabled(!b);
}

tvheadend.idnode_grid(panel, {
Expand All @@ -253,13 +269,7 @@ tvheadend.dvr_finished = function(panel, index) {
'sched_status,url',
columns: {
filesize: {
renderer: function() {
return function(v) {
if (v == null)
return '';
return parseInt(v / 1000000) + ' MB';
}
}
renderer: tvheadend.filesizeRenderer()
}
},
sort: {
Expand Down Expand Up @@ -317,8 +327,9 @@ tvheadend.dvr_failed = function(panel, index) {
};

function selected(s, abuttons) {
var count = s.getCount();
abuttons.download.setDisabled(count < 1);
var r = s.getSelections();
var b = r.length > 0 && r[0].data.filesize > 0;
abuttons.download.setDisabled(!b);
}

tvheadend.idnode_grid(panel, {
Expand All @@ -332,17 +343,11 @@ tvheadend.dvr_failed = function(panel, index) {
tabIndex: index,
del: true,
list: 'disp_title,episode,start_real,stop_real,' +
'duration,channelname,creator,' +
'duration,filesize,channelname,creator,' +
'status,sched_status,url',
columns: {
columns: {
filesize: {
renderer: function() {
return function(v) {
if (v == null)
return '';
return parseInt(v / 1000000) + ' MB';
}
}
renderer: tvheadend.filesizeRenderer()
}
},
sort: {
Expand Down

0 comments on commit 1a97e86

Please sign in to comment.