mirror of
https://github.com/UiO-Gaming/infoscreen3.git
synced 2026-11-06 14:24:31 +01:00
fixes #7 - background upload
This commit is contained in:
1 parent
36f2c71565
commit
ea7fe05bf2
7 files changed
+93
-59
No files matched your search
@@ -24,7 +24,7 @@ let passport = require('passport');
|
||||
let LocalStrategy = require('passport-local').Strategy;
|
||||
let User = require("./modules/db.js");
|
||||
|
||||
passport.use(new LocalStrategy(
|
||||
passport.use("local", new LocalStrategy(
|
||||
{
|
||||
|
||||
},
|
||||
@@ -36,7 +36,7 @@ passport.use(new LocalStrategy(
|
||||
if (!user) {
|
||||
return cb(null, false);
|
||||
}
|
||||
if (user.password != password) {
|
||||
if (user.password !== password) {
|
||||
return cb(null, false);
|
||||
}
|
||||
return cb(null, user);
|
||||
@@ -124,8 +124,8 @@ app.use(require('express-session')({ secret: config.sessionKey, resave: false, s
|
||||
|
||||
// Initialize Passport and restore authentication state, if any, from the
|
||||
// session.
|
||||
app.use(passport.initialize());
|
||||
app.use(passport.session());
|
||||
app.use(passport.initialize({}));
|
||||
app.use(passport.session({}));
|
||||
|
||||
let websocket = require("./modules/websocket")(server, app, io, eventDispatcher);
|
||||
let indexRouter = require('./routes/index.js')(websocket, eventDispatcher);
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
"editBundle": "Edit bundle",
|
||||
"msg1": "Most of the changes are applied for live environment at next slide change.",
|
||||
"name": "Bundle name",
|
||||
"backgroundfile": "Select a file",
|
||||
"msgupload": "You can upload a new background (.jpg or .mp4) here.",
|
||||
"background": "Background",
|
||||
"transition": "Default transition (applied on restart)",
|
||||
"time": "Display time",
|
||||
@@ -66,7 +68,7 @@
|
||||
"fontName": "Font Name",
|
||||
"fontSize": "Size",
|
||||
"fontColor": "Color",
|
||||
"fontBorder": "Border Color"
|
||||
"fontBorder": "Border Color",
|
||||
},
|
||||
"editSlide": {
|
||||
"changeColor": "Change Color",
|
||||
@@ -92,4 +94,4 @@
|
||||
"lite": "Lite",
|
||||
"splitter": "or"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,8 @@
|
||||
"name": "Nimi",
|
||||
"background": "Tausta",
|
||||
"transition": "Oletussiirtymä",
|
||||
"backgroundfile": "Valitse tiedosto",
|
||||
"msgupload": "Voit ladata uuden taustakuvan (.jpg or .mp4) alta.",
|
||||
"time": "Näytä aika",
|
||||
"duration": "Oletusarvo dian pituudelle",
|
||||
"msg2title": "Huomio Web-fonteille",
|
||||
@@ -92,4 +94,4 @@
|
||||
"lite": "Kevyt",
|
||||
"splitter": "tai"
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -37,6 +37,8 @@ class display {
|
||||
* @property {boolean} blackout - should the blackout be enabled
|
||||
* @property {boolean} isStreaming - is media server stream enabled at client
|
||||
* @property {string} streamSource - URL for FLV media stream
|
||||
* @property {bool} isAnnounce - if the next slide is announce one
|
||||
* @property {bool} announceMeta - all data needed for announces
|
||||
* @property {string} transition values supported: bars,blinds,blinds3d,zip,blocks,blocks2,concentric,warp,cube,tiles3d,tiles3dprev,slide,swipe,dissolve
|
||||
*/
|
||||
this.serverOptions = {
|
||||
@@ -52,6 +54,7 @@ class display {
|
||||
isStreaming: false,
|
||||
streamSource: "",
|
||||
isAnnounce: false,
|
||||
announceMeta: {},
|
||||
transition: "tiles3d",
|
||||
displayTime: true
|
||||
};
|
||||
@@ -254,4 +257,4 @@ class display {
|
||||
/**
|
||||
* @type {display}
|
||||
*/
|
||||
module.exports = display;
|
||||
module.exports = display;
|
||||
+66
-43
@@ -56,51 +56,74 @@ module.exports = function (websocket, dispatcher) {
|
||||
});
|
||||
|
||||
router.post('/edit/bundleProperties', function (req, res, next) {
|
||||
let bundleData = {};
|
||||
let bundleData = {};
|
||||
let fields = {};
|
||||
|
||||
var transition = null;
|
||||
if (req.body.transition !== "") {
|
||||
transition = req.body.transition;
|
||||
req.busboy.on('field', function (fieldname, val) {
|
||||
fields[fieldname] = val;
|
||||
});
|
||||
|
||||
req.busboy.on('file', function (fieldname, file, filename, encoding, mimeType) {
|
||||
if (fieldname === "newBackground")
|
||||
if (filename.length > 0 && (mimeType === "image/jpeg" || mimeType === "video/mp4" || mimeType === "image/png")) {
|
||||
console.log(filename)
|
||||
let fstream = fs.createWriteStream('./data/backgrounds/' + filename);
|
||||
file.pipe(fstream);
|
||||
} else {
|
||||
file.resume();
|
||||
}
|
||||
});
|
||||
|
||||
req.busboy.on('finish', function () {
|
||||
|
||||
if (fields.hasOwnProperty("sUpload")) {
|
||||
res.redirect("/admin/edit/bundleProperties?bundle=" + fields.bundle);
|
||||
} else {
|
||||
var transition = null;
|
||||
if (fields.transition !== "") {
|
||||
transition = fields.transition;
|
||||
}
|
||||
|
||||
var useWebFonts = false;
|
||||
if (fields.hasOwnProperty('useWebFonts')) {
|
||||
useWebFonts = true;
|
||||
}
|
||||
|
||||
var displayTime = false;
|
||||
if (fields.hasOwnProperty('displayTime')) {
|
||||
displayTime = true;
|
||||
}
|
||||
|
||||
try {
|
||||
let bundle = bundleManager.getBundle(fields.bundle);
|
||||
bundleData = bundle.getBundleData();
|
||||
bundleData.displayName = fields.displayName;
|
||||
bundleData.background = fields.background;
|
||||
bundleData.duration = parseInt(fields.duration);
|
||||
bundleData.transition = transition;
|
||||
bundleData.useWebFonts = useWebFonts;
|
||||
bundleData.displayTime = displayTime;
|
||||
bundleData.styleHeader.fontFamily = fields.headerFontFamily;
|
||||
bundleData.styleHeader.fontSize = parseInt(fields.headerFontSize);
|
||||
bundleData.styleHeader.fill = fields.headerFill;
|
||||
bundleData.styleHeader.stroke = fields.headerStroke;
|
||||
bundleData.styleText.fontFamily = fields.textFontFamily;
|
||||
bundleData.styleText.fontSize = parseInt(fields.textFontSize);
|
||||
bundleData.styleText.fill = fields.textFill;
|
||||
bundleData.styleText.stroke = fields.textStroke;
|
||||
bundle.setBundleData(bundleData);
|
||||
bundle.save();
|
||||
|
||||
} catch (err) {
|
||||
cli.error("error loading bundle", err);
|
||||
}
|
||||
|
||||
dispatcher.emit("updateBundles");
|
||||
res.send("<!doctype HTML><html><head><script>window.close();</script></head><body></body></html>");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var useWebFonts = false;
|
||||
if (req.body.useWebFonts) {
|
||||
useWebFonts = true;
|
||||
}
|
||||
|
||||
var displayTime = false;
|
||||
if (req.body.displayTime) {
|
||||
displayTime = true;
|
||||
}
|
||||
|
||||
try {
|
||||
let bundle = bundleManager.getBundle(req.body.bundle);
|
||||
bundleData = bundle.getBundleData();
|
||||
bundleData.displayName = req.body.displayName;
|
||||
bundleData.background = req.body.background;
|
||||
bundleData.duration = parseInt(req.body.duration);
|
||||
bundleData.transition = transition;
|
||||
bundleData.useWebFonts = useWebFonts;
|
||||
bundleData.displayTime = displayTime;
|
||||
bundleData.styleHeader.fontFamily = req.body.headerFontFamily;
|
||||
bundleData.styleHeader.fontSize = parseInt(req.body.headerFontSize);
|
||||
bundleData.styleHeader.fill = req.body.headerFill;
|
||||
bundleData.styleHeader.stroke = req.body.headerStroke;
|
||||
bundleData.styleText.fontFamily = req.body.textFontFamily;
|
||||
bundleData.styleText.fontSize = parseInt(req.body.textFontSize);
|
||||
bundleData.styleText.fill = req.body.textFill;
|
||||
bundleData.styleText.stroke = req.body.textStroke;
|
||||
bundle.setBundleData(bundleData);
|
||||
bundle.save();
|
||||
|
||||
} catch (err) {
|
||||
cli.error("error loading bundle", err);
|
||||
|
||||
}
|
||||
|
||||
dispatcher.emit("updateBundles");
|
||||
res.send("<!doctype HTML><html><head><script>window.close();</script></head><body></body></html>");
|
||||
});
|
||||
);
|
||||
|
||||
router.get('/edit/bundleProperties', function (req, res, next) {
|
||||
let bundle = req.query['bundle'];
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
<p>{{ t("admin.editBundleProperties.msg1") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<form action="/admin/edit/bundleProperties" method="post" class="ui form">
|
||||
<input name="bundle" value="{{ bundle }}" hidden/>
|
||||
<form action="/admin/edit/bundleProperties" method="post" enctype="multipart/form-data" class="ui form">
|
||||
<input type="text" name="bundle" value="{{ bundle }}" hidden/>
|
||||
|
||||
<div class="field">
|
||||
<label>{{ t("admin.editBundleProperties.name") }}</label>
|
||||
@@ -28,11 +28,16 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="ui action input">
|
||||
<input type="file" name="newBackground"/>
|
||||
<button class="ui info button" type="submit" name="sUpload" value="true">{{ t("actions.upload") }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>{{ t("admin.editBundleProperties.transition") }}</label>
|
||||
<div id="transitions" class="ui selection dropdown">
|
||||
<input id="inputTransition" name="transition" value="{{ bundleData.transition }}" hidden/>
|
||||
<input type="text" id="inputTransition" name="transition" value="{{ bundleData.transition }}" hidden/>
|
||||
<div class="ui small breadcrumb">
|
||||
<span id="currentTransition" class="section"></span>
|
||||
</div>
|
||||
@@ -125,7 +130,7 @@
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<button type="submit" class="ui basic button">{{ t("actions.save") }}</button>
|
||||
<button name="sNormal" value="true" type="submit" class="ui basic button">{{ t("actions.save") }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -173,4 +178,4 @@
|
||||
}
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
+1
-2
@@ -31,8 +31,7 @@
|
||||
<img id="bgimg" class="fsimage" src=""/>
|
||||
</div>
|
||||
|
||||
<video muted loop autoplay id="bgvid" class="fsimage" poster="">
|
||||
</video>
|
||||
<video loop autoplay id="bgvid" class="fsimage" poster=""></video>
|
||||
|
||||
<script>
|
||||
var socket = io.connect("{{ config.serverUrl }}:{{ config.serverListenPort }}/display-{{ displayId }}");
|
||||
|
||||
Reference in new issue
Block a user