Skip to content

Commit

Permalink
Merge pull request #1151 from vedfordev/fix/report
Browse files Browse the repository at this point in the history
Fix : Hardcoded reporting urls in home page
  • Loading branch information
vedfordev authored Mar 14, 2024
2 parents 003fdd4 + 67e69ba commit fb5e1a9
Showing 1 changed file with 54 additions and 30 deletions.
84 changes: 54 additions & 30 deletions src/rootApp/views/SignInView.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { RemoveRedEye } from "@material-ui/icons";
import Button from "@material-ui/core/Button";
import Link from "@material-ui/core/Link";
import Typography from "@material-ui/core/Typography";
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import SideImage from "../../avni-background.jpeg";
import { withStyles } from "@material-ui/core/styles";
import ApplicationContext from "../../ApplicationContext";
import http from "common/utils/httpClient";

function SignInView({
classes,
Expand All @@ -29,6 +30,19 @@ function SignInView({
}) {
const [passwordIsMasked, setPasswordIsMasked] = useState(true);
const autoComplete = ApplicationContext.isDevEnv() ? "on" : "off";
const [reportingSystems, setReportingSystems] = useState(null);

useEffect(() => {
http
.get("/Config")
.then(
response =>
response.data &&
response.data.reportingSystems &&
response.data.reportingSystems.length > 0 &&
setReportingSystems(response.data.reportingSystems)
);
}, []);

return (
<Grid container component="main" className={classes.root}>
Expand Down Expand Up @@ -115,40 +129,50 @@ function SignInView({
</form>
</CardContent>
</Card>
<Grid style={{ backgroundColor: "#f0f2f0" }}>
<CardHeader title={"View Reports"} />
<CardContent>
<Typography variant="body2" color="secondary">
Avni provides reports using one of two different external BI tools - Metabase and
Jasper Reports. You can find out the reports used by your organisation from your
system administrator.
</Typography>
<Typography variant="body2" color="secondary">
<br />
Choose your reporting system
</Typography>
</CardContent>
<CardActions>
<Link href={"https://reporting.avniproject.org"}>
<Button size="small" variant={"contained"} className={classes.submit}>
Metabase Reports
</Button>
</Link>
<Link
href={"https://reporting-jasper.avniproject.org/jasperserver"}
style={{ marginLeft: "56px" }}
>
<Button size="small" variant={"contained"} className={classes.submit}>
Jasper Reports
</Button>
</Link>
</CardActions>
</Grid>
{reportingSystems && <ShowReport classes={classes} reportingSystems={reportingSystems} />}
</Grid>
</Grid>
);
}

const ShowReport = ({ classes, reportingSystems }) => {
return (
<>
<Grid style={{ backgroundColor: "#f0f2f0" }}>
<CardHeader title={"View Reports"} />
<CardContent>
<Typography variant="body2" color="secondary">
Avni provides reports using one of two different external BI tools - Metabase and Jasper
Reports. You can find out the reports used by your organisation from your system
administrator.
</Typography>
<Typography variant="body2" color="secondary">
<br />
Choose your reporting system
</Typography>
</CardContent>
<CardActions style={{ justifyContent: "space-evenly" }}>
{reportingSystems.map(({ name, url }) => (
<ReportDetails key={name} name={name} url={url} classes={classes} />
))}
</CardActions>
</Grid>
</>
);
};

const ReportDetails = ({ name, url, classes }) => {
return (
<>
<Link href={url}>
<Button size="small" variant={"contained"} className={classes.submit}>
{name}
</Button>
</Link>
</>
);
};

const useStyles = theme => ({
root: {
height: "100vh"
Expand Down

0 comments on commit fb5e1a9

Please sign in to comment.