Working on implementation of alert policies. Some refactoring in user profile and patching a bug in status endpoint api.

This commit is contained in:
charlesgauthereau
2025-11-28 23:10:37 +01:00
parent d968aa9c16
commit 934e635cdb
29 changed files with 3364 additions and 1551 deletions
@@ -1,22 +1,22 @@
import { cn } from "@/lib/utils";
import {cn} from "@/lib/utils";
export type ConnectionCircleProps = {
date?: Date | null;
};
export const ConnectionCircle = ({ date }: ConnectionCircleProps) => {
export const ConnectionCircle = ({date}: ConnectionCircleProps) => {
let style = "bg-gray-300 border-gray-400";
if (date instanceof Date && !isNaN(date.getTime())) {
const now = Date.now();
const timestamp = date.getTime();
const interval = now - timestamp;
const interval_seconds = (now - timestamp) / 1000;
console.log({ now, timestamp, interval });
console.log({now, timestamp, interval_seconds});
if (interval < 10000) {
if (interval_seconds < 55) {
style = "bg-green-400 border-green-600";
} else if (interval <= 20000) {
} else if (interval_seconds <= 60) {
style = "bg-orange-400 border-orange-600";
} else {
style = "bg-red-400 border-red-600";
@@ -27,5 +27,5 @@ export const ConnectionCircle = ({ date }: ConnectionCircleProps) => {
console.log(style);
return <div className={cn("w-5 h-5 rounded-full border-4", style)} />;
return <div className={cn("w-5 h-5 rounded-full border-4", style)}/>;
};
@@ -1,28 +1,36 @@
import {Icon} from "@iconify/react";
import {CircleHelp, KeyRound} from "lucide-react";
import {cn} from "@/lib/utils";
export const providerSwitch = (provider: string) => {
export const providerSwitch = (provider: string, small?: boolean) => {
switch (provider) {
case "google":
return (
<div className="p-4">
<Icon icon={"logos:google"} height="24" />
<div className={cn(small ? "p-0" : "p-4")}>
{small ?
<Icon icon={"flat-color-icons:google"} height="24"/>
:
<Icon icon={"logos:google"} height="24"/>
}
</div>
);
case "credential":
return (
<div className="flex flex-row gap-x-2 items-center p-4">
<KeyRound height="24" />
<span>Email and Password</span>
<div className={cn("flex flex-row gap-x-2 items-center", small ? "p-0" : "p-4")}>
<KeyRound height="24"/>
{!small && (<span>Email and Password</span>)}
</div>
);
default:
return (
<div className="flex flex-row gap-x-2 items-center p-4">
<CircleHelp height="24" />
<span>No credentials</span>
<div className={cn("flex flex-row gap-x-2 items-center", small ? "p-0" : "p-4")}>
<CircleHelp height="24"/>
{!small && (<span>No credentials</span>)}
</div>
);
}
}
}