Skip to content

Commit

Permalink
navigation from edit_timers
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Ehrnsperger committed Jul 12, 2024
1 parent 839abd3 commit 36c5c96
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
3 changes: 2 additions & 1 deletion epg_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ void AppendScraperData(cToSvConcat<0> &target, cScraperVideo *scraperVideo) {
cOrientations(eOrientation::landscape, eOrientation::portrait, eOrientation::banner), false);
AppendScraperData(target, s_IMDB_ID, s_image, scraperVideo->getVideoType(), s_title, scraperVideo->getSeasonNumber(), scraperVideo->getEpisodeNumber(), s_episode_name, s_runtime, s_release_date);
}
bool appendEpgItem(cToSvConcat<0> &epg_item, RecordingsItemRecPtr &recItem, const cEvent *Event, const cChannel *Channel, bool withChannel) {
bool appendEpgItem(cToSvConcat<0> &epg_item, RecordingsItemRecPtr &recItem, const cEvent *Event, const cChannel *Channel, bool withChannel, bool form) {
cGetScraperVideo getScraperVideo(Event, NULL);
getScraperVideo.call(LiveSetup().GetPluginScraper());

Expand All @@ -512,6 +512,7 @@ bool appendEpgItem(cToSvConcat<0> &epg_item, RecordingsItemRecPtr &recItem, cons
epg_item.append(EpgEvents::EncodeDomId(Channel->GetChannelID(), Event->EventID()).c_str() + 6);
epg_item.append("\",\"");
// [1] : Timer ID
if (form) epg_item.append("-"); // timer id starts with - to indicate that history.back is not working
const cTimer* timer = LiveTimerManager().GetTimer(Event->EventID(), Channel->GetChannelID() );
if (timer) epg_item.append(vdrlive::EncodeDomId(LiveTimerManager().GetTimers().GetTimerId(*timer), ".-:", "pmc"));
epg_item.append("\",");
Expand Down
3 changes: 2 additions & 1 deletion epg_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ namespace vdrlive
mutable bool m_checkedArchived;
mutable std::string m_archived;
};
bool appendEpgItem(cToSvConcat<0> &epg_item, RecordingsItemRecPtr &recItem, const cEvent *Event, const cChannel *Channel, bool withChannel);
bool appendEpgItem(cToSvConcat<0> &epg_item, RecordingsItemRecPtr &recItem, const cEvent *Event, const cChannel *Channel, bool withChannel, bool form = false);
// set form = true if history.back is not working because the list of epg items is a result of an html form
}; // namespace vdrlive

#endif // VDR_LIVE_EPG_EVENTS_H
11 changes: 11 additions & 0 deletions pages/edit_timer.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ using namespace vdrlive;
std::string aux = "";
std::string directory = "";
int nav_back = 1;
std::string navigate_back = "";
</%args>
<%session scope="global">
bool logged_in(false);
Expand Down Expand Up @@ -101,6 +102,7 @@ const cTimer* timer;
// dsyslog("live: remote '%s'", remote);
LiveTimerManager().UpdateTimer( timerId, remote, oldRemote, flags, channel, weekdays, date, start, stop, priority, lifetime, file, aux );
timerNotifier.SetTimerModification();
if (navigate_back.empty() ) {
</%cpp>
<!DOCTYPE html>
<html>
Expand All @@ -109,6 +111,10 @@ const cTimer* timer;
</script>
</html>
<%cpp>
} else {
timerid.clear();
return reply.redirect(navigate_back);
}
// return reply.redirect("html/back.html");
// return reply.redirect(!edit_timerreferer.empty()?edit_timerreferer:"timers.html");
} else {
Expand Down Expand Up @@ -203,6 +209,7 @@ const cTimer* timer;
<input type="hidden" name="timerid" value="<$ timerid $>"/>
<input type="hidden" name="aux" value="<$ aux $>"/>
<input type="hidden" name="nav_back" value="<$ nav_back $>"/>
<input type="hidden" name="navigate_back" value="<$ navigate_back $>"/>
<table class="formular" cellpadding="0" cellspacing="0">
<tr class="head">
<td class="toprow leftcol rightcol" colspan="2"><div class="boxheader"><div><div class="caption"><$ timer ? tr("Edit timer") : tr("New timer") $></div></div></div></td>
Expand Down Expand Up @@ -353,7 +360,11 @@ const cTimer* timer;
<td class="buttonpanel leftcol rightcol bottomrow" colspan="2">
<div class="withmargin">
<button class="green" type="submit"><$ tr("Save") $></button>
% if (navigate_back.empty() ) {
<button type="button" class="red" onclick="history.go(<$-nav_back$>)"><$ tr("Cancel") $></button>
% } else {
<a href="<$navigate_back$>"><button type="button" class="red"><$ tr("Cancel") $></button></a>
% }
</div>
</td>
</tr>
Expand Down
12 changes: 10 additions & 2 deletions pages/pageelems.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,21 @@ function addEvent(s, bottomrow_i, obj) {
let bottomrow = ''
if (bottomrow_i != 0) bottomrow = 'bottomrow'
s.a += `<tr><td class=\"action leftcol ${bottomrow}\">`
if (obj[1].length != 0) {
if (obj[1].length > 1) {
s.a += '<a href=\"edit_timer.html?timerid=timer_'
s.a += obj[1]
if (obj[1].startsWith('-')) {
s.a += obj[1].substring(1)
s.a += '&navigate_back=timers.html'
} else {
s.a += obj[1]
}
s.a += '\"><img class=\"icon\" src=\"<$ LiveSetup().GetThemedLink("img", "record_timer.png") $>\" title=\"<$tr("Edit timer")$>\" />'
} else {
s.a += '<a href=\"edit_timer.html?epgid=event_'
s.a += obj[0]
if (obj[1].startsWith('-')) {
s.a += '&navigate_back=timers.html'
}
s.a += '\"><img class=\"icon\" src=\"<$ LiveSetup().GetThemedLink("img", "record.png") $>\" title=\"<$tr("Record this")$>\" />'
}
s.a += '</a>'
Expand Down
2 changes: 1 addition & 1 deletion pages/searchresults.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool logged_in(false);
}

StateKey.Remove(); // release channels read lock before calling event_timer which make a timers read lock
recItemFound = appendEpgItem(epg_itemS, recItem, event, channel, true);
recItemFound = appendEpgItem(epg_itemS, recItem, event, channel, true, !searchtimerquery.empty() );
int col_span = 4;
if (display_pictures) col_span++;
if (current_day != day) {
Expand Down
2 changes: 1 addition & 1 deletion pages/timers.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using namespace vdrlive;
TimerConflicts timerConflicts;

timer = 0;
if ( !timerid.empty() ) {
if ( !timerid.empty() && !action.empty() ) {
std::string tId = SortedTimers::DecodeDomId(timerid);
// dsyslog("live: DEBUG: TIMER: tId = %s", tId.c_str());
timer = timers.GetByTimerId(tId);
Expand Down

0 comments on commit 36c5c96

Please sign in to comment.