Skip to content

Commit 4839317

Browse files
committed
reflow org
1 parent 0d02858 commit 4839317

File tree

20 files changed

+171
-70
lines changed

20 files changed

+171
-70
lines changed

src/app/core/models/post.models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export interface PostCardInfo {
22
id: string;
3+
orgId: string;
34
avatar: string;
45
author: string;
56
accountName: string;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ export function getNavHorizontalItems(roles: string[]): SidebarItem[] {
5454
},
5555
{
5656
id: 'organization ',
57-
path: roles.includes('ADMIN')
58-
? '/organization/orgs-list'
59-
: '/organization/org-list-post',
57+
path: '/organization/orgs-list',
6058
label: 'Tổ chức',
6159
icon: 'fa-solid fa-building-user',
6260
// needHidden: !roles.includes(auth_lv2[0]),

src/app/core/router-manager/vetical-menu-dynamic/org-vertical-menu.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export function sidebarOrgRouter(roles: string[]): SidebarItem[] {
99
path: '/organization/orgs-list',
1010
label: 'Danh sách tổ chức',
1111
icon: 'fa-solid fa-tasks',
12-
needHidden: !roles.includes(auth_lv2[0]),
1312
},
1413
{
1514
id: 'list-posts-org',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const version = 'v1';
1212

1313
export const API_CONFIG = {
1414
BASE_URLS: {
15-
MAIN_API: environment.IP_SERVER, //chạy ở local thì đổi ip thành IP_SERVER_LOCAL và thêm "+ version" vào chuỗi MAIN_API (sau IP). push lên github nhớ stash commit hoặc không làm thay đổi dòng này.
15+
MAIN_API: environment.IP_SERVER_LOCAL + version, //chạy ở local thì đổi ip thành IP_SERVER_LOCAL và thêm "+ version" vào chuỗi MAIN_API (sau IP). push lên github nhớ stash commit hoặc không làm thay đổi dòng này.
1616
SECONDARY_API: '',
1717
},
1818
ENDPOINTS: {

src/app/features/auth/pages/login/login.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class Login {
135135
onGoogleLogin() {
136136
const params = new URLSearchParams({
137137
client_id: OAuthConfig.google.clientId,
138-
redirect_uri: OAuthConfig.google.redirectUriServer,
138+
redirect_uri: OAuthConfig.google.redirectUri,
139139
response_type: 'code',
140140
scope: 'email profile openid',
141141
include_granted_scopes: 'true',

src/app/features/auth/pages/oauth-callback/oauth-callback.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import { Router, ActivatedRoute } from '@angular/router';
44
import { AuthService } from '../../../../core/services/api-service/auth.service';
55
import { LoadingOverlayComponent } from '../../../../shared/components/fxdonad-shared/loading-overlay/loading-overlay.component';
66
import { Store } from '@ngrx/store';
7-
import {
8-
openModalNotification,
9-
sendNotification,
10-
} from '../../../../shared/utils/notification';
11-
import { setVariable } from '../../../../shared/store/variable-state/variable.actions';
7+
import { sendNotification } from '../../../../shared/utils/notification';
128

139
@Component({
1410
selector: 'app-oauth-callback',

src/app/features/example-slide/using-card-data/using-card-data.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Component } from '@angular/core';
22
import type { CardExcercise } from '../../../shared/components/fxdonad-shared/card-excercise/card-excercise.component';
33
import { CardExcerciseComponent } from '../../../shared/components/fxdonad-shared/card-excercise/card-excercise.component';
44

5-
65
@Component({
76
selector: 'app-using-card-data',
87
imports: [CardExcerciseComponent],
@@ -14,6 +13,7 @@ export class UsingCardDataComponent {
1413

1514
data: CardExcercise = {
1615
id: 'kjdhajsdas-sdadadas-fsdgadfa',
16+
orgId: '',
1717
title: 'Thuật toán tìm kiếm nhị phân sử dụng ngôn ngữ JavaScript',
1818
description:
1919
'Bài viết về thuật toán tìm kiếm nhị phân, một thuật toán hiệu quả để tìm kiếm một phần tử trong một mảng đã sắp xếp. Có thể là một thuật toán tuyệt vời',

src/app/features/excercise/exercise-pages/list-exercise/list-exercise.component.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,27 @@
5858
>
5959
</app-dropdown-button>
6060
</div>
61+
<div class="dropdown-filter">
62+
<app-dropdown-button
63+
[label]="'Loại bài tập'"
64+
[options]="isJustOrg"
65+
[variant]="'secondary'"
66+
[size]="'medium'"
67+
[customDropField]="'main-type'"
68+
[disabled]="false"
69+
[multiSelect]="false"
70+
[isDisplayCheckbox]="false"
71+
(onSelect)="handleSelect(isJustOrgKey, $event)"
72+
[isOpen]="activeDropdown === isJustOrgKey"
73+
(toggle)="toggleDropdown(isJustOrgKey)"
74+
[isDisplaySelectedOpptionLabels]="true"
75+
[isButtonControl]="false"
76+
[isSearchable]="false"
77+
[minHeight]="true"
78+
[needIndexColor]="true"
79+
>
80+
</app-dropdown-button>
81+
</div>
6182

6283
@if (isActionActive) {
6384
<div class="create-exercise-btn">

src/app/features/excercise/exercise-pages/list-exercise/list-exercise.component.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
tagsData,
3131
} from '../../../../core/constants/value.constant';
3232
import { activeForAdminAndTeacher } from '../../../../shared/utils/authenRoleActions';
33+
import { getMyOrgId } from '../../../../shared/utils/userInfo';
3334

3435
@Component({
3536
selector: 'app-list-exercise',
@@ -42,8 +43,8 @@ import { activeForAdminAndTeacher } from '../../../../shared/utils/authenRoleAct
4243
ScrollEndDirective,
4344
BtnType1Component,
4445
GenerateExerciseModalComponent,
45-
LottieComponent
46-
],
46+
LottieComponent,
47+
],
4748
templateUrl: './list-exercise.component.html',
4849
styleUrl: './list-exercise.component.scss',
4950
})
@@ -64,6 +65,7 @@ export class ListExerciseComponent implements OnInit {
6465

6566
filterTagsKey = 'tags';
6667
filterDifficultyKey = 'do-kho';
68+
isJustOrgKey = 'isJustOrg';
6769

6870
tagsSelected: string = '';
6971
difficultySelected: number | null = null;
@@ -72,9 +74,12 @@ export class ListExerciseComponent implements OnInit {
7274
selectedOptions: { [key: string]: any } = {};
7375
activeDropdown: string | null = null;
7476
errorSearch = '';
77+
myOrgId = '';
7578

7679
listExercise: CardExcercise[] = [];
80+
listExerciseForSeacrh: CardExcercise[] = [];
7781
tags: { value: string; label: string }[] = [];
82+
isJustOrg: { value: string; label: string }[] = [];
7883
difficultyLevel: { value: string; label: string }[] = [];
7984

8085
isActionActive = activeForAdminAndTeacher();
@@ -86,13 +91,20 @@ export class ListExerciseComponent implements OnInit {
8691
{ value: '1', label: 'Trung bình' },
8792
{ value: '2', label: 'Khó' },
8893
];
94+
95+
this.isJustOrg = [
96+
{ value: '0', label: 'Bài tập công khai' },
97+
{ value: '1', label: 'Bài tập trong tổ chức' },
98+
];
8999
}
90100

91101
private mapExerciseResToCardDataUI(data: ExerciseItem[]): CardExcercise[] {
92102
return data.map((info) => mapExerciseResToCardUI(info));
93103
}
94104

95105
ngOnInit(): void {
106+
this.myOrgId = getMyOrgId();
107+
96108
this.fetchData();
97109
}
98110

@@ -111,6 +123,7 @@ export class ListExerciseComponent implements OnInit {
111123
next: (res) => {
112124
const data = this.mapExerciseResToCardDataUI(res.result.data);
113125
this.listExercise = data;
126+
this.listExerciseForSeacrh = data;
114127
if (res.result.currentPage >= res.result.totalPages) {
115128
this.hasMore = false;
116129
}
@@ -142,6 +155,7 @@ export class ListExerciseComponent implements OnInit {
142155
this.hasMore = false;
143156
}
144157
this.listExercise = [...this.listExercise, ...newData];
158+
this.listExerciseForSeacrh = [...this.listExercise, ...newData];
145159
this.isLoadingMore = false;
146160
},
147161
error: (err) => {
@@ -175,25 +189,33 @@ export class ListExerciseComponent implements OnInit {
175189
handleSelect(dropdownKey: string, selected: any): void {
176190
// Reset toàn bộ các lựa chọn trước đó tránh thừa query
177191
this.selectedOptions = {};
178-
179192
this.pageIndex = 1;
180193

181194
// Lưu lại option vừa chọn
182195
this.selectedOptions[dropdownKey] = selected;
183196

184197
if (dropdownKey === this.filterTagsKey) {
185198
this.tagsSelected = this.filterData(dropdownKey);
199+
this.fetchData();
186200
} else if (dropdownKey === this.filterDifficultyKey) {
187201
this.difficultySelected = this.filterData(dropdownKey)
188202
? Number(this.filterData(dropdownKey))
189203
: null;
204+
this.fetchData();
205+
} else if (dropdownKey === this.isJustOrgKey) {
206+
// ✅ Filter FE: không call API
207+
if (selected.value === '1') {
208+
// chỉ lấy bài tập trong tổ chức
209+
this.listExercise = this.listExerciseForSeacrh.filter(
210+
(ex) => ex.orgId === this.myOrgId
211+
);
212+
} else {
213+
// lấy tất cả
214+
this.listExercise = [...this.listExerciseForSeacrh];
215+
}
190216
} else {
191217
console.log('filter không khả dụng: ', dropdownKey);
192218
}
193-
194-
this.fetchData();
195-
196-
// this.router.navigate(['/', dropdownKey, selected.label]);
197219
}
198220

199221
toggleDropdown(id: string): void {

src/app/features/organization/organization-routing.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ const routes: Routes = [
1717
path: 'orgs-list',
1818
component: OrganizationManagementComponent,
1919
title: 'Quản lý tổ chức',
20-
data: { breadcrumb: 'Quản lý tổ chức', roles: ['ADMIN'] },
21-
canActivate: [RoleGuard],
20+
data: { breadcrumb: 'Quản lý tổ chức' },
2221
},
2322
{
2423
path: 'in-org/:orgId',

0 commit comments

Comments
 (0)