1
0
mirror of https://github.com/moparisthebest/rcrdit synced 2024-12-21 23:08:57 -05:00

Can now schedule individual recordings by clicking on an item in the schedule and clicking the "Single Record" icon. NOTE: this should enter the start/stop time as well, but the code to do so is commented out because it crashes the program after the recording is added when it reads the schedule.

This commit is contained in:
Jeff Lamb 2017-03-08 23:01:29 -05:00
parent 9ce3baaca5
commit ccd29b6169
6 changed files with 181 additions and 49 deletions

View File

@ -74,6 +74,7 @@ import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
import com.moparisthebest.rcrdit.requestbeans.GetScheduleRequest;
import com.moparisthebest.rcrdit.requestbeans.NewRecordingRequest;
import com.moparisthebest.rcrdit.responsebeans.GetScheduleResponse;
import org.glassfish.jersey.jackson.JacksonFeature;
@ -459,6 +460,28 @@ public class RcrdIt extends ResourceConfig implements AutoCloseable {
return new GetScheduleResponse(scheduleRequest,channelList);
}
@POST
@Path("recordSingleInstanceOfProgram")
@Consumes(MediaType.APPLICATION_JSON)
//List<Channel>
public String recordSingleInstanceOfProgram(NewRecordingRequest recordingRequest) {
try (Connection conn = DriverManager.getConnection(databaseUrl);
QueryMapper qm = new QueryMapper(conn)) {
String sql = "INSERT INTO autorecs (autorec_id, profile_id, priority, title, channel_name, days_of_week, between_time_start, between_time_end, time_min, time_max) "
+ "VALUES (NULL, ?, ?, ?, ?, NULL, NULL,NULL, from_unixtime(?), from_unixtime(?))";
Long startDate = null;
Long endDate = null;
//if(recordingRequest.getStartDateEpochSeconds() != null)startDate = recordingRequest.getStartDateEpochSeconds();
//if(recordingRequest.getEndDateEpochSeconds() != null)endDate = recordingRequest.getEndDateEpochSeconds();
qm.executeUpdate(sql, recordingRequest.getProfileNo(),recordingRequest.getPriority(),recordingRequest.getTitle(),recordingRequest.getChannelName(),startDate,endDate);
timer.schedule(new AutoRecTask(), 0);
}catch(Exception e){
log.error("Error in recordSingleInstanceOfProgram",e);
}
return "OK";
}
@POST
@Path("refreshAutoRecs")

View File

