Skip to content

Commit ac34e41

Browse files
committed
Feature: Config Editor UI: Support newly introduced config properties, even if they don't exist in old config files.
1 parent f639ac6 commit ac34e41

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

htdocs/js/pages/admin/Config.class.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Page.Config = class Config extends Page.PageUtils {
3434
// receive config from server
3535
var self = this;
3636
this.lastResp = resp;
37-
var { config, overrides, markdown } = resp;
37+
var { config, overrides, sample, markdown } = resp;
3838

3939
// parse markdown into sections
4040
var rows = [];
@@ -73,9 +73,14 @@ Page.Config = class Config extends Page.PageUtils {
7373
else row.value = get_path( config, path );
7474

7575
if (row.value === undefined) {
76-
// should never happen, but who knows
77-
row = null;
78-
return;
76+
// try sample config
77+
row.value = get_path( sample, path );
78+
79+
if (row.value === undefined) {
80+
// should never happen, but who knows
81+
row = null;
82+
return;
83+
}
7984
}
8085

8186
row.type = typeof(row.value);

lib/api/config.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,16 @@ class Configuration {
184184
}
185185
}
186186

187-
fs.readFile( 'docs/config.md', 'utf8', function(err, markdown) {
188-
if (err) return self.doError('fs', "Failed to load config doc: " + err, callback);
189-
callback({ code: 0, config, overrides, markdown });
190-
}); // fs.readFile
187+
fs.readFile( 'sample_conf/config.json', 'utf8', function(err, raw_sample) {
188+
var sample = null;
189+
try { sample = JSON.parse(raw_sample || '{}'); }
190+
catch (err) { sample = {}; }
191+
192+
fs.readFile( 'docs/config.md', 'utf8', function(err, markdown) {
193+
if (err) return self.doError('fs', "Failed to load config doc: " + err, callback);
194+
callback({ code: 0, config, overrides, sample, markdown });
195+
}); // fs.readFile (md)
196+
}); // fs.readFile (sample)
191197
}); // loadSession
192198
}
193199

0 commit comments

Comments
 (0)