diff --git a/web/directives/channel-config.js b/web/directives/channel-config.js index 41a0f35..d8da0fe 100644 --- a/web/directives/channel-config.js +++ b/web/directives/channel-config.js @@ -11,7 +11,7 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get }, link: { - post: function (scope, element, attrs) { + post: function (scope, $element, attrs) { scope.screenW = 1920; scope.screenh = 1080; @@ -326,9 +326,10 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get duration: duration, isOffline: true } - scope.channel.programs.splice(scope.minProgramIndex, 0, program); + scope.channel.programs.splice(scope.channel.programs.length, 0, program); scope._selectedOffline = null scope._addingOffline = null; + scrollToLast(); updateChannelDuration() } @@ -1077,11 +1078,37 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get } } - scope.importPrograms = (selectedPrograms) => { + + function getAllMethods(object) { + + return Object.getOwnPropertyNames(object).filter(function (p) { + return typeof object[p] == 'function'; + }); + } + function scrollToLast() { + var programListElement = document.getElementById("channelConfigProgramList"); + $timeout(() => { programListElement.scrollTo(0, 2000000); }, 0) + } + scope.importPrograms = (selectedPrograms, insertPoint) => { for (let i = 0, l = selectedPrograms.length; i < l; i++) { delete selectedPrograms[i].commercials; } - scope.channel.programs = scope.channel.programs.concat(selectedPrograms) + + var programListElement = document.getElementById("channelConfigProgramList"); + if (insertPoint === "start") { + scope.channel.programs = selectedPrograms.concat(scope.channel.programs); + programListElement.scrollTo(0, 0); + } else if (insertPoint === "current") { + scope.channel.programs = [ + ...scope.channel.programs.slice(0, scope.currentStartIndex), + ...selectedPrograms, + ...scope.channel.programs.slice(scope.currentStartIndex) + ]; + } else { + scope.channel.programs = scope.channel.programs.concat(selectedPrograms) + + scrollToLast(); + } updateChannelDuration() setTimeout( () => { @@ -1093,7 +1120,9 @@ module.exports = function ($timeout, $location, dizquetv, resolutionOptions, get } scope.finishRedirect = (program) => { if (scope.selectedProgram == -1) { - scope.channel.programs.splice(scope.minProgramIndex, 0, program); + scope.channel.programs.splice(scope.channel.programs.length, 0, program); + scrollToLast(); + } else { scope.channel.programs[ scope.selectedProgram ] = program; } diff --git a/web/directives/plex-library.js b/web/directives/plex-library.js index 23b89d9..153b2e2 100644 --- a/web/directives/plex-library.js +++ b/web/directives/plex-library.js @@ -6,6 +6,7 @@ module.exports = function (plex, dizquetv, $timeout, commonProgramTools) { scope: { onFinish: "=onFinish", height: "=height", + positionChoice: "=positionChoice", visible: "=visible", limit: "=limit", }, @@ -14,6 +15,7 @@ module.exports = function (plex, dizquetv, $timeout, commonProgramTools) { if ( typeof(scope.limit) == 'undefined') { scope.limit = 1000000000; } + scope.insertPoint = "end"; scope.customShows = []; scope.origins = []; scope.currentOrigin = undefined; @@ -37,7 +39,7 @@ module.exports = function (plex, dizquetv, $timeout, commonProgramTools) { updateCustomShows(); } } - scope._onFinish = (s) => { + scope._onFinish = (s, insertPoint) => { if (s.length > scope.limit) { if (scope.limit == 1) { scope.error = "Please select only one clip."; @@ -45,7 +47,7 @@ module.exports = function (plex, dizquetv, $timeout, commonProgramTools) { scope.error = `Please select at most ${scope.limit} clips.`; } } else { - scope.onFinish(s) + scope.onFinish(s, insertPoint) scope.selection = [] scope.visible = false } diff --git a/web/public/templates/channel-config.html b/web/public/templates/channel-config.html index 97dcddb..081300d 100644 --- a/web/public/templates/channel-config.html +++ b/web/public/templates/channel-config.html @@ -170,6 +170,7 @@ ng-init="setUpWatcher()" ng-if="true" ng-style="{'max-height':programmingHeight()}" + id="channelConfigProgramList" >