Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
5fd44ed
start of websocket implementation
PaulaScharf Oct 2, 2024
61ebe62
redirect to login if unauthorized
PaulaScharf Oct 7, 2024
978cdea
Create template.env
bkari02 Oct 7, 2024
ddd6083
websocket for trashcan charts
PaulaScharf Oct 7, 2024
51387fd
Merge branch 'main' of github.com:TinyAIoT/trashcan-frontend
PaulaScharf Oct 7, 2024
3753adb
update github link
PaulaScharf Oct 7, 2024
5423aef
live updating of trahscans in lists and other minor fixes
PaulaScharf Oct 9, 2024
c1aa86d
only update specific sensor value via mqtt
PaulaScharf Oct 9, 2024
a647412
minor refactoring
PaulaScharf Oct 10, 2024
1baf95a
update dashboard
PaulaScharf Oct 23, 2024
6a8aefd
fix dashboard heatmap
PaulaScharf Oct 24, 2024
3ff9de3
adjust bandwidth of heatmap
PaulaScharf Oct 24, 2024
58f6f31
adjust bandwidth of heatmap
PaulaScharf Oct 24, 2024
171bc3d
fix fill and battery updates from web socket
PaulaScharf Oct 28, 2024
7d27900
fix ts errors
PaulaScharf Nov 13, 2024
e0ce105
update comments
PaulaScharf Nov 15, 2024
e01ca35
login page and icons has been fixed
ammar450 Nov 19, 2024
988f6e3
Updated Map.tsx with optimized logic
ammar450 Nov 20, 2024
4954fd0
Merge pull request #13 from TinyAIoT/my-bug-fix-map-branch
PaulaScharf Nov 25, 2024
d13439e
Fix: Updated Map.tsx in bugs-fix-map branch
ammar450 Nov 25, 2024
45b58e8
Fix: Updated Map.tsx in bugs-fix-map branch tokern from local storage
ammar450 Nov 25, 2024
f8307f6
Fix: Updated Map.tsx in bugs-fix-map branch tokern from local storage
ammar450 Nov 25, 2024
bb375c6
Fix: icon and template.env file
ammar450 Nov 25, 2024
3463f08
Fix: Removeextra lines
ammar450 Nov 25, 2024
7b4bddd
Fix: types.ts
ammar450 Nov 25, 2024
658bea6
Merge pull request #11 from TinyAIoT/bugs-fix-map
PaulaScharf Nov 25, 2024
a01f169
language fix is resolved
ammar450 Nov 26, 2024
9f3ade5
Merge branch 'main' of https://github.com/TinyAIoT/trashcan-frontend …
ammar450 Nov 26, 2024
6096035
adjust some german translations
PaulaScharf Nov 26, 2024
1804ede
Language for given issues has been resolved
ammar450 Nov 26, 2024
d688a1c
Merge branch 'language-fix-bug' of https://github.com/TinyAIoT/trashc…
ammar450 Nov 26, 2024
4b82689
Fixed language
ammar450 Nov 26, 2024
f691aae
Loading history branched fix
ammar450 Nov 27, 2024
c1998bb
language bracnh and table issue has been resolved
ammar450 Nov 29, 2024
d1bed9c
Merge pull request #15 from TinyAIoT/language-fix-bug
PaulaScharf Dec 2, 2024
5ce9dd2
fixing routes
ammar450 Dec 2, 2024
36909da
routing issue has been fixed
ammar450 Dec 3, 2024
5612c2f
Merge branch 'main' into loading-history
PaulaScharf Dec 3, 2024
efad50b
add translations for no history
PaulaScharf Dec 3, 2024
b4d7b5c
Merge pull request #17 from TinyAIoT/loading-history
PaulaScharf Dec 3, 2024
2d92258
Merge pull request #19 from TinyAIoT/route-correction-bug
PaulaScharf Dec 4, 2024
d6b1af2
axios import
PaulaScharf Dec 4, 2024
f91c988
Merge pull request #20 from TinyAIoT/fix/axios-import
PaulaScharf Dec 4, 2024
4132e23
axios post and patch instead of api
PaulaScharf Dec 4, 2024
eb20f2e
Merge pull request #22 from TinyAIoT/fix/axios-post-patch
PaulaScharf Dec 4, 2024
0d60fca
collector_ID issue has been fixed
ammar450 Dec 4, 2024
f31fc66
build issue and path issue has been fixed
ammar450 Dec 5, 2024
c2fe2b7
Trashbin and Build and also routing issue has been resolved
ammar450 Dec 5, 2024
37d3985
fixed all the issues related to collector id routing and build and al…
ammar450 Dec 6, 2024
0423914
some buttons green and only selected icon for routing
PaulaScharf Dec 6, 2024
34b971b
Merge pull request #23 from TinyAIoT/Trashbin-collector-id
PaulaScharf Dec 6, 2024
742b08d
three days ago instead of a week
PaulaScharf Dec 6, 2024
7bdd26f
Merge pull request #24 from TinyAIoT/feat/three-days
PaulaScharf Dec 6, 2024
c413740
rename
PaulaScharf Dec 6, 2024
200f681
Merge pull request #25 from TinyAIoT/feat/three-days
PaulaScharf Dec 6, 2024
f21f8b0
proxy
PaulaScharf Dec 10, 2024
e9493e1
fix socket url
PaulaScharf Dec 12, 2024
2cace8b
Project page and fill level interval has been resolved
ammar450 Dec 17, 2024
f9f104c
redirect all unauthorized to login
PaulaScharf Dec 17, 2024
c0b54d0
Merge pull request #29 from TinyAIoT/feat/redirect-unauthorized-login
PaulaScharf Dec 17, 2024
a37071f
log has been removed
ammar450 Dec 18, 2024
19c4d64
Merge pull request #30 from TinyAIoT/Project-page-setting
PaulaScharf Dec 19, 2024
215bdd1
login instead of email on frontend has been implemented
ammar450 Dec 19, 2024
50c9325
remove menu
shadiamanan Dec 20, 2024
9b44912
clustring wiht different color has been implemented
ammar450 Dec 21, 2024
fe4aba2
Merge pull request #31 from TinyAIoT/name-login-instead-email
PaulaScharf Dec 21, 2024
49572e8
fixed the comments
ammar450 Dec 22, 2024
b2d7226
Merge branch 'main' into Clustering-visualization
PaulaScharf Dec 22, 2024
af3963e
Merge pull request #33 from TinyAIoT/Clustering-visualization
PaulaScharf Dec 22, 2024
5810ed6
Update SideNavbar.tsx
shadiamanan Dec 23, 2024
67d3a4e
Update en.json
shadiamanan Dec 23, 2024
58d6a02
Added new menu item for "Project Settings" in the Navigation Bar
shadiamanan Dec 23, 2024
83e44ae
Update SideNavbar.tsx
shadiamanan Dec 24, 2024
ed4a3e5
Update SideNavbar.tsx
shadiamanan Dec 24, 2024
0c55a77
Added the logout button in Side Navigation bar and added the logout f…
shadiamanan Dec 27, 2024
7579ca1
Update de.json
shadiamanan Jan 2, 2025
39571a1
localization issues has been fixed
ammar450 Jan 4, 2025
f57e1cb
Features added: Added ThemeProvider for dark mode support. Added Them…
shadiamanan Jan 8, 2025
3af78ec
dynamic userid has been implemented
ammar450 Jan 13, 2025
1172c1b
mix up issues has been fixed
ammar450 Jan 13, 2025
55b851b
localization has been fixed also mixup
ammar450 Jan 13, 2025
e86f302
Merge pull request #34 from TinyAIoT/localization-fix
PaulaScharf Jan 13, 2025
4eddb96
Implemented Dark Mode in front end (Issue#8 on GitHub)
shadiamanan Jan 14, 2025
afdea5b
osrm https
PaulaScharf Jan 21, 2025
dc61bc1
Tooltips in main dashboard and in "Trashbins" tab were disappearing i…
shadiamanan Jan 28, 2025
6aea2b2
Space between Route and Trashbins tab fixed and reduced in SideNavBar
shadiamanan Jan 30, 2025
ff95f04
Fixed the issue that "Dashboard Tab" is always selected in dark mode …
shadiamanan Jan 31, 2025
8f31a52
fix authToken
PaulaScharf Feb 3, 2025
9edc937
Merge pull request #38 from TinyAIoT/fix/auth-token
PaulaScharf Feb 3, 2025
67248f9
Merge pull request #36 from TinyAIoT/fix/osrm-https
PaulaScharf Feb 3, 2025
c108726
fix router dependency
PaulaScharf Feb 3, 2025
c01c399
The bar on the left hand side of the screen has been removed now for …
shadiamanan Feb 6, 2025
c26f356
Fixed trashbin table styling. It is now restored.
shadiamanan Feb 7, 2025
325abd1
Merge branch 'main' into shadia-branch
PaulaScharf Feb 11, 2025
4e8a393
Merge pull request #32 from TinyAIoT/shadia-branch
PaulaScharf Feb 11, 2025
f30ac39
Line Chart Updated Based on Time Gap Between the Data Points
shadiamanan Feb 20, 2025
2312558
Updated the line chart for reflecting the gaps on x-axis based on tim…
shadiamanan Mar 12, 2025
8f6afc3
remove commented out
PaulaScharf Mar 17, 2025
9698767
Merge branch 'main' into graph-branch
PaulaScharf Mar 17, 2025
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is a frontend dashboard application for displaying information collected by

To get a local copy running, follow these steps:

1. Clone the repository: `git clone git@github.com:tinyaiot-ps/frontend.git`
1. Clone the repository: `git clone git@github.com:TinyAIoT/trashcan-frontend.git`
2. Install [NodeJS](https://nodejs.org/en/download/)
3. Install the dependencies: `npm install`
4. Obtain the `.env` variables (-> cf. documentation)
Expand Down
129 changes: 129 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,132 @@
visibility: visible;
opacity: 1;
}
/* Add this to your global CSS or a dedicated CSS module */
.language-switcher-container {
position: fixed; /* Fixed position to stay at the top-right of the viewport */
top: 16px; /* Distance from the top */
right: 16px; /* Distance from the right */
z-index: 1000; /* Ensure it's above other elements */
display: flex;
align-items: center;
justify-content: center;
}

.language-switcher-container .icon-button {
width: 40px; /* Adjust size */
height: 40px;
background: white;
border-radius: 50%; /* Circular button */
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Subtle shadow effect */
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: transform 0.2s ease, background-color 0.2s ease;
}

.language-switcher-container .icon-button:hover {
transform: scale(1.1); /* Slightly enlarge on hover */
background-color: #f0f0f0; /* Light gray hover effect */
}

/* Apply background and text colors dynamically */
body {
background-color: #ffffff; /* Light mode */
color: #000000;
transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transitions */

/* Light Mode Input */
.input {
background-color: hsl(var(--input)); /* Light mode background */
color: hsl(var(--foreground)); /* Light mode text color */
border: 1px solid hsl(var(--border)); /* Light mode border */
}

/* Dark Mode Input */
html.dark .input {
background-color: hsl(var(--secondary)); /* Dark mode background */
color: hsl(var(--foreground)); /* Dark mode text color */
border: 1px solid hsl(var(--border)); /* Dark mode border */
}


}

/* Additional utility classes for reusable theming */
.card {
background-color: hsl(var(--card));
color: hsl(var(--card-foreground));
}

.border {
border-color: hsl(var(--border));
}

.input {
background-color: hsl(var(--input));
color: hsl(var(--foreground));
border-color: hsl(var(--border));
}

/* Smooth transition for theme toggle */
* {
transition: background-color 0.3s ease, color 0.3s ease;
}

/* Container for theme switcher button */
.theme-switcher-container {
position: fixed;
top: 16px; /* Align with the language switcher */
right: 72px; /* Positioned near the language switcher */
z-index: 1000; /* Ensure it appears above other elements */
display: flex;
align-items: center;
justify-content: center;
}

.theme-switcher-container .icon-button {
width: 40px;
height: 40px;
background: white;
border-radius: 50%; /* Circular button */
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: transform 0.2s ease, background-color 0.2s ease;
}

.theme-switcher-container .icon-button:hover {
transform: scale(1.1); /* Hover effect */
background-color: #f0f0f0; /* Light gray hover effect */
}


html.light body {
background-color: hsl(var(--background));
color: hsl(var(--foreground));
}

html.dark body {
background-color: #1a202c; /* Dark mode */
color: #ffffff;
}

/* Focus state for input fields */
.input:focus {
outline: none;
border-color: hsl(var(--ring)); /* Focus ring color */
box-shadow: 0 0 0 2px hsl(var(--ring)); /* Outer ring effect */
}

/* Placeholder color */
.input::placeholder {
color: hsl(var(--muted-foreground)); /* Subtle placeholder color */
}

/* Dark mode placeholder */
html.dark .input::placeholder {
color: hsl(var(--muted-foreground)); /* Match dark mode style */
}
70 changes: 49 additions & 21 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
"use client";

import { ThemeProvider, useTheme } from "@/lib/ThemeContext";
import ThemeSwitcher from "@/components/ThemeSwitcher";
import { Inter } from "next/font/google";
import "./globals.css";
import { TranslationProvider } from "../lib/TranslationContext";
import "../app/globals.css"
import { cn } from "../lib/utils";
import SideNavbar from "@/components/SideNavbar";
import LanguageSwitcher from "@/components/LanguageSwitcher";
import { useEffect, useState } from "react";
//import { useTheme } from "@/lib/ThemeContext";


const inter = Inter({ subsets: ["latin"] });

type HistoryStateArguments = [data: any, unused: string, url?: string | URL | null | undefined];

// Override pushState and replaceState methods, as they otherwise don't trigger events
// when only navigating within the app instead of reloading the page
const overrideHistoryMethods = () => {
const pushState = history.pushState;
history.pushState = function (...args: HistoryStateArguments) {
Expand All @@ -34,36 +38,40 @@ const overrideHistoryMethods = () => {
});
};


export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const [showNavigation, setShowNavigation] = useState(false);
const [token, setToken] = useState<string>("");

const [loading, setLoading] = useState(true);

// Add mounted state
const [mounted, setMounted] = useState(false);

// Set mounted to true after client-side rendering
useEffect(() => {
setMounted(true);
}, []);

useEffect(() => {
overrideHistoryMethods();
const storedToken = localStorage.getItem("authToken");
if (storedToken) setToken(storedToken);
setLoading(false);
}, []);

// Enforce login on all pages except the login page
useEffect(() => {
if (loading) return;
// This effect depends on `token`, so it will re-run when `token` changes.
// Initially, it runs after the token is retrieved from localStorage.
const pathname = window.location.pathname;
const noAuthPaths = ["/login"];
if (!token && !noAuthPaths.includes(pathname)) {
window.location.href = "/login"; // Redirect to login page
window.location.href = "/login";
}
}, [token, loading]); // Depend on `token` to re-run this effect when it changes
}, [token, loading]);

