diff --git a/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java b/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java index 84cd3e6..e213be3 100644 --- a/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java +++ b/src/main/java/com/moparisthebest/rcrdit/RcrdIt.java @@ -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 + 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") diff --git a/src/main/java/com/moparisthebest/rcrdit/requestbeans/NewRecordingRequest.java b/src/main/java/com/moparisthebest/rcrdit/requestbeans/NewRecordingRequest.java new file mode 100644 index 0000000..e87abdb --- /dev/null +++ b/src/main/java/com/moparisthebest/rcrdit/requestbeans/NewRecordingRequest.java @@ -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; + } + + +} diff --git a/src/main/webapp/css/rcrdit.css b/src/main/webapp/css/rcrdit.css index 4d428e5..d18e48c 100644 --- a/src/main/webapp/css/rcrdit.css +++ b/src/main/webapp/css/rcrdit.css @@ -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; } \ No newline at end of file diff --git a/src/main/webapp/images/recordMulti.png b/src/main/webapp/images/recordMulti.png new file mode 100644 index 0000000..8a538ab Binary files /dev/null and b/src/main/webapp/images/recordMulti.png differ diff --git a/src/main/webapp/images/recordSingle.png b/src/main/webapp/images/recordSingle.png new file mode 100644 index 0000000..9ce0118 Binary files /dev/null and b/src/main/webapp/images/recordSingle.png differ diff --git a/src/main/webapp/js/rcrdit.js b/src/main/webapp/js/rcrdit.js index 9d2435d..ae15932 100644 --- a/src/main/webapp/js/rcrdit.js +++ b/src/main/webapp/js/rcrdit.js @@ -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($("").addClass("programTitle").append($("").html(obj.title))); + if(!isNull(obj.subTitle)){ + $("#programInfoTable").append($("").addClass("programSubtitleLine").append($("").html(obj.subTitle))); + } + if(!isNull(obj.desc)){ + $("#programInfoTable").append($("").append($("").addClass("blankSpace"))); + $("#programInfoTable").append($("").addClass("programDescription").append($("").html(obj.desc))); + } + + $("#programInfo").dialog("open"); + var recordSingleDiv = $("
").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($("
").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 = $("
"); - - 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 = $(""+padToTwoDigits(requestStartDate.getHours())+":"+padToTwoDigits(requestStartDate.getMinutes())+""+padToTwoDigits(nextDate.getHours())+":"+padToTwoDigits(nextDate.getMinutes())+""); - guideTable.append(timeDisplayRow); - for(var idx in channelList){ - var channel = channelList[idx]; - var channelTableRow = $(""+channel.displayName+""); - 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+="
"+program.subTitle+""; - } - channelTableRow.append(""+programText+""); - } - 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 = $("
").attr("id","programInfo"); + programInfoDiv.append($("
").attr("id","programInfoTable")); + $("body").append(programInfoDiv); + } + $("#programInfoTable tr").remove(); + + $("#programInfo").dialog({ + autoOpen: false, + dialogClass: 'noTitleStuff2', + width: "600" + }); } \ No newline at end of file