Skip to content

Commit

Permalink
fix context storage configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Jan 15, 2019
1 parent 31c9f21 commit 5e8bae0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
6 changes: 4 additions & 2 deletions addon_files/redmatic/etc/default-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
},
"file": {
"module": "localfilesystem",
"dir": "/usr/local/addons/redmatic/var",
"flushInterval": 30
"config": {
"dir": "/usr/local/addons/redmatic/var",
"flushInterval": 30
}
}
},
"editorTheme": {
Expand Down
12 changes: 9 additions & 3 deletions addon_files/redmatic/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,23 @@ if (!settings.contextStorage.memory) {
if (!settings.contextStorage.file) {
settings.contextStorage.file = {
'module': 'localfilesystem',
dir: '/usr/local/addons/redmatic/var',
flushInterval: 30
config: {
dir: '/usr/local/addons/redmatic/var',
flushInterval: 30
}
}
}

const defaultContextStorage = Object.assign({}, settings.contextStorage[settings.contextStorage.default.module]);
delete settings.contextStorage[settings.contextStorage.default.module];
settings.contextStorage.default = defaultContextStorage;

module.exports = Object.assign(
const result = Object.assign(
defaults,
settings,
logging
);

fs.writeFileSync('/tmp/red-settings.json', JSON.stringify(result));

module.exports = result;
23 changes: 19 additions & 4 deletions addon_files/redmatic/www/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,15 @@ $(document).ready(() => {
}
if (!config.contextStorage.file) {
config.contextStorage.file = {
'module': 'localfilesystem',
'module': 'localfilesystem'
};
}

if (!config.contextStorage.file.config) {
config.contextStorage.file.config = {
dir: '/usr/local/addons/redmatic/var',
flushInterval: 30
};
}
}

if (!config.editorTheme) {
Expand Down Expand Up @@ -239,8 +244,8 @@ $(document).ready(() => {

$contextStorageDefault.val(config.contextStorage.default.module);

$contextStorageFilePath.val(config.contextStorage.file.dir);
$contextStorageFileInterval.val(config.contextStorage.file.flushInterval);
$contextStorageFilePath.val(config.contextStorage.file.config.dir);
$contextStorageFileInterval.val(config.contextStorage.file.config.flushInterval);

$('#autorestart').find('option[value="' + config.restartOnCrash + '"]').attr('selected', true);

Expand Down Expand Up @@ -287,6 +292,16 @@ $(document).ready(() => {
save();
});

$contextStorageFilePath.change(() => {
config.contextStorage.file.config.dir = $contextStorageFilePath.val();
save();
});

$contextStorageFileInterval.change(() => {
config.contextStorage.file.config.flushInterval = parseInt($contextStorageFileInterval.val(), 10);
save();
});

$adminauthSessionExpiryTime.change(() => {
if (!config.adminAuth) {
config.adminAuth = {};
Expand Down

0 comments on commit 5e8bae0

Please sign in to comment.