@@ -50,19 +56,19 @@ class AdminPanelAdvancedSettings extends React.Component {
@@ -86,6 +92,12 @@ class AdminPanelAdvancedSettings extends React.Component {
);
}
+ renderMessage() {
+ return (
+
{this.state.messageContent}
+ );
+ }
+
getListingProps() {
return {
title: i18n('REGISTRATION_API_KEYS'),
@@ -114,10 +126,102 @@ class AdminPanelAdvancedSettings extends React.Component {
});
}
- onToggleButtonChange() {
- AreYouSure.openModal(
{i18n('PLEASE_CONFIRM_PASSWORD')}
, (a) => a, 'secure');
+ onToggleButtonUserSystemChange() {
+ AreYouSure.openModal(
{i18n('PLEASE_CONFIRM_PASSWORD')}
, this.onAreYouSureUserSystemOk.bind(this), 'secure');
}
+ onToggleButtonRegistrationChange() {
+ AreYouSure.openModal(
{i18n('PLEASE_CONFIRM_PASSWORD')}
, this.onAreYouSureRegistrationOk.bind(this), 'secure');
+ }
+
+ onAreYouSureUserSystemOk(password) {
+ API.call({
+ path: this.props.config['user-system-enabled'] ? '/system/disable-user-system' : '/system/enable-user-system',
+ data: {
+ password: password
+ }
+ }).then(() => {
+ this.setState({
+ messageType: 'success',
+ messageContent: this.props.config['user-system-enabled'] ? i18n('USER_SYSTEM_DISABLE_DESCRIPTION') : i18n('USER_SYSTEM_ENABLE_DESCRIPTION')
+ });
+ this.props.dispatch(ConfigActions.updateData());
+ }).catch(() => this.setState({messageType: 'fail', messageContent: i18n('ERROR_UPDATING_SETTINGS')}));
+ }
+
+ onAreYouSureRegistrationOk(password) {
+ API.call({
+ path: this.props.config['user-system-enabled'] ? '/system/disable-registration' : '/system/enable-registration',
+ data: {
+ password: password
+ }
+ }).then(() => {
+ this.setState({
+ messageType: 'success',
+ messageContent: this.props.config['user-system-enabled'] ? i18n('REGISTRATION_DISABLE_DESCRIPTION') : i18n('REGISTRATION_ENABLE_DESCRIPTION')
+ });
+ this.props.dispatch(ConfigActions.updateData());
+ }).catch(() => this.setState({messageType: 'fail', messageContent: i18n('ERROR_UPDATING_SETTINGS')}));
+ }
+
+ onImportCSV(event) {
+ AreYouSure.openModal(
{i18n('PLEASE_CONFIRM_PASSWORD')}
, this.onAreYouSureCSVOk.bind(this, event.target.value), 'secure');
+ }
+
+ onImportSQL(event) {
+ AreYouSure.openModal(
{i18n('PLEASE_CONFIRM_PASSWORD')}
, this.onAreYouSureSQLOk.bind(this, event.target.value), 'secure');
+ }
+
+ onAreYouSureCSVOk(file, password) {
+ API.call({
+ path: '/system/import-csv',
+ data: {
+ file: file,
+ password: password
+ }
+ }).then(() => this.setState({messageType: 'success', messageContent: i18n('SUCCESS_IMPORTING_CSV_DESCRIPTION')}
+ )).catch(() => this.setState({messageType: 'fail', messageContent: i18n('ERROR_IMPORTING_CSV_DESCRIPTION')}));
+ }
+
+ onAreYouSureSQLOk(file, password) {
+ API.call({
+ path: '/system/import-sql',
+ data: {
+ file: file,
+ password: password
+ }
+ }).then(() => this.setState({messageType: 'success', messageContent: i18n('SUCCESS_IMPORTING_SQL_DESCRIPTION')}
+ )).catch(() => this.setState({messageType: 'fail', messageContent: i18n('ERROR_IMPORTING_SQL_DESCRIPTION')}));
+ }
+
+ onBackupDatabase() {
+ API.call({
+ path: '/system/backup-database',
+ plain: true,
+ data: {}
+ }).then((result) => {
+ let contentType = 'application/octet-stream';
+ let link = document.createElement('a');
+ let blob = new Blob([result], {'type': contentType});
+ link.href = window.URL.createObjectURL(blob);
+ link.download = 'backup.sql';
+ link.click();
+ });
+ }
+
+ onDeleteAllUsers() {
+ AreYouSure.openModal(
{i18n('PLEASE_CONFIRM_PASSWORD')}
, this.onAreYouSureDeleteAllUsersOk.bind(this), 'secure');
+ }
+
+ onAreYouSureDeleteAllUsersOk(password) {
+ API.call({
+ path: '/system/delete-all-users',
+ data: {
+ password: password
+ }
+ }).then(() => this.setState({messageType: 'success', messageContent: i18n('SUCCESS_DELETING_ALL_USERS')}
+ )).catch(() => this.setState({messageType: 'fail', messageContent: i18n('ERROR_DELETING_ALL_USERS')}));
+ }
}
diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js
index 3e98c9a8..f84766b7 100644
--- a/client/src/data/fixtures/system-fixtures.js
+++ b/client/src/data/fixtures/system-fixtures.js
@@ -122,6 +122,24 @@ module.exports = [
return 'text content';
}
},
+ {
+ path: '/system/delete-all-users',
+ time: 100,
+ response: function () {
+ return {
+ status: 'success',
+ data: {}
+ };
+ }
+ },
+ {
+ path: '/system/backup-database',
+ time: 100,
+ contentType: 'application/octet-stream',
+ response: function () {
+ return 'text content';
+ }
+ },
{
path: '/system/get-mail-templates',
time: 100,
@@ -169,12 +187,52 @@ module.exports = [
};
}
},
+ {
+ path: '/system/enable-user-system',
+ time: 100,
+ response: function () {
+ return {
+ status: 'success',
+ data: {}
+ }
+ }
+ },
+ {
+ path: '/system/disable-user-system',
+ time: 100,
+ response: function () {
+ return {
+ status: 'success',
+ data: {}
+ }
+ }
+ },
+ {
+ path: '/system/enable-registration',
+ time: 100,
+ response: function () {
+ return {
+ status: 'success',
+ data: {}
+ }
+ }
+ },
+ {
+ path: '/system/disable-registration',
+ time: 100,
+ response: function () {
+ return {
+ status: 'success',
+ data: {}
+ }
+ }
+ },
{
path: '/system/get-all-keys',
time: 300,
response: function () {
return {
- status: "success",
+ status: 'success',
data: [
{
name: 'Game System Registration',