From 8dc4dd82f5815c046b163ae0e727dfda3cf05298 Mon Sep 17 00:00:00 2001 From: hazeltonbw Date: Tue, 25 Jun 2024 22:05:17 -0700 Subject: [PATCH 01/10] Admin panel overhaul to admin preferences, translations updated. --- .../app/components/HeaderButtonsComponent.tsx | 2 +- .../app/components/admin/AdminComponent.tsx | 37 +- .../app/components/admin/AdminSideBar.tsx | 56 ++ .../components/admin/PreferencesComponent.tsx | 529 +++++++++--------- src/client/app/translations/data.ts | 42 +- 5 files changed, 362 insertions(+), 304 deletions(-) create mode 100644 src/client/app/components/admin/AdminSideBar.tsx diff --git a/src/client/app/components/HeaderButtonsComponent.tsx b/src/client/app/components/HeaderButtonsComponent.tsx index 5e289288e..9e01a718f 100644 --- a/src/client/app/components/HeaderButtonsComponent.tsx +++ b/src/client/app/components/HeaderButtonsComponent.tsx @@ -209,7 +209,7 @@ export default function HeaderButtonsComponent() { disabled={state.shouldAdminButtonDisabled} tag={Link} to="/admin"> - + ('graph'); + - const sectionTitleStyle: React.CSSProperties = { - fontWeight: 'bold', - margin: 0, - paddingBottom: '5px' - }; const titleStyle: React.CSSProperties = { - textAlign: 'center' + textAlign: 'start', + paddingLeft: '10px', + margin: 0 }; const tooltipStyle = { display: 'inline', fontSize: '50%' }; return ( -
+
-
-

- +
+

+

-
-
-
-

:

-
- -
+
+ +
+
+
-
diff --git a/src/client/app/components/admin/AdminSideBar.tsx b/src/client/app/components/admin/AdminSideBar.tsx new file mode 100644 index 000000000..8c6bd7542 --- /dev/null +++ b/src/client/app/components/admin/AdminSideBar.tsx @@ -0,0 +1,56 @@ +import * as React from 'react'; + +interface SidebarProps { + onSelectPreference: (preference: string) => void, + selectedPreference: string; +} + +/** + * Admin navigation side bar + * @param props Props for side bar + * @returns Admin navigation side bar + */ +export default function AdminSideBar(props: SidebarProps): React.JSX.Element { + return ( +
+
+ + + + + +
+ +
+ ); +} diff --git a/src/client/app/components/admin/PreferencesComponent.tsx b/src/client/app/components/admin/PreferencesComponent.tsx index fee69356a..3eb598d85 100644 --- a/src/client/app/components/admin/PreferencesComponent.tsx +++ b/src/client/app/components/admin/PreferencesComponent.tsx @@ -17,12 +17,15 @@ import translate from '../../utils/translate'; import TimeZoneSelect from '../TimeZoneSelect'; import { defaultAdminState } from '../../redux/slices/adminSlice'; +interface PreferencesProps { + selectedPreference: string; +} // TODO: Add warning for invalid data /** * @returns Preferences Component for Administrative use */ -export default function PreferencesComponent() { +export default function PreferencesComponent(props: PreferencesProps) { const { data: adminPreferences = defaultAdminState } = preferencesApi.useGetPreferencesQuery(); const [localAdminPref, setLocalAdminPref] = React.useState(cloneDeep(adminPreferences)); const [submitPreferences] = preferencesApi.useSubmitPreferencesMutation(); @@ -47,271 +50,299 @@ export default function PreferencesComponent() { successMessage='updated.preferences' failureMessage='failed.to.submit.changes' /> -
-

- {`${translate('default.site.title')}:`} -

- makeLocalChanges('displayTitle', e.target.value)} - maxLength={50} - /> -
-
-

- : -

- { - Object.values(ChartTypes).map(chartType => ( -
- -
- )) - } -
-

- : -

-
- -
-
- -
-
+ {/* Graph Settings */} + {props.selectedPreference === 'graph' && + <> +
+

+ : +

+ { + Object.values(ChartTypes).map(chartType => ( +
+ +
+ )) + } +

- {translate('default.area.unit')} - + :

-
+
-
+
-
-
-

- {translate('default.language')} -

-
- +
+

+ {translate('default.area.unit')} + +

+
+ +
+
+ +
-
- + + } + {/* Misc Settings */} + {props.selectedPreference === 'misc' && + <> +
+

+ {`${translate('site.title')}:`} +

+ makeLocalChanges('displayTitle', e.target.value)} + maxLength={50} + />
-
- +
+

+ : +

+ makeLocalChanges('defaultHelpUrl', e.target.value)} + />
-
-
-

