Skip to content

Commit 61ca103

Browse files
committed
fix some flows org
1 parent b35079b commit 61ca103

File tree

19 files changed

+316
-228
lines changed

19 files changed

+316
-228
lines changed

src/app/app.routes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ export const routes: Routes = [
144144
import('./features/organization/organization.module').then(
145145
(m) => m.OrganizationModule
146146
),
147-
data: { roles: ['ADMIN'] },
148-
canActivate: [RoleGuard],
149147
},
150148
],
151149
},

src/app/core/models/comment.models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface CommentResponse {
3232
content: string;
3333
replies?: CommentResponse[] | []; // đệ quy
3434
user: User;
35+
createdAt: string;
3536
}
3637

3738
export interface AddCommentResponse {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface NotificationEvent {
2+
channel: string;
3+
recipient: string;
4+
templateCode: string;
5+
param: Record<string, any>;
6+
subject: string;
7+
body: string;
8+
}

src/app/core/router-manager/horizontal-menu.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ export function getNavHorizontalItems(roles: string[]): SidebarItem[] {
5353
},
5454
{
5555
id: 'organization ',
56-
path: '/organization/orgs-list',
56+
path: roles.includes('ADMIN')
57+
? '/organization/orgs-list'
58+
: '/organization/org-list-post',
5759
label: 'Tổ chức',
5860
icon: 'fa-solid fa-building-user',
59-
isVisible: !roles.includes(auth_lv2[0]),
61+
// isVisible: !roles.includes(auth_lv2[0]),
6062
},
6163
];
6264
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
import { SidebarItem } from '../../models/data-handle';
22

33
export function sidebarOrgRouter(roles: string[]): SidebarItem[] {
4+
const auth_lv2 = ['ADMIN'];
5+
46
return [
57
{
68
id: 'list-orgs',
79
path: '/organization/orgs-list',
810
label: 'Danh sách tổ chức',
911
icon: 'fa-solid fa-tasks',
12+
isVisible: !roles.includes(auth_lv2[0]),
13+
},
14+
{
15+
id: 'list-posts-org',
16+
path: '/organization/org-list-post',
17+
label: 'Danh sách bài viết',
18+
icon: 'fa-solid fa-newspaper',
19+
},
20+
{
21+
id: 'list-exercise-org',
22+
path: '/organization/org-list-exercise',
23+
label: 'Danh sách bài tập',
24+
icon: 'fa-solid fa-book',
1025
},
1126
];
1227
}

src/app/core/services/api-service/notification-list.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ export class NotificationListService {
3131
Ids
3232
);
3333
}
34+
35+
countMyUnread() {
36+
return this.api.get<ApiResponse<number>>(
37+
API_CONFIG.ENDPOINTS.GET.GET_COUNT_MY_UNREAD
38+
);
39+
}
3440
}

src/app/core/services/config-service/api.enpoints.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ export const API_CONFIG = {
207207
readStatus: ReadStatusNotice
208208
) =>
209209
`/notification/my?page=${page}&size=${size}&readStatus=${readStatus}`,
210+
GET_COUNT_MY_UNREAD: '/notification/my/unread-count',
210211
},
211212
POST: {
212213
LOGIN: '/identity/auth/login',
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export const CODE_COMPILER_SOCKET = 'http://localhost:4098';
22
export const CONVERSATION_CHAT_SOCKET = 'http://localhost:4099';
3+
export const NOTIFICATION_SOCKET_PORT = 'http://localhost:4101';
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// notification.service.ts
2+
import { Injectable } from '@angular/core';
3+
import { Observable } from 'rxjs';
4+
import { SocketConnectionService } from '../config-socket/socketConnection.service';
5+
import { NOTIFICATION_SOCKET_PORT } from '../config-socket/port-socket';
6+
7+
export interface NotificationEvent {
8+
channel: string;
9+
recipient: string;
10+
templateCode: string;
11+
param: Record<string, any>;
12+
subject: string;
13+
body: string;
14+
}
15+
16+
@Injectable({ providedIn: 'root' })
17+
export class NotificationService {
18+
private readonly url = `${NOTIFICATION_SOCKET_PORT}?token=${localStorage.getItem(
19+
'token'
20+
)}`;
21+
22+
constructor(private socketService: SocketConnectionService) {
23+
this.socketService.connect(this.url);
24+
}
25+
26+
listenNotifications(): Observable<NotificationEvent> {
27+
return this.socketService.on<NotificationEvent>(this.url, 'notification');
28+
}
29+
}

0 commit comments

Comments
 (0)