Fix Pad Time bug. To improve on channel loading times in the UI, channel editor will only show 100 programs at once, but there's a slider to see more.

This commit is contained in:
vexorian 2020-08-04 22:43:15 -04:00
parent 0e1d2e4bb1
commit e1d79490a5
2 changed files with 61 additions and 11 deletions

View File

@ -13,6 +13,7 @@ module.exports = function ($timeout, $location) {
scope._frequencyModified = false;
scope._frequencyMessage = "";
scope.millisecondsOffset = 0;
scope.minProgramIndex = 0;
if (typeof scope.channel === 'undefined' || scope.channel == null) {
scope.channel = {}
scope.channel.programs = []
@ -97,6 +98,17 @@ module.exports = function ($timeout, $location) {
scope._selectedProgram = null
updateChannelDuration()
}
scope.dropFunction = (dropIndex, index, program) => {
if (scope.channel.programs[index].start == program.start) {
return false;
}
setTimeout( () => {
scope.channel.programs.splice(dropIndex + index, 0, program);
updateChannelDuration()
}, 1);
return true;
}
scope.updateChannelFromOfflineResult = (program) => {
scope.channel.offlineMode = program.channelOfflineMode;
scope.channel.offlinePicture = program.channelPicture;
@ -170,6 +182,9 @@ module.exports = function ($timeout, $location) {
scope.channel.programs = newProgs.concat(movies)
updateChannelDuration()
}
scope.dateForGuide = (date) => {
return date.toLocaleString();
}
scope.sortByDate = () => {
scope.removeOffline();
scope.channel.programs.sort( (a,b) => {
@ -474,7 +489,7 @@ module.exports = function ($timeout, $location) {
scope.wipeSchedule = () => {
wipeSchedule(scope.channel.programs);
scope.channel.programs = [];
updateChannelDuration();
}
scope.makeOfflineFromChannel = (duration) => {
@ -520,10 +535,6 @@ module.exports = function ($timeout, $location) {
}
return array
}
function wipeSchedule(array) {
array.splice(0, array.length)
return array;
}
function equalizeShows(array, freqObject) {
let shows = {};
let progs = [];
@ -702,6 +713,7 @@ module.exports = function ($timeout, $location) {
updateChannelDuration()
}
scope.paddingOptions = [
{ id: -1, description: "Allowed start times", allow5: false },
{ id: 30, description: ":00, :30", allow5: false },
{ id: 15, description: ":00, :15, :30, :45", allow5: false },
{ id: 60, description: ":00", allow5: false },
@ -712,6 +724,7 @@ module.exports = function ($timeout, $location) {
{ id: 30, description: ":00, :05, :30, :35", allow5: true },
]
scope.paddingOption = scope.paddingOptions[0];
scope.breakAfterOptions = [
{ id: -1, description: "After" },
{ id: 5, description: "5 minutes" },

View File

@ -216,7 +216,7 @@
ng-options="o as o.description for o in paddingOptions" />
</div>
<button ng-disabled="typeof(paddingOption)===&quot;undefined&quot;" class="btn btn-sm btn-warning form-control form-control-sm" type="button" ng-click="padTimes(paddingOption.id, paddingOption.allow5)">Pad Times</button>
<button ng-disabled="paddingOption.id==-1" class="btn btn-sm btn-warning form-control form-control-sm" type="button" ng-click="padTimes(paddingOption.id, paddingOption.allow5)">Pad Times</button>
</div>
</div>
@ -248,11 +248,27 @@
</h6>
</div>
<div class="list-group list-group-root" dnd-list="channel.programs">
<li class="list-group-item flex-container" ng-repeat="x in channel.programs" ng-click="selectProgram($index)" dnd-draggable="x" dnd-moved="channel.programs.splice($index, 1); updateChannelDuration()" dnd-effect-allowed="move">
<div class="list-group list-group-root">
<div ng-show="channel.programs.length &gt; 100">
<div>Showing programs {{minProgramIndex+1}} to {{minProgramIndex+100}}</div>
</div>
<input ng-show="channel.programs.length &gt; 100" type="range" ng-model="minProgramIndex" min="0" max="{{ channel.programs.length - 100 }}" />
<div ng-if="minProgramIndex &gt; 0" class="list-group-item flex-container" >
<div class="small" style="width: 180px; margin-right: 5px;">
<div class="text-success">{{x.start.toLocaleString()}}</div>
<div class="text-danger">{{x.stop.toLocaleString()}}</div>
<div class="text-success">{{ dateForGuide(channel.startTime) }}</div>
<div class="text-danger">{{ dateForGuide(channel.programs[minProgramIndex-1].stop)}}</div>
</div>
<div style="margin-right: 5px; font-weight:ligther; text-align:center">
&#8942;
</div>
</div>
<div ng-if="minProgramIndex &lt;= $index &amp;&amp; $index &lt; minProgramIndex+100" ng-repeat="x in channel.programs" ng-click="selectProgram($index)" dnd-list="" dnd-drop="dropFunction(index , $index, item)"
>
<div class="list-group-item flex-container" dnd-draggable="x" dnd-moved="channel.programs.splice($index, 1);" dnd-effect-allowed="move" >
<div class="small" style="width: 180px; margin-right: 5px;">
<div class="text-success">{{ dateForGuide(x.start) }}</div>
<div class="text-danger">{{ dateForGuide(x.stop) }}</div>
</div>
<div style="margin-right: 15px; text-align: center" >
<span class="badge badge-dark">{{x.isOffline? channel.fillerContent.length: x.commercials.length}}</span>
@ -264,7 +280,28 @@
<i>Flex</i>
</div>
<span class="flex-pull-right btn fa fa-trash" ng-click="removeItem($index); $event.stopPropagation()"></span>
</li>
</div>
</div>
<div ng-if="minProgramIndex &lt; channel.programs.length - 100" class="list-group-item flex-container" >
<div class="small" style="width: 180px; margin-right: 5px;">
<div class="text-success">{{ dateForGuide(channel.programs[minProgramIndex + 100 - 1].stop)}}</div>
<div class="text-danger">{{ dateForGuide(channel.programs[channel.programs.length-1].stop) }}</div>
</div>
<div style="margin-right: 5px; font-weight:ligther; text-align:center">
&#8942;
</div>
</div>
<div class="list-group-item flex-container" >
<div class="small" style="width: 180px; margin-right: 5px;">
<div class="text-success">{{ dateForGuide(channel.programs[channel.programs.length-1].stop)}}</div>
</div>
<div style="margin-right: 5px; font-weight:ligther; text-align:center">
<i>(Restart programming from beginning)</i>
</div>
</div>
</div>
</div>
</div>