diff --git a/src/renderer/components/notification/notification-item.component.tsx b/src/renderer/components/notification/notification-item.component.tsx index f2c6e6cd..3790fd72 100644 --- a/src/renderer/components/notification/notification-item.component.tsx +++ b/src/renderer/components/notification/notification-item.component.tsx @@ -10,10 +10,10 @@ import { BsmButton } from "../shared/bsm-button.component"; export function NotificationItem({resolver, index, notification}: {resolver?: (value: NotificationResult|string) => void, index: number, notification: Notification}) { const renderImage = () => { - if(notification.type === NotificationType.SUCCESS){ return ; } - if(notification.type === NotificationType.WARNING){ return ; } - if(notification.type === NotificationType.ERROR){ return ; } - return + if(notification.type === NotificationType.SUCCESS){ return BeatRunningImg; } + if(notification.type === NotificationType.WARNING){ return BeatWaitingImg; } + if(notification.type === NotificationType.ERROR){ return BeatConflictImg; } + return BeatImpatientImg; } const renderNeonColors = () => { @@ -24,23 +24,23 @@ export function NotificationItem({resolver, index, notification}: {resolver?: (v } return ( - -
+ +
- {renderImage()} +
-

{notification.title}

- {notification.desc &&

{notification.desc}

} +

{notification.title}

+ {notification.desc &&

{notification.desc}

}
{notification.actions && (
- {notification.actions.map(a => {a.title})} + {notification.actions.map(a => resolver(a.id)} className={`px-1 cursor-pointer flex-1 grow rounded-md text-center bg-blue-500 hover:brightness-110 transition-all text-gray-200 whitespace-nowrap m-[3px] ${a.cancel && "!bg-gray-500"}`}>{a.title})}
)}
- + resolver(NotificationResult.CLOSE)}/>
) } diff --git a/src/renderer/components/notification/notification-overlay.component.tsx b/src/renderer/components/notification/notification-overlay.component.tsx index f1398aaa..4751c627 100644 --- a/src/renderer/components/notification/notification-overlay.component.tsx +++ b/src/renderer/components/notification/notification-overlay.component.tsx @@ -1,7 +1,7 @@ import { useObservable } from "renderer/hooks/use-observable.hook" import { NotificationService } from "renderer/services/notification.service" import { NotificationItem } from "./notification-item.component"; -import { AnimatePresence, AnimateSharedLayout, motion } from "framer-motion"; +import { AnimatePresence, motion } from "framer-motion"; export function NotificationOverlay() { diff --git a/src/renderer/services/bs-downloader.service.ts b/src/renderer/services/bs-downloader.service.ts index 58b86875..989a2841 100644 --- a/src/renderer/services/bs-downloader.service.ts +++ b/src/renderer/services/bs-downloader.service.ts @@ -19,6 +19,7 @@ export class BsDownloaderService{ private readonly authService: AuthUserService; public readonly currentBsVersionDownload$: BehaviorSubject = new BehaviorSubject(null); + public readonly downloadProgress$: BehaviorSubject = new BehaviorSubject(0); public readonly downloadWarning$: BehaviorSubject = new BehaviorSubject(null); diff --git a/src/renderer/services/notification.service.ts b/src/renderer/services/notification.service.ts index d12b7082..2a99af11 100644 --- a/src/renderer/services/notification.service.ts +++ b/src/renderer/services/notification.service.ts @@ -14,17 +14,13 @@ export class NotificationService{ private constructor(){ this.notifications$ = new BehaviorSubject([]); - - setInterval(() => { - this.notify({title: "coucou le testaze aze azeazeaze", desc: "ceci est un test de notification ne rien faire", actions:[{id: "1",title: "Continuer"}, {id: "1",title: "Faire autre"}, {id: "1",title: "Annuler", cancel: true}]}); - }, 5000) } public notify(notification: Notification): Promise{ let resovableNotification: ResolvableNotification; const promise = new Promise(resolve => { resovableNotification = {id: uuidv4(), notification: notification, resolver: resolve } - setTimeout(() => resolve(NotificationResult.NO_CHOICE), notification.duration || 10000); + setTimeout(() => resolve(NotificationResult.NO_CHOICE), notification.duration || 7000); }); this.notifications$.next([...this.notifications$.value, resovableNotification]); @@ -36,6 +32,21 @@ export class NotificationService{ return promise; } + public notifyError(notification: Notification): Promise{ + notification.type = NotificationType.ERROR; + return this.notify(notification); + } + + public notifyWarning(notification: Notification): Promise{ + notification.type = NotificationType.WARNING; + return this.notify(notification); + } + + public notifySuccess(notification: Notification): Promise{ + notification.type = NotificationType.SUCCESS; + return this.notify(notification); + } + } export interface Notification {