From: pablozg Date: Wed, 3 Jan 2018 12:18:33 +0000 (+0100) Subject: webui: add the grouping for the finished recordings X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=457e12d572902fb9a929fb8a1d7e4eac4bbc0264;p=thirdparty%2Ftvheadend.git webui: add the grouping for the finished recordings --- diff --git a/src/webui/static/app/dvr.js b/src/webui/static/app/dvr.js index ef847bfad..1d2250276 100644 --- a/src/webui/static/app/dvr.js +++ b/src/webui/static/app/dvr.js @@ -295,6 +295,7 @@ tvheadend.dvr_upcoming = function(panel, index) { list + ',owner,creator' : list) + ',retention,removal'; var duplicates = 0; var buttonFcn = tvheadend.dvrButtonFcn; + var columnId = null; var stopButton = { name: 'stop', @@ -355,6 +356,8 @@ tvheadend.dvr_upcoming = function(panel, index) { }, callback: function(conf, e, store, select) { duplicates ^= 1; + select.grid.colModel.setHidden(columnId, !duplicates); + select.grid.bottomToolbar.changePage(0); this.setText(duplicates ? _('Hide duplicates') : _('Show duplicates')); store.baseParams.duplicates = duplicates; store.reload(); @@ -377,6 +380,16 @@ tvheadend.dvr_upcoming = function(panel, index) { return false; } + function viewready(grid) { + if(!grid.store.baseParams.duplicates){ + columnId = grid.colModel.findColumnIndex('duplicate'); + grid.colModel.setHidden(columnId, true); + }else{ + var buttonIndex = grid.topToolbar.items.findIndex('text','Show duplicates'); + grid.topToolbar.items.item(buttonIndex).setText(_('Hide duplicates')); + } + } + tvheadend.idnode_grid(panel, { url: 'api/dvr/entry', gridURL: 'api/dvr/entry/grid_upcoming', @@ -441,7 +454,8 @@ tvheadend.dvr_upcoming = function(panel, index) { ], tbar: [stopButton, abortButton, prevrecButton, dupButton], selected: selected, - beforeedit: beforeedit + beforeedit: beforeedit, + viewready: viewready }); return panel; @@ -520,6 +534,30 @@ tvheadend.dvr_finished = function(panel, index) { } }; + var groupingButton = { + name: 'grouping', + builder: function() { + return new Ext.Toolbar.Button({ + tooltip: _('When enabled, group the recordings by the selected column.'), + iconCls: 'grouping', + text: _('Enable grouping') + }); + }, + callback: function(conf, e, store, select) { + this.setText(store.groupField ? _('Enable grouping') : _('Disable grouping')); + if (!store.groupField){ + select.grid.view.enableGrouping = true; + select.grid.store.groupBy(store.sortInfo.field); + select.grid.fireEvent('groupchange', select.grid, store.getGroupState()); + select.grid.view.refresh(); + }else{ + store.clearGrouping(); + select.grid.view.enableGrouping = false; + select.grid.fireEvent('groupchange', select.grid, null); + } + } + }; + function selected(s, abuttons) { var r = s.getSelections(); var b = r.length > 0 && r[0].data.filesize > 0; @@ -529,6 +567,11 @@ tvheadend.dvr_finished = function(panel, index) { abuttons.remove.setDisabled(!b); } + function viewready(grid) { + var buttonIndex = grid.topToolbar.items.findIndex('text','Enable grouping'); + grid.topToolbar.items.item(buttonIndex).setText(grid.store.groupField ? _('Disable grouping') : _('Enable grouping')); + } + tvheadend.idnode_grid(panel, { url: 'api/dvr/entry', gridURL: 'api/dvr/entry/grid_finished', @@ -569,8 +612,9 @@ tvheadend.dvr_finished = function(panel, index) { return tvheadend.playLink('play/dvrfile/' + r.id, title); } }], - tbar: [removeButton, downloadButton, rerecordButton, moveButton], - selected: selected + tbar: [removeButton, downloadButton, rerecordButton, moveButton, groupingButton], + selected: selected, + viewready: viewready }); return panel; @@ -668,7 +712,7 @@ tvheadend.dvr_failed = function(panel, index) { }, sort: { field: 'start_real', - direction: 'ASC' + direction: 'DESC' }, plugins: [actions], lcol: [ @@ -742,7 +786,7 @@ tvheadend.dvr_removed = function(panel, index) { }, sort: { field: 'start_real', - direction: 'ASC' + direction: 'DESC' }, plugins: [actions], lcol: [actions], diff --git a/src/webui/static/app/ext.css b/src/webui/static/app/ext.css index 8b44bc8d6..239706510 100644 --- a/src/webui/static/app/ext.css +++ b/src/webui/static/app/ext.css @@ -232,6 +232,10 @@ background-image: url(../icons/control_repeat_blue.png) !important; } +.grouping { + background-image: url(../icons/control_repeat_blue.png) !important; +} + .cancel { background-image: url(../icons/cancel.png) !important; } diff --git a/src/webui/static/app/idnode.js b/src/webui/static/app/idnode.js index bd31c35de..3be0ead40 100644 --- a/src/webui/static/app/idnode.js +++ b/src/webui/static/app/idnode.js @@ -1618,6 +1618,7 @@ tvheadend.idnode_grid = function(panel, conf) var event = null; var auto = null; var idnode = null; + var groupReader = null; var update = function(o) { if ((o.create || o.moveup || o.movedown || 'delete' in o) && auto.getValue()) { @@ -1720,15 +1721,31 @@ tvheadend.idnode_grid = function(panel, conf) var params = {}; if (conf.all) params['all'] = 1; if (conf.extraParams) conf.extraParams(params); - store = new Ext.data.JsonStore({ + + groupReader = new Ext.data.JsonReader({ + totalProperty: 'total', root: 'entries', + fields: fields, + idProperty: 'uuid' + }); + + store = new Ext.data.GroupingStore({ url: conf.gridURL || (conf.url + '/grid'), baseParams: params, autoLoad: true, id: 'uuid', - totalProperty: 'total', - fields: fields, - remoteSort: true, + remoteSort: true, // We lost multi sort at server side :-(, maybe perexg has a better idea + reader: groupReader, + remoteGroup: true, + groupField: conf.groupField ? conf.groupField : false, + groupDir: 'ASC', + groupOnSort: true, + /*multiSort: true, + multiSortInfo:{ + sorters: [{field : 'disp_title', direction : 'ASC'}, + conf.sort ? conf.sort : null], + direction: 'ASC' + },*/ pruneModifiedRecords: true, sortInfo: conf.sort ? conf.sort : null }); @@ -2085,9 +2102,13 @@ tvheadend.idnode_grid = function(panel, conf) cm: model, selModel: select, plugins: plugins, - viewConfig: { - forceFit: true - }, + view: new Ext.grid.GroupingView({ + forceFit: true, + startCollapsed: true, + showGroupName: false, + // custom grouping text template to display the number of recordings per group + groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Recordings" : "Recording"]})' + }), keys: { key: 'a', ctrl: true, @@ -2104,8 +2125,13 @@ tvheadend.idnode_grid = function(panel, conf) grid.on('filterupdate', function() { page.changePage(0); }); + if (conf.beforeedit) - grid.on('beforeedit', conf.beforeedit); + grid.on('beforeedit', conf.beforeedit); + + if (conf.viewready) + grid.on('viewready', conf.viewready); + grid.abuttons = abuttons; dpanel.add(grid);