add templates support

This commit is contained in:
Reaby committed 2019-08-24 16:10:44 +03:00
1 parent ea7fe05bf2
commit a6c4327b5d
7 files changed
+45 -5

No files matched your search

+12 -1
View File
@@ -373,6 +373,9 @@ class admin {
let bundle = self.bundleManager.getBundle(data.bundleName);
let bundleData = bundle.getBundleData();
let json = "{}";
if (fs.existsSync("./data/template.json")) {
json = fs.readFileSync("./data/template.json").toString();
}
let slide = {displayTime: null};
if (data.fileName) {
json = bundle.getSlideJsonFile(data.fileName);
@@ -403,6 +406,14 @@ class admin {
self.updateDashboard(io);
});
socket.on('edit.saveTemplate', function (data) {
try {
fs.writeFileSync("./data/template.json", JSON.stringify(data.json));
} catch (e) {
cli.error(e, "save template");
}
});
socket.on('edit.save', function (data) {
let filename = data.fileName.replace(".json", "");
@@ -601,4 +612,4 @@ class admin {
/**
* @type {admin}
*/
module.exports = admin;
module.exports = admin;