var list = 'disp_title,start,start_extra,stop,stop_extra,' +
'channel,config_name';
+ var abortButton = {
+ name: 'abort',
+ builder: function() {
+ return new Ext.Toolbar.Button({
+ tooltip: 'Abort selected recording',
+ iconCls: 'cancel',
+ text: 'Abort',
+ disabled: true,
+ });
+ },
+ callback: function(conf, e, store, select) {
+ var r = select.getSelections();
+ if (r && r.length > 0) {
+ var uuids = [];
+ for (var i = 0; i < r.length; i++)
+ uuids.push(r[i].id);
+ tvheadend.Ajax({
+ url: 'api/dvr/entry/cancel',
+ params: {
+ uuid: Ext.encode(uuids)
+ },
+ success: function(d) {
+ store.reload();
+ }
+ });
+ }
+ }
+ };
+
+ function selected(s, abuttons) {
+ var recording = 0;
+ s.each(function(s) {
+ if (s.data.sched_status == 'recording')
+ recording++;
+ });
+ abuttons.abort.setDisabled(recording < 1);
+ }
+
+ function beforeedit(e, grid) {
+ if (e.record.data.sched_status == 'recording')
+ return false;
+ }
+
tvheadend.idnode_grid(panel, {
url: 'api/dvr/entry',
gridURL: 'api/dvr/entry/grid_upcoming',
},
plugins: [actions],
lcol: [actions],
+ tbar: [abortButton],
+ selected: selected,
+ beforeedit: beforeedit,
help: function() {
new tvheadend.help('DVR', 'config_dvr.html');
},
var filters = [];
var fields = [];
var buttons = [];
+ var abuttons = {};
var plugins = conf.plugins || [];
- var saveBtn = null;
- var undoBtn = null;
- var addBtn = null;
- var delBtn = null;
- var upBtn = null;
- var downBtn = null;
- var editBtn = null;
/* Some copies */
if (conf.add && !conf.add.titleS && conf.titleS)
/* Event handlers */
store.on('update', function(s, r, o) {
var d = (s.getModifiedRecords().length === 0);
- undoBtn.setDisabled(d);
- saveBtn.setDisabled(d);
+ if (abuttons.undo)
+ abuttons.undo.setDisabled(d);
+ if (abuttons.save)
+ abuttons.save.setDisabled(d);
});
select.on('selectionchange', function(s) {
var count = s.getCount();
- if (delBtn)
- delBtn.setDisabled(count === 0);
- if (upBtn) {
- upBtn.setDisabled(count === 0);
- downBtn.setDisabled(count === 0);
+ if (abuttons.del)
+ abuttons.del.setDisabled(count === 0);
+ if (abuttons.up) {
+ abuttons.up.setDisabled(count === 0);
+ abuttons.down.setDisabled(count === 0);
}
- if (editBtn)
- editBtn.setDisabled(count !== 1);
+ if (abuttons.edit)
+ abuttons.edit.setDisabled(count !== 1);
if (conf.selected)
- conf.selected(s);
+ conf.selected(s, abuttons);
});
/* Top bar */
if (!conf.readonly) {
- saveBtn = new Ext.Toolbar.Button({
+ abuttons.save = new Ext.Toolbar.Button({
tooltip: 'Save pending changes (marked with red border)',
iconCls: 'save',
text: 'Save',
});
}
});
- buttons.push(saveBtn);
- undoBtn = new Ext.Toolbar.Button({
+ buttons.push(abuttons.save);
+ abuttons.undo = new Ext.Toolbar.Button({
tooltip: 'Revert pending changes (marked with red border)',
iconCls: 'undo',
text: 'Undo',
store.rejectChanges();
}
});
- buttons.push(undoBtn);
+ buttons.push(abuttons.undo);
}
if (conf.add) {
if (buttons.length > 0)
buttons.push('-');
- addBtn = new Ext.Toolbar.Button({
+ abuttons.add = new Ext.Toolbar.Button({
tooltip: 'Add a new entry',
iconCls: 'add',
text: 'Add',
tvheadend.idnode_create(conf.add);
}
});
- buttons.push(addBtn);
+ buttons.push(abuttons.add);
}
if (conf.del) {
if (!conf.add && buttons.length > 0)
buttons.push('-');
- delBtn = new Ext.Toolbar.Button({
+ abuttons.del = new Ext.Toolbar.Button({
tooltip: 'Delete selected entries',
iconCls: 'remove',
text: 'Delete',
}
}
});
- buttons.push(delBtn);
+ buttons.push(abuttons.del);
}
if (conf.move) {
- upBtn = new Ext.Toolbar.Button({
+ abuttons.up = new Ext.Toolbar.Button({
tooltip: 'Move selected entries up',
iconCls: 'moveup',
text: 'Move Up',
}
}
});
- buttons.push(upBtn);
- downBtn = new Ext.Toolbar.Button({
+ buttons.push(abuttons.up);
+ abuttons.down = new Ext.Toolbar.Button({
tooltip: 'Move selected entries down',
iconCls: 'movedown',
text: 'Move Down',
}
}
});
- buttons.push(downBtn);
+ buttons.push(abuttons.down);
}
if (!conf.readonly) {
if (buttons.length > 0)
buttons.push('-');
- editBtn = new Ext.Toolbar.Button({
+ abuttons.edit = new Ext.Toolbar.Button({
tooltip: 'Edit selected entry',
iconCls: 'edit',
text: 'Edit',
}
}
});
- buttons.push(editBtn);
+ buttons.push(abuttons.edit);
}
/* Hide Mode */
if (conf.tbar) {
buttons.push('-');
for (i = 0; i < conf.tbar.length; i++) {
- if (conf.tbar[i].callback) {
- conf.tbar[i].handler = function(b, e) {
- this.callback(this, e, store, select);
- };
+ var t = conf.tbar[i];
+ if (t.name && t.builder) {
+ var b = t.builder();
+ if (t.callback) {
+ b.callback = t.callback;
+ b.handler = function(b, e) {
+ this.callback(this, e, store, select);
+ }
+ }
+ abuttons[t.name] = b;
+ buttons.push(b);
}
- buttons.push(conf.tbar[i]);
}
}
grid.on('filterupdate', function() {
page.changePage(0);
});
+ if (conf.beforeedit)
+ grid.on('beforeedit', conf.beforeedit);
dpanel.add(grid);
dpanel.doLayout(false, true);
conf.builder(conf);
var buttons = [];
+ var abuttons = {};
var plugins = conf.plugins || [];
- var saveBtn = null;
- var undoBtn = null;
- var addBtn = null;
- var delBtn = null;
- var current = null;
/* Store */
store = new Ext.data.JsonStore({
select.on('selectionchange', function(s) {
roweditor(s.getSelected());
if (conf.selected)
- conf.selected(s);
+ conf.selected(s, abuttons);
});
/* Top bar */
- saveBtn = new Ext.Toolbar.Button({
+ abuttons.save = new Ext.Toolbar.Button({
tooltip: 'Save pending changes (marked with red border)',
iconCls: 'save',
text: 'Save',
});
}
});
- buttons.push(saveBtn);
- undoBtn = new Ext.Toolbar.Button({
+ buttons.push(abuttons.save);
+ abuttons.undo = new Ext.Toolbar.Button({
tooltip: 'Revert pending changes (marked with red border)',
iconCls: 'undo',
text: 'Undo',
current.editor.getForm().reset();
}
});
- buttons.push(undoBtn);
+ buttons.push(abuttons.undo);
buttons.push('-');
if (conf.add) {
- addBtn = new Ext.Toolbar.Button({
+ abuttons.add = new Ext.Toolbar.Button({
tooltip: 'Add a new entry',
iconCls: 'add',
text: 'Add',
tvheadend.idnode_create(conf.add, true);
}
});
- buttons.push(addBtn);
+ buttons.push(abuttons.add);
}
if (conf.del) {
- delBtn = new Ext.Toolbar.Button({
+ abuttons.del = new Ext.Toolbar.Button({
tooltip: 'Delete selected entries',
iconCls: 'remove',
text: 'Delete',
}
}
});
- buttons.push(delBtn);
+ buttons.push(abuttons.del);
}
if (conf.add || conf.del)
buttons.push('-');
if (conf.tbar) {
buttons.push('-');
for (i = 0; i < conf.tbar.length; i++) {
- if (conf.tbar[i].callback) {
- conf.tbar[i].handler = function(b, e) {
- this.callback(this, e, store, select);
- };
+ var t = conf.tbar[i];
+ if (t.name && t.builder) {
+ var b = t.builder();
+ if (t.callback) {
+ b.callback = t.callback;
+ b.handler = function(b, e) {
+ this.callback(this, e, store, select);
+ }
+ }
+ abuttons[t.name] = b;
+ buttons.push(b);
}
- buttons.push(conf.tbar[i]);
}
}
uuid: d[0].id,
editor: editor
}
- saveBtn.setDisabled(false);
- undoBtn.setDisabled(false);
- delBtn.setDisabled(false);
+ abuttons.save.setDisabled(false);
+ abuttons.undo.setDisabled(false);
+ abuttons.del.setDisabled(false);
mpanel.add(editor);
mpanel.doLayout();
}