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

refactor: changed branch and type execution of workflow to main #74

Merged
merged 2 commits into from
Jul 4, 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
3 changes: 1 addition & 2 deletions .github/workflows/formating.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: Check formatting of project files with Prettier

on:
pull_request:
types: [opened, edited, synchronize]
branches:
- Dev
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
4 changes: 3 additions & 1 deletion nextjs-interface/src/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default function Layout({ children }: { children: React.ReactNode }) {
<div className="hidden w-1/6 pl-5 dark:bg-slate-700 lg:block">
<SideBarElement />
</div>
<div className="w-full h-screen pt-5 dark:bg-slate-800 lg:w-5/6">{children}</div>
<div className="h-screen w-full pt-5 dark:bg-slate-800 lg:w-5/6">
{children}
</div>
</div>
</>
);
Expand Down
14 changes: 7 additions & 7 deletions nextjs-interface/src/app/ui/all/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import { ThemeContext } from "@/lib/Theme";
// import scripts
import { getCookie, setCookie } from "@/lib/cookies";

export function Providers({ children }: { children: React.ReactNode; }) {
export function Providers({ children }: { children: React.ReactNode }) {
// set dark mode
const [darkMode, setDarkMode] = useState(() => {
const savedMode = getCookie("darkMode");
return savedMode ? savedMode === 'true' : false;
return savedMode ? savedMode === "true" : false;
});

// toggle dark mode
const toggleDarkMode = () => {
const newDarkMode = !darkMode;
setDarkMode(newDarkMode);
setCookie({name: "darkMode", value: newDarkMode});
setCookie({ name: "darkMode", value: newDarkMode });
};

return (
<ThemeContext.Provider value={{ darkMode, toggleDarkMode }}>
{children}
</ThemeContext.Provider>
<ThemeContext.Provider value={{ darkMode, toggleDarkMode }}>
{children}
</ThemeContext.Provider>
);
}
}
16 changes: 11 additions & 5 deletions nextjs-interface/src/app/ui/dashboard/ChartElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ export function ChartElement({ data }: { data: avgData[] }) {
<div className="w-[250px] rounded-xl bg-secondary dark:bg-gray-900">
<div className="p-5">
<div className="flex flex-col">
<h1 className="text-black dark:text-zinc-50">Date : {new Date(payload[0].payload.date).toLocaleDateString()}</h1>
<p className="text-black dark:text-zinc-50">
Temperature : {payload[0].payload.avg_temperature.toFixed(2)}°C</p>
<p className="text-black dark:text-zinc-50">
Humidity : {payload[0].payload.avg_humidity.toFixed(2)}%</p>
<h1 className="text-black dark:text-zinc-50">
Date :{" "}
{new Date(payload[0].payload.date).toLocaleDateString()}
</h1>
<p className="text-black dark:text-zinc-50">
Temperature :{" "}
{payload[0].payload.avg_temperature.toFixed(2)}°C
</p>
<p className="text-black dark:text-zinc-50">
Humidity : {payload[0].payload.avg_humidity.toFixed(2)}%
</p>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion nextjs-interface/src/app/ui/dashboard/EspLinksElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function EspLinksElement() {
<CirclePlus className="mt-1 w-[20px]" />
</button>
</PopoverTrigger>
<PopoverContent className="w-80 ml-5 bg-secondary dark:bg-gray-900">
<PopoverContent className="ml-5 w-80 bg-secondary dark:bg-gray-900">
<form onSubmit={handleSubmit}>
<div className="flex gap-2">
<Label>name</Label>
Expand Down
48 changes: 24 additions & 24 deletions nextjs-interface/src/lib/cookies.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
export function getCookie(cname: any) {
if (typeof window === 'undefined') {
return ""; // Early return if not in browser environment
}
if (typeof window === "undefined") {
return ""; // Early return if not in browser environment
}

const theme = cname + "=";
const decodedCookie = decodeURIComponent(document.cookie);
const ca = decodedCookie.split(';');
const theme = cname + "=";
const decodedCookie = decodeURIComponent(document.cookie);
const ca = decodedCookie.split(";");

for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(theme) == 0) {
return c.substring(theme.length, c.length);
}
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1);
}
if (c.indexOf(theme) == 0) {
return c.substring(theme.length, c.length);
}
return "";
}
return "";
}

export function setCookie(name: { name: string, value:any }) {
if (typeof window === 'undefined') {
return;
}
export function setCookie(name: { name: string; value: any }) {
if (typeof window === "undefined") {
return;
}

const d = new Date();
d.setTime(d.getTime() + (365*24*60*60*1000));
const expires = "expires=" + d.toUTCString();
document.cookie = name.name + "=" + name.value + ";" + expires + ";path=/";
}
const d = new Date();
d.setTime(d.getTime() + 365 * 24 * 60 * 60 * 1000);
const expires = "expires=" + d.toUTCString();
document.cookie = name.name + "=" + name.value + ";" + expires + ";path=/";
}