// Hide the navigation bar on some subpages
useEffect(() => {
const noNavigationPaths = ["/login", "/projects"];

Expand All @@ -72,36 +80,56 @@ export default function RootLayout({
setShowNavigation(!noNavigationPaths.includes(pathname));
};

handlePathChange(); // Call initially to set the correct state
handlePathChange();
window.addEventListener("locationchange", handlePathChange);

return () => {
window.removeEventListener("locationchange", handlePathChange);
};
}, []);

return (
<html lang="en">
const { theme } = useTheme(); // Get theme context

// Prevent rendering until mounted to avoid hydration errors
if (!mounted) {
return null; // Return nothing until mounted
}

return (
<ThemeProvider>
<html lang="en" data-theme={theme}>
<head>
<title>TinyAIoT Dashboard</title>
</head>
<body
className={cn(
"min-h-screen w-full bg-white text-black flex ",
`min-h-screen w-full flex ${
theme === "dark" ? "bg-black text-white" : "bg-white text-black"
}`,
inter.className,
{
"debug-screens": process.env.NODE_ENV === "development",
}
)}
>
{showNavigation && (
<div className="h-screen">
<SideNavbar />
</div>
)}
{/* Main page */}
<div className="p-8 w-full">{children}</div>


<TranslationProvider>
{/* Language Switcher in the Header */}
<header className="flex justify-end p-4 bg-gray-100">
<LanguageSwitcher />
<ThemeSwitcher />
</header>
{showNavigation && (
<div className="h-screen">
<SideNavbar />
</div>
)}
<main className="p-8 w-full">{children}</main>
</TranslationProvider>

</body>
</html>
</ThemeProvider>
);
}
Loading