Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of https://github.com/rchuk/fms
Browse files Browse the repository at this point in the history
  • Loading branch information
W1nLin4n committed Jun 15, 2024
2 parents 174fcdc + 0606e5a commit c46e438
Show file tree
Hide file tree
Showing 27 changed files with 228 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public OrganizationToUserRepository(FmsDbContext ctx) : base(ctx) {}
if (criteria.Query is { } searchQuery)
{
query = query.Where(map => map.User.FirstName.ToLower().Contains(searchQuery.ToLower())
|| map.User.LastName.ToLower().Contains(searchQuery.ToLower()));
|| map.User.LastName.ToLower().Contains(searchQuery.ToLower())
|| map.User.Email.ToLower().Contains(searchQuery.ToLower()));
}

query = query.Include(map => map.User)
Expand Down
3 changes: 2 additions & 1 deletion backend/Fms/Repositories/Implementations/UserRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public UserRepository(FmsDbContext ctx) : base(ctx) {}
if (criteria.Query is { } searchQuery)
{
query = query.Where(user => user.FirstName.ToLower().Contains(searchQuery.ToLower())
|| user.LastName.ToLower().Contains(searchQuery.ToLower()));
|| user.LastName.ToLower().Contains(searchQuery.ToLower())
|| user.Email.ToLower().Contains(searchQuery.ToLower()));
}

query = query.OrderBy(user => user.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ WorkspaceKindRepository workspaceKindRepository

query = query.Where(map =>
map.Account.Organization != null && map.Account.Organization.Name.ToLower().Contains(needle)
|| map.Account.User != null && (map.Account.User.FirstName.ToLower().Contains(needle) || map.Account.User.LastName.ToLower().Contains(needle))
|| map.Account.User != null&& (map.Account.User.FirstName.ToLower().Contains(needle)
|| map.Account.User.LastName.ToLower().Contains(needle)
|| map.Account.User.Email.ToLower().Contains(needle))
);
}

Expand Down
32 changes: 32 additions & 0 deletions frontend/public/fms_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 24 additions & 1 deletion frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ServicesProvider, {createServices, Services} from "@/lib/services/Service
import {AdapterDayjs} from "@mui/x-date-pickers/AdapterDayjs";
import {createTheme, CssBaseline, responsiveFontSizes, ThemeProvider} from "@mui/material";
import {LocalizationProvider} from "@mui/x-date-pickers";
import {Roboto} from "next/font/google";
import {Roboto, Montserrat} from "next/font/google";
import { AlertProvider } from "@/lib/services/AlertService";
import {Configuration} from "../../generated";
import NextLink, {LinkProps} from 'next/link';
Expand All @@ -18,6 +18,12 @@ const roboto = Roboto({
subsets: ["latin", "cyrillic"]
});

const montserrat = Montserrat({
weight: ["500", "600", "700"],
subsets: ["latin", "cyrillic"],
fallback: ["Arial", "sans-serif"]
});

type LinkBehaviourProps = LinkProps & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>;

const LinkBehaviour = forwardRef<HTMLAnchorElement, LinkBehaviourProps>(function LinkBehaviour(props, ref) {
Expand Down Expand Up @@ -45,6 +51,23 @@ let theme = createTheme({
LinkComponent: LinkBehaviour
}
}
},
typography: {
h1: {
fontFamily: montserrat.style.fontFamily
},
h2: {
fontFamily: montserrat.style.fontFamily
},
h3: {
fontFamily: montserrat.style.fontFamily
},
h4: {
fontFamily: montserrat.style.fontFamily
},
h5: {
fontFamily: montserrat.style.fontFamily
}
}
});

Expand Down
6 changes: 5 additions & 1 deletion frontend/src/app/organizations/[id]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export default function OrganizationLayout({ children, params }: {
setOrganization(newOrganization);
};

fetch().catch(e => getRequestError(e).then(m => showAlert(m, "error")));
fetch()
.catch(e => {
getRequestError(e).then(m => showAlert(m, "error"));
router.back();
});
}

const router = useRouter();
Expand Down
17 changes: 9 additions & 8 deletions frontend/src/app/organizations/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ export default function OrganizationPage({ params }: { params: { id: number } })
return await organizationService.getOrganization({ id: params.id });
}

if (organization === null)
return <ProgressSpinner />;

const canCreateWorkspace = organization.role === "OWNER" || organization.role === "ADMIN";
const canCreateWorkspace = organization != null && (organization.role === "OWNER" || organization.role === "ADMIN");