- {`${translate('default.time.zone')}:`} -

- makeLocalChanges('defaultTimezone', e)} /> -
-
-

- {`${translate('default.warning.file.size')}:`} -

- makeLocalChanges('defaultWarningFileSize', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.file.size.limit')}:`} -

- makeLocalChanges('defaultFileSizeLimit', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.meter.reading.frequency')}:`} -

- makeLocalChanges('defaultMeterReadingFrequency', e.target.value)} - /> -
-
-

- {`${translate('default.meter.minimum.value')}:`} -

- makeLocalChanges('defaultMeterMinimumValue', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.meter.maximum.value')}:`} -

- makeLocalChanges('defaultMeterMaximumValue', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.meter.minimum.date')}:`} -

- makeLocalChanges('defaultMeterMinimumDate', e.target.value)} - placeholder='YYYY-MM-DD HH:MM:SS' - /> -
-
-

- {`${translate('default.meter.maximum.date')}:`} -

- makeLocalChanges('defaultMeterMaximumDate', e.target.value)} - placeholder='YYYY-MM-DD HH:MM:SS' - /> -
-
-

- {`${translate('default.meter.reading.gap')}:`} -

- makeLocalChanges('defaultMeterReadingGap', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.meter.maximum.errors')}:`} -

- makeLocalChanges('defaultMeterMaximumErrors', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.meter.disable.checks')}:`} -

- makeLocalChanges('defaultMeterDisableChecks', e.target.value)}> - {Object.keys(TrueFalseType).map(key => { - return (); - })} - -
-
-

- : -

- makeLocalChanges('defaultHelpUrl', e.target.value)} - /> -
+ + } + + {/* Meter Settings */} + + {props.selectedPreference === 'meter' && + <> +
+

+ {`${translate('default.meter.reading.frequency')}:`} +

+ makeLocalChanges('defaultMeterReadingFrequency', e.target.value)} + /> +
+
+

+ {`${translate('default.meter.minimum.value')}:`} +

+ makeLocalChanges('defaultMeterMinimumValue', e.target.value)} + maxLength={50} + /> +
+
+

+ {`${translate('default.meter.maximum.value')}:`} +

+ makeLocalChanges('defaultMeterMaximumValue', e.target.value)} + maxLength={50} + /> +
+
+

+ {`${translate('default.meter.minimum.date')}:`} +

+ makeLocalChanges('defaultMeterMinimumDate', e.target.value)} + placeholder='YYYY-MM-DD HH:MM:SS' + /> +
+
+

+ {`${translate('default.meter.maximum.date')}:`} +

+ makeLocalChanges('defaultMeterMaximumDate', e.target.value)} + placeholder='YYYY-MM-DD HH:MM:SS' + /> +
+
+

+ {`${translate('default.meter.reading.gap')}:`} +

+ makeLocalChanges('defaultMeterReadingGap', e.target.value)} + maxLength={50} + /> +
+
+

+ {`${translate('default.meter.maximum.errors')}:`} +

+ makeLocalChanges('defaultMeterMaximumErrors', e.target.value)} + maxLength={50} + /> +
+
+

+ {`${translate('default.meter.disable.checks')}:`} +

