Skip to content

Commit 61fc230

Browse files
committed
added button to export (show) client settings as JSON
1 parent 1d4fcfb commit 61fc230

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

www/scripts/sepiaFW.app.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,35 @@ function sepiaFW_build_config(){
392392
}
393393
//NOTE: see SepiaFW.account #skipLogin for temporary setup settings (e.g. TTS off)
394394

395+
Config.exportSettingsForHeadlessMode = function(){
396+
//build
397+
var headlessConfigJson;
398+
if (SepiaFW.settings && SepiaFW.settings.headless){
399+
headlessConfigJson = JSON.parse(JSON.stringify(SepiaFW.settings)); //copy
400+
}else{
401+
headlessConfigJson = {headless: {}};
402+
}
403+
headlessConfigJson.headless.device = SepiaFW.data.getAllPermanent();
404+
headlessConfigJson.headless.user = SepiaFW.data.getAll();
405+
//filter account
406+
delete headlessConfigJson.headless.user["account"];
407+
delete headlessConfigJson.headless.user["contacts-from-chat"];
408+
delete headlessConfigJson.headless.user["lastChannelMessageTimestamps"];
409+
//... more?
410+
//show
411+
var msgBox = document.createElement("div");
412+
var titleBox = document.createElement("div");
413+
titleBox.innerHTML = "<h3>Client Settings</h3><p>Copy this to your SEPIA client settings.js file:</p>";
414+
var jsonBox = document.createElement("textarea");
415+
jsonBox.value = JSON.stringify(headlessConfigJson, null, 4);
416+
jsonBox.style.whiteSpace = "pre";
417+
msgBox.appendChild(titleBox);
418+
msgBox.appendChild(jsonBox);
419+
SepiaFW.ui.showPopup(msgBox);
420+
//adjust size
421+
jsonBox.style.height = jsonBox.scrollHeight + 32 + "px";
422+
}
423+
395424
Config.loadAppSettings = function(readyCallback){
396425
//TODO: this should be simplified with a service! ...
397426
addAppSettingsReadyCallback(readyCallback);

www/scripts/sepiaFW.local.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function sepiaFW_build_strings(){
7474
StringsDE.save = 'Speichern';
7575
StringsDE.store = 'Speichern';
7676
StringsDE.load = 'Laden';
77+
StringsDE.export = 'Exportieren';
7778
StringsDE.edit = 'Bearbeiten';
7879
StringsDE.copy = 'Kopieren';
7980
StringsDE.show = 'Anzeigen';
@@ -292,6 +293,7 @@ function sepiaFW_build_strings(){
292293
StringsEN.save = 'Save';
293294
StringsEN.store = 'Store';
294295
StringsEN.load = 'Load';
296+
StringsEN.export = 'Export';
295297
StringsEN.edit = 'Edit';
296298
StringsEN.copy = 'Copy';
297299
StringsEN.show = 'Show';

www/scripts/sepiaFW.ui.build.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ function sepiaFW_build_ui_build(sepiaSessionId){
724724
+ "<div>"
725725
+ "<button id='sepiaFW-menu-load-app-settings-btn' class='sepiaFW-button-inline'>" + SepiaFW.local.g('load') + "</button>"
726726
+ "<button id='sepiaFW-menu-store-app-settings-btn' class='sepiaFW-button-inline'>" + SepiaFW.local.g('save') + "</button>"
727+
+ "<button id='sepiaFW-menu-export-app-settings-btn' class='sepiaFW-button-inline'>" + SepiaFW.local.g('export') + "</button>"
727728
//TODO: add delete button
728729
+ "</div>"
729730
+ "</li>"
@@ -1483,13 +1484,16 @@ function sepiaFW_build_ui_build(sepiaSessionId){
14831484
//update account cache
14841485
SepiaFW.account.setUserPreferredTemperatureUnit(selectedOption.value);
14851486
}));
1486-
//Store and load app settings
1487+
//Store, load and export app settings
14871488
document.getElementById("sepiaFW-menu-store-app-settings-btn").addEventListener("click", function(){
14881489
SepiaFW.account.saveAppSettings();
14891490
});
14901491
document.getElementById("sepiaFW-menu-load-app-settings-btn").addEventListener("click", function(){
14911492
SepiaFW.account.loadAppSettings();
14921493
});
1494+
document.getElementById("sepiaFW-menu-export-app-settings-btn").addEventListener("click", function(){
1495+
SepiaFW.config.exportSettingsForHeadlessMode();
1496+
});
14931497
//Sign-out all clients
14941498
document.getElementById("sepiaFW-menu-ui-signoutall-btn").addEventListener("click", function(){
14951499
SepiaFW.account.logoutAction(true);

0 commit comments

Comments
 (0)