return (
<EntityPage id={params.id} entity={organization} setEntity={setOrganization} fetch={fetch}>
<WorkspaceList
source={{ kind: "organization", organizationId: params.id }}
enableCreation={canCreateWorkspace}
/>
{
organization != null
? <WorkspaceList
source={{ kind: "organization", organizationId: params.id }}
enableCreation={canCreateWorkspace}
/>
: <ProgressSpinner />
}
</EntityPage>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ export default function OrganizationTransactionCategoriesPage({ params }: { para
return await organizationService.getOrganization({ id: params.id });
}

if (organization === null)
return <ProgressSpinner />;

const canCreateCategory = organization.role === "OWNER" || organization.role === "ADMIN";
const canCreateCategory = organization != null && (organization.role === "OWNER" || organization.role === "ADMIN");

return (
<EntityPage id={params.id} entity={organization} setEntity={setOrganization} fetch={fetch}>
<TransactionCategoryList source={{ kind: "organization", organizationId: params.id }} enableCreation={canCreateCategory}/>
{
organization != null
? <TransactionCategoryList source={{ kind: "organization", organizationId: params.id }} enableCreation={canCreateCategory}/>
: <ProgressSpinner />
}
</EntityPage>
);
}
Expand Down
19 changes: 10 additions & 9 deletions frontend/src/app/organizations/[id]/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ export default function OrganizationUsersPage({ params }: { params: { id: number
return await organizationService.getOrganization({ id: params.id });
}

if (organization === null)
return <ProgressSpinner />;

const canAddUsers = organization.role === "OWNER" || organization.role === "ADMIN";
const canAddUsers = organization != null && (organization.role === "OWNER" || organization.role === "ADMIN");

return (
<EntityPage id={params.id} entity={organization} setEntity={setOrganization} fetch={fetch}>
<UserMemberList
source={{ kind: "organization", organizationId: params.id }}
addSource={{ kind: "global" }}
enableCreation={canAddUsers}
/>
{
organization != null
? <UserMemberList
source={{ kind: "organization", organizationId: params.id }}
addSource={{ kind: "global" }}
enableCreation={canAddUsers}
/>
: <ProgressSpinner />
}
</EntityPage>
);
}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/app/workspaces/[id]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export default function WorkspaceLayout({ children, params }: {
setWorkspace(newOrganization);
};

fetch().catch(e => getRequestError(e).then(m => showAlert(m, "error")));
fetch().catch(e => {
getRequestError(e).then(m => showAlert(m, "error"));
router.back();
});
}

function navigate(tab: NavigationTabKind) {
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/app/workspaces/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ export default function WorkspacePage({ params }: { params: { id: number } }) {
return await workspaceService.getWorkspace({ id: params.id });
}

if (workspace === null)
return <ProgressSpinner />;

const canCreateTransaction = workspace?.role !== "VIEWER";
const canCreateTransaction = workspace != null && workspace.role !== "VIEWER";

return (
<EntityPage id={params.id} entity={workspace} setEntity={setWorkspace} fetch={fetch}>
<TransactionList workspaceId={params.id} enableCreation={canCreateTransaction} />
{
workspace != null
? <TransactionList workspaceId={params.id} enableCreation={canCreateTransaction} />
: <ProgressSpinner />
}
</EntityPage>
);
}
11 changes: 6 additions & 5 deletions frontend/src/app/workspaces/[id]/transaction-categories/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ export default function WorkspaceTransactionCategoriesPage({ params }: { params:
return await workspaceService.getWorkspace({ id: params.id });
}

if (workspace === null)
return <ProgressSpinner />;

// If we are not "VIEWER" and have access to the workspace, then we have admin role within the organization
const canCreateCategory = workspace.role !== "VIEWER";
const canCreateCategory = workspace != null && workspace.role !== "VIEWER";

return (
<EntityPage id={params.id} entity={workspace} setEntity={setWorkspace} fetch={fetch}>
<TransactionCategoryList source={{ kind: "workspace", workspaceId: params.id }} enableCreation={canCreateCategory} />
{
workspace != null
? <TransactionCategoryList source={{ kind: "workspace", workspaceId: params.id }} enableCreation={canCreateCategory} />
: <ProgressSpinner />
}
</EntityPage>
);
}
Expand Down
22 changes: 12 additions & 10 deletions frontend/src/app/workspaces/[id]/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@ export default function WorkspaceUsersPage({ params }: { params: { id: number }
return await workspaceService.getWorkspace({ id: params.id });
}

if (workspace === null)
return <ProgressSpinner />;

// TODO: Add join with organization role on the backend. Currently has false positives
const canAddUser = workspace.kind !== "PRIVATE" && (workspace.role !== "COLLABORATOR" && workspace.role !== "VIEWER");
const addSource = workspace?.owner.organization !== undefined
const canAddUser = workspace!= null && workspace.kind !== "PRIVATE"
&& (workspace.role !== "COLLABORATOR" && workspace.role !== "VIEWER");
const addSource = workspace != null && workspace?.owner.organization !== undefined
? { kind: "organization", organizationId: workspace.owner.organization.id } as const
: { kind: "global" } as const;

return (
<EntityPage id={params.id} entity={workspace} setEntity={setWorkspace} fetch={fetch}>
<UserMemberList
source={{ kind: "workspace", workspaceId: params.id }}
addSource={addSource}
enableCreation={canAddUser}
/>
{
workspace != null
? <UserMemberList
source={{ kind: "workspace", workspaceId: params.id }}
addSource={addSource}
enableCreation={canAddUser}
/>
: <ProgressSpinner />
}
</EntityPage>
);
}
Expand Down
25 changes: 9 additions & 16 deletions frontend/src/lib/components/common/DrawerNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, Divider, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Typography } from "@mui/material";
import { Box, Button, Divider, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Typography } from "@mui/material";
import { AccountCircleOutlined, CorporateFareOutlined, WorkspacesOutlined, SpaceDashboardOutlined, LoyaltyOutlined, CategoryOutlined, LogoutOutlined } from "@mui/icons-material";
import Image from "next/image";
import DrawerNavButton from "./DrawerNavButton";
import { useContext } from "react";
import { SessionServiceContext } from "@/lib/services/SessionService";
Expand All @@ -25,18 +26,11 @@ export default function DrawerNav() {
}}
>
<ListItem disablePadding>
<ListItemText>
<Typography
variant="h1"
fontFamily={"Helvetica"}
sx={{
py: 1,
px: 2
}}
>
FMS
</Typography>
</ListItemText>
<Box display="flex" flexGrow={1} justifyContent="center">
<Button disableRipple sx={{ padding: 0 }} onClick={() => router.push("/dashboard")}>
<Image src="fms_logo.svg" width={200} height={80} alt="FMS" />
</Button>
</Box>
</ListItem>
<Divider />
<DrawerNavButton
Expand Down Expand Up @@ -87,8 +81,7 @@ export default function DrawerNav() {
/>
</ListItemIcon>
<ListItemText>
<Typography
variant="h5"
<Typography
color="error"
>
Logout
Expand All @@ -98,4 +91,4 @@ export default function DrawerNav() {
</ListItem>
</List>
);
}
}
13 changes: 6 additions & 7 deletions frontend/src/lib/components/common/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { AppBar, Box, Drawer, IconButton, Toolbar, useTheme } from "@mui/materia
import { Menu } from "@mui/icons-material";
import { useState } from "react";
import DrawerNav from "./DrawerNav";