+ makeLocalChanges('defaultMeterDisableChecks', e.target.value)}> + {Object.keys(TrueFalseType).map(key => { + return (); + })} + +
+ + } + + {/* Date/Language Settings */} + {props.selectedPreference === 'dateLanguage' && + <> +
+

+ {translate('default.language')} +

+
+ +
+
+ +
+
+ +
+
+
+

+ {`${translate('default.time.zone')}:`} +

+ makeLocalChanges('defaultTimezone', e)} /> +
+ + } + {/* File Settings */} + {props.selectedPreference === 'file' && + <> +
+

+ {`${translate('default.warning.file.size')}:`} +

+ makeLocalChanges('defaultWarningFileSize', e.target.value)} + maxLength={50} + /> +
+
+

+ {`${translate('default.file.size.limit')}:`} +

+ makeLocalChanges('defaultFileSizeLimit', e.target.value)} + maxLength={50} + /> +
+ + } - -
diff --git a/src/client/app/components/admin/PreferencesComponent.tsx b/src/client/app/components/admin/PreferencesComponent.tsx index 3eb598d85..668083b56 100644 --- a/src/client/app/components/admin/PreferencesComponent.tsx +++ b/src/client/app/components/admin/PreferencesComponent.tsx @@ -52,216 +52,114 @@ export default function PreferencesComponent(props: PreferencesProps) { /> {/* Graph Settings */} {props.selectedPreference === 'graph' && - <> -
-

- : -

- { - Object.values(ChartTypes).map(chartType => ( -
- -
- )) - } -
-

- : -

-
- -
-
- -
-
+ <> +
+

+ : +

+ { + Object.values(ChartTypes).map(chartType => ( +
+ +
+ )) + } +

- {translate('default.area.unit')} - + :

-
+
-
+
-
- +
+

+ {translate('default.area.unit')} + +

+
+ +
+
+ +
+
+ } {/* Misc Settings */} {props.selectedPreference === 'misc' && - <> -
-

- {`${translate('site.title')}:`} -

- makeLocalChanges('displayTitle', e.target.value)} - maxLength={50} - /> -
-
-

- : -

- makeLocalChanges('defaultHelpUrl', e.target.value)} - /> -
- - } - - {/* Meter Settings */} - - {props.selectedPreference === 'meter' && - <> -
-

- {`${translate('default.meter.reading.frequency')}:`} -

- makeLocalChanges('defaultMeterReadingFrequency', e.target.value)} - /> -
-
-

- {`${translate('default.meter.minimum.value')}:`} -

- makeLocalChanges('defaultMeterMinimumValue', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.meter.maximum.value')}:`} -

- makeLocalChanges('defaultMeterMaximumValue', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.meter.minimum.date')}:`} -

- makeLocalChanges('defaultMeterMinimumDate', e.target.value)} - placeholder='YYYY-MM-DD HH:MM:SS' - /> -
-
-

- {`${translate('default.meter.maximum.date')}:`} -

- makeLocalChanges('defaultMeterMaximumDate', e.target.value)} - placeholder='YYYY-MM-DD HH:MM:SS' - /> -
-
-

- {`${translate('default.meter.reading.gap')}:`} -

- makeLocalChanges('defaultMeterReadingGap', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.meter.maximum.errors')}:`} -

- makeLocalChanges('defaultMeterMaximumErrors', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.meter.disable.checks')}:`} -

- makeLocalChanges('defaultMeterDisableChecks', e.target.value)}> - {Object.keys(TrueFalseType).map(key => { - return (); - })} - -
- - } - - {/* Date/Language Settings */} - {props.selectedPreference === 'dateLanguage' && <> +
+

+ {`${translate('site.title')}:`} +

+ makeLocalChanges('displayTitle', e.target.value)} + maxLength={50} /> +
+
+

+ : +

+ makeLocalChanges('defaultHelpUrl', e.target.value)} /> +
+ + {/* Date/Language Settings */}

