accept both new and old data format for server info on admin panel

master
ansuz 3 years ago
parent 1b2c6de355
commit 071c9706af

@ -356,10 +356,10 @@ var instanceStatus = function (Env, Server, cb) {
updateAvailable: Env.updateAvailable, updateAvailable: Env.updateAvailable,
instancePurpose: Env.instancePurpose, instancePurpose: Env.instancePurpose,
instanceDescription: Env.instanceDescription.default, instanceDescription: Env.instanceDescription,
instanceJurisdiction: Env.instanceJurisdiction.default, instanceJurisdiction: Env.instanceJurisdiction,
instanceName: Env.instanceName.default, instanceName: Env.instanceName,
instanceNotice: Env.instanceNotice.default, instanceNotice: Env.instanceNotice,
}); });
}; };

@ -437,7 +437,7 @@ define([
var input = h('input.cp-listing-info', { var input = h('input.cp-listing-info', {
type: 'text', type: 'text',
value: APP.instanceStatus.instanceJurisdiction || '', value: getInstanceString('instanceJurisdiction') || '', // XXX
placeholder: Messages.owner_unknownUser || '', placeholder: Messages.owner_unknownUser || '',
}); });
var $input = $(input); var $input = $(input);
@ -469,11 +469,10 @@ define([
return $div; return $div;
}; };
Messages.admin_noticeTitle = "admin_noticeTitle"; Messages.admin_noticeTitle = "Home page notice"; // XXX
Messages.admin_noticeHint = "admin_noticeHint"; Messages.admin_noticeHint = "An optional message to display on the home page"; // XXX
//Messages.admin_noticeButton = "admin_noticeButton";
create['notice'] = function () { // XXX add input, make translateable create['notice'] = function () { // XXX make translateable
var key = 'notice'; var key = 'notice';
var $div = makeBlock(key, true); var $div = makeBlock(key, true);
@ -481,8 +480,8 @@ define([
var input = h('input.cp-listing-info', { var input = h('input.cp-listing-info', {
type: 'text', type: 'text',
value: APP.instanceStatus.instanceNotice || '', value: getInstanceString('instanceNotice') || '', // XXX
placeholder: Messages.owner_unknownUser || '', placeholder: '',
}); });
var $input = $(input); var $input = $(input);
var innerDiv = h('div.cp-admin-setnotice-form', input); var innerDiv = h('div.cp-admin-setnotice-form', input);
@ -522,6 +521,16 @@ define([
)); ));
}; };
var getInstanceString = function (attr) {
var val = APP.instanceStatus[attr];
var type = typeof(val);
switch (type) {
case 'string': return val;
case 'object': return val.default;
default: return;
}
};
create['name'] = function () { // XXX make translateable create['name'] = function () { // XXX make translateable
var key = 'name'; var key = 'name';
var $div = makeBlock(key, true); var $div = makeBlock(key, true);
@ -530,7 +539,7 @@ define([
var input = h('input.cp-listing-info', { var input = h('input.cp-listing-info', {
type: 'text', type: 'text',
value: APP.instanceStatus.instanceName || ApiConfig.httpUnsafeOrigin || '', value: getInstanceString('instanceName') || ApiConfig.httpUnsafeOrigin || '',
placeholder: ApiConfig.httpUnsafeOrigin, placeholder: ApiConfig.httpUnsafeOrigin,
style: 'margin-bottom: 5px;', style: 'margin-bottom: 5px;',
}); });
@ -569,7 +578,7 @@ define([
var textarea = h('textarea.cp-admin-description-text.cp-listing-info', { var textarea = h('textarea.cp-admin-description-text.cp-listing-info', {
placeholder: Messages.home_host || '', placeholder: Messages.home_host || '',
}, APP.instanceStatus.instanceDescription || ''); }, getInstanceString('instanceDescription') || '');
var $button = $div.find('button').text(Messages.settings_save); var $button = $div.find('button').text(Messages.settings_save);

Loading…
Cancel
Save