|
|
|
@ -85,15 +85,26 @@ define([
|
|
|
|
|
'performance': [ // Msg.admin_cat_performance
|
|
|
|
|
'cp-admin-refresh-performance',
|
|
|
|
|
'cp-admin-performance-profiling',
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'network': [ // Msg.admin_cat_network
|
|
|
|
|
'cp-admin-checkup',
|
|
|
|
|
'cp-admin-block-daily-check',
|
|
|
|
|
'cp-admin-consent-to-contact',
|
|
|
|
|
'cp-admin-list-my-instance',
|
|
|
|
|
'cp-admin-provide-aggregate-statistics',
|
|
|
|
|
'cp-admin-remove-donate-button',
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var create = {};
|
|
|
|
|
|
|
|
|
|
var keyToCamlCase = function (key) {
|
|
|
|
|
return key.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var makeBlock = function (key, addButton) { // Title, Hint, maybeButton
|
|
|
|
|
// Convert to camlCase for translation keys
|
|
|
|
|
var safeKey = key.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
|
|
|
|
|
|
|
|
|
var safeKey = keyToCamlCase(key);
|
|
|
|
|
var $div = $('<div>', {'class': 'cp-admin-' + key + ' cp-sidebarlayout-element'});
|
|
|
|
|
$('<label>').text(Messages['admin_'+safeKey+'Title'] || key).appendTo($div);
|
|
|
|
|
$('<span>', {'class': 'cp-sidebarlayout-description'})
|
|
|
|
@ -260,7 +271,7 @@ define([
|
|
|
|
|
var $div = makeBlock(key); // Msg.admin_registrationHint, .admin_registrationTitle, .admin_registrationButton
|
|
|
|
|
|
|
|
|
|
var state = APP.instanceStatus.restrictRegistration;
|
|
|
|
|
var $cbox = $(UI.createCheckbox('cp-settings-userfeedback',
|
|
|
|
|
var $cbox = $(UI.createCheckbox('cp-settings-' + key,
|
|
|
|
|
Messages.admin_registrationTitle,
|
|
|
|
|
state, { label: { class: 'noTitle' } }));
|
|
|
|
|
var spinner = UI.makeSpinner($cbox);
|
|
|
|
@ -289,6 +300,55 @@ define([
|
|
|
|
|
return $div;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var makeAdminCheckbox = function (data) {
|
|
|
|
|
return function () {
|
|
|
|
|
var state = data.getState();
|
|
|
|
|
var key = data.key;
|
|
|
|
|
var $div = makeBlock(key);
|
|
|
|
|
|
|
|
|
|
var labelKey = 'admin_' + keyToCamlCase(key) + 'Label';
|
|
|
|
|
var titleKey = 'admin_' + keyToCamlCase(key) + 'Title';
|
|
|
|
|
var $cbox = $(UI.createCheckbox('cp-admin-' + key,
|
|
|
|
|
Messages[labelKey] || Messages[titleKey],
|
|
|
|
|
state, { label: { class: 'noTitle' } }));
|
|
|
|
|
var spinner = UI.makeSpinner($cbox);
|
|
|
|
|
var $checkbox = $cbox.find('input').on('change', function() {
|
|
|
|
|
spinner.spin();
|
|
|
|
|
var val = $checkbox.is(':checked') || false;
|
|
|
|
|
$checkbox.attr('disabled', 'disabled');
|
|
|
|
|
data.query(val, function (state) {
|
|
|
|
|
spinner.done();
|
|
|
|
|
$checkbox[0].checked = state;
|
|
|
|
|
$checkbox.removeAttr('disabled');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
$cbox.appendTo($div);
|
|
|
|
|
return $div;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Msg.admin_registrationHint, .admin_registrationTitle, .admin_registrationButton
|
|
|
|
|
create['registration'] = makeAdminCheckbox({
|
|
|
|
|
key: 'registration',
|
|
|
|
|
getState: function () {
|
|
|
|
|
return APP.instanceStatus.restrictRegistration;
|
|
|
|
|
},
|
|
|
|
|
query: function (val, setState) {
|
|
|
|
|
sFrameChan.query('Q_ADMIN_RPC', {
|
|
|
|
|
cmd: 'ADMIN_DECREE',
|
|
|
|
|
data: ['RESTRICT_REGISTRATION', [val]]
|
|
|
|
|
}, function (e, response) {
|
|
|
|
|
if (e || response.error) {
|
|
|
|
|
UI.warn(Messages.error);
|
|
|
|
|
console.error(e, response);
|
|
|
|
|
}
|
|
|
|
|
APP.updateStatus(function () {
|
|
|
|
|
setState(APP.instanceStatus.restrictRegistration);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
create['email'] = function () {
|
|
|
|
|
var key = 'email';
|
|
|
|
|
var $div = makeBlock(key, true); // Msg.admin_emailHint, Msg.admin_emailTitle, Msg.admin_emailButton
|
|
|
|
@ -1663,6 +1723,166 @@ define([
|
|
|
|
|
return $div;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Messages.admin_cat_network = 'Network'; // XXX
|
|
|
|
|
|
|
|
|
|
Messages.admin_checkupTitle = 'admin_checkupTitle'; // XXX
|
|
|
|
|
Messages.admin_checkupHint = 'admin_checkupHint'; // XXX
|
|
|
|
|
Messages.admin_checkupButton = 'Run diagnostics'; // XXX
|
|
|
|
|
|
|
|
|
|
create['checkup'] = function () {
|
|
|
|
|
var $div = makeBlock('checkup', true);
|
|
|
|
|
$div.find('button').click(function () {
|
|
|
|
|
common.openURL('/checkup/');
|
|
|
|
|
});
|
|
|
|
|
return $div;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Messages.admin_consentToContactTitle = 'admin_consentToContactTitle'; // XXX
|
|
|
|
|
Messages.admin_consentToContactHint = 'admin_consentToContactHint'; // XXX
|
|
|
|
|
Messages.admin_consentToContactLabel = 'admin_consentToContactLabel'; // XXX
|
|
|
|
|
|
|
|
|
|
create['consent-to-contact'] = makeAdminCheckbox({
|
|
|
|
|
key: 'consent-to-contact',
|
|
|
|
|
getState: function () {
|
|
|
|
|
return APP.instanceStatus.consentToContact;
|
|
|
|
|
},
|
|
|
|
|
query: function (val, setState) {
|
|
|
|
|
sFrameChan.query('Q_ADMIN_RPC', {
|
|
|
|
|
cmd: 'ADMIN_DECREE',
|
|
|
|
|
data: ['CONSENT_TO_CONTACT', [val]]
|
|
|
|
|
}, function (e, response) {
|
|
|
|
|
if (e || response.error) {
|
|
|
|
|
UI.warn(Messages.error);
|
|
|
|
|
console.error(e, response);
|
|
|
|
|
}
|
|
|
|
|
APP.updateStatus(function () {
|
|
|
|
|
setState(APP.instanceStatus.consentToContact);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Messages.admin_listMyInstanceTitle = 'admin_listMyInstanceTitle'; // XXX
|
|
|
|
|
Messages.admin_listMyInstanceHint = 'admin_listMyInstanceHint'; // XXX
|
|
|
|
|
Messages.admin_listMyInstanceLabel = 'admin_listMyInstanceLabel'; // XXX
|
|
|
|
|
|
|
|
|
|
create['list-my-instance'] = makeAdminCheckbox({
|
|
|
|
|
key: 'list-my-instance',
|
|
|
|
|
getState: function () {
|
|
|
|
|
return APP.instanceStatus.listMyInstance;
|
|
|
|
|
},
|
|
|
|
|
query: function (val, setState) {
|
|
|
|
|
sFrameChan.query('Q_ADMIN_RPC', {
|
|
|
|
|
cmd: 'ADMIN_DECREE',
|
|
|
|
|
data: ['LIST_MY_INSTANCE', [val]]
|
|
|
|
|
}, function (e, response) {
|
|
|
|
|
if (e || response.error) {
|
|
|
|
|
UI.warn(Messages.error);
|
|
|
|
|
console.error(e, response);
|
|
|
|
|
}
|
|
|
|
|
APP.updateStatus(function () {
|
|
|
|
|
setState(APP.instanceStatus.listMyInstance);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Messages.admin_provideAggregateStatisticsTitle = 'admin_provideAggregateStatisticsTitle'; // XXX
|
|
|
|
|
Messages.admin_provideAggregateStatisticsHint = 'admin_provideAggregateStatisticsHint'; // XXX
|
|
|
|
|
Messages.admin_provideAggregateStatisticsLabel = 'admin_provideAggregateStatisticsLabel'; // XXX
|
|
|
|
|
|
|
|
|
|
create['provide-aggregate-statistics'] = makeAdminCheckbox({
|
|
|
|
|
key: 'provide-aggregate-statistics',
|
|
|
|
|
getState: function () {
|
|
|
|
|
return APP.instanceStatus.provideAggregateStatistics;
|
|
|
|
|
},
|
|
|
|
|
query: function (val, setState) {
|
|
|
|
|
sFrameChan.query('Q_ADMIN_RPC', {
|
|
|
|
|
cmd: 'ADMIN_DECREE',
|
|
|
|
|
data: ['PROVIDE_AGGREGATE_STATISTICS', [val]]
|
|
|
|
|
}, function (e, response) {
|
|
|
|
|
if (e || response.error) {
|
|
|
|
|
UI.warn(Messages.error);
|
|
|
|
|
console.error(e, response);
|
|
|
|
|
}
|
|
|
|
|
APP.updateStatus(function () {
|
|
|
|
|
setState(APP.instanceStatus.provideAggregateStatistics);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Messages.admin_removeDonateButtonTitle = 'admin_removeDonateButtonTitle'; // XXX
|
|
|
|
|
Messages.admin_removeDonateButtonHint = 'admin_removeDonateButtonHint'; // XXX
|
|
|
|
|
Messages.admin_removeDonateButtonLabel = 'admin_removeDonateButtonLabel'; // XXX
|
|
|
|
|
|
|
|
|
|
/* // XXX
|
|
|
|
|
* We're very proud that CryptPad is available to the public as free software!
|
|
|
|
|
* We do, however, still need to pay our bills as we develop the platform.
|
|
|
|
|
*
|
|
|
|
|
* By default CryptPad will prompt users to consider donating to
|
|
|
|
|
* our OpenCollective campaign. We publish the state of our finances periodically
|
|
|
|
|
* so you can decide for yourself whether our expenses are reasonable.
|
|
|
|
|
*
|
|
|
|
|
* You can disable any solicitations for donations by setting 'removeDonateButton' to true,
|
|
|
|
|
* but we'd appreciate it if you didn't!
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
create['remove-donate-button'] = makeAdminCheckbox({
|
|
|
|
|
key: 'remove-donate-button',
|
|
|
|
|
getState: function () {
|
|
|
|
|
return APP.instanceStatus.removeDonateButton;
|
|
|
|
|
},
|
|
|
|
|
query: function (val, setState) {
|
|
|
|
|
sFrameChan.query('Q_ADMIN_RPC', {
|
|
|
|
|
cmd: 'ADMIN_DECREE',
|
|
|
|
|
data: ['REMOVE_DONATE_BUTTON', [val]]
|
|
|
|
|
}, function (e, response) {
|
|
|
|
|
if (e || response.error) {
|
|
|
|
|
UI.warn(Messages.error);
|
|
|
|
|
console.error(e, response);
|
|
|
|
|
}
|
|
|
|
|
APP.updateStatus(function () {
|
|
|
|
|
setState(APP.instanceStatus.removeDonateButton);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Messages.admin_blockDailyCheckTitle = 'admin_blockDailyCheckTitle'; // XXX
|
|
|
|
|
Messages.admin_blockDailyCheckHint = 'admin_blockDailyCheckHint'; // XXX
|
|
|
|
|
Messages.admin_blockDailyCheckLabel = 'admin_blockDailyCheckLabel'; // XXX
|
|
|
|
|
|
|
|
|
|
/* // XXX
|
|
|
|
|
* By default, CryptPad contacts one of our servers once a day.
|
|
|
|
|
* This check-in will also send some very basic information about your instance including its
|
|
|
|
|
* version and the adminEmail so we can reach you if we are aware of a serious problem.
|
|
|
|
|
* We will never sell it or send you marketing mail.
|
|
|
|
|
*
|
|
|
|
|
* If you want to block this check-in and remain set 'blockDailyCheck' to true.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
create['block-daily-check'] = makeAdminCheckbox({
|
|
|
|
|
key: 'block-daily-check',
|
|
|
|
|
getState: function () {
|
|
|
|
|
return APP.instanceStatus.blockDailyCheck;
|
|
|
|
|
},
|
|
|
|
|
query: function (val, setState) {
|
|
|
|
|
sFrameChan.query('Q_ADMIN_RPC', {
|
|
|
|
|
cmd: 'ADMIN_DECREE',
|
|
|
|
|
data: ['BLOCK_DAILY_CHECK', [val]]
|
|
|
|
|
}, function (e, response) {
|
|
|
|
|
if (e || response.error) {
|
|
|
|
|
UI.warn(Messages.error);
|
|
|
|
|
console.error(e, response);
|
|
|
|
|
}
|
|
|
|
|
APP.updateStatus(function () {
|
|
|
|
|
setState(APP.instanceStatus.blockDailyCheck);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var hideCategories = function () {
|
|
|
|
|
APP.$rightside.find('> div').hide();
|
|
|
|
|
};
|
|
|
|
@ -1680,6 +1900,7 @@ define([
|
|
|
|
|
support: 'fa fa-life-ring',
|
|
|
|
|
broadcast: 'fa fa-bullhorn',
|
|
|
|
|
performance: 'fa fa-heartbeat',
|
|
|
|
|
network: 'fa fa-sitemap', // or fa-university ?
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var createLeftside = function () {
|
|
|
|
|