{translate('default.language')} @@ -274,8 +172,7 @@ export default function PreferencesComponent(props: PreferencesProps) { name='languageTypes' value={LanguageTypes.en} onChange={e => makeLocalChanges('defaultLanguage', e.target.value)} - checked={localAdminPref.defaultLanguage === LanguageTypes.en} - /> + checked={localAdminPref.defaultLanguage === LanguageTypes.en} /> English

@@ -287,8 +184,7 @@ export default function PreferencesComponent(props: PreferencesProps) { name='languageTypes' value={LanguageTypes.fr} onChange={e => makeLocalChanges('defaultLanguage', e.target.value)} - checked={localAdminPref.defaultLanguage === LanguageTypes.fr} - /> + checked={localAdminPref.defaultLanguage === LanguageTypes.fr} /> Français
@@ -300,8 +196,7 @@ export default function PreferencesComponent(props: PreferencesProps) { name='languageTypes' value={LanguageTypes.es} onChange={e => makeLocalChanges('defaultLanguage', e.target.value)} - checked={localAdminPref.defaultLanguage === LanguageTypes.es} - /> + checked={localAdminPref.defaultLanguage === LanguageTypes.es} /> Español
@@ -314,47 +209,137 @@ export default function PreferencesComponent(props: PreferencesProps) { current={localAdminPref.defaultTimezone} handleClick={e => makeLocalChanges('defaultTimezone', e)} />
+ + {/* File Settings */} +
+

+ {`${translate('default.warning.file.size')}:`} +

+ makeLocalChanges('defaultWarningFileSize', e.target.value)} + maxLength={50} /> +
+
+

+ {`${translate('default.file.size.limit')}:`} +

+ makeLocalChanges('defaultFileSizeLimit', e.target.value)} + maxLength={50} /> +
} - {/* File Settings */} - {props.selectedPreference === 'file' && - <> -
-

- {`${translate('default.warning.file.size')}:`} -

- makeLocalChanges('defaultWarningFileSize', e.target.value)} - maxLength={50} - /> -
-
-

- {`${translate('default.file.size.limit')}:`} -

- makeLocalChanges('defaultFileSizeLimit', e.target.value)} - maxLength={50} - /> -
- + + {/* Meter Settings */} + + { + props.selectedPreference === 'meter' && + <> +
+

+ {`${translate('default.meter.reading.frequency')}:`} +

+ makeLocalChanges('defaultMeterReadingFrequency', e.target.value)} + /> +
+
+

+ {`${translate('default.meter.minimum.value')}:`} +

+ makeLocalChanges('defaultMeterMinimumValue', e.target.value)} + maxLength={50} + /> +
+
+

+ {`${translate('default.meter.maximum.value')}:`} +

+ makeLocalChanges('defaultMeterMaximumValue', e.target.value)} + maxLength={50} + /> +
+
+

+ {`${translate('default.meter.minimum.date')}:`} +

+ makeLocalChanges('defaultMeterMinimumDate', e.target.value)} + placeholder='YYYY-MM-DD HH:MM:SS' + /> +
+
+

+ {`${translate('default.meter.maximum.date')}:`} +

+ makeLocalChanges('defaultMeterMaximumDate', e.target.value)} + placeholder='YYYY-MM-DD HH:MM:SS' + /> +
+
+

+ {`${translate('default.meter.reading.gap')}:`} +

+ makeLocalChanges('defaultMeterReadingGap', e.target.value)} + maxLength={50} + /> +
+
+

+ {`${translate('default.meter.maximum.errors')}:`} +

+ makeLocalChanges('defaultMeterMaximumErrors', e.target.value)} + maxLength={50} + /> +
+
+

+ {`${translate('default.meter.disable.checks')}:`} +

