Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed reports with orgs with spaces #159

Merged
merged 4 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions CoVAR-app/src/app/(pages)/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ const Dashboard: React.FC = () => {
<ReportsPerClient reportsPerClient={reportsPerClient} />
)}
</Paper>
<Paper elevation={3} sx={{ padding: 2, marginBottom: 2 }}>
{users.length === 0 && organizations.length === 0 ? (
<Typography>No assigned clients or organisations found.</Typography>
) : (
<List>
{users.map((user) => (
<ListItem key={user.user_id} sx={{ marginBottom: 1, padding: 1, borderRadius: 1, boxShadow: 1 }}>
{users.map((user) => (
<Paper key={user.user_id} sx={{ padding: 1, marginBottom: 2 }}>
<ListItem key={user.user_id} sx={{ marginBottom: 1, padding: 1, borderRadius: 1 }}>
<ListItemText
primary={`User: ${user.username}`}
secondary={`Last Report: ${formatDate(lastReportDatesClients.find(c => c.client_name === user.username)?.last_report_date as string) || 'No report'}`}
Expand All @@ -333,23 +333,26 @@ const Dashboard: React.FC = () => {
</Button>
</ListItemSecondaryAction>
</ListItem>
))}
{organizations.map((org) => (
<ListItem key={org.organization_id} sx={{ marginBottom: 1, padding: 1, borderRadius: 1, boxShadow: 1 }}>
</Paper>
))}
{organizations.map((org) => (
<Paper key={org.organization_id} sx={{ padding: 1, marginBottom: 2 }}>
<ListItem key={org.organization_id} sx={{ marginBottom: 1, padding: 1, borderRadius: 1 }}>
<ListItemText
primary={`Organisation: ${org.name}`}
secondary={`Last Report: ${formatDate(lastReportDatesOrgs.find(o => o.organization_name === org.name)?.last_report_date as string) || 'No report'}`}
secondary={`Last Report: ${formatDate(lastReportDatesOrgs.find(o => o.organization_name === org.name)?.last_report_date as string) || 'No report' }`}
/>
<ListItemSecondaryAction>
<Button variant="contained" onClick={() => handleOrganizationButtonClick(org)}>
Evaluate
</Button>
</ListItemSecondaryAction>
</ListItem>
))}
</List>
</Paper>
))}
</List>

)}
</Paper>
</Box>
);
}
Expand Down
17 changes: 16 additions & 1 deletion CoVAR-app/src/app/(pages)/evaluate/conflicts/[name]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ const UserConflicts = () => {
alignItems: 'center',
width: '100%',
height: '100%',


}}>
<Loader />
Expand All @@ -756,7 +757,21 @@ const UserConflicts = () => {

return (

<ReportsContainer sx={mainContentStyles} id="reportsContainer">
<ReportsContainer sx={{... mainContentStyles,
overflowY: 'auto',
'&::-webkit-scrollbar': {
width: '0.2vw',
},
'&::-webkit-scrollbar-thumb': {
backgroundColor: 'gray',
borderRadius: '0.4vw',
},
'&::-webkit-scrollbar-track': {
backgroundColor: 'transparent',
},
scrollbarWidth: 'thin',
scrollbarColor: 'gray transparent',
}} id="reportsContainer">
{matchedReports.length > 0 && (
<Box>
{renderedMatchedReports}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const OrganizationEvaluation: React.FC = () => {
}, [router]);

const pathname = usePathname();
const organizationName = pathname.split('/').pop();
const organizationName = decodeURIComponent(pathname.split('/').pop() || '');

const [uploads, setUploads] = useState<FileUpload[]>([]);
const [reportIds, setReportIds] = useState<number[]>([]);
Expand Down Expand Up @@ -238,7 +238,22 @@ const OrganizationEvaluation: React.FC = () => {
</Paper>
</Grid>
<Grid item xs={6}>
<Paper sx={{ overflowY: 'scroll', height: 'calc(80vh + 16px)' }}>
<Paper sx={{
overflowY: 'scroll',
height: 'calc(80vh + 16px)',
'&::-webkit-scrollbar': {
width: '0.2vw',
},
'&::-webkit-scrollbar-thumb': {
backgroundColor: 'gray',
borderRadius: '0.4vw',
},
'&::-webkit-scrollbar-track': {
backgroundColor: 'transparent',
},
scrollbarWidth: 'thin',
scrollbarColor: 'gray transparent',
}}>

<ReportPreview reports={reports.slice(0, 3)} reportIds={reportIds} client={organizationName ?? ''} reportNames={reportNames} />

Expand Down
19 changes: 18 additions & 1 deletion CoVAR-app/src/app/(pages)/evaluate/user/[username]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,24 @@ const UserEvaluation: React.FC = () => {
</Paper>
</Grid>
<Grid item xs={6}>
<Paper sx={{ overflowY: 'scroll', height: 'calc(80vh + 16px)' }}>
<Paper sx={{
overflowY: 'scroll',
height: 'calc(80vh + 16px)',
'&::-webkit-scrollbar': {
width: '0.2vw',
},
'&::-webkit-scrollbar-thumb': {
backgroundColor: 'gray',
borderRadius: '0.4vw',
},
'&::-webkit-scrollbar-track': {
backgroundColor: 'transparent',
},
scrollbarWidth: 'thin',
scrollbarColor: 'gray transparent',


}}>

<ReportPreview reports={reports} reportIds={reportIds} client={username ?? ''} reportNames={reportNames} />

Expand Down
4 changes: 2 additions & 2 deletions CoVAR-app/src/functions/requests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ export const fetchAndMatchReports = async (reportIds: number[]) => {
export const generateReportRequest = async (finalReport: any[], name: string | undefined, type: string | null) => {
try {
const token = localStorage.getItem('accessToken');


name = decodeURIComponent(name || '');
console.log(name)
const request: AxiosRequestConfig = {
method: 'post',
url: '/api/uploads/generateReport',
Expand Down
1 change: 1 addition & 0 deletions server/routes/uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ router.get('/uploads/client/:clientName', authenticateToken, async (req, res) =>
// Endpoint to generate report
router.post('/uploads/generateReport', authenticateToken, async (req, res) => {
const { finalReport, name, type } = req.body;
console.log("finalReport:",finalReport, "name:", name, "type:", type);

if (!finalReport || finalReport.length === 0) {
return res.status(400).json({ error: 'Reports or report IDs are missing' });
Expand Down
Loading