Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 877d3a7e rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Edit the config from amadeus, need a restart to apply

parent ee254731
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!10Settings in instance
...@@ -37,10 +37,30 @@ var config = { ...@@ -37,10 +37,30 @@ var config = {
this.database = __config.database.path; this.database = __config.database.path;
this.host = __config.lektord.host; this.host = __config.lektord.host;
this.port = __config.lektord.port; this.port = __config.lektord.port;
this.attachmode = __config.lektord.attach;
this.loglevel = __config.log.level; this.loglevel = __config.log.level;
this.loglektord = __config.log.lektord; this.loglektord = __config.log.lektord;
fs.writeFileSync(__configFile, ini.stringify(__config)); fs.writeFileSync(__configFile, ini.stringify(__config));
this.flush();
},
flush() {
const __config = {
database: {
path: this.database,
},
lektord: {
host: this.host,
port: this.port,
attach: this.attachmode,
},
log: {
level: this.loglevel,
lektord: this.loglektord,
},
};
fs.writeFileSync(__configFile, ini.stringify(__config));
}, },
}; };
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<fieldset class="form-group"> <fieldset class="form-group">
<div class="row"> <div class="row">
<legend class="col-form-label col-sm-2 pt-0">Log level</legend> <legend class="col-form-label col-sm-2 pt-0">Log level</legend>
<div class="col-sm-10"> <div class="col-sm-10" id="inputLogLevel">
<div class="form-check"> <div class="form-check">
<input <input
class="form-check-input" class="form-check-input"
...@@ -84,10 +84,10 @@ ...@@ -84,10 +84,10 @@
class="form-check-input" class="form-check-input"
type="radio" type="radio"
name="gridRadios" name="gridRadios"
id="logWARNINGS" id="logWARNING"
value="WARNINGS" value="WARNING"
/> />
<label class="form-check-label" for="logWARNINGS">Warnings</label> <label class="form-check-label" for="logWARNING">Warning</label>
</div> </div>
<div class="form-check"> <div class="form-check">
<input <input
......
...@@ -43,10 +43,27 @@ function autoFillSettings() { ...@@ -43,10 +43,27 @@ function autoFillSettings() {
$('#inputPort').val(config.port); $('#inputPort').val(config.port);
$('#inputAttachMode').prop('checked', true); $('#inputAttachMode').prop('checked', true);
$('#inputDbPath').val(config.database); $('#inputDbPath').val(config.database);
$('#inputLogLektord').val(config.loglektord); $('#inputLogLektord').prop('checked', config.loglektord);
$(`#log${config.loglevel.toUpperCase()}`).prop('checked', true); $(`#log${config.loglevel.toUpperCase()}`).prop('checked', true);
} }
function flushFillSettings() {
const set = {
host: $('#inputHost').val(),
port: $('#inputPort').val(),
attachmode: $('#inputAttachMode').prop('checked'),
db: $('#inputDbPath').val(),
loglektord: $('#inputLogLektord').prop('checked'),
loglevel: {
ERROR: $('#logERROR').prop('checked'),
WARNING: $('#logWARNING').prop('checked'),
INFO: $('#logINFO').prop('checked'),
DEBUG: $('#logDEBUG').prop('checked'),
},
};
ipcRenderer.send('set-settings', set);
}
window.onload = () => { window.onload = () => {
createButtonList(buttonList); createButtonList(buttonList);
...@@ -151,6 +168,7 @@ function createButtonList(list) { ...@@ -151,6 +168,7 @@ function createButtonList(list) {
span.onclick = function () { span.onclick = function () {
modal.style.display = 'none'; modal.style.display = 'none';
flushFillSettings();
}; };
window.onclick = function (event) { window.onclick = function (event) {
......
...@@ -252,3 +252,20 @@ ipcMain.on('get-song-time-data', (event, arg) => { ...@@ -252,3 +252,20 @@ ipcMain.on('get-song-time-data', (event, arg) => {
}); });
} }
}); });
ipcMain.on('set-settings', (event, arg) => {
logger.info('main', `Settings are now: ${JSON.stringify(arg)}`);
config.host = arg.host;
config.port = arg.port;
config.database = arg.db;
config.loglektord = arg.loglektord;
config.attachmode = arg.attachmode;
/* prettier-ignore */
config.loglevel = arg.loglevel.ERROR ? 'error'
: arg.loglevel.WARNING ? 'warning'
: arg.loglevel.INFO ? 'info'
: 'debug';
config.flush();
});
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter