-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial notifications component u#2899
- Loading branch information
Showing
20 changed files
with
656 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
javascript/apps/taiga/src/app/modules/auth/data-access/+state/actions/user.actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright (c) 2023-present Kaleidos INC | ||
*/ | ||
|
||
import { createActionGroup, emptyProps, props } from '@ngrx/store'; | ||
import { NotificationType } from '@taiga/data'; | ||
|
||
export const UserActions = createActionGroup({ | ||
source: 'User', | ||
events: { | ||
'Set notification number': props<{ | ||
notifications: { | ||
read: number; | ||
total: number; | ||
unread: number; | ||
}; | ||
}>(), | ||
'Init notification section': emptyProps(), | ||
'Fetch notifications success': props<{ | ||
notifications: NotificationType[]; | ||
}>(), | ||
}, | ||
}); | ||
|
||
export const UserEventsActions = createActionGroup({ | ||
source: 'User ws', | ||
events: { | ||
'new notification': props<{ notification: NotificationType }>(), | ||
}, | ||
}); |
52 changes: 52 additions & 0 deletions
52
...cript/apps/taiga/src/app/modules/auth/data-access/+state/effects/notifications.effects.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright (c) 2023-present Kaleidos INC | ||
*/ | ||
|
||
import { Injectable, inject } from '@angular/core'; | ||
import { Actions, createEffect, ofType } from '@ngrx/effects'; | ||
import * as AuthActions from '../actions/auth.actions'; | ||
import { Store } from '@ngrx/store'; | ||
import { UsersApiService } from '@taiga/api'; | ||
import { exhaustMap, map } from 'rxjs'; | ||
import { UserActions, UserEventsActions } from '../actions/user.actions'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class NotificationsEffects { | ||
private actions$ = inject(Actions); | ||
private store = inject(Store); | ||
private usersApiService = inject(UsersApiService); | ||
|
||
public notificationCount$ = createEffect(() => { | ||
return this.actions$.pipe( | ||
ofType( | ||
AuthActions.setUser, | ||
AuthActions.loginSuccess, | ||
UserEventsActions.newNotification | ||
), | ||
exhaustMap(() => { | ||
return this.usersApiService.notificationsCount().pipe( | ||
map((notifications) => { | ||
return UserActions.setNotificationNumber({ notifications }); | ||
}) | ||
); | ||
}) | ||
); | ||
}); | ||
|
||
public fetchNotifications$ = createEffect(() => { | ||
return this.actions$.pipe( | ||
ofType(UserActions.initNotificationSection), | ||
exhaustMap(() => { | ||
return this.usersApiService.notifications().pipe( | ||
map((notifications) => { | ||
return UserActions.fetchNotificationsSuccess({ notifications }); | ||
}) | ||
); | ||
}) | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
javascript/apps/taiga/src/app/shared/navigation/notification/notification.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
Copyright (c) 2023-present Kaleidos INC | ||
*/ | ||
|
||
:host { | ||
&:not(:last-child) { | ||
border-block-end: 1px solid var(--color-gray20); | ||
padding-block-end: var(--spacing-12); | ||
} | ||
|
||
&::ng-deep .username { | ||
color: var(--color-secondary); | ||
} | ||
} | ||
|
||
.type { | ||
color: var(--color-gray80); | ||
} | ||
|
||
.date { | ||
color: var(--color-gray70); | ||
font-size: var(--font-size-small); | ||
} | ||
|
||
.notification-inner { | ||
display: flex; | ||
gap: var(--spacing-8); | ||
inline-size: 100%; | ||
padding: var(--spacing-8); | ||
} | ||
|
||
p { | ||
line-height: 21px; | ||
margin: 0; | ||
} | ||
|
||
a { | ||
&:hover { | ||
text-decoration: underline; | ||
} | ||
} | ||
|
||
.unread .notification-inner { | ||
background-color: var(--color-gray10); | ||
border-radius: 4px; | ||
position: relative; | ||
|
||
&::before { | ||
aspect-ratio: 1; | ||
background-color: var(--color-secondary); | ||
block-size: 8px; | ||
border-radius: 50%; | ||
content: ""; | ||
inset-block-start: var(--spacing-12); | ||
inset-inline-end: var(--spacing-8); | ||
position: absolute; | ||
} | ||
} |
Oops, something went wrong.