From 071c9706af6e5187ad5dc78b62c28e674fffe806 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 10 May 2022 13:11:53 +0530 Subject: [PATCH] accept both new and old data format for server info on admin panel --- lib/commands/admin-rpc.js | 8 ++++---- www/admin/inner.js | 27 ++++++++++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/commands/admin-rpc.js b/lib/commands/admin-rpc.js index 9f991231a..a291cd969 100644 --- a/lib/commands/admin-rpc.js +++ b/lib/commands/admin-rpc.js @@ -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, }); }; diff --git a/www/admin/inner.js b/www/admin/inner.js index 57f39fe16..369a1bc42 100644 --- a/www/admin/inner.js +++ b/www/admin/inner.js @@ -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);