mirror of
https://github.com/UiO-Gaming/infoscreen3.git
synced 2026-11-05 13:56:52 +01:00
update dependencies, move to use es6 modules imports, bind /data/video to /video for easier video displaying
This commit is contained in:
1 parent
88dbbaa567
commit
04af03891b
28 files changed
+3499
-1639
No files matched your search
+20
-26
@@ -1,7 +1,6 @@
|
||||
let fs = require("fs");
|
||||
let config = require(`../config.js`);
|
||||
let cli = require(`./cli.js`);
|
||||
|
||||
import fs from 'fs';
|
||||
import config from '../config.js';
|
||||
import cli from './cli.js';
|
||||
|
||||
/** Generate an uuid
|
||||
* @url https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript#2117523 **/
|
||||
@@ -15,7 +14,7 @@ function uuidv4() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class admin {
|
||||
export default class admin {
|
||||
|
||||
/**
|
||||
* @param sharedIO
|
||||
@@ -225,11 +224,11 @@ class admin {
|
||||
self.screenView.overrideSlide(data.json, null, data.duration, data.transition);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
socket.on('admin.overrideVideo', function (data) {
|
||||
if (data.displayId === null) {
|
||||
if (data.displayId === null) {
|
||||
dispatcher.emit("all.override", data);
|
||||
} else {
|
||||
} else {
|
||||
self.screenView.overrideSlide(data.json, null, data.json.duration, null);
|
||||
}
|
||||
});
|
||||
@@ -315,8 +314,8 @@ class admin {
|
||||
}
|
||||
socket.emit("callback.webpage", {bundleData: bundleData, json: json});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
socket.on('edit.saveLink', function (data) {
|
||||
|
||||
let filename = data.filename;
|
||||
@@ -379,16 +378,16 @@ class admin {
|
||||
}
|
||||
socket.emit("callback.video", {bundleData: bundleData, json: json});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
socket.on('edit.saveVideo', function (data) {
|
||||
|
||||
let filename = data.filename;
|
||||
if (filename === "") {
|
||||
filename = uuidv4();
|
||||
}
|
||||
|
||||
if (data.duration === "") {
|
||||
|
||||
if (data.duration === "") {
|
||||
socket.emit("callback.saveVideo", {erro: "Video duration is not known. Remember to load metadata!"});
|
||||
return;
|
||||
}
|
||||
@@ -398,8 +397,8 @@ class admin {
|
||||
|
||||
let template = {
|
||||
uuid: filename,
|
||||
name: data.name,
|
||||
duration: data.duration,
|
||||
name: data.name,
|
||||
duration: data.duration,
|
||||
enabled: true,
|
||||
displayTime: data.displayTime,
|
||||
type: "video",
|
||||
@@ -415,8 +414,8 @@ class admin {
|
||||
bundle.allSlides.push(template);
|
||||
} else {
|
||||
obj.url = data.url;
|
||||
obj.name = data.name;
|
||||
obj.duration = data.duration;
|
||||
obj.name = data.name;
|
||||
obj.duration = data.duration;
|
||||
obj.displayTime = data.displayTime;
|
||||
obj.mute = data.mute;
|
||||
obj.loop = data.loop;
|
||||
@@ -476,11 +475,11 @@ class admin {
|
||||
});
|
||||
|
||||
socket.on('edit.saveTemplate', function (data) {
|
||||
let templates = {};
|
||||
|
||||
let templates = {};
|
||||
|
||||
if (fs.existsSync("./data/template.json")) {
|
||||
templates = JSON.parse(fs.readFileSync("./data/template.json").toString());
|
||||
}
|
||||
}
|
||||
templates[data.name] = data.json;
|
||||
try {
|
||||
fs.writeFileSync("./data/template.json", JSON.stringify(templates));
|
||||
@@ -683,8 +682,3 @@ class admin {
|
||||
|
||||
// admin
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {admin}
|
||||
*/
|
||||
module.exports = admin;
|
||||
+7
-11
@@ -1,6 +1,6 @@
|
||||
let cli = require(`./cli.js`);
|
||||
import cli from './cli.js'
|
||||
|
||||
class adminLobby {
|
||||
export default class adminLobby {
|
||||
|
||||
/**
|
||||
* @param sharedIO
|
||||
@@ -66,11 +66,11 @@ class adminLobby {
|
||||
cli.error("error while duplicating slide", err);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
socket.on('admin.moveSlide', function (data) {
|
||||
try {
|
||||
let bundle = bundleManager.moveSlide(data.from, data.to, data.uuid, data.position);
|
||||
socket.emit("callback.updateBundleData");
|
||||
try {
|
||||
let bundle = bundleManager.moveSlide(data.from, data.to, data.uuid, data.position);
|
||||
socket.emit("callback.updateBundleData");
|
||||
updateSlides(data.from, bundle);
|
||||
} catch (err) {
|
||||
cli.error("error while moving slide", err);
|
||||
@@ -83,7 +83,7 @@ class adminLobby {
|
||||
let bundle = bundleManager.getBundle(data.bundleName);
|
||||
bundle.setName(data.uuid, data.name);
|
||||
updateSlides(data.bundleName, bundle);
|
||||
socket.emit("callback.updateBundleData");
|
||||
socket.emit("callback.updateBundleData");
|
||||
} catch (err) {
|
||||
cli.error("error while renaming slide", err);
|
||||
}
|
||||
@@ -144,7 +144,3 @@ class adminLobby {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = adminLobby;
|
||||
|
||||
|
||||
+5
-11
@@ -1,10 +1,10 @@
|
||||
let cli = require("./cli.js");
|
||||
let fs = require("fs");
|
||||
import fs from 'fs';
|
||||
import cli from './cli.js';
|
||||
|
||||
/**
|
||||
* @module infoscreen3/bundle
|
||||
*/
|
||||
class bundleClass {
|
||||
export default class bundleClass {
|
||||
|
||||
constructor(name, data, slides) {
|
||||
this.name = name;
|
||||
@@ -85,11 +85,11 @@ class bundleClass {
|
||||
if (fs.existsSync(path + "/slides/" + uuid)) {
|
||||
fs.renameSync(path + "/slides/" + uuid, toPath + "/slides/" + uuid);
|
||||
}
|
||||
let slideData = clone(slide);
|
||||
let slideData = clone(slide);
|
||||
this.removeUuid(uuid);
|
||||
return slideData;
|
||||
} catch (err) {
|
||||
cli.error("error while moving file:" + uuid, err);
|
||||
cli.error("error while moving file:" + uuid, err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -231,9 +231,3 @@ function uuidv4() {
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {bundleClass}
|
||||
*/
|
||||
module.exports = bundleClass;
|
||||
@@ -1,11 +1,11 @@
|
||||
const bundle = require(`./bundle.js`);
|
||||
let fs = require("fs");
|
||||
let cli = require(`./cli.js`);
|
||||
import fs from 'fs';
|
||||
import cli from './cli.js';
|
||||
import bundle from './bundle.js';
|
||||
|
||||
/**
|
||||
* @module infoscreen3/bundleManager
|
||||
*/
|
||||
class bundleManager {
|
||||
export default class bundleManager {
|
||||
|
||||
constructor() {
|
||||
this.syncBundles();
|
||||
@@ -49,15 +49,15 @@ class bundleManager {
|
||||
}
|
||||
}
|
||||
|
||||
moveSlide(fromBundle, toBundle, uuid, position) {
|
||||
let slideData = this.getBundle(fromBundle).moveTo(toBundle, uuid);
|
||||
moveSlide(fromBundle, toBundle, uuid, position) {
|
||||
let slideData = this.getBundle(fromBundle).moveTo(toBundle, uuid);
|
||||
let bundle = this.getBundle(toBundle);
|
||||
slideData.index = position;
|
||||
if (slideData) {
|
||||
bundle.allSlides.push(slideData);
|
||||
bundle.save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
reorderSlides(bundleName, sortedIDs) {
|
||||
@@ -105,8 +105,3 @@ function getDirectories(path) {
|
||||
function getJson(file) {
|
||||
return JSON.parse(fs.readFileSync(file).toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {bundleManager}
|
||||
*/
|
||||
module.exports = bundleManager;
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
let chalk = require('chalk');
|
||||
import chalk from 'chalk';
|
||||
let lastStamp = "";
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
error: function (error, title) {
|
||||
if (title == null) {
|
||||
title = "";
|
||||
|
||||
+4
-2
@@ -1,6 +1,8 @@
|
||||
const records = require(`../config.js`).admins;
|
||||
import config from '../config.js'
|
||||
|
||||
module.exports = {
|
||||
const records = config.admins;
|
||||
|
||||
export default {
|
||||
|
||||
findById: function (id, cb) {
|
||||
process.nextTick(function () {
|
||||
|
||||
+3
-8
@@ -1,11 +1,10 @@
|
||||
'use strict'
|
||||
let fs = require("fs");
|
||||
let cli = require(`./cli.js`);
|
||||
import fs from 'fs';
|
||||
import cli from './cli.js';
|
||||
|
||||
/**
|
||||
* handles one display instance
|
||||
*/
|
||||
class display {
|
||||
export default class display {
|
||||
|
||||
/**
|
||||
* @param {object} sharedIO - socketIO
|
||||
@@ -273,7 +272,3 @@ class display {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {display}
|
||||
*/
|
||||
module.exports = display;
|
||||
+18
-20
@@ -1,6 +1,6 @@
|
||||
let express = require('express');
|
||||
let Twig = require('twig');
|
||||
let fs = require('fs');
|
||||
import express from 'express';
|
||||
import Twig from 'twig';
|
||||
import fs from 'fs';
|
||||
|
||||
/**
|
||||
* Base plugin class
|
||||
@@ -8,11 +8,11 @@ let fs = require('fs');
|
||||
* Strucure of plugin:
|
||||
* D /public/ -- serves files statically at http path: /data/pluginName/
|
||||
* D /views/ -- directory for twig templates
|
||||
* F /plugin.js -- pluginfile which will be loaded
|
||||
*
|
||||
* F /plugin.js -- pluginfile which will be loaded
|
||||
*
|
||||
* if you need external libs, just add `package.json` to the plugin dir, and call npm install :)
|
||||
*/
|
||||
class plugin {
|
||||
export default class plugin {
|
||||
|
||||
constructor(pluginName, app, io, dispatcher) {
|
||||
this.pluginName = pluginName;
|
||||
@@ -35,33 +35,33 @@ class plugin {
|
||||
return Twig.twig({ data: fs.readFileSync("plugins/" + this.pluginName + "/views/" + template + ".twig").toString() }).render(data);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called at infoscreen init-phase
|
||||
*
|
||||
* the example will render a view from `pluginName/Views/test.twig` to route `/admin/test`
|
||||
* @example
|
||||
*
|
||||
* the example will render a view from `pluginName/Views/test.twig` to route `/admin/test`
|
||||
* @example
|
||||
* let self = this;
|
||||
* router.get("/test", function (req, res, next) {
|
||||
* res.send(self.renderPluginView("test", { test: "hello!" }));
|
||||
* // res.render(); will render from infoscreen/views/*.twig
|
||||
* });
|
||||
* @param {express.Router} router
|
||||
* });
|
||||
* @param {express.Router} router
|
||||
*/
|
||||
onAdminRouter(router) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called at infoscreen init-phase
|
||||
*
|
||||
*
|
||||
* the example will render a view from `pluginName/Views/test.twig` to route `/test`
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* router.get("/test", function (req, res) {
|
||||
* res.render("test", { test: "hello!" });
|
||||
* });
|
||||
*
|
||||
* @param {express.Router} router
|
||||
*
|
||||
* @param {express.Router} router
|
||||
*/
|
||||
onPluginRouter(router) {
|
||||
|
||||
@@ -72,12 +72,10 @@ class plugin {
|
||||
}
|
||||
/**
|
||||
* Inserts html to display views
|
||||
*
|
||||
*
|
||||
* @returns {string} HTML to be added to display View
|
||||
*/
|
||||
setDisplayViewAdditions() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = plugin;
|
||||
+13
-11
@@ -1,17 +1,22 @@
|
||||
let fs = require("fs");
|
||||
let cli = require(`./cli.js`);
|
||||
let config = require(`../config.js`);
|
||||
import fs from 'fs';
|
||||
import cli from './cli.js'
|
||||
import config from '../config.js';
|
||||
|
||||
class pluginManager {
|
||||
export default class pluginManager {
|
||||
|
||||
constructor(app, io, eventDispatcher) {
|
||||
this.plugins = {};
|
||||
this.dispatcher = eventDispatcher;
|
||||
cli.info("Initializing plugins...");
|
||||
for (let pluginName of config.plugins) {
|
||||
this.load(app, io, eventDispatcher);
|
||||
}
|
||||
|
||||
async load(app, io, eventDispatcher) {
|
||||
for (const pluginName of config.plugins) {
|
||||
try {
|
||||
let pluginclass = require("../plugins/" + pluginName + "/plugin.js").default;
|
||||
let pluginInstance = new pluginclass(pluginName, app, io, eventDispatcher);
|
||||
const pluginclass = await import("../plugins/" + pluginName + "/plugin.js");
|
||||
const plugin = pluginclass.default;
|
||||
let pluginInstance = new plugin(pluginName, app, io, eventDispatcher);
|
||||
cli.info("" + pluginName, 'plugin');
|
||||
this.plugins[pluginName] = pluginInstance;
|
||||
} catch (err) {
|
||||
@@ -19,7 +24,6 @@ class pluginManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callMethod(method, params) {
|
||||
this.dispatcher.emit("plugin." + method, params);
|
||||
}
|
||||
@@ -32,6 +36,4 @@ class pluginManager {
|
||||
return additions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = pluginManager;
|
||||
}
|
||||
+10
-12
@@ -1,14 +1,12 @@
|
||||
let config = require(`../config.js`);
|
||||
import config from '../config.js';
|
||||
let availableDisplays = config.displays;
|
||||
let display = require(`./display.js`);
|
||||
let admin = require(`./admin.js`);
|
||||
let adminLobby = require(`./adminLobby.js`);
|
||||
let cli = require(`./cli.js`);
|
||||
let _bundleManager = require(`./bundleManager.js`);
|
||||
let chalk = require('chalk');
|
||||
let fs = require('fs');
|
||||
|
||||
|
||||
import display from './display.js';
|
||||
import admin from './admin.js';
|
||||
import adminLobby from './adminLobby.js';
|
||||
import cli from './cli.js';
|
||||
import _bundleManager from './bundleManager.js';
|
||||
import chalk from 'chalk';
|
||||
import fs from 'fs';
|
||||
|
||||
/**
|
||||
* @param server
|
||||
@@ -17,7 +15,7 @@ let fs = require('fs');
|
||||
* @param dispatcher
|
||||
* @return {{screenView: display[], adminView: admin[], bundleManager: bundleManager}}
|
||||
*/
|
||||
module.exports = function (pluginManager, io, dispatcher) {
|
||||
export default function (pluginManager, io, dispatcher) {
|
||||
/**
|
||||
* @type {display[]}
|
||||
*/
|
||||
@@ -36,7 +34,7 @@ module.exports = function (pluginManager, io, dispatcher) {
|
||||
cli.error("data directory (./data) is not writable", err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
fs.accessSync("./tmp", fs.W_OK);
|
||||
cli.success("temp directory (./tmp) is writable ");
|
||||
|
||||
Reference in new issue
Block a user