1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

add ability to create timer

This commit is contained in:
Luke Pulverenti 2013-12-17 15:02:12 -05:00
parent f030db9841
commit 121d1de0af
10 changed files with 355 additions and 16 deletions

View file

@ -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) {

View file

@ -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;

View file

@ -47,7 +47,7 @@
<div class="detailSectionHeader" style="margin-top: 0;">
Programs
</div>
<div class="detailSectionContent" style="padding: 1em;">
<div class="detailSectionContent" style="padding: 1em 0;">
<div id="programList"></div>
</div>

View file

@ -0,0 +1,109 @@
<!DOCTYPE html>
<html>
<head>
<title>Media Browser</title>
</head>
<body>
<div id="liveTvNewRecordingPage" data-role="page" class="page libraryPage" data-theme="a" data-view="livetv">
<div class="libraryViewNav">
<a href="livetvguide.html">Guide</a>
<a href="livetvchannels.html">Channels</a>
<a href="livetvrecordings.html" class="ui-btn-active">Recordings</a>
<a href="livetvtimers.html">Upcoming Recordings</a>
<a href="livetvseriestimers.html">Series Recordings</a>
</div>
<div data-role="content">
<form id="liveTvNewRecordingForm" style="margin: 0 auto;">
<p><span class="itemName inlineItemName"></span><span class="itemMiscInfo" style="display: inline;"></span></p>
<p class="itemEpisodeName"></p>
<p>
<span class="itemCommunityRating"></span>
</p>
<p class="itemChannelNumber"></p>
<p class="itemGenres"></p>
<p class="itemOverview"></p>
<br />
<p>
<input type="checkbox" data-mini="true" id="chkRecordSeries" />
<label for="chkRecordSeries">Record Series</label>
</p>
<br />
<ul data-role="listview" class="ulForm" id="seriesFields" style="display: none;">
<li>
<h3>Days</h3>
<div data-role="controlgroup">
<input type="checkbox" data-mini="true" id="chkSunday" />
<label for="chkSunday">Sunday</label>
<input type="checkbox" data-mini="true" id="chkMonday" />
<label for="chkMonday">Monday</label>
<input type="checkbox" data-mini="true" id="chkTuesday" />
<label for="chkTuesday">Tuesday</label>
<input type="checkbox" data-mini="true" id="chkWednesday" />
<label for="chkWednesday">Wednesday</label>
<input type="checkbox" data-mini="true" id="chkThursday" />
<label for="chkThursday">Thursday</label>
<input type="checkbox" data-mini="true" id="chkFriday" />
<label for="chkFriday">Friday</label>
<input type="checkbox" data-mini="true" id="chkSaturday" />
<label for="chkSaturday">Saturday</label>
</div>
</li>
<li>
<label for="chkNewOnly">Record only new episodes</label>
<input type="checkbox" id="chkNewOnly" data-mini="true" checked="checked" />
</li>
<li>
<label for="chkAnyTime">Record program at any time</label>
<input type="checkbox" id="chkAnyTime" data-mini="true" />
</li>
<li>
<label for="chkAllChannels">Record program on all channels</label>
<input type="checkbox" id="chkAllChannels" data-mini="true" />
</li>
</ul>
<br />
<ul data-role="listview" class="ulForm">
<li>
<label for="txtRequestedPrePaddingSeconds">Requested pre-padding seconds: </label>
<input type="number" id="txtRequestedPrePaddingSeconds" pattern="[0-9]*" required="required" min="0" data-mini="true" />
</li>
<li>
<label for="txtRequestedPostPaddingSeconds">Requested post-padding seconds: </label>
<input type="number" id="txtRequestedPostPaddingSeconds" pattern="[0-9]*" required="required" min="0" data-mini="true" />
</li>
<li>
<label for="txtRequiredPrePaddingSeconds">Required pre-padding seconds: </label>
<input type="number" id="txtRequiredPrePaddingSeconds" pattern="[0-9]*" required="required" min="0" data-mini="true" />
</li>
<li>
<label for="txtRequiredPostPaddingSeconds">Required post-padding seconds: </label>
<input type="number" id="txtRequiredPostPaddingSeconds" pattern="[0-9]*" required="required" min="0" data-mini="true" />
</li>
<li>
<button type="submit" data-theme="b" data-icon="ok" data-mini="true">
Save
</button>
<button type="button" onclick="Dashboard.navigate('livetvtimers.html');" data-icon="delete" data-mini="true">
Cancel
</button>
</li>
</ul>
</form>
</div>
<script type="text/javascript">
$('#liveTvNewRecordingForm').on('submit', LiveTvNewRecordingPage.onSubmit);
</script>
</div>
</body>
</html>

View file

@ -21,11 +21,11 @@
</td>
<td style="vertical-align: top; padding: 0;">
<p><span class="itemName inlineItemName"></span><span class="itemMiscInfo" style="display: inline;"></span></p>
<p class="itemEpisodeName"></p>
<p>
<span class="itemCommunityRating"></span>
<span class="userDataIcons"></span>
</p>
<p class="itemEpisodeName"></p>
<p class="itemGenres"></p>
<p class="itemOverview"></p>
</td>

View file

@ -53,9 +53,6 @@
<label for="chkSaturday">Saturday</label>
</div>
</li>
<li>
<h3>Advanced</h3>
</li>
<li>
<label for="chkNewOnly">Record only new episodes</label>
<input type="checkbox" id="chkNewOnly" data-mini="true" />

View file

@ -21,7 +21,7 @@
html += '<tr>';
html += '<th class="tabletColumn">&nbsp;</th>';
html += '<th>&nbsp;</th>';
html += '<th>Date</th>';
html += '<th>Start</th>';
html += '<th class="tabletColumn">End</th>';
@ -36,12 +36,12 @@
html += '<tr>';
html += '<td class="tabletColumn">';
html += '<td>';
if (program.RecordingId) {
html += '<button data-recordingid="' + program.RecordingId + '" class="btnCancelRecording" type="button" data-icon="delete" data-inline="true" data-mini="true" data-iconpos="notext">Cancel</button>';
} else {
html += '<button data-recordingid="' + program.RecordingId + '" class="btnScheduleRecording" type="button" data-icon="facetime-video" data-inline="true" data-mini="true" data-theme="b" data-iconpos="notext">Record</button>';
html += '<a href="livetvnewrecording.html?programid=' + program.Id + '" data-role="button" type="button" data-icon="facetime-video" data-inline="true" data-mini="true" data-theme="b" data-iconpos="notext">Record</a>';
}
html += '</td>';
@ -116,7 +116,7 @@
Dashboard.showLoadingMsg();
ApiClient.getLiveTvChannel(getParameterByName('id')).done(function (item) {
ApiClient.getLiveTvChannel(getParameterByName('id'), Dashboard.getCurrentUserId()).done(function (item) {
currentItem = item;

View file

@ -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:&nbsp;&nbsp;&nbsp;<a href="livetvchannel.html?id=' + program.ChannelId + '">' + program.ChannelName + '</a>').trigger('create');
if (program.EpisodeTitle) {
$('.itemEpisodeName', page).html('Episode:&nbsp;&nbsp;&nbsp;' + 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);

View file

@ -35,7 +35,11 @@
$('.itemName', page).html(name);
$('.itemChannelNumber', page).html('Channel:&nbsp;&nbsp;&nbsp;<a href="livetvchannel.html?id=' + item.ChannelId + '">' + item.ChannelName + '</a>').trigger('create');
$('.itemEpisodeName', page).html(item.EpisodeTitle);
if (item.EpisodeTitle) {
$('.itemEpisodeName', page).html('Episode:&nbsp;&nbsp;&nbsp;' + 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);

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.206" targetFramework="net45" />
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.209" targetFramework="net45" />
</packages>