Skip to content

Commit

Permalink
[#7] added search for config num in homepage and informations about l…
Browse files Browse the repository at this point in the history
…atest config + button to auth params
  • Loading branch information
Eriikah committed May 13, 2024
1 parent f19b78e commit 0948fc9
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 86 deletions.
11 changes: 11 additions & 0 deletions src/components/Footer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.footer {
position: fixed;
bottom: 0;
background-color: #2f3237;
width: 100%;
text-align: center;
color: #ffffffaf;
}
.footer span {
margin: 5px;
}
17 changes: 17 additions & 0 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useTranslation } from "react-i18next";
import "./NavBar.css";
import { useAppSelector } from "../app/hooks";
import "./Footer.css";
export function Footer() {
const { t } = useTranslation();
const cfgVersion = useAppSelector(
(state) => state.config.data.metadata.cfgVersion
);

return (
<footer className="footer">
<strong> {t("cfgVersion")}</strong>
<span>{cfgVersion}</span>
</footer>
);
}
2 changes: 1 addition & 1 deletion src/components/applicationsComponents/AppPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ tr:nth-child(even) {
border-radius: 5px;
}

table {
.appDesc table {
margin-top: 2%;
border: 1px solid #acacac;
width: 100%;
Expand Down
9 changes: 1 addition & 8 deletions src/components/managerComponents/Issuers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,7 @@ function Issuers() {
).length
),
});
}, [
config.issuerDBSAMLActivation,
config.samlSPMetaDataXML,
config.issuerDBOpenIDConnectActivation,
config.oidcRPMetaDataOptions,
config.issuerDBCASActivation,
config.casAppMetaDataOptions,
]);
}, [config]);
return (
<div className="issuersList">
<div className="issuers" data-testid="issuer.saml">
Expand Down
36 changes: 36 additions & 0 deletions src/dashboards/HomePage.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.infoTable {
border: 1px solid #acacac;
width: 100%;
text-align: left;
max-width: 100%;
flex-wrap: wrap;
border-collapse: collapse;
box-shadow: 5% #acacac;
}

.infoTable tr,
td,
th {
padding: 1%;
}

.desc {
display: flex;
flex-direction: row;
align-content: space-between;
margin: 2%;
}

.logo {
width: 400px;
}

.search-container {
display: flex;
justify-content: flex-end;
margin: 15px;
}

.search {
margin-right: 2%;
}
208 changes: 131 additions & 77 deletions src/dashboards/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
import { Button, TextField } from "@mui/material";
import { t } from "i18next";
import { useEffect, useState } from "react";

import "./HomePage.css";
import { Footer } from "../components/Footer";
export function HomePage() {
const config = useAppSelector((state) => state.config);
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -40,68 +41,51 @@ export function HomePage() {
);
} else {
const createdDate = new Date(config.data.metadata.cfgDate * 1000);
const appNum =
(config.data.config.locationRules
? Object.keys(config.data.config.locationRules).length
: 0) +
(config.data.config.samlSPMetaDataXML
? Object.keys(config.data.config.samlSPMetaDataXML).length
: 0) +
(config.data.config.oidcRPMetaDataOptions
? Object.keys(config.data.config.oidcRPMetaDataOptions).length
: 0) +
(config.data.config.casAppMetaDataOptions
? Object.keys(config.data.config.casAppMetaDataOptions).length
: 0);

return (
<div className="main">
<table>
<tbody>
<tr>
<th>{t("latest")}</th>
<td>
<Button
variant="contained"
onClick={() => {
dispatch(push(`#conf/latest`));
dispatch(getConfigAsync());
}}
>
{config.data.metadata.cfgNum}
</Button>
</td>
</tr>
<tr>
<th>{t("author")}</th>
<td>{config.data.metadata.cfgAuthor}</td>
</tr>
<tr>
<th>{t("authorIPAddress")}</th>
<td>{config.data.metadata.cfgAuthorIP}</td>
</tr>
<tr>
<th>{t("date")}</th>
<td>{createdDate.toLocaleString()}</td>
</tr>
<tr>
<th>{t("cfgVersion")}</th>
<td>{config.data.metadata.cfgVersion}</td>
</tr>
<tr>
<th>{t("chooseConf")}</th>
<td>
<TextField
type="number"
error={aimedConf <= 0}
helperText={`${
aimedConf === 0
? "Enter only positive and non nul numbers"
: ""
}`}
onChange={(e) => SetAimedConf(Number(e.target.value))}
onKeyDown={(e) => {
if (e.key === "Enter") {
if (aimedConf <= config.data.metadata.cfgNum) {
dispatch(push(`#conf/${aimedConf}`));
} else
dispatch(
setError(
`Latest Config : ${config.data.metadata.cfgNum}`
)
);
}
}}
/>
<Button
variant="contained"
onClick={() => {
<>
<div className="main">
<div>
<div>
<img
className="logo"
src={require("./../static/logo_llng_400px.png")}
alt="logo"
/>
</div>
<strong className="title1">{t("Configuration Manager")}</strong>
</div>
<div className="search-container">
<div className="search">
<Button variant="contained">{t("authParams")}</Button>
</div>
<div className="search">
<TextField
type="number"
size="small"
error={aimedConf <= 0}
helperText={`${
aimedConf === 0
? "Enter only positive and non nul numbers"
: ""
}`}
placeholder={t("search config num")}
onChange={(e) => SetAimedConf(Number(e.target.value))}
onKeyDown={(e) => {
if (e.key === "Enter") {
if (aimedConf <= config.data.metadata.cfgNum) {
dispatch(push(`#conf/${aimedConf}`));
} else
Expand All @@ -110,22 +94,92 @@ export function HomePage() {
`Latest Config : ${config.data.metadata.cfgNum}`
)
);
}}
>
{t("go")}
</Button>
</td>
</tr>
</tbody>
</table>
<div
style={{
visibility: config.error.errorContent ? "visible" : "hidden",
}}
>
<strong>{t("latestError")}</strong> {config.error.errorContent}
}
}}
/>
<Button
variant="contained"
onClick={() => {
if (aimedConf <= config.data.metadata.cfgNum) {
dispatch(push(`#conf/${aimedConf}`));
} else
dispatch(
setError(
`Latest Config : ${config.data.metadata.cfgNum}`
)
);
}}
>
{t("go")}
</Button>
</div>
</div>
<div className="desc">
<div>
<table className="infoTable">
<thead>
<tr>
<th>
<strong>{t("Latest conf info")}</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<th>
<span>{t("latest")}</span>
</th>
<td>
<Button
variant="contained"
onClick={() => {
dispatch(push(`#conf/latest`));
dispatch(getConfigAsync());
}}
>
{config.data.metadata.cfgNum}
</Button>
</td>
</tr>
<tr>
<th>
<span>{t("date")}</span>
</th>
<td>{createdDate.toLocaleString()}</td>
</tr>
<tr>
<th>
<span>{t("author")}</span>
</th>
<td>{config.data.metadata.cfgAuthor}</td>{" "}
</tr>
<tr>
<th>
<span>{t("authorIPAddress")}</span>
</th>
<td>{config.data.metadata.cfgAuthorIP}</td>
</tr>

<tr>
<th>
<span>{t("App Number")}</span>
</th>
<td>{appNum}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div
style={{
visibility: config.error.errorContent ? "visible" : "hidden",
}}
>
<strong>{t("latestError")}</strong> {config.error.errorContent}
</div>
</div>
</div>
<Footer />
</>
);
}
} catch (e) {
Expand Down
Binary file added src/static/logo_llng_400px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/utils/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ export function renderWithProviders(
},
},
},
router: {
location: {
pathname: "/manager.html",
search: "",
hash: "#conf/14",
state: null,
key: "o01z0jry",
},
},
},

store = setupStore(preloadedState),
Expand Down

0 comments on commit 0948fc9

Please sign in to comment.