mirror of
https://github.com/UiO-Gaming/infoscreen3.git
synced 2026-11-05 13:56:52 +01:00
Enhance template system, fix editor not to scroll sideways on text edit.
save templates, will save template with given slide name and there is now a dropdown menu to load template from. To remove template, just remove template.json from /data
This commit is contained in:
1 parent
8a6024d0e2
commit
44d1c0a514
8 files changed
+98
-32
No files matched your search
+12
-4
@@ -439,16 +439,17 @@ class admin {
|
||||
socket.on('admin.editSlide', function (data) {
|
||||
let bundle = self.bundleManager.getBundle(data.bundleName);
|
||||
let bundleData = bundle.getBundleData();
|
||||
let templateData = {};
|
||||
let json = "{}";
|
||||
if (fs.existsSync("./data/template.json")) {
|
||||
json = fs.readFileSync("./data/template.json").toString();
|
||||
templateData = JSON.parse(fs.readFileSync("./data/template.json").toString());
|
||||
}
|
||||
let slide = {displayTime: null};
|
||||
let slide = { displayTime: null };
|
||||
if (data.fileName) {
|
||||
json = bundle.getSlideJsonFile(data.fileName);
|
||||
slide = bundle.findSlideByUuid(data.fileName);
|
||||
}
|
||||
socket.emit("callback.edit", {bundleData: bundleData, slideData: slide, json: json});
|
||||
socket.emit("callback.edit", {bundleData: bundleData, slideData: slide, json: json, templates: templateData});
|
||||
});
|
||||
|
||||
/** rename **/
|
||||
@@ -474,8 +475,15 @@ class admin {
|
||||
});
|
||||
|
||||
socket.on('edit.saveTemplate', function (data) {
|
||||
let templates = {};
|
||||
console.log(data.name);
|
||||
|
||||
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(data.json));
|
||||
fs.writeFileSync("./data/template.json", JSON.stringify(templates));
|
||||
} catch (e) {
|
||||
cli.error(e, "save template");
|
||||
}
|
||||
|
||||
@@ -36,7 +36,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