+ makeLocalChanges('defaultMeterDisableChecks', e.target.value)}> + {Object.keys(TrueFalseType).map(key => { + return (); + })} + +
+ }
diff --git a/src/client/app/components/admin/CreateUserModalComponent.tsx b/src/client/app/components/admin/CreateUserModalComponent.tsx new file mode 100644 index 000000000..7d1d62ded --- /dev/null +++ b/src/client/app/components/admin/CreateUserModalComponent.tsx @@ -0,0 +1,167 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import * as React from 'react'; +import { useState } from 'react'; +import { Alert, Button, Col, Container, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader, Row } from 'reactstrap'; +import { FormattedMessage } from 'react-intl'; +import { UserRole } from '../../types/items'; +import { userApi } from '../../redux/api/userApi'; +import { NewUser } from '../../types/items'; +import { showErrorNotification, showSuccessNotification } from '../../utils/notifications'; +import translate from '../../utils/translate'; + +/** + * Defines the create user modal form + * @returns CreateUserModal component + */ +export default function CreateUserModal() { + const [showModal, setShowModal] = useState(false); + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const [passwordMatch, setPasswordMatch] = useState(true); + const [role, setRole] = useState(''); + const [createUser] = userApi.useCreateUserMutation(); + + const handleShowModal = () => setShowModal(true); + const handleCloseModal = () => { + setShowModal(false); + resetForm(); + }; + + const resetForm = () => { + setEmail(''); + setPassword(''); + setConfirmPassword(''); + setRole(''); + setPasswordMatch(true); + }; + + const handleSubmit = async () => { + if (password === confirmPassword) { + setPasswordMatch(true); + const userRole: UserRole = UserRole[role as keyof typeof UserRole]; + const newUser: NewUser = { email, role: userRole, password }; + createUser(newUser) + .unwrap() + .then(() => { + showSuccessNotification(translate('users.successfully.create.user')); + handleCloseModal(); + }) + .catch(() => { + showErrorNotification(translate('users.failed.to.create.user')); + }); + } else { + setPasswordMatch(false); + } + }; + + const isFormValid = email && password && confirmPassword === password && role; + + return ( + <> + + + + + + + + + + + + setEmail(e.target.value)} + required + /> + + + + {!passwordMatch && ( + + + {translate('user.password.mismatch')} + + + )} + + + + + setPassword(e.target.value)} + required + /> + + + + + + setConfirmPassword(e.target.value)} + invalid={confirmPassword !== password && confirmPassword !== ''} + required + /> + + + + + + + + + + + setRole(e.target.value)} + invalid={!role} + required + > + + {Object.entries(UserRole).map(([role, val]) => ( + + ))} + + + + + + + + + + + + + + + + ); +} \ No newline at end of file diff --git a/src/client/app/components/admin/PreferencesComponent.tsx b/src/client/app/components/admin/PreferencesComponent.tsx index 668083b56..81ec74fd1 100644 --- a/src/client/app/components/admin/PreferencesComponent.tsx +++ b/src/client/app/components/admin/PreferencesComponent.tsx @@ -23,6 +23,7 @@ interface PreferencesProps { // TODO: Add warning for invalid data /** + * @param props variables passed in to define * @returns Preferences Component for Administrative use */ export default function PreferencesComponent(props: PreferencesProps) { @@ -341,6 +342,7 @@ export default function PreferencesComponent(props: PreferencesProps) { showErrorNotification(translate('failed.to.submit.changes')); })} disabled={!hasChanges} + className={`${props.selectedPreference === 'users' ? 'd-none' : 'd-block'}`} > {translate('submit')} From f20a2e1be515e37640e603cbada55c6331e4d7d9 Mon Sep 17 00:00:00 2001 From: hazeltonbw Date: Tue, 23 Jul 2024 00:14:47 -0700 Subject: [PATCH 07/10] Revert translations to last known edit before unnecessary re-work. --- src/client/app/translations/data.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/client/app/translations/data.ts b/src/client/app/translations/data.ts index d7e064e10..9948314ab 100644 --- a/src/client/app/translations/data.ts +++ b/src/client/app/translations/data.ts @@ -14,7 +14,7 @@ const LocaleTranslationData = { "action": "Action", "add.new.meters": "Add new meters", "admin.only": "Admin Only", - "admin.preferences": "Admin Preferences", + "admin.panel": "Admin Panel", "alphabetically": "Alphabetically", "area": "Area:", "area.but.no.unit": "You have entered a nonzero area but no area unit.", @@ -129,6 +129,7 @@ const LocaleTranslationData = { "defaultGraphicUnit": "Default Graphic Unit:", "default.language": "Default Language", "default.meter.reading.frequency": "Default meter reading frequency", + "default.site.title": "Default Site Title", "default.warning.file.size": "Default Warning File Size", "default.file.size.limit": "Default File Size Limit", "default.help.url": "Help URL", @@ -413,7 +414,6 @@ const LocaleTranslationData = { "show": "Show", "show.grid": "Show grid", "show.options": "Show options", - "site.title": "Site Title", "sort": "Sort", "submit": "Submit", "submitting": "submitting", @@ -510,7 +510,7 @@ const LocaleTranslationData = { "action": "Action\u{26A1}", "add.new.meters": "Ajouter de Nouveaux Mètres", "admin.only": "Uniquement pour Les Administrateurs", - "admin.preferences": "Préférences d'administration", + "admin.panel": "Panneau d'administration", "alphabetically": "Alphabétiquement", "area": "Région:", "area.but.no.unit": "You have entered a nonzero area but no area unit.\u{26A1}", @@ -625,6 +625,7 @@ const LocaleTranslationData = { "defaultGraphicUnit": "Default Graphic Unit:\u{26A1}", "default.language": "Langue par Défaut", "default.meter.reading.frequency": "Default meter reading frequency\u{26A1}", + "default.site.title": "Titre du Site par Défaut", "default.warning.file.size": "Taille du fichier d'avertissement par défaut", "default.file.size.limit": "Limite de taille de fichier par défaut", "default.help.url": "Help URL\u{26A1}", @@ -910,7 +911,6 @@ const LocaleTranslationData = { "show.grid": "Show grid\u{26A1}", "show.options": "Options de désancrage", "sort": "Trier", - "site.title": "Titre du site", "submit": "Soumettre", "submitting": "submitting\u{26A1}", "submit.changes": "Soumettre les changements", @@ -1006,7 +1006,7 @@ const LocaleTranslationData = { "action": "Acción", "add.new.meters": "Agregar nuevos medidores", "admin.only": "Solo administrador", - "admin.preferences": "Preferencias de administrador", + "admin.panel": "Panel de administración", "alphabetically": "Alfabéticamente", "area": "Área:", "area.but.no.unit": "Ha ingresado un área distinta a cero sin unidad de área.", @@ -1406,7 +1406,6 @@ const LocaleTranslationData = { "show.grid": "Mostrar rejilla", "show.options": "Mostrar opciones", "sort": "Ordenar", - "site.title": "Título del sitio", "submit": "Enviar", "submitting": "Enviando", "submit.changes": "Ingresar los cambios", From 5e80d9e68c594b9142d5949924d4621ed8e0c938 Mon Sep 17 00:00:00 2001 From: hazeltonbw Date: Tue, 23 Jul 2024 00:21:26 -0700 Subject: [PATCH 08/10] Add and remove translations needed for admin settings dashboard --- src/client/app/translations/data.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client/app/translations/data.ts b/src/client/app/translations/data.ts index 9948314ab..fc9eb1e3e 100644 --- a/src/client/app/translations/data.ts +++ b/src/client/app/translations/data.ts @@ -14,7 +14,7 @@ const LocaleTranslationData = { "action": "Action", "add.new.meters": "Add new meters", "admin.only": "Admin Only", - "admin.panel": "Admin Panel", + "admin.settings": "Admin Settings", "alphabetically": "Alphabetically", "area": "Area:", "area.but.no.unit": "You have entered a nonzero area but no area unit.", @@ -129,7 +129,6 @@ const LocaleTranslationData = { "defaultGraphicUnit": "Default Graphic Unit:", "default.language": "Default Language", "default.meter.reading.frequency": "Default meter reading frequency", - "default.site.title": "Default Site Title", "default.warning.file.size": "Default Warning File Size", "default.file.size.limit": "Default File Size Limit", "default.help.url": "Help URL", @@ -366,6 +365,7 @@ const LocaleTranslationData = { "meter.type": "Type:", "minute": "Minute", "min": "min", + "misc": "Miscellaneous", "more.energy": "more energy", "more.options": "More Options", "name": "Name:", @@ -414,6 +414,7 @@ const LocaleTranslationData = { "show": "Show", "show.grid": "Show grid", "show.options": "Show options", + "site.title": "Site Title", "sort": "Sort", "submit": "Submit", "submitting": "submitting", @@ -510,7 +511,7 @@ const LocaleTranslationData = { "action": "Action\u{26A1}", "add.new.meters": "Ajouter de Nouveaux Mètres", "admin.only": "Uniquement pour Les Administrateurs", - "admin.panel": "Panneau d'administration", + "admin.settings": "Admin Settings\u{26A1}", "alphabetically": "Alphabétiquement", "area": "Région:", "area.but.no.unit": "You have entered a nonzero area but no area unit.\u{26A1}", @@ -625,7 +626,6 @@ const LocaleTranslationData = { "defaultGraphicUnit": "Default Graphic Unit:\u{26A1}", "default.language": "Langue par Défaut", "default.meter.reading.frequency": "Default meter reading frequency\u{26A1}", - "default.site.title": "Titre du Site par Défaut", "default.warning.file.size": "Taille du fichier d'avertissement par défaut", "default.file.size.limit": "Limite de taille de fichier par défaut", "default.help.url": "Help URL\u{26A1}", @@ -862,6 +862,7 @@ const LocaleTranslationData = { "meter.type": "Type de Mèters", "minute": "Minute\u{26A1}", "min": "min\u{26A1}", + "misc": "Miscellaneous\u{26A1}", "more.energy": "plus d'énergie", "more.options": "More Options\u{26A1}", "name": "Nom:", @@ -910,6 +911,7 @@ const LocaleTranslationData = { "show": "Montrer", "show.grid": "Show grid\u{26A1}", "show.options": "Options de désancrage", + "site.title": "Site Title\u{26A1}", "sort": "Trier", "submit": "Soumettre", "submitting": "submitting\u{26A1}", @@ -1006,7 +1008,7 @@ const LocaleTranslationData = { "action": "Acción", "add.new.meters": "Agregar nuevos medidores", "admin.only": "Solo administrador", - "admin.panel": "Panel de administración", + "admin.settings": "Admin Settings\u{26A1}", "alphabetically": "Alfabéticamente", "area": "Área:", "area.but.no.unit": "Ha ingresado un área distinta a cero sin unidad de área.", @@ -1357,6 +1359,7 @@ const LocaleTranslationData = { "meter.type": "Tipo:", "minute": "Minuto", "min": "mínimo", + "misc": "Miscellaneous\u{26A1}", "more.energy": "más energía", "more.options": "More Options\u{26A1}", "name": "Nombre:", @@ -1405,6 +1408,7 @@ const LocaleTranslationData = { "show": "Mostrar", "show.grid": "Mostrar rejilla", "show.options": "Mostrar opciones", + "site.title": "Site Title\u{26A1}", "sort": "Ordenar", "submit": "Enviar", "submitting": "Enviando", From 8405be6d2082d2ee03fe735e63b528782166c628 Mon Sep 17 00:00:00 2001 From: hazeltonbw Date: Tue, 23 Jul 2024 02:22:26 -0700 Subject: [PATCH 09/10] Add show all settings button, update translations, make sidebar sticky. --- src/client/app/components/admin/AdminSideBar.tsx | 9 ++++++++- src/client/app/components/admin/PreferencesComponent.tsx | 6 +++--- src/client/app/translations/data.ts | 5 ++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/client/app/components/admin/AdminSideBar.tsx b/src/client/app/components/admin/AdminSideBar.tsx index 6d9ceb3ce..da50823b7 100644 --- a/src/client/app/components/admin/AdminSideBar.tsx +++ b/src/client/app/components/admin/AdminSideBar.tsx @@ -18,7 +18,7 @@ interface SidebarProps { export default function AdminSideBar(props: SidebarProps): React.JSX.Element { return (
-
+
+
diff --git a/src/client/app/components/admin/PreferencesComponent.tsx b/src/client/app/components/admin/PreferencesComponent.tsx index 81ec74fd1..7509fbcee 100644 --- a/src/client/app/components/admin/PreferencesComponent.tsx +++ b/src/client/app/components/admin/PreferencesComponent.tsx @@ -52,7 +52,7 @@ export default function PreferencesComponent(props: PreferencesProps) { failureMessage='failed.to.submit.changes' /> {/* Graph Settings */} - {props.selectedPreference === 'graph' && + {(props.selectedPreference === 'graph' || props.selectedPreference === 'all') && <>

@@ -137,7 +137,7 @@ export default function PreferencesComponent(props: PreferencesProps) { } {/* Misc Settings */} - {props.selectedPreference === 'misc' && + {(props.selectedPreference === 'misc' || props.selectedPreference === 'all') && <>

@@ -238,7 +238,7 @@ export default function PreferencesComponent(props: PreferencesProps) { {/* Meter Settings */} { - props.selectedPreference === 'meter' && + (props.selectedPreference === 'meter' || props.selectedPreference === 'all') && <>

diff --git a/src/client/app/translations/data.ts b/src/client/app/translations/data.ts index fc9eb1e3e..140ff6b1d 100644 --- a/src/client/app/translations/data.ts +++ b/src/client/app/translations/data.ts @@ -15,6 +15,7 @@ const LocaleTranslationData = { "add.new.meters": "Add new meters", "admin.only": "Admin Only", "admin.settings": "Admin Settings", + "all.settings": "Show All Settings", "alphabetically": "Alphabetically", "area": "Area:", "area.but.no.unit": "You have entered a nonzero area but no area unit.", @@ -222,7 +223,7 @@ const LocaleTranslationData = { "help.admin.groupcreate": "This page allows admins to create groups. Please visit {link} for further details and information.", "help.admin.groupedit": "This page allows admins to edit groups. Please visit {link} for further details and information.", "help.admin.groupview": "This page allows admins to view groups. Please visit {link} for further details and information.", - "help.admin.header": "This page is to allow site administrators to set values and manage users. Please visit {link} for further details and information.", + "help.admin.header": "This page is to allow site administrators to set values. Please visit {link} for further details and information.", "help.admin.mapview": "This page allows admins to view and edit maps. Please visit {link} for further details and information", "help.admin.metercreate": "This page allows admins to create meters. Please visit {link} for further details and information.", "help.admin.meteredit": "This page allows admins to edit meters. Please visit {link} for further details and information.", @@ -512,6 +513,7 @@ const LocaleTranslationData = { "add.new.meters": "Ajouter de Nouveaux Mètres", "admin.only": "Uniquement pour Les Administrateurs", "admin.settings": "Admin Settings\u{26A1}", + "all.settings": "Show All Settings\u{26A1}", "alphabetically": "Alphabétiquement", "area": "Région:", "area.but.no.unit": "You have entered a nonzero area but no area unit.\u{26A1}", @@ -1009,6 +1011,7 @@ const LocaleTranslationData = { "add.new.meters": "Agregar nuevos medidores", "admin.only": "Solo administrador", "admin.settings": "Admin Settings\u{26A1}", + "all.settings": "Show All Settings\u{26A1}", "alphabetically": "Alfabéticamente", "area": "Área:", "area.but.no.unit": "Ha ingresado un área distinta a cero sin unidad de área.", From 60ab7214ba967234549285dfce11cb375718dbef Mon Sep 17 00:00:00 2001 From: hazeltonbw Date: Tue, 23 Jul 2024 03:21:42 -0700 Subject: [PATCH 10/10] Settings should take up available space on page --- src/client/app/components/admin/AdminComponent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/app/components/admin/AdminComponent.tsx b/src/client/app/components/admin/AdminComponent.tsx index dab93d074..8d7af0d5f 100644 --- a/src/client/app/components/admin/AdminComponent.tsx +++ b/src/client/app/components/admin/AdminComponent.tsx @@ -41,7 +41,7 @@ export default function AdminComponent() {

-
+