From 66bd06cf69b7482251a7d4b0321f029546a8decd Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Thu, 5 Sep 2019 19:07:14 +0300 Subject: [PATCH] + client: login page --- client/public/login.html | 17 +++ client/src/__locales/en.json | 12 +- client/src/__locales/ru.json | 9 +- client/src/actions/login.js | 20 +++ client/src/api/Api.js | 12 ++ client/src/components/App/index.js | 10 +- client/src/components/Header/Header.css | 117 +++++++++++------- client/src/components/Header/Menu.js | 2 +- client/src/components/Header/index.js | 32 ++--- client/src/components/ui/Footer.css | 20 ++- client/src/components/ui/Footer.js | 114 ++++++++++++----- client/src/components/ui/Icons.js | Bin 27827 -> 28151 bytes client/src/components/ui/PageTitle.css | 12 +- client/src/components/ui/Tabler.css | 2 +- client/src/components/ui/Version.css | 40 ++++++ .../src/components/{Header => ui}/Version.js | 22 +--- client/src/containers/Header.js | 8 +- client/src/helpers/form.js | 2 + client/src/install/Setup/Setup.css | 2 +- client/src/login/Login/Form.js | 75 +++++++++++ client/src/login/Login/Login.css | 47 +++++++ client/src/login/Login/index.js | 90 ++++++++++++++ client/src/login/index.js | 18 +++ client/src/reducers/index.js | 4 +- client/src/reducers/login.js | 24 ++++ client/webpack.common.js | 10 ++ 26 files changed, 603 insertions(+), 118 deletions(-) create mode 100644 client/public/login.html create mode 100644 client/src/actions/login.js create mode 100644 client/src/components/ui/Version.css rename client/src/components/{Header => ui}/Version.js (53%) create mode 100644 client/src/login/Login/Form.js create mode 100644 client/src/login/Login/Login.css create mode 100644 client/src/login/Login/index.js create mode 100644 client/src/login/index.js create mode 100644 client/src/reducers/login.js diff --git a/client/public/login.html b/client/public/login.html new file mode 100644 index 00000000..03179b42 --- /dev/null +++ b/client/public/login.html @@ -0,0 +1,17 @@ + + + + + + + + + Login + + + +
+ + diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index d472dc50..a978b315 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -199,7 +199,7 @@ "install_settings_dns_desc": "You will need to configure your devices or router to use the DNS server on the following addresses:", "install_settings_all_interfaces": "All interfaces", "install_auth_title": "Authentication", - "install_auth_desc": "It is highly recommended to configure password authentication to your AdGuard Home admin web interface. Even if it is accessible only in your local network, it is still important to to protect it from unrestricted access.", + "install_auth_desc": "It is highly recommended to configure password authentication to your AdGuard Home admin web interface. Even if it is accessible only in your local network, it is still important to protect it from unrestricted access.", "install_auth_username": "Username", "install_auth_password": "Password", "install_auth_confirm": "Confirm password", @@ -384,5 +384,13 @@ "filters_configuration": "Filters configuration", "filters_enable": "Enable filters", "filters_interval": "Filters update interval", - "disabled": "Disabled" + "disabled": "Disabled", + "username_label": "Username", + "username_placeholder": "Enter username", + "password_label": "Password", + "password_placeholder": "Enter password", + "sign_in": "Sign in", + "logout": "Logout", + "forgot_password": "Forgot password?", + "forgot_password_desc": "Please follow <0>these steps to create a new password for your user account." } diff --git a/client/src/__locales/ru.json b/client/src/__locales/ru.json index 88799f70..322d05f0 100644 --- a/client/src/__locales/ru.json +++ b/client/src/__locales/ru.json @@ -352,10 +352,17 @@ "unblock_all": "Разблокировать все", "domain": "Домен", "answer": "Ответ", + "interval_24_hour": "24 часа", "interval_hours_0": "{{count}} час", "interval_hours_1": "{{count}} часа", "interval_hours_2": "{{count}} часов", "interval_days_0": "{{count}} день", "interval_days_1": "{{count}} дня", - "interval_days_2": "{{count}} дней" + "interval_days_2": "{{count}} дней", + "for_last_days_0": "за последний {{count}} день", + "for_last_days_1": "за последние {{count}} дня", + "for_last_days_2": "за последние {{count}} дней", + "number_of_dns_query_days_0": "Количество DNS-запросов за {{count}} день", + "number_of_dns_query_days_1": "Количество DNS-запросов за {{count}} дня", + "number_of_dns_query_days_2": "Количество DNS-запросов за {{count}} дней" } \ No newline at end of file diff --git a/client/src/actions/login.js b/client/src/actions/login.js new file mode 100644 index 00000000..90cc0780 --- /dev/null +++ b/client/src/actions/login.js @@ -0,0 +1,20 @@ +import { createAction } from 'redux-actions'; + +import { addErrorToast } from './index'; +import apiClient from '../api/Api'; + +export const processLoginRequest = createAction('PROCESS_LOGIN_REQUEST'); +export const processLoginFailure = createAction('PROCESS_LOGIN_FAILURE'); +export const processLoginSuccess = createAction('PROCESS_LOGIN_SUCCESS'); + +export const processLogin = values => async (dispatch) => { + dispatch(processLoginRequest()); + try { + await apiClient.login(values); + window.location.replace(window.location.origin); + dispatch(processLoginSuccess()); + } catch (error) { + dispatch(addErrorToast({ error })); + dispatch(processLoginFailure()); + } +}; diff --git a/client/src/api/Api.js b/client/src/api/Api.js index 187b7312..b7a7d045 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -510,6 +510,18 @@ class Api { const { path, method } = this.QUERY_LOG_CLEAR; return this.makeRequest(path, method); } + + // Login + LOGIN = { path: 'login', method: 'POST' }; + + login(data) { + const { path, method } = this.LOGIN; + const config = { + data, + headers: { 'Content-Type': 'application/json' }, + }; + return this.makeRequest(path, method, config); + } } const apiClient = new Api(); diff --git a/client/src/components/App/index.js b/client/src/components/App/index.js index 6489649c..3fd4d1a5 100644 --- a/client/src/components/App/index.js +++ b/client/src/components/App/index.js @@ -64,7 +64,7 @@ class App extends Component { }; render() { - const { dashboard, encryption } = this.props; + const { dashboard, encryption, getVersion } = this.props; const updateAvailable = dashboard.isCoreRunning && dashboard.isUpdateAvailable; return ( @@ -109,7 +109,12 @@ class App extends Component { )} -