From c98f18747c5173539560d7f83eef51eb1ef6e4f8 Mon Sep 17 00:00:00 2001 From: ArtemBaskal Date: Tue, 6 Oct 2020 11:54:06 +0300 Subject: [PATCH] + client: 2152 Smartphone compatible design for user interface --- client/src/components/App/index.css | 10 ++-- client/src/components/Dashboard/Dashboard.css | 21 ++++++++ client/src/components/Dashboard/index.js | 50 +++++++++---------- .../components/Settings/Dhcp/Interfaces.js | 10 ++-- client/src/components/Settings/Dhcp/index.css | 31 ++++++++++++ client/src/components/Settings/Dhcp/index.js | 45 ++++++++--------- client/src/components/Settings/FormButton.css | 11 ++++ .../components/Settings/LogsConfig/Form.js | 3 +- .../components/Settings/StatsConfig/Form.js | 3 +- client/src/components/ui/PageTitle.css | 12 ----- client/src/components/ui/PageTitle.js | 23 ++++----- client/src/helpers/form.js | 6 +-- 12 files changed, 134 insertions(+), 91 deletions(-) create mode 100644 client/src/components/Settings/Dhcp/index.css create mode 100644 client/src/components/Settings/FormButton.css diff --git a/client/src/components/App/index.css b/client/src/components/App/index.css index e2b0304d..31f34bce 100644 --- a/client/src/components/App/index.css +++ b/client/src/components/App/index.css @@ -63,10 +63,6 @@ body { cursor: not-allowed; } -.select--no-warning { - margin-bottom: 1.375rem; -} - .button-action { visibility: hidden; } @@ -75,3 +71,9 @@ body { .button-action--active { visibility: visible; } + +@media (max-width: 500px) { + .dashboard .button-action { + visibility: visible; + } +} diff --git a/client/src/components/Dashboard/Dashboard.css b/client/src/components/Dashboard/Dashboard.css index 6d3aef7f..3418e76e 100644 --- a/client/src/components/Dashboard/Dashboard.css +++ b/client/src/components/Dashboard/Dashboard.css @@ -33,3 +33,24 @@ right: 0; } } + +.page-title--dashboard { + display: flex; + align-items: center; +} + +.dashboard-title__button{ + margin: 0 0.5rem; +} + +@media (max-width: 767.98px) { + .page-title--dashboard { + flex-direction: column; + align-items: flex-start; + } + + .dashboard-title__button{ + margin: 0.5rem 0; + display: block; + } +} diff --git a/client/src/components/Dashboard/index.js b/client/src/components/Dashboard/index.js index 4d229ffb..4de5b8dd 100644 --- a/client/src/components/Dashboard/index.js +++ b/client/src/components/Dashboard/index.js @@ -1,7 +1,7 @@ import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; import { Trans, useTranslation } from 'react-i18next'; - +import classNames from 'classnames'; import Statistics from './Statistics'; import Counters from './Counters'; import Clients from './Clients'; @@ -17,6 +17,7 @@ const Dashboard = ({ getStats, getStatsConfig, dashboard, + dashboard: { protectionEnabled, processingProtection }, toggleProtection, stats, access, @@ -33,20 +34,12 @@ const Dashboard = ({ getAllStats(); }, []); - const getToggleFilteringButton = () => { - const { protectionEnabled, processingProtection } = dashboard; - const buttonText = protectionEnabled ? 'disable_protection' : 'enable_protection'; - const buttonClass = protectionEnabled ? 'btn-gray' : 'btn-success'; + const buttonText = protectionEnabled ? 'disable_protection' : 'enable_protection'; - return ; - }; + const buttonClass = classNames('btn btn-sm dashboard-title__button', { + 'btn-gray': protectionEnabled, + 'btn-success': !protectionEnabled, + }); const refreshButton = ; - const statsProcessing = stats.processingStats || stats.processingGetConfig || access.processing; return <> - -
- {getToggleFilteringButton()} - {refreshFullButton} -
+ + + {statsProcessing && } {!statsProcessing &&
diff --git a/client/src/components/Settings/Dhcp/Interfaces.js b/client/src/components/Settings/Dhcp/Interfaces.js index 0674c3fd..e1480d25 100644 --- a/client/src/components/Settings/Dhcp/Interfaces.js +++ b/client/src/components/Settings/Dhcp/Interfaces.js @@ -46,7 +46,7 @@ const renderInterfaceValues = ({ gateway_ip, hardware_address, ip_addresses, -}) =>
+}) =>
    {getInterfaceValues({ gateway_ip, @@ -78,11 +78,11 @@ const Interfaces = () => { && interfaces && <>
    -
    +
    @@ -91,9 +91,9 @@ const Interfaces = () => { {renderInterfaces(interfaces)} + {interfaceValue + && renderInterfaceValues(interfaceValue)}
    - {interfaceValue - && renderInterfaceValues(interfaceValue)}
    ; }; diff --git a/client/src/components/Settings/Dhcp/index.css b/client/src/components/Settings/Dhcp/index.css new file mode 100644 index 00000000..5395f85d --- /dev/null +++ b/client/src/components/Settings/Dhcp/index.css @@ -0,0 +1,31 @@ +.dhcp-form__button { + margin: 0 1rem; +} + +.page-title--dhcp { + display: flex; + align-items: center; +} + +.col__dhcp { + flex: 0 0 50%; + max-width: 50%; +} + +@media (max-width: 991.98px) { + .dhcp-form__button { + margin: 0.5rem 0; + display: block; + } + + .page-title--dhcp { + flex-direction: column; + align-items: flex-start; + padding-bottom: 0.5rem; + } + + .col__dhcp { + flex: 0 0 100%; + max-width: 100%; + } +} diff --git a/client/src/components/Settings/Dhcp/index.js b/client/src/components/Settings/Dhcp/index.js index 1def906c..05732c19 100644 --- a/client/src/components/Settings/Dhcp/index.js +++ b/client/src/components/Settings/Dhcp/index.js @@ -31,6 +31,7 @@ import { calculateDhcpPlaceholdersIpv4, calculateDhcpPlaceholdersIpv6, } from '../../../helpers/helpers'; +import './index.css'; const Dhcp = () => { const { t } = useTranslation(); @@ -114,7 +115,7 @@ const Dhcp = () => { .every(Boolean) || Object.values(v6) .every(Boolean)); - const className = classNames('btn btn-sm mr-2', { + const className = classNames('btn btn-sm', { 'btn-gray': enabled, 'btn-outline-success': !enabled, }); @@ -141,7 +142,7 @@ const Dhcp = () => { ; }; - const statusButtonClass = classNames('btn btn-sm mx-2', { + const statusButtonClass = classNames('btn btn-sm dhcp-form__button', { 'btn-loading btn-primary': processingStatus, 'btn-outline-primary': !processingStatus, }); @@ -171,28 +172,24 @@ const Dhcp = () => { const toggleDhcpButton = getToggleDhcpButton(); return <> - -
    -
    - {toggleDhcpButton} - - -
    -
    + + {toggleDhcpButton} + + {!processing && !processingInterfaces && <> diff --git a/client/src/components/Settings/FormButton.css b/client/src/components/Settings/FormButton.css new file mode 100644 index 00000000..99d9e3c4 --- /dev/null +++ b/client/src/components/Settings/FormButton.css @@ -0,0 +1,11 @@ +.form__button { + margin-left: 1.5rem; +} + +@media (max-width: 500px) { + .form__button { + margin-left: 0; + margin-top: 1rem; + display: block; + } +} diff --git a/client/src/components/Settings/LogsConfig/Form.js b/client/src/components/Settings/LogsConfig/Form.js index aa3b61b3..a89c89db 100644 --- a/client/src/components/Settings/LogsConfig/Form.js +++ b/client/src/components/Settings/LogsConfig/Form.js @@ -6,6 +6,7 @@ import flow from 'lodash/flow'; import { renderCheckboxField, renderRadioField, toNumber } from '../../../helpers/form'; import { FORM_NAME, QUERY_LOG_INTERVALS_DAYS } from '../../../helpers/constants'; +import '../FormButton.css'; const getIntervalFields = (processing, t, toNumber) => QUERY_LOG_INTERVALS_DAYS.map((interval) => { const title = interval === 1 ? t('interval_24_hour') : t('interval_days', { count: interval }); @@ -68,7 +69,7 @@ const Form = (props) => {