@ -0,0 +1,69 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.moparisthebest.rcrdit.requestbeans;
/**
*
* @author Jeff
*/
public class NewRecordingRequest {
protected Long profileNo;
protected String title;
protected String channelName;
protected Long startDateEpochSeconds;
protected Long endDateEpochSeconds;
protected Long priority;
public Long getProfileNo() {
return profileNo;
}
public void setProfileNo(Long profileNo) {
this.profileNo = profileNo;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getChannelName() {
return channelName;
}
public void setChannelName(String channelName) {
this.channelName = channelName;
}
public Long getStartDateEpochSeconds() {
return startDateEpochSeconds;
}
public void setStartDateEpochSeconds(Long startDateEpochSeconds) {
this.startDateEpochSeconds = startDateEpochSeconds;
}
public Long getEndDateEpochSeconds() {
return endDateEpochSeconds;
}
public void setEndDateEpochSeconds(Long endDateEpochSeconds) {
this.endDateEpochSeconds = endDateEpochSeconds;
}
public Long getPriority() {
return priority;
}
public void setPriority(Long priority) {
this.priority = priority;
}
}

View File

@ -262,4 +262,40 @@ ul#channelGroups li ul li ul li.channel {
padding-right: 15px;
display: block;
}
.noTitleStuff .ui-dialog-titlebar {display:none}
.programTitle{
font-size: 22pt;
}
.programSubtitleLine{
font-size: 12pt;
}
.blankSpace{
height: 20px;
}
.recordSingleDiv{
height: 50px;
width: 50px;
background-image: url("../images/recordSingle.png");
float: left;
}
.recordSingleDiv:hover{
cursor:pointer;
}
.recordSingleDiv:active{
background-color:gray;
}
.recordMultiDiv{
height: 50px;
width: 50px;
background-image: url("../images/recordMulti.png");
float: left;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -7,6 +7,7 @@
$( document ).ready(function() {
initializeProgramInfoPopup();
getSchedule2(null);
});
@ -252,73 +253,76 @@ function getProgramDiv(program, requestObject, startAtPercent){
var widthPercent = (displayDurationMinutes/showingMinutes)*100;
programDiv.attr("style","left: "+startAtPercent+"%; width: "+widthPercent+"%");
program.widthPercent = widthPercent;
programDiv.click(function(){
$("#programInfoTable tr").remove();
$(".recordSingleDiv, .recordMultiDiv").remove();
var obj = $(this).data("programObj");
$("#programInfoTable").data("programObj",obj);
$("#programInfoTable").append($("<tr></tr>").addClass("programTitle").append($("<td></td>").html(obj.title)));
if(!isNull(obj.subTitle)){
$("#programInfoTable").append($("<tr></tr>").addClass("programSubtitleLine").append($("<td></td>").html(obj.subTitle)));
}
if(!isNull(obj.desc)){
$("#programInfoTable").append($("<tr></tr>").append($("<td></td>").addClass("blankSpace")));
$("#programInfoTable").append($("<tr></tr>").addClass("programDescription").append($("<td></td>").html(obj.desc)));
}
$("#programInfo").dialog("open");
var recordSingleDiv = $("<div></div>").attr("class","recordSingleDiv");
recordSingleDiv.click(function(){
var programToRecord = $("#programInfoTable").data("programObj");
var recordingScheduleObject = {"profileNo":"1","title": programToRecord.title,"channelName": programToRecord.channelName,"priority": "9999999","startDateEpochSeconds" : programToRecord.start.epochSecond , "endDateEpochSeconds" : programToRecord.stop.epochSecond};
scheduleRecording(recordingScheduleObject);
});
$("#programInfo").append(recordSingleDiv);
$("#programInfo").append($("<div></div>").attr("class","recordMultiDiv"));
});
return programDiv;
}
function getSchedule(requestObject){
if(isNull(requestObject)){
requestObject = {"channelsPerPage" : "100", "pageNum" : "1"};
}
function scheduleRecording(recordingDetails){
$.ajax({
url: 'rest/getSchedule',
url: 'rest/recordSingleInstanceOfProgram',
type: 'post',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(requestObject),
data: JSON.stringify(recordingDetails),
success: function (data) {
$("#guideGoesHere").html("");
var guideTable = $("<table border='1' cellpadding='1' cellspacing='0' style='border-collapse: collapse;'></table>");
var channelList = data.schedule;
var requestObject = data.requestObject;
var requestStartTimeEpochSeconds = requestObject.startTime.epochSecond;
var requestEndTimeEpochSeconds = requestObject.endTime.epochSecond;
var requestStartDate = new Date(requestStartTimeEpochSeconds*1000);
var requestEndDate = new Date(requestEndTimeEpochSeconds*1000);
var nextDate = new Date(requestStartDate.getTime());
nextDate.setHours(nextDate.getHours()+1);
var timeDisplayRow = $("<tr><td></td><td colspan=60>"+padToTwoDigits(requestStartDate.getHours())+":"+padToTwoDigits(requestStartDate.getMinutes())+"</td><td colspan=60>"+padToTwoDigits(nextDate.getHours())+":"+padToTwoDigits(nextDate.getMinutes())+"</td></tr>");
guideTable.append(timeDisplayRow);
for(var idx in channelList){
var channel = channelList[idx];
var channelTableRow = $("<tr><td>"+channel.displayName+"</td></tr>");
for(var idx2 in channel.programs){
var program = channel.programs[idx2];
var durationSeconds = program.stop.epochSecond-program.start.epochSecond;
var durationMinutes = durationSeconds/60;
var displayDurationSeconds = durationSeconds;
if(program.start.epochSecond < requestStartTimeEpochSeconds){
displayDurationSeconds = displayDurationSeconds-(requestStartTimeEpochSeconds-program.start.epochSecond);
}
if(program.stop.epochSecond > requestEndTimeEpochSeconds){
displayDurationSeconds = displayDurationSeconds-(program.stop.epochSecond-requestEndTimeEpochSeconds);
}
var displayDurationMinutes = displayDurationSeconds/60;
var programText = program.title;
if(!isNull(program.subTitle)){
programText+="<br/><font style='font-size:8pt'>"+program.subTitle+"</font>";
}
channelTableRow.append("<td colspan='"+Math.ceil(displayDurationMinutes)+"'>"+programText+"</td>");
}
guideTable.append(channelTableRow);
}
$("#guideGoesHere").append(guideTable);
alert("scheduled!");
},
error: function ( jqXHR, textStatus, errorThrown ){
alert(errorThrown);
}
});
}
function isNull(item){
if(item === null || typeof item === "undefined"){
return true;
}
return false;
}
function divExists(divId){
var found = $("#"+divId);
if(found.length === 0){
return false;
}
return true;
}
function initializeProgramInfoPopup(){
if(!divExists("programInfo")){
var programInfoDiv = $("<div></div>").attr("id","programInfo");
programInfoDiv.append($("<table></table>").attr("id","programInfoTable"));
$("body").append(programInfoDiv);
}
$("#programInfoTable tr").remove();
$("#programInfo").dialog({
autoOpen: false,
dialogClass: 'noTitleStuff2',
width: "600"
});
}