From a077a196398e6770cf97e46f8fe561f99a81bab2 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 4 Jan 2017 15:27:16 -0300 Subject: [PATCH 1/4] Max Red - Admin panel system preferences first layout WIP [skip ci] --- client/src/app-components/toggle-button.js | 32 ++++++ client/src/app-components/toggle-button.scss | 9 ++ .../admin-panel-system-preferences.js | 97 ++++++++++++++++++- .../admin-panel-system-preferences.scss | 32 ++++++ client/src/app/demo/components-demo-page.js | 1 + client/src/core-components/input.js | 2 +- client/src/core-components/input.scss | 4 + client/src/data/languages/en.js | 19 ++++ 8 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 client/src/app-components/toggle-button.js create mode 100644 client/src/app-components/toggle-button.scss create mode 100644 client/src/app/admin/panel/settings/admin-panel-system-preferences.scss diff --git a/client/src/app-components/toggle-button.js b/client/src/app-components/toggle-button.js new file mode 100644 index 00000000..dda2a00d --- /dev/null +++ b/client/src/app-components/toggle-button.js @@ -0,0 +1,32 @@ +import React from 'react'; + +import i18n from 'lib-app/i18n'; + +class ToggleButton extends React.Component { + + + static propTypes = { + value: React.PropTypes.bool, + onChange: React.PropTypes.func + }; + + render() { + return ( +
+ {this.props.value ? i18n('ON') : i18n('OFF')} +
+ ); + } + + onClick() { + if (this.props.onChange) { + this.props.onChange({ + target: { + value: !this.props.value + } + }); + } + } +} + +export default ToggleButton; \ No newline at end of file diff --git a/client/src/app-components/toggle-button.scss b/client/src/app-components/toggle-button.scss new file mode 100644 index 00000000..4711e8fe --- /dev/null +++ b/client/src/app-components/toggle-button.scss @@ -0,0 +1,9 @@ +@import "../scss/vars"; + +.toggle-button { + background-color: $light-grey; + width: 80px; + padding: 2px; + border-radius: 4px; + text-align: center; +} \ No newline at end of file diff --git a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js index cbeafabe..fa083b59 100644 --- a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js +++ b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js @@ -1,14 +1,107 @@ import React from 'react'; +import Form from 'core-components/form'; +import FormField from 'core-components/form-field'; +import Header from 'core-components/header'; +import SubmitButton from 'core-components/submit-button'; +import Button from 'core-components/button'; + +import ToggleButton from 'app-components/toggle-button'; +import i18n from 'lib-app/i18n'; + class AdminPanelSystemPreferences extends React.Component { + state = { + values: { + 'maintenance': false + } + }; + render() { return ( -
- /admin/panel/settings/system-preferences +
+
+
this.setState({values})} onSubmit={this.onSubmit.bind(this)}> +
+ Maintenance Mode + +
+ +
+
+ + +
+
+ + +
+
+ +
+
+asd +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ {i18n('ALLOW_FILE_ATTACHMENTS')} + +
+
+
+
+ {i18n('MAX_SIZE_KB')} + +
+
+
+
+
+
+
+ {i18n('UPDATE_SYSTEM')} +
+
+ +
+
+
); } + + onSubmit() { + alert('WESA'); + } } export default AdminPanelSystemPreferences; \ No newline at end of file diff --git a/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss b/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss new file mode 100644 index 00000000..ae2962fc --- /dev/null +++ b/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss @@ -0,0 +1,32 @@ +@import "../../../../scss/vars"; + +.admin-panel-system-preferences { + + &__maintenance { + text-align: left; + } + + &__maintenance-field { + display: inline-block; + margin-left: 30px; + } + + &__file-attachments { + margin-top: 8px; + text-align: left; + } + + &__file-attachments-field { + display: inline-block; + margin-left: 30px; + } + + &__max-size { + text-align: left; + } + + &__max-size-field { + display: inline-block; + margin-left: 30px; + } +} \ No newline at end of file diff --git a/client/src/app/demo/components-demo-page.js b/client/src/app/demo/components-demo-page.js index e3f68b67..5244975c 100644 --- a/client/src/app/demo/components-demo-page.js +++ b/client/src/app/demo/components-demo-page.js @@ -16,6 +16,7 @@ const Menu = require('core-components/menu'); const Tooltip = require('core-components/tooltip'); const Table = require('core-components/table'); const InfoTooltip = require('core-components/info-tooltip'); +const ToggleButton = require('app-components/toggle-button'); let dropDownItems = [{content: 'English'}, {content: 'Spanish'}, {content: 'German'}, {content: 'Portuguese'}, {content: 'Japanese'}]; let secondaryMenuItems = [ diff --git a/client/src/core-components/input.js b/client/src/core-components/input.js index d1a01476..8d9271d4 100644 --- a/client/src/core-components/input.js +++ b/client/src/core-components/input.js @@ -14,7 +14,7 @@ class Input extends React.Component { value: React.PropTypes.string, validation: React.PropTypes.string, onChange: React.PropTypes.func, - size: React.PropTypes.oneOf(['small', 'medium', 'large']), + size: React.PropTypes.oneOf(['small', 'medium', 'large', 'auto']), password: React.PropTypes.bool, required: React.PropTypes.bool, icon: React.PropTypes.string, diff --git a/client/src/core-components/input.scss b/client/src/core-components/input.scss index 2bcb1f54..f312de99 100644 --- a/client/src/core-components/input.scss +++ b/client/src/core-components/input.scss @@ -19,6 +19,10 @@ } } + &_auto { + width: 100%; + } + &_small { width: 200px; } diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index b1472eee..cdf88c81 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -118,6 +118,25 @@ export default { 'COMMENTS': 'Comments', 'DELETE_STAFF_MEMBER': 'Delete staff member', 'MAINTENANCE_MODE': 'Maintenance mode', + 'SUPPORT_CENTER_URL': 'Support Center URL', + 'SUPPORT_CENTER_TITLE': 'Support Center Title', + 'SUPPORT_CENTER_LAYOUT': 'Support Center Layout', + 'DEFAULT_TIMEZONE': 'Default Timezone', + 'NOREPLY_EMAIL': 'Noreply Email', + 'SMTP_USER': 'SMTP User', + 'SMTP_SERVER': 'SMTP Server', + 'SMTP_PASSWORD': 'SMTP Password', + 'PORT': 'Port', + 'RECAPTCHA_PUBLIC_KEY': 'Recaptcha Public Key', + 'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Private Key', + 'ALLOW_FILE_ATTACHMENTS': 'Allow file attachments', + 'MAX_SIZE_KB': 'Max Size (KB)', + 'UPDATE_SYSTEM': 'Update system', + 'DISCARD_CHANGES': 'Discard changes', + 'ON': 'On', + 'OFF': 'Off', + 'BOXED': 'Boxed', + 'FULL_WIDTH': 'Full width', //VIEW DESCRIPTIONS 'CREATE_TICKET_DESCRIPTION': 'This is a form for creating tickets. Fill the form and send us your issues/doubts/suggestions. Our support system will answer it as soon as possible.', From f6a0ab29a08f1caf2bacea26a1b12e367b350fbe Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 4 Jan 2017 17:57:20 -0300 Subject: [PATCH 2/4] Max Red - Modified fixtures, added recoverSettings and modified visual layout [skip ci] --- .../admin-panel-system-preferences.js | 133 +++++++++++++----- .../admin-panel-system-preferences.scss | 16 +++ client/src/data/fixtures/system-fixtures.js | 62 +++++--- client/src/data/languages/en.js | 3 +- 4 files changed, 163 insertions(+), 51 deletions(-) diff --git a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js index fa083b59..98776505 100644 --- a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js +++ b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js @@ -1,4 +1,6 @@ import React from 'react'; +import _ from 'lodash'; +import languageList from 'data/language-list'; import Form from 'core-components/form'; import FormField from 'core-components/form-field'; @@ -6,6 +8,7 @@ import Header from 'core-components/header'; import SubmitButton from 'core-components/submit-button'; import Button from 'core-components/button'; +import API from 'lib-app/api-call'; import ToggleButton from 'app-components/toggle-button'; import i18n from 'lib-app/i18n'; @@ -17,73 +20,92 @@ class AdminPanelSystemPreferences extends React.Component { } }; + componentDidMount() { + this.recoverSettings(); + } + render() { return (
this.setState({values})} onSubmit={this.onSubmit.bind(this)}> -
- Maintenance Mode - +
+
+
+ Maintenance Mode + +
+
+
+
+
+ +
-
- +
-
-
-asd -
-
+
+
- - + +
- + +
- +
-
+
+
+
+
-
-
- +
+
+
+
+
{i18n('ALLOWED_LANGUAGES')}
+
-
- +
+
{i18n('SUPPORTED_LANGUAGES')}
+
+
+
+ + +
+ {i18n('ALLOW_FILE_ATTACHMENTS')} + +
+
+ {i18n('MAX_SIZE_KB')} + +
+
+
+
+
-
-
-
- {i18n('ALLOW_FILE_ATTACHMENTS')} - -
-
-
-
- {i18n('MAX_SIZE_KB')} - -
-
-
@@ -102,6 +124,49 @@ asd onSubmit() { alert('WESA'); } + + getLanguageList() { + return Object.keys(languageList).map(key => languageList[key].name); + } + + recoverSettings() { + API.call({ + path: '/system/get-settings', + data: { + allSettings: true + } + }).then(this.onRecoverSettingsSuccess.bind(this)).catch(this.onRecoverSettingsFail.bind(this)); + } + + onRecoverSettingsSuccess(result) { + let fullList = Object.keys(languageList); + this.setState({ + values: { + 'language': result.data.language, + 'reCaptchaKey': result.data.reCaptchaKey, + 'reCaptchaPrivate': result.data.reCaptchaPrivate, + 'url': result.data['url'], + 'title': result.data['title'], + 'layout': result.data['layout'] == 'Full width' ? 1 : 0, + 'time-zone': result.data['time-zone'], + 'no-reply-email': result.data['no-reply-email'], + 'smtp-host': result.data['smtp-host'], + 'smtp-port': result.data['smtp-port'], + 'smtp-user': result.data['smtp-user'], + 'smtp-pass': '', + 'maintenance-mode': result.data['maintenance-mode'], + 'file-attachments': result.data['file-attachments'], + 'max-size': result.data['max-size'], + 'departments': result.data.departments, + 'allowedLanguages': result.data.allowedLanguages.map(lang => (_.indexOf(fullList, lang))), + 'supportedLanguages': result.data.supportedLanguages.map(lang => (_.indexOf(fullList, lang))) + } + }); + } + + onRecoverSettingsFail(result) { + + } } export default AdminPanelSystemPreferences; \ No newline at end of file diff --git a/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss b/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss index ae2962fc..a468c5c3 100644 --- a/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss +++ b/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss @@ -29,4 +29,20 @@ display: inline-block; margin-left: 30px; } + + &__languages { + margin: 0 auto; + + &-allowed { + text-align: left; + display: inline-block; + //background-color: red; + } + + &-supported { + text-align: left; + display: inline-block; + //background-color: $light-grey; + } + } } \ No newline at end of file diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index a699df1c..c8f1ffd6 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -2,22 +2,52 @@ module.exports = [ { path: '/system/get-settings', time: 1000, - response: function () { - return { - status: 'success', - data: { - 'language': 'en', - 'reCaptchaKey': '6LfM5CYTAAAAAGLz6ctpf-hchX2_l0Ge-Bn-n8wS', - 'maintenance-mode': false, - 'departments': [ - {id: 1, name: 'Sales Support', owners: 2}, - {id: 2, name: 'Technical Issues', owners: 5}, - {id: 3, name: 'System and Administration', owners: 0} - ], - 'allowedLanguages': ['en', 'es', 'de', 'fr', 'pt', 'jp', 'ru', 'cn', 'in', 'tr'], - 'supportedLanguages': ['en', 'es', 'de'] - } - }; + response: function (params) { + if(params && params.allSettings) { + return { + status: 'success', + data: { + 'language': 'en', + 'reCaptchaKey': '6LfM5CYTAAAAAGLz6ctpf-hchX2_l0Ge-Bn-n8wS', + 'reCaptchaPrivate': 'LALA', + 'url': 'hola@lala.com', + 'title': 'Very Cool', + 'layout': 'Boxed', + 'time-zone': 3, + 'no-reply-email': 'shitr@post.com', + 'smtp-host': 'localhost', + 'smtp-port': '7070', + 'smtp-user': 'Wesa', + 'maintenance-mode': false, + 'fileAttachments': false, + 'max-size': 500, + 'departments': [ + {id: 1, name: 'Sales Support', owners: 2}, + {id: 2, name: 'Technical Issues', owners: 5}, + {id: 3, name: 'System and Administration', owners: 0} + ], + 'allowedLanguages': ['en', 'es', 'de', 'fr', 'pt', 'jp', 'ru', 'cn', 'in', 'tr'], + 'supportedLanguages': ['en', 'es', 'de'] + } + }; + + } else { + return { + status: 'success', + data: { + 'language': 'en', + 'reCaptchaKey': '6LfM5CYTAAAAAGLz6ctpf-hchX2_l0Ge-Bn-n8wS', + 'maintenance-mode': false, + 'departments': [ + {id: 1, name: 'Sales Support', owners: 2}, + {id: 2, name: 'Technical Issues', owners: 5}, + {id: 3, name: 'System and Administration', owners: 0} + ], + 'allowedLanguages': ['en', 'es', 'de', 'fr', 'pt', 'jp', 'ru', 'cn', 'in', 'tr'], + 'supportedLanguages': ['en', 'es', 'de'] + } + }; + } } }, { diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index cdf88c81..5ca8b107 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -132,7 +132,8 @@ export default { 'ALLOW_FILE_ATTACHMENTS': 'Allow file attachments', 'MAX_SIZE_KB': 'Max Size (KB)', 'UPDATE_SYSTEM': 'Update system', - 'DISCARD_CHANGES': 'Discard changes', + 'SUPPORTED_LANGUAGES': 'Supported Languages', + 'ALLOWED_LANGUAGES': 'Allowed Languages', 'ON': 'On', 'OFF': 'Off', 'BOXED': 'Boxed', From 3af899efcddc546658e776b046f136fc4ddb16e6 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 4 Jan 2017 18:39:15 -0300 Subject: [PATCH 3/4] Max Red - Add default language select [skip ci] --- .../admin-panel-system-preferences.js | 49 ++++++++++++++++--- client/src/data/fixtures/system-fixtures.js | 10 ++++ client/src/data/languages/en.js | 3 +- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js index 98776505..e35e68d2 100644 --- a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js +++ b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js @@ -7,6 +7,7 @@ import FormField from 'core-components/form-field'; import Header from 'core-components/header'; import SubmitButton from 'core-components/submit-button'; import Button from 'core-components/button'; +import Message from 'core-components/message'; import API from 'lib-app/api-call'; import ToggleButton from 'app-components/toggle-button'; @@ -15,6 +16,8 @@ import i18n from 'lib-app/i18n'; class AdminPanelSystemPreferences extends React.Component { state = { + loading: true, + message: false, values: { 'maintenance': false } @@ -28,7 +31,7 @@ class AdminPanelSystemPreferences extends React.Component { return (
- this.setState({values})} onSubmit={this.onSubmit.bind(this)}> + this.setState({values})} onSubmit={this.onSubmit.bind(this)} loading={this.state.loading}>
@@ -101,6 +104,10 @@ class AdminPanelSystemPreferences extends React.Component { {i18n('MAX_SIZE_KB')}
+
@@ -110,7 +117,7 @@ class AdminPanelSystemPreferences extends React.Component {
- {i18n('UPDATE_SYSTEM')} + {i18n('UPDATE_SETTINGS')}
@@ -121,8 +128,37 @@ class AdminPanelSystemPreferences extends React.Component { ); } - onSubmit() { - alert('WESA'); + onSubmit(form) { + let fullList = Object.keys(languageList); + this.setState({loading: true}); + + API.call({ + path: '/system/edit-settings', + data: { + 'language': fullList[form.language], + 'reCaptchaKey': form.reCaptchaKey, + 'reCaptchaPrivate': form.reCaptchaPrivate, + 'url': form['url'], + 'title': form['title'], + 'layout': form['layout'] == 1 ? 'Full width' : 'Boxed', + 'time-zone': form['time-zone'], + 'no-reply-email': form['no-reply-email'], + 'smtp-host': form['smtp-host'], + 'smtp-port': form['smtp-port'], + 'smtp-user': form['smtp-user'], + 'smtp-pass': form['smtp-password'], + 'maintenance-mode': form['maintenance-mode'], + 'file-attachments': form['file-attachments'], + 'max-size': form['max-size'], + 'allowedLanguages': form.allowedLanguages.map(index => fullList[index]), + 'supportedLanguages': form.supportedLanguages.map(index => fullList[index]) + } + }).then(this.onSubmitSuccess.bind(this)); + } + + onSubmitSuccess() { + this.recoverSettings(); + } getLanguageList() { @@ -140,9 +176,11 @@ class AdminPanelSystemPreferences extends React.Component { onRecoverSettingsSuccess(result) { let fullList = Object.keys(languageList); + this.setState({ + loading: false, values: { - 'language': result.data.language, + 'language': _.indexOf(fullList, result.data.language), 'reCaptchaKey': result.data.reCaptchaKey, 'reCaptchaPrivate': result.data.reCaptchaPrivate, 'url': result.data['url'], @@ -157,7 +195,6 @@ class AdminPanelSystemPreferences extends React.Component { 'maintenance-mode': result.data['maintenance-mode'], 'file-attachments': result.data['file-attachments'], 'max-size': result.data['max-size'], - 'departments': result.data.departments, 'allowedLanguages': result.data.allowedLanguages.map(lang => (_.indexOf(fullList, lang))), 'supportedLanguages': result.data.supportedLanguages.map(lang => (_.indexOf(fullList, lang))) } diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index c8f1ffd6..6ab473be 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -50,6 +50,16 @@ module.exports = [ } } }, + { + path: '/system/edit-settings', + time: 50, + response: function() { + return { + status: 'success', + data: {} + } + } + }, { path: '/staff/add-department', time: 100, diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 5ca8b107..1db093b1 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -131,7 +131,8 @@ export default { 'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Private Key', 'ALLOW_FILE_ATTACHMENTS': 'Allow file attachments', 'MAX_SIZE_KB': 'Max Size (KB)', - 'UPDATE_SYSTEM': 'Update system', + 'UPDATE_SETTINGS': 'Update settings', + 'DEFAULT_LANGUAGE': 'Default Language', 'SUPPORTED_LANGUAGES': 'Supported Languages', 'ALLOWED_LANGUAGES': 'Allowed Languages', 'ON': 'On', From 68fe99f395ac25d820c7ed4e18ee4c228b058009 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 4 Jan 2017 19:28:53 -0300 Subject: [PATCH 4/4] Max Red - Add functionality to "Discard changes" button, modified fixtures [skip ci] --- .../admin-panel-system-preferences.js | 61 +++++++++++++------ .../admin-panel-system-preferences.scss | 10 ++- client/src/data/fixtures/system-fixtures.js | 2 +- client/src/data/languages/en.js | 2 + 4 files changed, 52 insertions(+), 23 deletions(-) diff --git a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js index e35e68d2..03ed99a7 100644 --- a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js +++ b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js @@ -10,14 +10,15 @@ import Button from 'core-components/button'; import Message from 'core-components/message'; import API from 'lib-app/api-call'; -import ToggleButton from 'app-components/toggle-button'; import i18n from 'lib-app/i18n'; +import LanguageSelector from 'app-components/language-selector'; +import ToggleButton from 'app-components/toggle-button'; class AdminPanelSystemPreferences extends React.Component { state = { loading: true, - message: false, + message: null, values: { 'maintenance': false } @@ -31,7 +32,7 @@ class AdminPanelSystemPreferences extends React.Component { return (
- this.setState({values})} onSubmit={this.onSubmit.bind(this)} loading={this.state.loading}> + this.setState({values, message: null})} onSubmit={this.onSubmit.bind(this)} loading={this.state.loading}>
@@ -98,16 +99,13 @@ class AdminPanelSystemPreferences extends React.Component {
{i18n('ALLOW_FILE_ATTACHMENTS')} - +
{i18n('MAX_SIZE_KB')}
- +
@@ -120,14 +118,26 @@ class AdminPanelSystemPreferences extends React.Component { {i18n('UPDATE_SETTINGS')}
- +
+ {this.renderMessage()}
); } + renderMessage() { + switch (this.state.message) { + case 'success': + return {i18n('SETTINGS_UPDATED')}; + case 'fail': + return {i18n('ERROR_UPDATING_SETTINGS')}; + default: + return null; + } + } + onSubmit(form) { let fullList = Object.keys(languageList); this.setState({loading: true}); @@ -135,9 +145,9 @@ class AdminPanelSystemPreferences extends React.Component { API.call({ path: '/system/edit-settings', data: { - 'language': fullList[form.language], - 'reCaptchaKey': form.reCaptchaKey, - 'reCaptchaPrivate': form.reCaptchaPrivate, + 'language': form.language, + 'recaptcha-public': form.reCaptchaKey, + 'recaptcha-private': form.reCaptchaPrivate, 'url': form['url'], 'title': form['title'], 'layout': form['layout'] == 1 ? 'Full width' : 'Boxed', @@ -148,17 +158,20 @@ class AdminPanelSystemPreferences extends React.Component { 'smtp-user': form['smtp-user'], 'smtp-pass': form['smtp-password'], 'maintenance-mode': form['maintenance-mode'], - 'file-attachments': form['file-attachments'], + 'allow-attachments': form['allow-attachments'], 'max-size': form['max-size'], - 'allowedLanguages': form.allowedLanguages.map(index => fullList[index]), - 'supportedLanguages': form.supportedLanguages.map(index => fullList[index]) + 'allowedLanguages': JSON.stringify(form.allowedLanguages.map(index => fullList[index])), + 'supportedLanguages': JSON.stringify(form.supportedLanguages.map(index => fullList[index])) } - }).then(this.onSubmitSuccess.bind(this)); + }).then(this.onSubmitSuccess.bind(this)).catch(() => this.setState({loading: false, message: 'fail'})); } onSubmitSuccess() { this.recoverSettings(); - + this.setState({ + message: 'success', + loading: false + }); } getLanguageList() { @@ -180,7 +193,7 @@ class AdminPanelSystemPreferences extends React.Component { this.setState({ loading: false, values: { - 'language': _.indexOf(fullList, result.data.language), + 'language': result.data.language, 'reCaptchaKey': result.data.reCaptchaKey, 'reCaptchaPrivate': result.data.reCaptchaPrivate, 'url': result.data['url'], @@ -193,7 +206,7 @@ class AdminPanelSystemPreferences extends React.Component { 'smtp-user': result.data['smtp-user'], 'smtp-pass': '', 'maintenance-mode': result.data['maintenance-mode'], - 'file-attachments': result.data['file-attachments'], + 'allow-attachments': result.data['allow-attachments'], 'max-size': result.data['max-size'], 'allowedLanguages': result.data.allowedLanguages.map(lang => (_.indexOf(fullList, lang))), 'supportedLanguages': result.data.supportedLanguages.map(lang => (_.indexOf(fullList, lang))) @@ -202,7 +215,15 @@ class AdminPanelSystemPreferences extends React.Component { } onRecoverSettingsFail(result) { - + this.setState({ + message: 'error' + }); + } + + onDiscardChangesSubmit(event) { + event.preventDefault(); + this.setState({loading: true}); + this.recoverSettings(); } } diff --git a/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss b/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss index a468c5c3..9ee30de5 100644 --- a/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss +++ b/client/src/app/admin/panel/settings/admin-panel-system-preferences.scss @@ -36,13 +36,19 @@ &-allowed { text-align: left; display: inline-block; - //background-color: red; } &-supported { text-align: left; display: inline-block; - //background-color: $light-grey; } } + + &__default-language-field { + text-align: left; + } + + &__message { + margin-top: 20px; + } } \ No newline at end of file diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index 6ab473be..64614032 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -19,7 +19,7 @@ module.exports = [ 'smtp-port': '7070', 'smtp-user': 'Wesa', 'maintenance-mode': false, - 'fileAttachments': false, + 'allow-attachments': true, 'max-size': 500, 'departments': [ {id: 1, name: 'Sales Support', owners: 2}, diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 1db093b1..73f07de6 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -135,6 +135,7 @@ export default { 'DEFAULT_LANGUAGE': 'Default Language', 'SUPPORTED_LANGUAGES': 'Supported Languages', 'ALLOWED_LANGUAGES': 'Allowed Languages', + 'SETTINGS_UPDATED': 'Settings have been updated', 'ON': 'On', 'OFF': 'Off', 'BOXED': 'Boxed', @@ -189,6 +190,7 @@ export default { 'ERROR_RETRIEVING_BAN_LIST': 'An error occurred while trying to retrieve the list of banned emails.', 'ERROR_BANNING_EMAIL': 'An error occurred while trying to ban the email.', 'ERROR_RETRIEVING_ARTICLES': 'An error occurred while trying to retrieve articles.', + 'ERROR_UPDATING_SETTINGS': 'An error ocurred while trying to update settings.', //MESSAGES 'SIGNUP_SUCCESS': 'You have registered successfully in our support system.',