/* * jason - Javascript based skin for xxv * Copyright(c) 2008-2012, anbr * * http://projects.vdr-developer.org/projects/xxv * */ Ext.xxv.chronicleStore = function() { // create the data store return new Ext.data.Store({ baseParams:{cmd:'chrl'} ,autoLoad:{params:{start:0, limit:configuration.pageSize}} ,reader: new Ext.xxv.jsonReader({ fields: [ {name: 'id', type: 'int'}, {name: 'title', type: 'string'}, {name: 'channel', type: 'string'}, {name: 'day', type:'date', dateFormat:'timestamp'}, {name: 'start', type: 'string'}, {name: 'stop', type: 'string'}, {name: 'duration', type: 'int' }, {name: 'description', type: 'string'} ] }) ,proxy : new Ext.data.HttpProxy({ url: XXV.help.baseURL() ,method: 'GET' }) ,sortInfo:{field:'day', direction:'ASC'} }); }; Ext.xxv.ChronicleGrid = function(viewer) { this.viewer = viewer; this.preview = new Ext.xxv.ChroniclePreview(viewer); // create the data store this.store = new Ext.xxv.chronicleStore(); this.store.setDefaultSort('title', "ASC"); this.columns = [ { id:'expand' ,header: this.szColTitle ,dataIndex: 'title' ,width: 200 ,renderer: this.formatTitle }, { header: this.szColChannel ,dataIndex: 'channel' ,width: 130 },{ header: this.szColDay ,dataIndex: 'day' ,width: 50 ,renderer: Ext.util.Format.dateRenderer(this.szColDayFormat) },{ header: this.szColStart ,dataIndex: 'start' ,width: 30 },{ header: this.szColStop ,dataIndex: 'stop' ,width: 30 },{ header: this.szColDuration ,dataIndex: 'duration' ,width: 30 ,renderer: function (v, m, r) { return SecondsToHMS(v); } } ]; var cm = new Ext.grid.ColumnModel(this.columns); cm.defaultSortable = true; this.filter = new Ext.ux.grid.Search({ position:'top' ,shortcutKey:null ,paramNames: { fields:'cmd' ,all:'chrl' ,cmd:'chrs' ,query:'data' } }); Ext.xxv.ChronicleGrid.superclass.constructor.call(this, { region: 'center' ,id: 'chronicle-view-grid' ,loadMask: true ,clicksToEdit:1 ,autoExpandColumn:'expand' ,cm: cm ,sm: new Ext.grid.RowSelectionModel({ singleSelect:false }) ,tbar:new Ext.PagingToolbar({ pageSize: this.store.autoLoad.params.limit, store: this.store, displayInfo: true }) ,plugins:[this.filter] }); this.store.on({ 'load' : this.onLoad ,'beforeload' : this.onBeforeLoad ,'loadexception' : this.onLoadException ,scope:this }); this.on('rowcontextmenu', this.onContextClick, this); this.getSelectionModel().on('rowselect', this.select, this, {buffer:50}); this.on('rowdblclick', this.onEditItem, this); }; Ext.extend(Ext.xxv.ChronicleGrid, Ext.grid.EditorGridPanel, { szTitle : "Chronicle" ,szToolTip : "Display recordings in chronological order" ,szDelete : "Delete" ,szColTitle : "Title" ,szColDay : "Day" ,szColChannel : "Channel" ,szColStart : "Start" ,szColStop : "Stop" ,szColDuration : "Duration" ,szColDayFormat : "l, m/d/Y" ,szLoadException : "Couldn't get data from chronicle!\r\n{0}" ,szDeleteSuccess : "Data from chronicle deleted successful.\r\n{0}" ,szDeleteFailure : "Couldn't delete data from chronicle!\r\n{0}" ,stateful: true ,onLoadException : function( scope, o, arg, e) { new Ext.xxv.MessageBox().msgFailure(this.szLoadException, e.message); } ,onBeforeLoad : function( store, opt ) { this.preview.clear(); } ,onLoad : function( store, records, opt ) { this.ownerCt.SetPanelTitle(this.szTitle); this.getSelectionModel().selectFirstRow(); } ,onContextClick : function(grid, index, e){ if(!this.menu){ // create context menu on first right click this.menu = new Ext.menu.Menu({ id:'grid-ctx', items: [{ itemId:'s' ,text: Ext.xxv.timerGrid.prototype.szFindReRun ,iconCls: 'find-icon' ,scope:this ,disabled: true ,handler: function(){ this.viewer.searchTab(this.ctxRecord);} },{ itemId:'chrd' ,text: Ext.xxv.timerGrid.prototype.szDelete ,iconCls: 'delete-icon' ,scope:this ,disabled: true ,handler: function() { this.DeleteItem(this.ctxRecord); } } ] }); this.menu.on('hide', this.onContextHide, this); } e.stopEvent(); if(this.ctxRow){ Ext.fly(this.ctxRow).removeClass('x-node-ctx'); this.ctxRow = null; } this.ctxRow = this.view.getRow(index); this.ctxRecord = this.store.getAt(index); Ext.fly(this.ctxRow).addClass('x-node-ctx'); var items = this.menu.items; if(items) { items.eachKey(function(key, f) { if(XXV.help.cmdAllowed(f.itemId)) f.enable(); },items); } this.menu.showAt(e.getXY()); }, onContextHide : function(){ if(this.ctxRow){ Ext.fly(this.ctxRow).removeClass('x-node-ctx'); this.ctxRow = null; } if(this.menu) { this.menu.destroy(); delete this.menu; this.menu = null; } }, formatTitle: function(value, p, record) { return String.format( '