diff --git a/api/v1/config/instances/add/index.php b/api/v1/config/instances/add/index.php
index 54164e8..df39eb4 100644
--- a/api/v1/config/instances/add/index.php
+++ b/api/v1/config/instances/add/index.php
@@ -13,6 +13,6 @@ if (isset($data['error']))
$software = trim($_GET['software']);
$instance = trim($_GET['instance']);
-filedb_put("instances/$software/$instance/config");
+filedb_put("instances/$software/$instance", 'config');
$uri = preg_replace('#api/v1/config/instances.*#', '', $_SERVER['REQUEST_URI']);
header('Location: '.$uri.'#home');
diff --git a/index.php b/index.php
index 32475d6..d01abc5 100644
--- a/index.php
+++ b/index.php
@@ -16,8 +16,8 @@
window.consts = {
'instance_config': {
'mastodon': {
- 'musthave': ['instance_url','psql_host','psql_port','psql_db',
- 'psql_username','psql_password','redis_host','redis_port','api_authkey'],
+ 'fields': ['*instance_url','*psql_host','*psql_port','*psql_db',
+ '*psql_username','*psql_password','redis_host','redis_port','*api_authkey'],
},
}
};
diff --git a/views/add.php b/views/add.php
index 2402034..7a76242 100644
--- a/views/add.php
+++ b/views/add.php
@@ -17,8 +17,10 @@
-
+
@@ -25,10 +25,11 @@ window.view.instance_config = {
mastodon: function(hargs, config) {
E.element('#window-instance_config form').setAttribute('action',
`api/v1/config/put/?software=mastodon&instance=${hargs['instance']}`);
- const fields = window.consts['instance_config']['mastodon']['musthave'];
+ const fields = window.consts['instance_config']['mastodon']['fields'];
for (var i = 0; i < fields.length; i++) {
- if (config[fields[i]] !== undefined)
- E.elemid(`config_${fields[i]}`).value = config[fields[i]];
+ const f = fields[i].startsWith('*') ? fields[i].substr(1) : fields[i];
+ if (config[f] !== undefined)
+ E.elemid(`config_${f}`).value = config[f];
}
if (config['instance_url'] === undefined) {
http.get('api/v1/network/resolve-instance?hostname='+hargs['instance'],
@@ -54,11 +55,14 @@ function load__instance_config(args) {
capitalize(hargs['software']) + ` (${hargs['instance']})`);
E.template('config', function(TPL) {
var html = '';
- const fields = window.consts['instance_config'][hargs['software']]['musthave'];
+ const fields = window.consts['instance_config'][hargs['software']]['fields'];
for (var i = 0; i < fields.length; i++) {
+ const field = fields[i].startsWith('*') ? fields[i].substr(1) : fields[i];
+ const important = fields[i].startsWith('*');
var tpl = TPL;
- tpl = tpl.replaceAll('{field}', fields[i]);
- tpl = tpl.replaceAll('{placeholder}', human_field_name(fields[i]));
+ tpl = tpl.replaceAll('{field}', field);
+ tpl = tpl.replaceAll('{placeholder}', human_field_name(field));
+ tpl = tpl.replaceAll('{importantMark}', important ? '*' : '');
html += tpl;
}
return html;