const drawerWidth = 300
import {DRAWER_WIDTH} from "@/lib/utils/Constants";

type DrawerNavProps = {
children: React.ReactNode
Expand Down Expand Up @@ -59,7 +58,7 @@ export default function Nav({
<Box
component="nav"
sx={{
width: { sm: drawerWidth },
width: { sm: DRAWER_WIDTH },
flexShrink: { sm: 0 }
}}
>
Expand All @@ -78,7 +77,7 @@ export default function Nav({
},
'& .MuiDrawer-paper': {
boxSizing: 'border-box',
width: drawerWidth
width: DRAWER_WIDTH
}
}}
>
Expand All @@ -93,7 +92,7 @@ export default function Nav({
},
'& .MuiDrawer-paper': {
boxSizing: 'border-box',
width: drawerWidth
width: DRAWER_WIDTH
}
}}
open
Expand All @@ -109,7 +108,7 @@ export default function Nav({
flexGrow: 1,
p: 2,
width: {
sm: `calc(100% - ${drawerWidth}px)`
sm: `calc(100% - ${DRAWER_WIDTH}px)`
},
height: "100%"
}}
Expand All @@ -132,4 +131,4 @@ export default function Nav({
</Box>
</Box>
);
}
}
Loading

0 comments on commit c46e438

Please sign in to comment.