diff --git a/ApiClient.js b/ApiClient.js index 53f4fde2af..a42c27949e 100644 --- a/ApiClient.js +++ b/ApiClient.js @@ -389,13 +389,21 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getLiveTvChannel = function (id) { + self.getLiveTvChannel = function (id, userId) { if (!id) { throw new Error("null id"); } - var url = self.getUrl("LiveTv/Channels/" + id); + var options = { + + }; + + if (userId) { + options.userId = userId; + } + + var url = self.getUrl("LiveTv/Channels/" + id, options); return self.ajax({ type: "GET", @@ -437,13 +445,44 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getLiveTvRecording = function (id) { + self.getLiveTvRecording = function (id, userId) { if (!id) { throw new Error("null id"); } - var url = self.getUrl("LiveTv/Recordings/" + id); + var options = { + + }; + + if (userId) { + options.userId = userId; + } + + var url = self.getUrl("LiveTv/Recordings/" + id, options); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + + self.getLiveTvProgram = function (id, userId) { + + if (!id) { + throw new Error("null id"); + } + + var options = { + + }; + + if (userId) { + options.userId = userId; + } + + var url = self.getUrl("LiveTv/Programs/" + id, options); return self.ajax({ type: "GET", @@ -506,6 +545,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; + self.getNewLiveTvTimerDefaults = function () { + + var url = self.getUrl("LiveTv/Timers/Defaults"); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + self.createLiveTvTimer = function (item) { if (!item) { diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index f59d91a224..4bba9bd4c9 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -106,6 +106,12 @@ padding: 10px; } +@media all and (max-width: 400px) { + .libraryPage .ui-content { + padding: 10px 0; + } +} + .libraryPage, .libraryPage .itemListContent { background: #494949 url(images/bgflip.png) repeat-x!important; background-attachment: fixed!important; diff --git a/dashboard-ui/livetvchannel.html b/dashboard-ui/livetvchannel.html index e7725863ec..d0abd2692a 100644 --- a/dashboard-ui/livetvchannel.html +++ b/dashboard-ui/livetvchannel.html @@ -47,7 +47,7 @@
Programs
-
+
diff --git a/dashboard-ui/livetvnewrecording.html b/dashboard-ui/livetvnewrecording.html new file mode 100644 index 0000000000..f540e99102 --- /dev/null +++ b/dashboard-ui/livetvnewrecording.html @@ -0,0 +1,109 @@ + + + + Media Browser + + +
+ +
+
+

+

+

+ +

+

+

+

+ +
+ +

+ + +

+
+ + + +
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
+
+
+ +
+ + diff --git a/dashboard-ui/livetvrecording.html b/dashboard-ui/livetvrecording.html index cb953a6c7d..a13136c3f6 100644 --- a/dashboard-ui/livetvrecording.html +++ b/dashboard-ui/livetvrecording.html @@ -21,11 +21,11 @@

+

-

diff --git a/dashboard-ui/livetvseriestimer.html b/dashboard-ui/livetvseriestimer.html index ba053a2003..fc7e4e9ecd 100644 --- a/dashboard-ui/livetvseriestimer.html +++ b/dashboard-ui/livetvseriestimer.html @@ -53,9 +53,6 @@
-
  • -

    Advanced

    -
  • diff --git a/dashboard-ui/scripts/livetvchannel.js b/dashboard-ui/scripts/livetvchannel.js index 827bd94bd2..6f5b17c7da 100644 --- a/dashboard-ui/scripts/livetvchannel.js +++ b/dashboard-ui/scripts/livetvchannel.js @@ -21,7 +21,7 @@ html += ''; - html += ' '; + html += ' '; html += 'Date'; html += 'Start'; html += 'End'; @@ -36,12 +36,12 @@ html += ''; - html += ''; + html += ''; if (program.RecordingId) { html += ''; } else { - html += ''; + html += 'Record'; } html += ''; @@ -116,7 +116,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getLiveTvChannel(getParameterByName('id')).done(function (item) { + ApiClient.getLiveTvChannel(getParameterByName('id'), Dashboard.getCurrentUserId()).done(function (item) { currentItem = item; diff --git a/dashboard-ui/scripts/livetvnewrecording.js b/dashboard-ui/scripts/livetvnewrecording.js new file mode 100644 index 0000000000..6150a5c2c4 --- /dev/null +++ b/dashboard-ui/scripts/livetvnewrecording.js @@ -0,0 +1,173 @@ +(function ($, document, apiClient) { + + var currentProgram; + var daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + + function renderRecording(page, defaultTimer, program) { + + currentProgram = program; + + var context = 'livetv'; + + $('.itemName', page).html(program.Name); + $('.itemChannelNumber', page).html('Channel:   ' + program.ChannelName + '').trigger('create'); + + if (program.EpisodeTitle) { + $('.itemEpisodeName', page).html('Episode:   ' + program.EpisodeTitle); + } else { + $('.itemEpisodeName', page).html(''); + } + + if (program.CommunityRating) { + $('.itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(program)).show(); + } else { + $('.itemCommunityRating', page).hide(); + } + + LibraryBrowser.renderGenres($('.itemGenres', page), program, context); + LibraryBrowser.renderOverview($('.itemOverview', page), program); + + $('.itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(program)); + + $('#txtRequestedPrePaddingSeconds', page).val(defaultTimer.RequestedPrePaddingSeconds); + $('#txtRequestedPostPaddingSeconds', page).val(defaultTimer.RequestedPostPaddingSeconds); + $('#txtRequiredPrePaddingSeconds', page).val(defaultTimer.RequiredPrePaddingSeconds); + $('#txtRequiredPostPaddingSeconds', page).val(defaultTimer.RequiredPostPaddingSeconds); + + try { + + var startDate = parseISO8601Date(program.StartDate, { toLocal: true }); + + $('#chk' + daysOfWeek[startDate.getDay()], page).checked(true).checkboxradio('refresh'); + + } + catch (e) { + console.log("Error parsing date: " + program.StartDate); + } + + Dashboard.hideLoadingMsg(); + } + + function reload(page) { + + Dashboard.showLoadingMsg(); + + var programid = getParameterByName('programid'); + + var promise1 = apiClient.getNewLiveTvTimerDefaults(); + var promise2 = apiClient.getLiveTvProgram(programid, Dashboard.getCurrentUserId()); + + $.when(promise1, promise2).done(function (response1, response2) { + + var defaults = response1[0]; + var program = response2[0]; + + renderRecording(page, defaults, program); + }); + } + + function getDays(page) { + + var days = []; + + for (var i = 0, length = daysOfWeek.length; i < length; i++) { + + var day = daysOfWeek[i]; + + if ($('#chk' + day, page).checked()) { + days.push(day); + } + + } + + return days; + } + + function onSubmit() { + + Dashboard.showLoadingMsg(); + + var form = this; + + apiClient.getNewLiveTvTimerDefaults().done(function (item) { + + item.RequestedPrePaddingSeconds = $('#txtRequestedPrePaddingSeconds', form).val(); + item.RequestedPostPaddingSeconds = $('#txtRequestedPostPaddingSeconds', form).val(); + item.RequiredPrePaddingSeconds = $('#txtRequiredPrePaddingSeconds', form).val(); + item.RequiredPostPaddingSeconds = $('#txtRequiredPostPaddingSeconds', form).val(); + + item.RecordNewOnly = $('#chkNewOnly', form).checked(); + item.RecordAnyChannel = $('#chkAllChannels', form).checked(); + item.RecordAnyTime = $('#chkAnyTime', form).checked(); + + item.Days = getDays(form); + + item.Name = currentProgram.Name; + item.ProgramId = currentProgram.Id; + item.ChannelName = currentProgram.ChannelName; + item.ChannelId = currentProgram.ChannelId; + item.Overview = currentProgram.Overview; + item.StartDate = currentProgram.StartDate; + item.EndDate = currentProgram.EndDate; + + if ($('#chkRecordSeries', form).checked()) { + + apiClient.createLiveTvSeriesTimer(item).done(function () { + + Dashboard.hideLoadingMsg(); + Dashboard.navigate('livetvseriestimers.html'); + + }); + + } else { + apiClient.createLiveTvTimer(item).done(function () { + + Dashboard.hideLoadingMsg(); + Dashboard.navigate('livetvtimers.html'); + + }); + } + + }); + + // Disable default form submission + return false; + } + + function liveTvNewRecordingPage() { + + var self = this; + + self.onSubmit = onSubmit; + + } + + window.LiveTvNewRecordingPage = new liveTvNewRecordingPage(); + + $(document).on('pageinit', "#liveTvNewRecordingPage", function () { + + var page = this; + + $('#chkRecordSeries', page).on('change', function () { + + if (this.checked) { + $('#seriesFields', page).show(); + } else { + $('#seriesFields', page).hide(); + } + + }); + + }).on('pagebeforeshow', "#liveTvNewRecordingPage", function () { + + var page = this; + + reload(page); + + }).on('pagehide', "#liveTvNewRecordingPage", function () { + + currentProgram = null; + + }); + +})(jQuery, document, ApiClient); \ No newline at end of file diff --git a/dashboard-ui/scripts/livetvrecording.js b/dashboard-ui/scripts/livetvrecording.js index ac1ee575de..f05ff06ef4 100644 --- a/dashboard-ui/scripts/livetvrecording.js +++ b/dashboard-ui/scripts/livetvrecording.js @@ -35,7 +35,11 @@ $('.itemName', page).html(name); $('.itemChannelNumber', page).html('Channel:   ' + item.ChannelName + '').trigger('create'); - $('.itemEpisodeName', page).html(item.EpisodeTitle); + if (item.EpisodeTitle) { + $('.itemEpisodeName', page).html('Episode:   ' + item.EpisodeTitle); + } else { + $('.itemEpisodeName', page).html(''); + } if (item.CommunityRating) { $('.itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(item)).show(); @@ -91,7 +95,7 @@ var id = getParameterByName('id'); - apiClient.getLiveTvRecording(id).done(function (result) { + apiClient.getLiveTvRecording(id, Dashboard.getCurrentUserId()).done(function (result) { renderRecording(page, result); diff --git a/packages.config b/packages.config index 808183a672..12f78c773a 100644 --- a/packages.config +++ b/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file