Updated scheduler to display schedule archives upon request.
This commit is contained in:
parent
baf8255b2c
commit
50b1e15a6c
3 changed files with 61 additions and 1 deletions
|
|
@ -533,6 +533,14 @@ class queue{
|
|||
//Yeetus-Deletus bitch
|
||||
return;
|
||||
}
|
||||
|
||||
//If our startDate isn't before our endDate
|
||||
if(data.startDate >= data.endDate){
|
||||
//Bitch, moan, an' complain!
|
||||
loggerUtils.socketErrorHandler(socket, "Invalid Date Range!", "validation");
|
||||
//Yeetus-Deletus bitch
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the current channel from the database
|
||||
const chanDB = await channelModel.findOne({name: socket.chan});
|
||||
|
|
|
|||
|
|
@ -126,6 +126,10 @@ class channel{
|
|||
this.queueBroadcastSocket.on("queue", (data) => {
|
||||
this.queue = new Map(data.queue);
|
||||
});
|
||||
|
||||
this.socket.on("archive", (data) =>{
|
||||
this.sortQueue(data.archive);
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -157,6 +161,39 @@ class channel{
|
|||
this.streamType = data.streamType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts queue, optionally adding new items along the way
|
||||
* @param {object} queueData - Contains list of entries to add to the queue
|
||||
*/
|
||||
sortQueue(queueData){
|
||||
//Create array to temporary sort schedule within
|
||||
const tempSched = [];
|
||||
//Get current queue as entries
|
||||
let entries = Array.from(this.queue.entries());
|
||||
|
||||
//Blow-out existing queue since we've already pulled out the data we need from it
|
||||
this.queue = new Map();
|
||||
|
||||
|
||||
//If we have new queue data
|
||||
if(queueData != null){
|
||||
//Concat passed queue data to beggining of entries pulled from queue map
|
||||
entries = queueData.concat(entries);
|
||||
}
|
||||
|
||||
//For each media entry accounted for
|
||||
for(let entry of entries){
|
||||
//Store entry item in array indexed to its start epoch in seconds
|
||||
tempSched[Math.round(entry[0] / 1000)] = entry[1];
|
||||
}
|
||||
|
||||
//Iterate through populated indices of tempSched to skip over empty indexes, just like in the server-side
|
||||
for(let startTime of Object.keys(tempSched)){
|
||||
//Add each entry to the queue in order of start time
|
||||
this.queue.set(tempSched[startTime].startTime, tempSched[startTime]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and applies default config on any unset settings
|
||||
* @param {Boolean} force - Whether or not to forcefully reset already set settings
|
||||
|
|
|
|||
|
|
@ -142,7 +142,8 @@ class queuePanel extends panelObj{
|
|||
defineListeners(){
|
||||
//Render queue when we receive a new copy of the queue data from the server
|
||||
//Render queue should be called within an arrow function so that it's called with default parameters, and not handed an event as a date
|
||||
this.client.queueBroadcastSocket.on("queue", () => {this.renderQueue();});
|
||||
this.client.queueBroadcastSocket.on("queue", this.renderQueue.bind(this));
|
||||
this.client.socket.on("archive", this.renderQueue.bind(this));
|
||||
this.client.socket.on("start", this.handleStart.bind(this));
|
||||
this.client.socket.on("end", this.handleEnd.bind(this));
|
||||
this.client.socket.on("lock", this.handleScheduleLock.bind(this));
|
||||
|
|
@ -491,6 +492,20 @@ class queuePanel extends panelObj{
|
|||
//Re-render/hide the time marker
|
||||
this.renderTimeMarker();
|
||||
|
||||
//If we're not looking at today
|
||||
if(!utils.isSameDate(date, new Date())){
|
||||
//Clone given epoch twice
|
||||
const dayBefore = new Date(date.getTime());
|
||||
const dayAfter = new Date(date.getTime());
|
||||
|
||||
//Make it a day before/after
|
||||
dayBefore.setDate(dayBefore.getDate() - 1);
|
||||
dayAfter.setDate(dayAfter.getDate() + 1);
|
||||
|
||||
//Request the archives from that day
|
||||
this.client.socket.emit("getArchive", {startDate: dayBefore.getTime(), endDate: dayAfter.getTime()});
|
||||
}
|
||||
|
||||
//If autoscroll is enabled
|
||||
if(this.autoscroll){
|
||||
//Simulate a button click to un/re-light the button and trigger a scroll when the date is set to today
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue