From c5ff15d6f42640b85c485e57b703532a79f63801 Mon Sep 17 00:00:00 2001 From: Noe Date: Mon, 3 Jul 2023 14:43:12 +0200 Subject: [PATCH] Color --- typescript/Frontend/src/Login.tsx | 5 ++-- typescript/Frontend/src/ResetPassword.tsx | 6 ++-- .../AccessManagement/AccessManagement.tsx | 3 +- .../Frontend/src/components/Groups/Folder.tsx | 10 ++++--- .../src/components/Groups/FolderForm.tsx | 5 ++-- .../src/components/Groups/GroupTabs.tsx | 5 ++-- .../src/components/Groups/Tree/GroupTree.tsx | 8 +++-- .../components/Installations/Installation.tsx | 10 ++++--- .../Installations/InstallationList.tsx | 19 +++++++----- .../Installations/InstallationTabs.tsx | 8 ++--- .../Installations/Log/CheckboxTree.tsx | 12 +++++--- .../Installations/Log/DateRangePicker.tsx | 13 +++++---- .../Installations/Log/ScalarGraph.tsx | 6 ++-- .../Installations/Log/TopologyView.tsx | 9 ++++-- .../Frontend/src/components/Layout/Detail.tsx | 5 ++-- .../components/Layout/InnovenergyButton.tsx | 8 +++-- .../Layout/InnovenergyTextfield.tsx | 5 ++-- .../src/components/Layout/LanguageSelect.tsx | 2 +- .../src/components/Layout/LogoutButton.tsx | 3 +- .../src/components/Layout/ModeButtons.tsx | 11 ++++--- .../Frontend/src/components/Layout/Search.tsx | 29 ++++++++++++++----- .../Frontend/src/components/Users/User.tsx | 10 ++++--- .../src/components/Users/UserForm.tsx | 5 ++-- .../src/components/Users/UserList.tsx | 13 +++++---- typescript/Frontend/src/index.css | 2 +- typescript/Frontend/src/index.tsx | 29 ++++++++++++------- .../Frontend/src/util/installation.util.tsx | 15 ++-------- 27 files changed, 153 insertions(+), 103 deletions(-) diff --git a/typescript/Frontend/src/Login.tsx b/typescript/Frontend/src/Login.tsx index a63dc349b..091daafb3 100644 --- a/typescript/Frontend/src/Login.tsx +++ b/typescript/Frontend/src/Login.tsx @@ -1,5 +1,5 @@ import React, { useContext, useState } from "react"; -import { Alert, CircularProgress, Grid } from "@mui/material"; +import { Alert, CircularProgress, Grid, useTheme } from "@mui/material"; import Container from "@mui/material/Container"; import { axiosConfigWithoutToken } from "./config/axiosConfig"; import InnovenergyTextfield from "./components/Layout/InnovenergyTextfield"; @@ -23,6 +23,7 @@ const Login = ({ setToken, setLanguage }: I_LoginProps) => { const [loading, setLoading] = useState(false); const [error, setError] = useState(); const { saveCurrentUser } = useContext(UserContext); + const theme = useTheme(); const verifyToken = async (token: string) => { axiosConfigWithoutToken.get("/GetAllInstallations", { @@ -80,7 +81,7 @@ const Login = ({ setToken, setLanguage }: I_LoginProps) => { Login - {loading && } + {loading && } ); }; diff --git a/typescript/Frontend/src/ResetPassword.tsx b/typescript/Frontend/src/ResetPassword.tsx index 916c13e43..d96979bb7 100644 --- a/typescript/Frontend/src/ResetPassword.tsx +++ b/typescript/Frontend/src/ResetPassword.tsx @@ -1,5 +1,5 @@ import React, { useContext, useState } from "react"; -import { Alert, CircularProgress, Grid, Typography } from "@mui/material"; +import { Alert, CircularProgress, Grid, Typography, useTheme } from "@mui/material"; import Container from "@mui/material/Container"; import axiosConfig from "./config/axiosConfig"; import InnovenergyTextfield from "./components/Layout/InnovenergyTextfield"; @@ -20,6 +20,7 @@ const ResetPassword = () => { .oneOf([Yup.ref("password")], "Passwords must match") .required(), }); + const theme = useTheme(); const formik = useFormik({ initialValues: { @@ -42,6 +43,7 @@ const ResetPassword = () => { }); return ( + Change password @@ -72,7 +74,7 @@ const ResetPassword = () => { Submit - {loading && } + {loading && } ); diff --git a/typescript/Frontend/src/components/Groups/AccessManagement/AccessManagement.tsx b/typescript/Frontend/src/components/Groups/AccessManagement/AccessManagement.tsx index 516d82a34..fa8c5da02 100644 --- a/typescript/Frontend/src/components/Groups/AccessManagement/AccessManagement.tsx +++ b/typescript/Frontend/src/components/Groups/AccessManagement/AccessManagement.tsx @@ -6,6 +6,7 @@ import UsersWithDirectAccess from "./UsersWithDirectAccess"; import UsersWithInheritedAccess from "./UsersWithInheritedAccess"; import { useContext } from "react"; import { UserContext } from "../../Context/UserContextProvider"; +import { colors } from "../../.."; const AccessManagement = () => { const { getCurrentUser } = useContext(UserContext); @@ -13,7 +14,7 @@ const AccessManagement = () => { return ( - + {getCurrentUser().hasWriteAccess && } diff --git a/typescript/Frontend/src/components/Groups/Folder.tsx b/typescript/Frontend/src/components/Groups/Folder.tsx index a1983c39d..d1765a1f6 100644 --- a/typescript/Frontend/src/components/Groups/Folder.tsx +++ b/typescript/Frontend/src/components/Groups/Folder.tsx @@ -1,4 +1,4 @@ -import { Box, CircularProgress, Alert } from "@mui/material"; +import { Box, CircularProgress, Alert, useTheme } from "@mui/material"; import { AxiosError } from "axios"; import { useState, useEffect } from "react"; import { useParams } from "react-router-dom"; @@ -7,6 +7,7 @@ import { I_Folder } from "../../util/types"; import AddNewDialog from "./AddNewDialog"; import FolderForm from "./FolderForm"; import MoveDialog from "./Tree/MoveDialog"; +import { colors } from "/home/ig/code/git_trunk/typescript/Frontend/src/index"; const Folder = () => { const { id } = useParams(); @@ -31,6 +32,7 @@ const Folder = () => { const handleSubmit = (data: I_Folder, formikValues: Partial) => { return axiosConfig.put("/UpdateFolder", { ...data, ...formikValues }); }; + const theme = useTheme(); if (values && values.id && values.id.toString() === id) { const moveDialog = ; @@ -41,7 +43,7 @@ const Folder = () => { { WebkitBorderTopRightRadius: 0, borderBottomLeftRadius: 4, borderBottomRightRadius: 4, - borderColor: "#90a7c5", + borderColor: colors.greyLight, marginTop: 0.05, }} > @@ -68,7 +70,7 @@ const Folder = () => { - + ); } else if (error) { diff --git a/typescript/Frontend/src/components/Groups/FolderForm.tsx b/typescript/Frontend/src/components/Groups/FolderForm.tsx index dcdcf527e..6012a95c1 100644 --- a/typescript/Frontend/src/components/Groups/FolderForm.tsx +++ b/typescript/Frontend/src/components/Groups/FolderForm.tsx @@ -1,4 +1,4 @@ -import { CircularProgress, Grid } from "@mui/material"; +import { CircularProgress, Grid, useTheme } from "@mui/material"; import { AxiosResponse } from "axios"; import { useFormik } from "formik"; import { ReactNode, useContext, useState } from "react"; @@ -52,6 +52,7 @@ const FolderForm = (props: I_CustomerFormProps) => { }); }, }); + const theme = useTheme(); return ( <> @@ -79,7 +80,7 @@ const FolderForm = (props: I_CustomerFormProps) => { handleChange={formik.handleChange} /> - {loading && } + {loading && } {!readOnly && additionalButtons && additionalButtons.map((button) => button)} diff --git a/typescript/Frontend/src/components/Groups/GroupTabs.tsx b/typescript/Frontend/src/components/Groups/GroupTabs.tsx index 7bddabd7a..e52121c34 100644 --- a/typescript/Frontend/src/components/Groups/GroupTabs.tsx +++ b/typescript/Frontend/src/components/Groups/GroupTabs.tsx @@ -10,6 +10,7 @@ import { StyledTab, StyledTabBlue, } from "../../util/installation.util"; +import { colors } from "../.."; const GroupTabs = () => { const routeMatch = useRouteMatch([ @@ -35,7 +36,6 @@ const GroupTabs = () => { > {currentType === "Folder" ? ( { /> ) : ( { )} { const { setCurrentType, fetchData, data, loading } = useContext(GroupContext); @@ -27,6 +28,7 @@ const GroupTree = () => { } return null; }; + const theme = useTheme(); const renderTree = (data: (I_Folder | I_Installation)[]): ReactNode => { return data.map((element) => { @@ -53,7 +55,7 @@ const GroupTree = () => { onClick={() => setCurrentType(element.type)} sx={{ ".MuiTreeItem-content": { paddingY: "12px" }, - bgcolor: "#CCD6E4", + bgcolor: colors.greyDark, borderRadius: 2, }} > @@ -66,7 +68,7 @@ const GroupTree = () => { if (loading) { return ( - + ); } diff --git a/typescript/Frontend/src/components/Installations/Installation.tsx b/typescript/Frontend/src/components/Installations/Installation.tsx index 7c622bf6e..5edf6ea04 100644 --- a/typescript/Frontend/src/components/Installations/Installation.tsx +++ b/typescript/Frontend/src/components/Installations/Installation.tsx @@ -1,10 +1,11 @@ -import { Alert, Box, CircularProgress } from "@mui/material"; +import { Alert, Box, CircularProgress, useTheme } from "@mui/material"; import { AxiosError } from "axios"; import { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; import axiosConfig from "../../config/axiosConfig"; import { I_Installation } from "../../util/types"; import InstallationForm from "./InstallationForm"; +import { colors } from "../.."; interface I_InstallationProps { hasMoveButton?: boolean; @@ -14,6 +15,7 @@ const Installation = (props: I_InstallationProps) => { const [values, setValues] = useState(); const [loading, setLoading] = useState(false); const [error, setError] = useState(); + const theme = useTheme(); useEffect(() => { setLoading(true); @@ -34,7 +36,7 @@ const Installation = (props: I_InstallationProps) => { { WebkitBorderTopRightRadius: 0, borderBottomLeftRadius: 4, borderBottomRightRadius: 4, - borderColor: "#90a7c5", + borderColor: colors.greyLight, marginTop: 0.05, }} > @@ -59,7 +61,7 @@ const Installation = (props: I_InstallationProps) => { - + ); } else if (error) { diff --git a/typescript/Frontend/src/components/Installations/InstallationList.tsx b/typescript/Frontend/src/components/Installations/InstallationList.tsx index 2b519c4b6..a6692848c 100644 --- a/typescript/Frontend/src/components/Installations/InstallationList.tsx +++ b/typescript/Frontend/src/components/Installations/InstallationList.tsx @@ -1,13 +1,14 @@ import List from "@mui/material/List"; import ListItemButton from "@mui/material/ListItemButton"; import ListItemText from "@mui/material/ListItemText"; -import { Alert, CircularProgress, Divider, Grid } from "@mui/material"; +import { Alert, CircularProgress, Divider, Grid, useTheme } from "@mui/material"; import { Link } from "react-router-dom"; import useRouteMatch from "../../hooks/useRouteMatch"; import routes from "../../routes.json"; import { Fragment, useContext, useEffect } from "react"; import { I_Installation } from "../../util/types"; import { InstallationContext } from "../Context/InstallationContextProvider"; +import { colors } from "../.."; interface InstallationListProps { searchQuery: string; @@ -44,7 +45,11 @@ const InstallationList = (props: InstallationListProps) => { routes.installations + routes.list + routes.installation + ":id", routes.installations + routes.list + routes.liveView + ":id", routes.installations + routes.list + routes.log + ":id", + ]); + + const theme = useTheme(); + useEffect(() => { fetchData(); @@ -53,7 +58,7 @@ const InstallationList = (props: InstallationListProps) => { if (loading) { return ( - + ); } else if (data && data.length) { @@ -83,7 +88,7 @@ const InstallationList = (props: InstallationListProps) => { to={ getPathWithoutId(routeMatch?.pattern?.path) + installation.id } - style={{ textDecoration: "none", color: "#2b3e54" }} + style={{ textDecoration: "none", color: colors.black }} > { sx={{ mr: "1px", borderStyle: "solid", - backgroundColor: "#577ba840", + backgroundColor: theme.palette.primary.dark, "&.Mui-selected": { - backgroundColor: "#90A7C5", + backgroundColor: colors.orangeSelected, }, ":hover": { - backgroundColor: "#AFC0D5", + backgroundColor: colors.orangeHover, }, "&.Mui-selected:hover": { - backgroundColor: "#90A7C5", + backgroundColor: colors.orangeSelected, }, }} > diff --git a/typescript/Frontend/src/components/Installations/InstallationTabs.tsx b/typescript/Frontend/src/components/Installations/InstallationTabs.tsx index 63a57e2b5..e91d6fb10 100644 --- a/typescript/Frontend/src/components/Installations/InstallationTabs.tsx +++ b/typescript/Frontend/src/components/Installations/InstallationTabs.tsx @@ -10,8 +10,8 @@ import { StyledTabBlue, StyledTabWhite, } from "../../util/installation.util"; -import { colors } from "@mui/material"; import { Background } from "reactflow"; +import {colors} from '/home/ig/code/git_trunk/typescript/Frontend/src/index'; const InstallationTabs = () => { const routeMatch = useRouteMatch([ @@ -35,7 +35,7 @@ const InstallationTabs = () => { })} > { to={routes.installation + id} /> { to={routes.liveView + id} /> { ) => { event.stopPropagation(); }; - + const theme = useTheme(); const renderTree = (data: TreeElement[]): ReactNode => { return data.map((element) => { const checked = checkedToggles.find((toggle) => element.id === toggle); @@ -66,7 +67,10 @@ const CheckboxTree = () => { handleClick(e, element, checked)} - color="info" + style ={{ + color: theme.palette.text.primary , + }} + /> )} {splitName[splitName.length - 1]} @@ -74,7 +78,7 @@ const CheckboxTree = () => { } sx={{ ".MuiTreeItem-content": { paddingY: "5px" }, - bgcolor: "#CCD6E4", + bgcolor: colors.greyDark, }} > {getNodes(element)} diff --git a/typescript/Frontend/src/components/Installations/Log/DateRangePicker.tsx b/typescript/Frontend/src/components/Installations/Log/DateRangePicker.tsx index 08afdb376..10a7454e4 100644 --- a/typescript/Frontend/src/components/Installations/Log/DateRangePicker.tsx +++ b/typescript/Frontend/src/components/Installations/Log/DateRangePicker.tsx @@ -6,7 +6,8 @@ import { FormattedMessage } from "react-intl"; import ShortcutButton from "./ShortcutButton"; import { createTimes } from "../../../util/graph.util"; import { TimeRange, UnixTime } from "../../../dataCache/time"; -import { TextField } from "@mui/material"; +import { TextField, useTheme } from "@mui/material"; +import { colors } from "../../.."; interface DateRangePickerProps { setRange: (value: Date[]) => void; @@ -14,6 +15,7 @@ interface DateRangePickerProps { getCacheSeries: (xaxisRange0: Date, xaxisRange1: Date) => void; } const DateRangePicker = (props: DateRangePickerProps) => { + const theme = useTheme(); const { setRange, range, getCacheSeries } = props; const handleChange = (fromDate: Date, toDate: Date) => { @@ -41,14 +43,14 @@ const DateRangePicker = (props: DateRangePickerProps) => { value={dayjs(range[0])} sx={{ ".MuiInputLabel-root": { - color: "#2b3e54", + color: colors.black, }, ".Mui-disabled": { color: "red", }, ".Mui-focused fieldset.MuiOutlinedInput-notchedOutline": { - borderColor: "#2b3e54", + borderColor: theme.palette.secondary.main, }, marginRight: 5, }} @@ -65,15 +67,14 @@ const DateRangePicker = (props: DateRangePickerProps) => { value={dayjs(range[1])} sx={{ ".MuiInputLabel-root": { - color: "#2b3e54", + color: colors.black, }, ".Mui-disabled": { color: "red", }, ".Mui-focused fieldset.MuiOutlinedInput-notchedOutline": { - borderColor: "#2b3e54", - }, + borderColor: theme.palette.secondary.main, }, }} onChange={(newValue) => { if (newValue) { diff --git a/typescript/Frontend/src/components/Installations/Log/ScalarGraph.tsx b/typescript/Frontend/src/components/Installations/Log/ScalarGraph.tsx index 72105d71a..c1db57e39 100644 --- a/typescript/Frontend/src/components/Installations/Log/ScalarGraph.tsx +++ b/typescript/Frontend/src/components/Installations/Log/ScalarGraph.tsx @@ -21,7 +21,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import { FormattedMessage } from "react-intl"; import DateRangePicker from "./DateRangePicker"; import { LocalizationProvider } from "@mui/x-date-pickers"; -import { Alert } from "@mui/material"; +import { Alert, useTheme } from "@mui/material"; const NUMBER_OF_NODES = 100; @@ -167,6 +167,8 @@ const ScalarGraph = () => { [getCacheSeries] ); + + const theme = useTheme(); const renderGraphs = () => { if (checkedToggles.length > 0) { const coordinateTimeSeries = transformToGraphData(timeSeries); @@ -243,7 +245,7 @@ const ScalarGraph = () => { } } return ( - + { const [values, setValues] = useState(null); @@ -37,6 +39,7 @@ const TopologyView = () => { return () => clearInterval(interval); }, []); + const theme = useTheme(); if (values) { const highestConnectionValue = getHighestConnectionValue(values); @@ -54,7 +57,7 @@ const TopologyView = () => { WebkitBorderTopRightRadius: 0, borderBottomLeftRadius: 4, borderBottomRightRadius: 4, - borderColor: "#CCD6E4", + borderColor: colors.greyDark, borderTopColor: "white", marginTop: 0.05, fontFamily: `"Ubuntu", sans-serif`, @@ -222,7 +225,7 @@ const TopologyView = () => { ); } return ( - + (props: I_DetailProps) => { setLoading(false); }); }, [id, route]); + const theme = useTheme(); if (values && values.id && values.id.toString() === id) { return ( @@ -43,7 +44,7 @@ const Detail = (props: I_DetailProps) => { - + ); } else if (error) { diff --git a/typescript/Frontend/src/components/Layout/InnovenergyButton.tsx b/typescript/Frontend/src/components/Layout/InnovenergyButton.tsx index 0a893c1a2..69f4053b6 100644 --- a/typescript/Frontend/src/components/Layout/InnovenergyButton.tsx +++ b/typescript/Frontend/src/components/Layout/InnovenergyButton.tsx @@ -1,4 +1,4 @@ -import { Button, SxProps, Theme, colors } from "@mui/material"; +import { Button, SxProps, Theme, colors, useTheme } from "@mui/material"; import { DAY_MARGIN } from "@mui/x-date-pickers/internals"; import { ReactNode } from "react"; import { Background } from "reactflow"; @@ -12,18 +12,20 @@ interface I_InnovenergyButtonProps { } const InnovenergyButton = (props: I_InnovenergyButtonProps) => { + const theme = useTheme(); return ( ); }; + export default InnovenergyButton; + diff --git a/typescript/Frontend/src/components/Layout/InnovenergyTextfield.tsx b/typescript/Frontend/src/components/Layout/InnovenergyTextfield.tsx index 811e5e20c..4a74e9a5f 100644 --- a/typescript/Frontend/src/components/Layout/InnovenergyTextfield.tsx +++ b/typescript/Frontend/src/components/Layout/InnovenergyTextfield.tsx @@ -1,4 +1,4 @@ -import { Grid, InputLabel, TextField } from "@mui/material"; +import { Grid, InputLabel, TextField, useTheme } from "@mui/material"; interface I_InnovenergyTextfieldProps { id: string; @@ -14,6 +14,7 @@ interface I_InnovenergyTextfieldProps { } const InnovenergyTextfield = (props: I_InnovenergyTextfieldProps) => { + const theme = useTheme(); return ( @@ -21,7 +22,7 @@ const InnovenergyTextfield = (props: I_InnovenergyTextfieldProps) => { { return (