mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-12 11:46:40 +00:00
Splitted ProgressBar and Info into 2 components; add progress bar to horizontal card top
This commit is contained in:
parent
382150fffa
commit
4469039757
7 changed files with 114 additions and 72 deletions
|
|
@ -54,3 +54,4 @@
|
||||||
- [x] Azure
|
- [x] Azure
|
||||||
- [ ] Refactor TabPanels code
|
- [ ] Refactor TabPanels code
|
||||||
- [ ] Refactor Lists code
|
- [ ] Refactor Lists code
|
||||||
|
- [ ] Query project members in UserPage
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@ import { makeStyles } from "@material-ui/core/styles";
|
||||||
import Card from "@material-ui/core/Card";
|
import Card from "@material-ui/core/Card";
|
||||||
import CardActions from "@material-ui/core/CardActions";
|
import CardActions from "@material-ui/core/CardActions";
|
||||||
import CardContent from "@material-ui/core/CardContent";
|
import CardContent from "@material-ui/core/CardContent";
|
||||||
import Button from "@material-ui/core/Button";
|
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import { getRemainingdays } from "../utils/methods";
|
import { ProgressBar } from "./ProgressBar";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
link?: string;
|
link?: string;
|
||||||
|
progress?: number;
|
||||||
content: ReactNode;
|
content: ReactNode;
|
||||||
actions?: ReactNode;
|
actions?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
@ -26,11 +26,13 @@ export const HorizontalCard: FC<IProps> = ({
|
||||||
link = "#",
|
link = "#",
|
||||||
content,
|
content,
|
||||||
actions,
|
actions,
|
||||||
|
progress = 0,
|
||||||
}) => {
|
}) => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className={classes.root}>
|
<Card className={classes.root}>
|
||||||
|
<ProgressBar value={progress} />
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Typography variant="h5" component="h2">
|
<Typography variant="h5" component="h2">
|
||||||
<Link to={link}>
|
<Link to={link}>
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,6 @@ import { PlaylistAddCheck } from "@material-ui/icons";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
value: number;
|
value: number;
|
||||||
max?: number;
|
|
||||||
tasksTotalCount?: number;
|
|
||||||
tasksDone?: number;
|
|
||||||
remainingDays?: number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
|
|
@ -17,19 +13,13 @@ const useStyles = makeStyles((theme: Theme) =>
|
||||||
root: {
|
root: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
"& > * + *": {
|
"& > * + *": {
|
||||||
marginTop: theme.spacing(2)
|
marginTop: theme.spacing(2),
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
export const ProgressBar: FC<IProps> = ({
|
export const ProgressBar: FC<IProps> = ({ value }) => {
|
||||||
value,
|
|
||||||
// max = 100,
|
|
||||||
tasksDone,
|
|
||||||
tasksTotalCount,
|
|
||||||
remainingDays
|
|
||||||
}) => {
|
|
||||||
// const styleString: CSSProperties = { width: `${value}%` };
|
// const styleString: CSSProperties = { width: `${value}%` };
|
||||||
// let barColor: string = "green";
|
// let barColor: string = "green";
|
||||||
|
|
||||||
|
|
@ -46,27 +36,17 @@ export const ProgressBar: FC<IProps> = ({
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Box className="row">
|
||||||
<div className="row">
|
<div className={classes.root}>
|
||||||
<Box className="row">
|
<LinearProgress variant="determinate" value={value} />
|
||||||
<div className={classes.root}>
|
{/* <LinearProgress variant="determinate" value={value} color={barColor} /> */}
|
||||||
<LinearProgress variant="determinate" value={value} />
|
|
||||||
{/* <LinearProgress variant="determinate" value={value} color={barColor} /> */}
|
|
||||||
</div>
|
|
||||||
</Box>
|
|
||||||
{/* <div className="progress">
|
|
||||||
<div className={`determinate ${barColor}`} style={styleString}></div>
|
|
||||||
</div> */}
|
|
||||||
<Box>
|
|
||||||
<PlaylistAddCheck />
|
|
||||||
<span>
|
|
||||||
{tasksDone}/{tasksTotalCount}
|
|
||||||
</span>
|
|
||||||
<Box className="right">
|
|
||||||
<span>Due {remainingDays} days</span>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
/* <div className="progress">
|
||||||
|
<div className={`determinate ${barColor}`} style={styleString}></div>
|
||||||
|
</div> */
|
||||||
|
}
|
||||||
|
|
|
||||||
42
client/src/components/ProgressInfo.tsx
Normal file
42
client/src/components/ProgressInfo.tsx
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
import React, { FC } from "react";
|
||||||
|
import { makeStyles, Theme, createStyles } from "@material-ui/core/styles";
|
||||||
|
import LinearProgress from "@material-ui/core/LinearProgress";
|
||||||
|
import { Box } from "@material-ui/core";
|
||||||
|
import { PlaylistAddCheck } from "@material-ui/icons";
|
||||||
|
|
||||||
|
type IProps = {
|
||||||
|
tasksTotalCount?: number;
|
||||||
|
tasksDone?: number;
|
||||||
|
remainingDays?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
|
createStyles({
|
||||||
|
root: {
|
||||||
|
width: "100%",
|
||||||
|
"& > * + *": {
|
||||||
|
marginTop: theme.spacing(2),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
export const ProgressInfo: FC<IProps> = ({
|
||||||
|
tasksDone,
|
||||||
|
tasksTotalCount,
|
||||||
|
remainingDays,
|
||||||
|
}) => {
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<PlaylistAddCheck />
|
||||||
|
<span>
|
||||||
|
{tasksDone}/{tasksTotalCount}
|
||||||
|
</span>
|
||||||
|
<Box className="right">
|
||||||
|
<span>Due {remainingDays} days</span>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
@ -1,34 +1,60 @@
|
||||||
import React, { FC, MouseEvent } from "react";
|
import React, { FC } from "react";
|
||||||
import { HorizontalCard } from "./HorizontalCard";
|
import { HorizontalCard } from "./HorizontalCard";
|
||||||
import { Typography } from "@material-ui/core";
|
import { Typography, makeStyles, Theme, createStyles } from "@material-ui/core";
|
||||||
import { getRemainingdays } from "../utils/methods";
|
import { getRemainingdays } from "../utils/methods";
|
||||||
|
import { User } from "../types/User";
|
||||||
|
import { AvatarList } from "./AvatarList";
|
||||||
|
import { ProgressBar } from "./ProgressBar";
|
||||||
|
import { ProgressInfo } from "./ProgressInfo";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
remainingDays?: string;
|
remainingDays?: string;
|
||||||
link?: string;
|
link?: string;
|
||||||
|
members?: User[];
|
||||||
|
progress?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProjectCard: FC<IProps> = ({ title, remainingDays, link = "#" }) => {
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
|
createStyles({
|
||||||
|
progress: {
|
||||||
|
paddingTop: theme.spacing(4),
|
||||||
|
paddingBottom: theme.spacing(4),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const ProjectCard: FC<IProps> = ({
|
||||||
|
title,
|
||||||
|
remainingDays,
|
||||||
|
link = "#",
|
||||||
|
members,
|
||||||
|
progress = 0,
|
||||||
|
}) => {
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
const Content: FC = () => {
|
const Content: FC = () => {
|
||||||
return (
|
return (
|
||||||
<Typography variant="body2" component="p">
|
<>
|
||||||
<span>
|
{members && <AvatarList users={members} />}
|
||||||
Due{" "}
|
<div className={classes.progress}>
|
||||||
{remainingDays ? (
|
{/* <Typography variant="body2" component="p">
|
||||||
getRemainingdays(remainingDays)
|
Progression:
|
||||||
) : (
|
</Typography> */}
|
||||||
<span>
|
<ProgressInfo />
|
||||||
<del>Too much</del> 0
|
</div>
|
||||||
</span>
|
</>
|
||||||
)}{" "}
|
|
||||||
days
|
|
||||||
</span>
|
|
||||||
</Typography>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return <HorizontalCard title={title} link={link} content={<Content />} />;
|
return (
|
||||||
|
<HorizontalCard
|
||||||
|
title={title}
|
||||||
|
link={link}
|
||||||
|
content={<Content />}
|
||||||
|
progress={progress}
|
||||||
|
/>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProjectCard;
|
export default ProjectCard;
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,9 @@ import {
|
||||||
createStyles,
|
createStyles,
|
||||||
Theme,
|
Theme,
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
import { HorizontalCard } from "./HorizontalCard";
|
|
||||||
import { FilterBar } from "./FilterBar";
|
import { FilterBar } from "./FilterBar";
|
||||||
import { Ticket } from "../types/Ticket";
|
|
||||||
import { HttpResponse } from "../types/HttpResponse";
|
|
||||||
import { Project } from "../types/Project";
|
|
||||||
import { put } from "../utils/http";
|
|
||||||
import { Constants } from "../utils/Constants";
|
|
||||||
import ProjectCard from "./ProjectCard";
|
import ProjectCard from "./ProjectCard";
|
||||||
|
import { Project } from "../types/Project";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
|
|
@ -37,7 +32,7 @@ export const ProjectList: FC<IProps> = ({ projects }) => {
|
||||||
setFilterText(e.target.value);
|
setFilterText(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
let filteredTickets = projects.filter(
|
let filteredProjects = projects.filter(
|
||||||
(t) =>
|
(t) =>
|
||||||
t.status !== "Done" &&
|
t.status !== "Done" &&
|
||||||
t.title.toLowerCase().includes(filterText.toLowerCase())
|
t.title.toLowerCase().includes(filterText.toLowerCase())
|
||||||
|
|
@ -65,22 +60,17 @@ export const ProjectList: FC<IProps> = ({ projects }) => {
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<div className="col s12 grey lighten-1">
|
<div className="col s12 grey lighten-1">
|
||||||
{filteredTickets.length === 0 ? (
|
{filteredProjects.length === 0 ? (
|
||||||
<ProjectCard />
|
<ProjectCard />
|
||||||
) : (
|
) : (
|
||||||
filteredTickets.map((t: Project) => (
|
filteredProjects.map((t: Project) => (
|
||||||
<ProjectCard
|
<ProjectCard
|
||||||
key={t.id}
|
key={t.id}
|
||||||
title={t.title}
|
title={t.title}
|
||||||
remainingDays={t.endingDate}
|
remainingDays={t.endingDate}
|
||||||
link={`/projects/${t.id}`}
|
link={`/projects/${t.id}`}
|
||||||
// validateTicket={async (e: MouseEvent) => {
|
members={t.users}
|
||||||
// e.preventDefault();
|
progress={t.progression}
|
||||||
// await put<HttpResponse<Ticket>>(
|
|
||||||
// `${Constants.ticketsURI}/${t.id}/closed`,
|
|
||||||
// {}
|
|
||||||
// );
|
|
||||||
// }}
|
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import { UsersModal } from "../components/UsersModal";
|
||||||
import { ProjectTabPanel } from "../components/ProjectTabPanel";
|
import { ProjectTabPanel } from "../components/ProjectTabPanel";
|
||||||
import ProjectVM from "../VM/ProjectVM";
|
import ProjectVM from "../VM/ProjectVM";
|
||||||
import PageLayout from "../layouts/PageLayout";
|
import PageLayout from "../layouts/PageLayout";
|
||||||
|
import { ProgressInfo } from "../components/ProgressInfo";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
viewModel: ProjectVM;
|
viewModel: ProjectVM;
|
||||||
|
|
@ -67,8 +68,8 @@ export const ProjectPage: FC<IProps> = ({ viewModel }) => {
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<ProgressBar
|
<ProgressBar value={progression} />
|
||||||
value={progression}
|
<ProgressInfo
|
||||||
tasksDone={ticketsDone}
|
tasksDone={ticketsDone}
|
||||||
tasksTotalCount={ticketsTotalCount}
|
tasksTotalCount={ticketsTotalCount}
|
||||||
remainingDays={remainingDays}
|
remainingDays={remainingDays}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue