Continued work on media schedule panel.

This commit is contained in:
rainbow napkin 2025-02-02 18:49:20 -05:00
parent d5a2a51be2
commit 90be85de26
6 changed files with 475 additions and 103 deletions

View file

@ -14,6 +14,9 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
//NPM imports
const validator = require('validator');
//Local imports
const queuedMedia = require('./queuedMedia');
const yanker = require('../../../utils/media/yanker');
@ -51,8 +54,37 @@ module.exports = class{
async queueURL(socket, data){
try{
//Set url
const url = encodeURI(data.url);
//pull URL and start time from data
let {url, start, title} = data;
//let {url, start, title} = data;
//If we where given a bad URL
if(!validator.isURL(url)){
//Bitch, moan, complain...
loggerUtils.socketErrorHandler(socket, "Bad URL!", "validation");
//and ignore it!
return;
}
//If the title is too long
if(!validator.isLength(data.title, {max:30})){
//Bitch, moan, complain...
loggerUtils.socketErrorHandler(socket, "Title too long!", "validation");
//and ignore it!
return;
}
//Set title
const title = validator.escape(validator.trim(data.title));
//set start
var start = data.start;
//If start time isn't an integer after the current epoch
if(start != null &&!validator.isInt(String(start), (new Date().getTime()))){
//Null out time to tell the later parts of the function to start it now
start = null;
}
//Pull media list
const mediaList = await yanker.yankMedia(url, title);
@ -86,6 +118,14 @@ module.exports = class{
deleteMedia(socket, data){
try{
//If we don't have a valid UUID
if(!validator.isUUID(data.uuid)){
//Bitch, moan, complain...
loggerUtils.socketErrorHandler(socket, "Bad UUID!", "validation");
//and ignore it!
return;
}
//Remove media by UUID
this.removeMedia(data.uuid, socket);
}catch(err){
@ -95,6 +135,20 @@ module.exports = class{
moveMedia(socket, data){
try{
//If we don't have a valid UUID
if(!validator.isUUID(data.uuid)){
//Bitch, moan, complain...
loggerUtils.socketErrorHandler(socket, "Bad UUID!", "validation");
//and ignore it!
return;
}
//If start time isn't an integer after the current epoch
if(data.start != null && !validator.isInt(String(data.start), new Date().getTime())){
//Null out time to tell the later parts of the function to start it now
data.start = null;
}
//Move media by UUID
this.rescheduleMedia(data.uuid, data.start, socket);
}catch(err){

View file

@ -19,11 +19,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. %>
<div id="queue-control-buttons">
<button id="queue-add-media"><i class="bi-plus-lg"></i></button>
<button id="queue-search-media"><i class="bi-search"></i></button>
<button id="queue-scroll-lock" class="positive-button"><i class="bi-clock-fill"></i><i class="bi-arrows-expand"></i></button>
<button id="queue-date"><i class="bi-calendar-fill"></i></button>
<button id="queue-playlists"><i class="bi-list"></i></button>
<button id="queue-scroll-lock" class="positive-button"><i class="bi-clock-fill"></i></button>
<button id="queue-export-clear"><i class="bi-trash-fill"></i></button>
<button id="queue-export-date"><i class="bi-calendar-fill"></i></button>
<button id="queue-export-lock" class="positive-button"><i class="bi-unlock-fill"></i></button>
<button id="queue-clear" class="danger-button"><i class="bi-trash-fill"></i></button>
<button id="queue-lock" class="positive-button"><i class="bi-unlock-fill"></i></button>
</div>
<div id="queue-control-date" style="display: none">
<i class="bi-caret-left" id="queue-control-date-decrement"></i>
<input id="queue-control-date-prompt" type="date">
<i class="bi-caret-right" id="queue-control-date-increment"></i>
</div>
<div id="queue-media-prompts" style="display: none;">
<div class="panel-control-prompt control-prompt">