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

This commit is contained in:
ansuz 2022-05-10 13:11:53 +05:30
parent 1b2c6de355
commit 071c9706af
2 changed files with 22 additions and 13 deletions

View File

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

View File

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