WEBUI JS: root panel cleanups, ancient file removal

This commit is contained in:
Jaroslav Kysela 2014-09-02 20:57:07 +02:00
parent 565004f63a
commit 0fa4c91b5c
15 changed files with 118 additions and 747 deletions

View file

@ -153,10 +153,6 @@ extjs_root(http_connection_t *hc, const char *remain, void *opaque)
extjs_load(hq, "static/app/esfilter.js");
#if ENABLE_MPEGTS
extjs_load(hq, "static/app/mpegts.js");
#endif
extjs_load(hq, "static/app/iptv.js");
#if ENABLE_V4L
extjs_load(hq, "static/app/v4l.js");
#endif
#if ENABLE_TIMESHIFT
extjs_load(hq, "static/app/timeshift.js");

View file

@ -2,16 +2,19 @@
* Access Control
*/
tvheadend.acleditor = function(panel)
tvheadend.acleditor = function(panel, index)
{
panel = new Ext.TabPanel({
panel2 = new Ext.TabPanel({
activeTab: 0,
autoScroll: true,
title: 'Access Control',
iconCls: 'group',
tabIndex: index,
items: []
});
tvheadend.paneladd(panel, panel2, index);
var list = 'enabled,username,password,prefix,streaming,adv_streaming,' +
'dvr,dvr_config,webui,admin,channel_min,channel_max,channel_tag,' +
'comment';

View file

@ -1,4 +1,5 @@
tvheadend.capmteditor = function() {
tvheadend.capmteditor = function(panel, index) {
var fm = Ext.form;
function setMetaAttr(meta, record) {
@ -104,6 +105,8 @@ tvheadend.capmteditor = function() {
}
});
return new tvheadend.tableEditor('Capmt Connections', 'capmt', cm, rec,
var p = new tvheadend.tableEditor('Capmt Connections', 'capmt', cm, rec,
[], store, 'config_capmt.html', 'key');
tvheadend.paneladd(panel, p, index);
};

View file

@ -31,7 +31,7 @@ tvheadend.comet.on('config', function(m) {
}
});
tvheadend.miscconf = function() {
tvheadend.miscconf = function(panel, index) {
/*
* Basic Config
@ -240,7 +240,7 @@ tvheadend.miscconf = function() {
if (imagecache_form)
_items.push(imagecache_form);
var panel = new Ext.Panel({
var mpanel = new Ext.Panel({
title: 'General',
iconCls: 'wrench',
border: false,
@ -251,6 +251,8 @@ tvheadend.miscconf = function() {
tbar: [saveButton, '->', helpButton]
});
tvheadend.paneladd(panel, mpanel, index);
/* ****************************************************************
* Load/Save
* ***************************************************************/
@ -297,6 +299,4 @@ tvheadend.miscconf = function() {
}
});
}
return panel;
};

View file

@ -1,4 +1,4 @@
tvheadend.cwceditor = function() {
tvheadend.cwceditor = function(panel, index) {
var fm = Ext.form;
function setMetaAttr(meta, record) {
@ -125,5 +125,5 @@ tvheadend.cwceditor = function() {
}
});
return grid;
tvheadend.paneladd(panel, grid, index);
};

View file

@ -263,17 +263,17 @@ tvheadend.autorec_editor = function(panel, index) {
/**
*
*/
tvheadend.dvr = function() {
var panel = new Ext.TabPanel({
tvheadend.dvr = function(panel, index) {
var p = new Ext.TabPanel({
activeTab: 0,
autoScroll: true,
title: 'Digital Video Recorder',
iconCls: 'drive',
items: [],
});
tvheadend.dvr_upcoming(panel, 0);
tvheadend.dvr_finished(panel, 1);
tvheadend.dvr_failed(panel, 2);
tvheadend.autorec_editor(panel, 3);
return panel;
tvheadend.dvr_upcoming(p, 0);
tvheadend.dvr_finished(p, 1);
tvheadend.dvr_failed(p, 2);
tvheadend.autorec_editor(p, 3);
return p;
}

View file

@ -8,7 +8,7 @@ tvheadend.epggrabChannels = new Ext.data.JsonStore({
'mod-name']
});
tvheadend.epggrab = function() {
tvheadend.epggrab = function(panel, index) {
/* ****************************************************************
* Data
@ -394,5 +394,5 @@ tvheadend.epggrab = function() {
});
}
return confpanel;
tvheadend.paneladd(panel, confpanel, index);
};

View file

@ -1240,10 +1240,7 @@ tvheadend.idnode_grid = function(panel, conf)
page.changePage(0);
});
if (conf.tabIndex != null)
panel.insert(conf.tabIndex, grid);
else
panel.add(grid);
tvheadend.paneladd(panel, grid, conf.tabIndex);
/* Add comet listeners */
var update = function(o) {
@ -1496,10 +1493,7 @@ tvheadend.idnode_form_grid = function(panel, conf)
items: [grid]
});
if (conf.tabIndex != null)
panel.insert(conf.tabIndex, mpanel);
else
panel.add(mpanel);
tvheadend.paneladd(panel, mpanel, conf.tabIndex);
/* Add comet listeners */
var update = function(o) {
@ -1512,7 +1506,7 @@ tvheadend.idnode_form_grid = function(panel, conf)
/*
* IDNode Tree
*/
tvheadend.idnode_tree = function(conf)
tvheadend.idnode_tree = function(panel, conf)
{
var current = null;
var events = {};
@ -1576,7 +1570,7 @@ tvheadend.idnode_tree = function(conf)
}
});
var panel = new Ext.Panel({
var mpanel = new Ext.Panel({
title: conf.title || '',
layout: 'hbox',
flex: 1,
@ -1588,11 +1582,10 @@ tvheadend.idnode_tree = function(conf)
items: [tree]
});
tvheadend.paneladd(panel, mpanel, conf.tabIndex);
tree.on('beforerender', function() {
// To be honest this isn't quite right, but it'll do
tree.expandAll();
});
return panel;
};

View file

@ -1,318 +0,0 @@
/**
* IPTV service grid
*/
tvheadend.iptv = function(adapterId) {
var servicetypeStore = new Ext.data.JsonStore({
root: 'entries',
id: 'val',
url: '/iptv/services',
baseParams: {
op: 'servicetypeList'
},
fields: ['val', 'str'],
autoLoad: false,
sortInfo: {
field: 'channelname',
direction: 'ASC'
}
});
var fm = Ext.form;
var actions = new Ext.ux.grid.RowActions({
header: '',
dataIndex: 'actions',
width: 45,
actions: [{
iconCls: 'info',
qtip: 'Detailed information about service',
cb: function(grid, record, action, row, col) {
Ext.Ajax.request({
url: "servicedetails/" + record.id,
success: function(response, options) {
r = Ext.util.JSON.decode(response.responseText);
tvheadend.showTransportDetails(r);
}
});
}
}]
});
var cm = new Ext.grid.ColumnModel({
defaultSortable: true,
columns: [
{
xtype: 'checkcolumn',
header: "Enabled",
dataIndex: 'enabled',
width: 45
},
{
header: "Channel name",
dataIndex: 'channelname',
width: 150,
renderer: function(value, metadata, record, row, col, store) {
return value ? value
: '<span class="tvh-grid-unset">Unmapped</span>';
},
editor: new fm.ComboBox({
store: tvheadend.channels,
allowBlank: true,
typeAhead: true,
minChars: 2,
lazyRender: true,
triggerAction: 'all',
mode: 'local',
displayField: 'name'
})
},
{
header: "Interface",
dataIndex: 'interface',
width: 100,
renderer: function(value, metadata, record, row, col, store) {
return value ? value : '<span class="tvh-grid-unset">Unset</span>';
},
editor: new fm.TextField({
allowBlank: false
})
},
{
header: "Group",
dataIndex: 'group',
width: 100,
renderer: function(value, metadata, record, row, col, store) {
return value ? value : '<span class="tvh-grid-unset">Unset</span>';
},
editor: new fm.TextField({
allowBlank: false
})
},
{
header: "UDP Port",
dataIndex: 'port',
width: 60,
editor: new fm.NumberField({
minValue: 1,
maxValue: 65535
})
},
{
header: "Service ID",
dataIndex: 'sid',
width: 50,
hidden: true
},
{
header: 'Service Type',
width: 100,
dataIndex: 'stype',
hidden: true,
editor: new fm.ComboBox({
valueField: 'val',
displayField: 'str',
forceSelection: false,
editable: false,
mode: 'local',
triggerAction: 'all',
store: servicetypeStore
}),
renderer: function(value, metadata, record, row, col, store) {
var val = value ? servicetypeStore.getById(value) : null;
return val ? val.get('str')
: '<span class="tvh-grid-unset">Unset</span>';
}
}, {
header: "PMT PID",
dataIndex: 'pmt',
width: 50,
hidden: true
}, {
header: "PCR PID",
dataIndex: 'pcr',
width: 50,
hidden: true
}, actions]});
var rec = Ext.data.Record.create(['id', 'enabled', 'channelname',
'interface', 'group', 'port', 'sid', 'pmt', 'pcr', 'stype']);
var store = new Ext.data.JsonStore({
root: 'entries',
fields: rec,
url: "iptv/services",
autoLoad: true,
id: 'id',
baseParams: {
op: "get"
},
listeners: {
'update': function(s, r, o) {
d = s.getModifiedRecords().length === 0
saveBtn.setDisabled(d);
rejectBtn.setDisabled(d);
}
}
});
/*
var storeReloader = new Ext.util.DelayedTask(function() {
store.reload()
});
tvheadend.comet.on('dvbService', function(m) {
storeReloader.delay(500);
});
*/
function addRecord() {
Ext.Ajax.request({
url: "iptv/services",
params: {
op: "create"
},
failure: function(response, options) {
Ext.MessageBox.alert('Server Error',
'Unable to generate new record');
},
success: function(response, options) {
var responseData = Ext.util.JSON.decode(response.responseText);
var p = new rec(responseData, responseData.id);
grid.stopEditing();
store.insert(0, p);
grid.startEditing(0, 0);
}
});
}
;
function delSelected() {
var selectedKeys = grid.selModel.selections.keys;
if (selectedKeys.length > 0) {
Ext.MessageBox.confirm('Message',
'Do you really want to delete selection?', deleteRecord);
}
else {
Ext.MessageBox.alert('Message',
'Please select at least one item to delete');
}
}
;
function deleteRecord(btn) {
if (btn === 'yes') {
var selectedKeys = grid.selModel.selections.keys;
Ext.Ajax.request({
url: "iptv/services",
params: {
op: "delete",
entries: Ext.encode(selectedKeys)
},
failure: function(response, options) {
Ext.MessageBox.alert('Server Error', 'Unable to delete');
},
success: function(response, options) {
store.reload();
}
});
}
}
function saveChanges() {
var mr = store.getModifiedRecords();
var out = new Array();
for (var x = 0; x < mr.length; x++) {
v = mr[x].getChanges();
out[x] = v;
out[x].id = mr[x].id;
}
Ext.Ajax.request({
url: "iptv/services",
params: {
op: "update",
entries: Ext.encode(out)
},
success: function(response, options) {
store.commitChanges();
},
failure: function(response, options) {
Ext.MessageBox.alert('Message', response.statusText);
}
});
}
var delButton = new Ext.Toolbar.Button({
tooltip: 'Delete one or more selected rows',
iconCls: 'remove',
text: 'Delete selected services',
handler: delSelected,
disabled: true
});
var saveBtn = new Ext.Toolbar.Button({
tooltip: 'Save any changes made (Changed cells have red borders).',
iconCls: 'save',
text: "Save changes",
handler: saveChanges,
disabled: true
});
var rejectBtn = new Ext.Toolbar.Button({
tooltip: 'Revert any changes made (Changed cells have red borders).',
iconCls: 'undo',
text: "Revert changes",
handler: function() {
store.rejectChanges();
},
disabled: true
});
var selModel = new Ext.grid.RowSelectionModel({
singleSelect: false
});
var grid = new Ext.grid.EditorGridPanel({
stripeRows: true,
title: 'IPTV',
iconCls: 'iptv',
plugins: [actions],
store: store,
clicksToEdit: 2,
cm: cm,
viewConfig: {
forceFit: true
},
selModel: selModel,
tbar: [
{
tooltip: 'Create a new entry on the server. '
+ 'The new entry is initially disabled so it must be enabled '
+ 'before it start taking effect.',
iconCls: 'add',
text: 'Add service',
handler: addRecord
}, '-', delButton, '-', saveBtn, rejectBtn, '->',
{
text: 'Help',
handler: function() {
new tvheadend.help('IPTV', 'config_iptv.html');
}
}]
});
store.on('update', function(s, r, o) {
d = s.getModifiedRecords().length === 0;
saveBtn.setDisabled(d);
rejectBtn.setDisabled(d);
});
selModel.on('selectionchange', function(self) {
delButton.setDisabled(self.getCount() === 0);
});
return grid;
};

View file

@ -25,13 +25,13 @@ tvheadend.comet.on('mpegts_network', function() {
tvheadend.network_list.reload();
});
tvheadend.networks = function(panel)
tvheadend.networks = function(panel, index)
{
tvheadend.idnode_grid(panel, {
url: 'api/mpegts/network',
titleS: 'Network',
titleP: 'Networks',
tabIndex: 1,
tabIndex: index,
help: function() {
new tvheadend.help('Networks', 'config_networks.html');
},
@ -56,13 +56,13 @@ tvheadend.networks = function(panel)
});
};
tvheadend.muxes = function(panel)
tvheadend.muxes = function(panel, index)
{
tvheadend.idnode_grid(panel, {
url: 'api/mpegts/mux',
titleS: 'Mux',
titleP: 'Muxes',
tabIndex: 2,
tabIndex: index,
hidemode: true,
help: function() {
new tvheadend.help('Muxes', 'config_muxes.html');
@ -193,7 +193,7 @@ tvheadend.show_service_streams = function(data) {
win.show();
};
tvheadend.services = function(panel)
tvheadend.services = function(panel, index)
{
var mapButton = new Ext.Toolbar.Button({
tooltip: 'Map services to channels',
@ -233,7 +233,7 @@ tvheadend.services = function(panel)
url: 'api/mpegts/service',
titleS: 'Service',
titleP: 'Services',
tabIndex: 3,
tabIndex: index,
hidemode: true,
add: false,
del: false,
@ -262,13 +262,13 @@ tvheadend.services = function(panel)
});
};
tvheadend.mux_sched = function(panel)
tvheadend.mux_sched = function(panel, index)
{
tvheadend.idnode_grid(panel, {
url: 'api/mpegts/mux_sched',
titleS: 'Mux Scheduler',
titleP: 'Mux Schedulers',
tabIndex: 4,
tabIndex: index,
help: function() {
new tvheadend.help('Mux Schedulers', 'config_muxsched.html');
},

View file

@ -1,4 +1,4 @@
tvheadend.timeshift = function() {
tvheadend.timeshift = function(panel, index) {
/* ****************************************************************
* Data
@ -177,5 +177,5 @@ tvheadend.timeshift = function() {
});
}
return confpanel;
tvheadend.paneladd(panel, confpanel, index);
};

View file

@ -1,9 +1,13 @@
tvheadend.tvadapters = function() {
return tvheadend.idnode_tree({
tvheadend.tvadapters = function(panel, index) {
tvheadend.idnode_tree(panel, {
url: 'api/hardware/tree',
title: 'TV adapters',
tabIndex: index,
help: function() {
new tvheadend.help('TV adapters', 'config_tvadapters.html');
}
});
return panel;
};

View file

@ -1,9 +1,7 @@
tvheadend.accessupdate = null;
tvheadend.capabilties = null;
tvheadend.conf_chepg = null;
tvheadend.conf_dvbin = null;
tvheadend.conf_tsdvr = null;
tvheadend.conf_csa = null;
tvheadend.dvrpanel = null;
tvheadend.confpanel = null;
/* State Provider */
Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
@ -40,6 +38,13 @@ tvheadend.help = function(title, pagename) {
});
};
tvheadend.paneladd = function(dst, add, idx) {
if (idx != null)
dst.insert(idx, add);
else
dst.add(add);
};
tvheadend.Ajax = function(conf) {
var orig_success = conf.success;
var orig_failure = conf.failure;
@ -248,102 +253,108 @@ function accessUpdate(o) {
}
if (o.admin == true && tvheadend.confpanel == null) {
var tabs1 = [
new tvheadend.miscconf,
new tvheadend.acleditor
];
var tabs2;
/* DVB inputs */
tabs2 = [];
if (tvheadend.capabilities.indexOf('linuxdvb') !== -1 ||
tvheadend.capabilities.indexOf('satip_client') !== -1 ||
tvheadend.capabilities.indexOf('v4l') !== -1) {
tabs2.push(new tvheadend.tvadapters);
}
/*
tabs2.push(new tvheadend.iptv);
*/
tvheadend.conf_dvbin = new Ext.TabPanel({
var cp = new Ext.TabPanel({
activeTab: 0,
autoScroll: true,
title: 'Configuration',
iconCls: 'wrench',
items: []
});
tvheadend.miscconf(cp);
tvheadend.acleditor(cp);
/* DVB inputs, networks, muxes, services */
var dvbin = new Ext.TabPanel({
activeTab: 0,
autoScroll: true,
title: 'DVB Inputs',
iconCls: 'hardware',
items: tabs2
items: []
});
tvheadend.networks(tvheadend.conf_dvbin);
tvheadend.muxes(tvheadend.conf_dvbin);
tvheadend.services(tvheadend.conf_dvbin);
tvheadend.mux_sched(tvheadend.conf_dvbin);
tabs1.push(tvheadend.conf_dvbin);
var idx = 0;
if (tvheadend.capabilities.indexOf('linuxdvb') !== -1 ||
tvheadend.capabilities.indexOf('satip_client') !== -1 ||
tvheadend.capabilities.indexOf('v4l') !== -1)
tvheadend.tvadapters(dvbin);
tvheadend.networks(dvbin);
tvheadend.muxes(dvbin);
tvheadend.services(dvbin);
tvheadend.mux_sched(dvbin);
cp.add(dvbin);
/* Channel / EPG */
tvheadend.conf_chepg = new Ext.TabPanel({
var chepg = new Ext.TabPanel({
activeTab: 0,
autoScroll: true,
title: 'Channel / EPG',
iconCls: 'television',
items: []
});
tvheadend.channel_tab(tvheadend.conf_chepg, 0);
tvheadend.cteditor(tvheadend.conf_chepg, 1);
tvheadend.conf_chepg.insert(2, new tvheadend.epggrab);
tabs1.push(tvheadend.conf_chepg);
tvheadend.channel_tab(chepg);
tvheadend.cteditor(chepg);
tvheadend.epggrab(chepg);
cp.add(chepg);
/* DVR / Timeshift */
tvheadend.conf_tsdvr = new Ext.TabPanel({
var tsdvr = new Ext.TabPanel({
activeTab: 0,
autoScroll: true,
title: 'Recording',
iconCls: 'drive',
items: []
});
tvheadend.dvr_settings(tvheadend.conf_tsdvr, 0);
tvheadend.dvr_settings(tsdvr);
if (tvheadend.capabilities.indexOf('timeshift') !== -1)
tvheadend.conf_tsdvr.add(new tvheadend.timeshift);
tabs1.push(tvheadend.conf_tsdvr);
tvheadend.timeshift(tsdvr);
cp.add(tsdvr);
/* CSA */
tabs2 = [];
if (tvheadend.capabilities.indexOf('cwc') !== -1)
tabs2.push(new tvheadend.cwceditor);
if (tvheadend.capabilities.indexOf('capmt') !== -1)
tabs2.push(new tvheadend.capmteditor);
if (tabs2.length > 0) {
tvheadend.conf_csa = new Ext.TabPanel({
if (tvheadend.capabilities.indexOf('cwc') !== -1 ||
tvheadend.capabilities.indexOf('capmt') !== -1) {
var csa = new Ext.TabPanel({
activeTab: 0,
autoScroll: true,
title: 'CSA',
iconCls: 'key',
items: tabs2
items: []
});
tabs1.push(tvheadend.conf_csa);
if (tvheadend.capabilities.indexOf('cwc') !== -1)
tvheadend.cwceditor(csa);
if (tvheadend.capabilities.indexOf('capmt') !== -1)
tvheadend.capmteditor(csa);
cp.add(csa);
}
/* Stream Config */
tvheadend.conf_stream = new Ext.TabPanel({
var stream = new Ext.TabPanel({
activeTab: 0,
autoScroll: true,
title: 'Stream',
iconCls: 'stream_config',
items: []
});
tvheadend.esfilter_tab(tvheadend.conf_stream);
tabs1.push(tvheadend.conf_stream);
tvheadend.esfilter_tab(stream);
cp.add(stream);
/* Debug */
tabs1.push(new tvheadend.tvhlog);
tvheadend.tvhlog(cp);
tvheadend.confpanel = new Ext.TabPanel({
activeTab: 0,
autoScroll: true,
title: 'Configuration',
iconCls: 'wrench',
items: tabs1
});
tvheadend.rootTabPanel.add(tvheadend.confpanel);
tvheadend.confpanel.doLayout();
/* Finish */
tvheadend.rootTabPanel.add(cp);
tvheadend.confpanel = cp;
cp.doLayout();
}
if (o.admin == true && tvheadend.statuspanel == null) {
@ -412,7 +423,7 @@ tvheadend.app = function() {
tvheadend.rootTabPanel = new Ext.TabPanel({
region: 'center',
activeTab: 0,
items: [new tvheadend.epg]
items: [tvheadend.epg()]
});
var viewport = new Ext.Viewport({

View file

@ -1,4 +1,4 @@
tvheadend.tvhlog = function() {
tvheadend.tvhlog = function(panel, index) {
/*
* Basic Config
*/
@ -115,5 +115,5 @@ tvheadend.tvhlog = function() {
});
}
return confpanel;
tvheadend.paneladd(panel, confpanel, index);
};

View file

@ -1,321 +0,0 @@
/**
* V4L adapter details
*/
tvheadend.v4l_adapter_general = function(adapterData) {
adapterId = adapterData.identifier;
/* Conf panel */
var confreader = new Ext.data.JsonReader({
root: 'v4ladapters'
}, ['name', 'logging']);
function saveConfForm() {
confform.getForm().submit({
url: 'v4l/adapter/' + adapterId,
params: {
'op': 'save'
},
waitMsg: 'Saving Data...'
});
}
var items = [{
fieldLabel: 'Adapter name',
name: 'name',
width: 250
}, new Ext.form.Checkbox({
fieldLabel: 'Detailed logging',
name: 'logging'
})];
var confform = new Ext.FormPanel({
title: 'Adapter configuration',
columnWidth: .40,
frame: true,
border: true,
disabled: true,
style: 'margin:10px',
bodyStyle: 'padding:5px',
labelAlign: 'right',
labelWidth: 110,
waitMsgTarget: true,
reader: confreader,
defaultType: 'textfield',
items: items,
buttons: [{
text: 'Save',
handler: saveConfForm
}]
});
confform.getForm().load({
url: 'v4l/adapter/' + adapterId,
params: {
'op': 'load'
},
success: function(form, action) {
confform.enable();
}
});
/**
* Information / capabilities panel
*/
var infoTemplate = new Ext.XTemplate(
'<h2 style="font-size: 150%">Hardware</h2>'
+ '<h3>Device path:</h3>{path}' + '<h3>Device name:</h3>{devicename}'
+ '<h2 style="font-size: 150%">Status</h2>'
+ '<h3>Currently tuned to:</h3>{currentMux}&nbsp');
var infoPanel = new Ext.Panel({
title: 'Information and capabilities',
columnWidth: .35,
frame: true,
border: true,
style: 'margin:10px',
bodyStyle: 'padding:5px',
html: infoTemplate.applyTemplate(adapterData)
});
/**
* Main adapter panel
*/
var panel = new Ext.Panel({
title: 'General',
layout: 'column',
items: [confform, infoPanel]
});
/**
* Subscribe and react on updates for this adapter
*/
tvheadend.tvAdapterStore.on('update', function(s, r, o) {
if (r.data.identifier !== adapterId)
return;
infoTemplate.overwrite(infoPanel.body, r.data);
});
return panel;
};
/**
* V4L service grid
*/
tvheadend.v4l_services = function(adapterId) {
var fm = Ext.form;
var enabledColumn = new Ext.grid.CheckColumn({
header: "Enabled",
dataIndex: 'enabled',
width: 45
});
var cm = new Ext.grid.ColumnModel({
defaultSortable: true,
columns: [
enabledColumn, {
header: "Channel name",
dataIndex: 'channelname',
width: 150,
renderer: function(value, metadata, record, row, col, store) {
return value ? value : '<span class="tvh-grid-unset">Unmapped</span>';
},
editor: new fm.ComboBox({
store: tvheadend.channels,
allowBlank: true,
typeAhead: true,
minChars: 2,
lazyRender: true,
triggerAction: 'all',
mode: 'local',
displayField: 'name'
})
}, {
header: "Frequency",
dataIndex: 'frequency',
width: 60,
editor: new fm.NumberField({
minValue: 10000,
maxValue: 1000000000
})
}]});
var rec = Ext.data.Record.create(['id', 'enabled', 'channelname',
'frequency']);
var store = new Ext.data.JsonStore({
root: 'entries',
fields: rec,
url: "v4l/services/" + adapterId,
autoLoad: true,
id: 'id',
baseParams: {
op: "get"
},
listeners: {
'update': function(s, r, o) {
d = s.getModifiedRecords().length === 0;
saveBtn.setDisabled(d);
rejectBtn.setDisabled(d);
}
}
});
function addRecord() {
Ext.Ajax.request({
url: "v4l/services/" + adapterId,
params: {
op: "create"
},
failure: function(response, options) {
Ext.MessageBox.alert('Server Error',
'Unable to generate new record');
},
success: function(response, options) {
var responseData = Ext.util.JSON.decode(response.responseText);
var p = new rec(responseData, responseData.id);
grid.stopEditing();
store.insert(0, p);
grid.startEditing(0, 0);
}
});
};
function delSelected() {
var selectedKeys = grid.selModel.selections.keys;
if (selectedKeys.length > 0) {
Ext.MessageBox.confirm('Message',
'Do you really want to delete selection?', deleteRecord);
}
else {
Ext.MessageBox.alert('Message',
'Please select at least one item to delete');
}
};
function deleteRecord(btn) {
if (btn === 'yes') {
var selectedKeys = grid.selModel.selections.keys;
Ext.Ajax.request({
url: "v4l/services/" + adapterId,
params: {
op: "delete",
entries: Ext.encode(selectedKeys)
},
failure: function(response, options) {
Ext.MessageBox.alert('Server Error', 'Unable to delete');
},
success: function(response, options) {
store.reload();
}
});
}
}
function saveChanges() {
var mr = store.getModifiedRecords();
var out = new Array();
for (var x = 0; x < mr.length; x++) {
v = mr[x].getChanges();
out[x] = v;
out[x].id = mr[x].id;
}
Ext.Ajax.request({
url: "v4l/services/" + adapterId,
params: {
op: "update",
entries: Ext.encode(out)
},
success: function(response, options) {
store.commitChanges();
},
failure: function(response, options) {
Ext.MessageBox.alert('Message', response.statusText);
}
});
}
var delButton = new Ext.Toolbar.Button({
tooltip: 'Delete one or more selected rows',
iconCls: 'remove',
text: 'Delete selected services',
handler: delSelected,
disabled: true
});
var saveBtn = new Ext.Toolbar.Button({
tooltip: 'Save any changes made (Changed cells have red borders).',
iconCls: 'save',
text: "Save changes",
handler: saveChanges,
disabled: true
});
var rejectBtn = new Ext.Toolbar.Button({
tooltip: 'Revert any changes made (Changed cells have red borders).',
iconCls: 'undo',
text: "Revert changes",
handler: function() {
store.rejectChanges();
},
disabled: true
});
var selModel = new Ext.grid.RowSelectionModel({
singleSelect: false
});
var grid = new Ext.grid.EditorGridPanel({
stripeRows: true,
title: 'Services',
plugins: [enabledColumn],
store: store,
clicksToEdit: 2,
cm: cm,
viewConfig: {
forceFit: true
},
selModel: selModel,
tbar: [
{
tooltip: 'Create a new entry on the server. '
+ 'The new entry is initially disabled so it must be enabled '
+ 'before it start taking effect.',
iconCls: 'add',
text: 'Add service',
handler: addRecord
}, '-', delButton, '-', saveBtn, rejectBtn]
});
store.on('update', function(s, r, o) {
d = s.getModifiedRecords().length === 0;
saveBtn.setDisabled(d);
rejectBtn.setDisabled(d);
});
selModel.on('selectionchange', function(self) {
delButton.setDisabled(self.getCount() === 0);
});
return grid;
};
/**
*
*/
tvheadend.v4l_adapter = function(data) {
var panel = new Ext.TabPanel({
border: false,
activeTab: 0,
autoScroll: true,
items: [new tvheadend.v4l_adapter_general(data),
new tvheadend.v4l_services(data.identifier)]
});
return panel;
};