From ea9cd4cfd0964c69a3476bf0d57b48d96bb7abdc Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 6 May 2015 11:01:33 +0200 Subject: [PATCH] Web EPG: more DVR icon cleanups, added possibility to delete scheduled recording --- src/api/api_epg.c | 4 +-- src/dvr/dvr_db.c | 2 +- src/dvr/dvr_inotify.c | 3 +- src/webui/static/app/epg.js | 62 ++++++++++++++++++++++++++++--------- 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/src/api/api_epg.c b/src/api/api_epg.c index c348af7de..117ab9d5b 100644 --- a/src/api/api_epg.c +++ b/src/api/api_epg.c @@ -533,7 +533,7 @@ api_epg_related } static int -api_epg_byid +api_epg_load ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp ) { uint32_t id = 0, entries = 0; @@ -611,7 +611,7 @@ void api_epg_init ( void ) { "epg/events/grid", ACCESS_ANONYMOUS, api_epg_grid, NULL }, { "epg/events/alternative", ACCESS_ANONYMOUS, api_epg_alternative, NULL }, { "epg/events/related", ACCESS_ANONYMOUS, api_epg_related, NULL }, - { "epg/events/byid", ACCESS_ANONYMOUS, api_epg_byid, NULL }, + { "epg/events/load", ACCESS_ANONYMOUS, api_epg_load, NULL }, { "epg/brand/list", ACCESS_ANONYMOUS, api_epg_brand_list, NULL }, { "epg/content_type/list", ACCESS_ANONYMOUS, api_epg_content_type_list, NULL }, diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index e095e8dc6..293c91618 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -802,7 +802,7 @@ dvr_entry_dec_ref(dvr_entry_t *de) if (de->de_title) lang_str_destroy(de->de_title); if (de->de_subtitle) lang_str_destroy(de->de_subtitle); if (de->de_desc) lang_str_destroy(de->de_desc); - if (de->de_bcast) de->de_bcast->putref((epg_object_t*)de->de_bcast); + dvr_entry_assign_broadcast(de, NULL); free(de->de_channel_name); free(de->de_episode); diff --git a/src/dvr/dvr_inotify.c b/src/dvr/dvr_inotify.c index 0ad32f54a..ace176b5f 100644 --- a/src/dvr/dvr_inotify.c +++ b/src/dvr/dvr_inotify.c @@ -97,7 +97,7 @@ void dvr_inotify_add ( dvr_entry_t *de ) if (_inot_fd < 0) return; - if (!de->de_filename) + if (!de->de_filename || de->de_filename[0] == '\0') return; path = strdup(de->de_filename); @@ -131,6 +131,7 @@ void dvr_inotify_del ( dvr_entry_t *de ) { dvr_entry_t *det; dvr_inotify_entry_t *e; + lock_assert(&global_lock); RB_FOREACH(e, &_inot_tree, link) { LIST_FOREACH(det, &e->entries, de_inotify_link) if (det == de) break; diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index 5b30f7b3f..5032521bd 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -137,9 +137,10 @@ tvheadend.epgDetails = function(event) { var now = new Date(); var buttons = []; - var recording = event.dvrState.indexOf('recording') == 0; + var recording = event.dvrState.indexOf('recording') === 0; + var scheduled = event.dvrState.indexOf('scheduled') === 0; - if (!recording) { + if (!recording && !scheduled) { buttons.push(new Ext.Button({ disabled: !event.title, handler: searchIMDB, @@ -181,7 +182,16 @@ tvheadend.epgDetails = function(event) { handler: stopDVR, iconCls: 'stopRec', tooltip: 'Stop recording of this program', - text: "Stop record" + text: "Stop recording" + })); + } + + if (scheduled) { + buttons.push(new Ext.Button({ + handler: deleteDVR, + iconCls: 'remove', + tooltip: 'Delete scheduled recording of this program', + text: "Delete recording" })); } @@ -266,7 +276,20 @@ tvheadend.epgDetails = function(event) { success: function(d) { win.close(); }, - question: 'Do you really want to abort/unschedule this event?' + question: 'Do you really want to abort/unschedule this recording?' + }); + } + + function deleteDVR() { + tvheadend.AjaxConfirm({ + url: 'api/idnode/delete', + params: { + uuid: event.dvrUuid, + }, + success: function(d) { + win.close(); + }, + question: 'Do you really want to remove this recording?' }); } @@ -290,20 +313,31 @@ tvheadend.epgDetails = function(event) { tvheadend.epg = function() { var lookup = ' '; + var detailsfcn = function(grid, rec, act, row) { + new tvheadend.epgDetails(grid.getStore().getAt(row).data); + }; + var actions = new Ext.ux.grid.RowActions({ id: 'details', header: 'Details', width: 45, dataIndex: 'actions', + callbacks: { + 'recording': detailsfcn, + 'recordingError': detailsfcn, + 'scheduled': detailsfcn, + 'completed': detailsfcn, + 'completedError': detailsfcn, + }, actions: [ { iconCls: 'broadcast_details', qtip: 'Broadcast details', - cb: function(grid, rec, act, row) { - new tvheadend.epgDetails(grid.getStore().getAt(row).data); - } + cb: detailsfcn, }, - { iconIndex: 'dvrState' } + { + iconIndex: 'dvrState', + } ] }); @@ -874,11 +908,12 @@ tvheadend.epg = function() { epgStore.remove(r); } } - if (m.update || m.dvr_update) { + if (m.update || m.dvr_update || m.dvr_delete) { + var a = m.update || m.dvr_update || m.dvr_delete; if (m.update && m.dvr_update) - var a = m.update.concat(m.dvr_update); - else - var a = m.update || m.dvr_update; + var a = m.update.concat(m.dvr_update); + if (m.update || m.dvr_update) + a = a.concat(m.dvr_delete); var ids = []; for (var i = 0; i < a.length; i++) { var r = epgStore.getById(a[i]); @@ -887,7 +922,7 @@ tvheadend.epg = function() { } if (ids) { Ext.Ajax.request({ - url: 'api/epg/events/byid', + url: 'api/epg/events/load', params: { eventId: ids }, @@ -905,7 +940,6 @@ tvheadend.epg = function() { r.commit(); } } - panel.getView().refresh(); }, failure: function(response, options) { Ext.MessageBox.alert('EPG Update', response.statusText); -- 2.47.2