Skip to content

Commit b72a1cf

Browse files
committed
implement logic into components from facades except project edit
1 parent fe266d2 commit b72a1cf

120 files changed

Lines changed: 1648 additions & 6814 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

projects/social_platform/src/app/api/auth/facades/auth-login.service.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ export class AuthLoginService {
1414
private readonly authService = inject(AuthService);
1515
private readonly route = inject(ActivatedRoute);
1616
private readonly router = inject(Router);
17+
private readonly validationService = inject(ValidationService);
1718
private readonly authUIInfoService = inject(AuthUIInfoService);
1819

1920
private readonly destroy$ = new Subject<void>();
2021

22+
private readonly loginForm = this.authUIInfoService.loginForm;
23+
2124
// Login Component
2225
readonly showPassword = this.authUIInfoService.showPassword;
2326
readonly loginIsSubmitting = this.authUIInfoService.loginIsSubmitting;
@@ -28,13 +31,17 @@ export class AuthLoginService {
2831
this.destroy$.complete();
2932
}
3033

31-
onSubmit(loginForm: LoginRequest) {
34+
onSubmit() {
3235
const redirectType = this.route.snapshot.queryParams["redirect"];
3336

37+
if (!this.validationService.getFormValidation(this.loginForm) || this.loginIsSubmitting()) {
38+
return;
39+
}
40+
3441
this.loginIsSubmitting.set(true);
3542

3643
this.authService
37-
.login(loginForm)
44+
.login(this.loginForm.value as LoginRequest)
3845
.pipe(takeUntil(this.destroy$))
3946
.subscribe({
4047
next: res => {

projects/social_platform/src/app/api/auth/facades/auth-password.service.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** @format */
22

3-
import { inject, Injectable, signal } from "@angular/core";
4-
import { FormGroup } from "@angular/forms";
3+
import { inject, Injectable } from "@angular/core";
54
import { ActivatedRoute, Router } from "@angular/router";
65
import { ValidationService } from "@corelib";
76
import { map, Subject, takeUntil } from "rxjs";
@@ -16,6 +15,9 @@ export class AuthPasswordService {
1615
private readonly validationService = inject(ValidationService);
1716
private readonly authUIInfoService = inject(AuthUIInfoService);
1817

18+
private readonly passwordForm = this.authUIInfoService.passwordForm;
19+
private readonly resetForm = this.authUIInfoService.resetForm;
20+
1921
private readonly destroy$ = new Subject<void>();
2022

2123
// ResetPassword-Confirmation Component
@@ -30,26 +32,34 @@ export class AuthPasswordService {
3032
readonly credsSubmitInitiated = this.authUIInfoService.credsSubmitInitiated;
3133
private readonly errorServer = this.authUIInfoService.errorServer;
3234

35+
init(): void {
36+
const token = this.route.snapshot.queryParamMap.get("token");
37+
if (!token) {
38+
// Handle the case where token is not present
39+
console.error("Token is missing");
40+
}
41+
}
42+
3343
// ResetPassword Component
34-
onSubmitResetPassword(resetForm: FormGroup): void {
35-
if (!this.validationService.getFormValidation(resetForm)) return;
44+
onSubmitResetPassword(): void {
45+
if (!this.validationService.getFormValidation(this.resetForm)) return;
3646

3747
this.errorServer.set(false);
3848
this.isSubmitting.set(true);
3949

40-
this.authService.resetPassword(resetForm.value.email).subscribe({
50+
this.authService.resetPassword(this.resetForm.value.email!).subscribe({
4151
next: () => {
4252
this.router
4353
.navigate(["/auth/reset_password/confirm"], {
44-
queryParams: { email: resetForm.value.email },
54+
queryParams: { email: this.resetForm.value.email },
4555
})
4656
.then(() => console.debug("ResetPasswordComponent"));
4757
},
4858
error: () => {
4959
this.errorServer.set(true);
5060
this.isSubmitting.set(false);
5161

52-
resetForm.reset();
62+
this.resetForm.reset();
5363
},
5464
complete: () => {
5565
this.isSubmitting.set(false);
@@ -58,13 +68,13 @@ export class AuthPasswordService {
5868
}
5969

6070
// SetPassword Component
61-
onSubmitSetPassword(passwordForm: FormGroup): void {
71+
onSubmitSetPassword(): void {
6272
this.credsSubmitInitiated.set(true);
6373
const token = this.route.snapshot.queryParamMap.get("token");
6474

65-
if (!token || !this.validationService.getFormValidation(passwordForm)) return;
75+
if (!token || !this.validationService.getFormValidation(this.passwordForm)) return;
6676

67-
this.authService.setPassword(passwordForm.value.password, token).subscribe({
77+
this.authService.setPassword(this.passwordForm.value.password!, token).subscribe({
6878
next: () => {
6979
this.router.navigateByUrl("/auth/login").then(() => console.debug("SetPasswordComponent"));
7080
},

projects/social_platform/src/app/api/auth/facades/auth-register.service.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/** @format */
22

33
import { inject, Injectable, signal } from "@angular/core";
4-
import { FormGroup } from "@angular/forms";
54
import { Router } from "@angular/router";
65
import { Subject, takeUntil } from "rxjs";
76
import { AuthService } from "../auth.service";
8-
import { ValidationService } from "@corelib";
97
import { AuthUIInfoService } from "./ui/auth-ui-info.service";
10-
import dayjs from "dayjs";
8+
import { ValidationService } from "@corelib";
119

1210
@Injectable()
1311
export class AuthRegisterService {
@@ -16,6 +14,8 @@ export class AuthRegisterService {
1614
private readonly validationService = inject(ValidationService);
1715
private readonly authUIInfoService = inject(AuthUIInfoService);
1816

17+
private readonly registerForm = this.authUIInfoService.registerForm;
18+
1919
readonly registerAgreement = this.authUIInfoService.registerAgreement;
2020
readonly ageAgreement = this.authUIInfoService.ageAgreement;
2121
readonly registerIsSubmitting = this.authUIInfoService.registerIsSubmitting;
@@ -38,8 +38,12 @@ export class AuthRegisterService {
3838
this.destroy$.complete();
3939
}
4040

41-
onSendForm(registerForm: FormGroup): void {
42-
const form = this.authUIInfoService.prepareFormValues(registerForm);
41+
onSendForm(): void {
42+
if (!this.validationService.getFormValidation(this.registerForm)) {
43+
return;
44+
}
45+
46+
const form = this.authUIInfoService.prepareFormValues(this.registerForm);
4347

4448
this.registerIsSubmitting.set(true);
4549

projects/social_platform/src/app/api/chat/facedes/chat-direct-info.service.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -70,32 +70,12 @@ export class ChatDirectInfoService {
7070
*
7171
*/
7272
initializationChatFiles(): void {
73-
if (this.chatType === "project") {
74-
// Загрузка файлов чата проекта
75-
this.chatService
76-
.loadProjectFiles(Number(this.route.parent?.snapshot.paramMap.get("projectId")))
77-
.pipe(takeUntil(this.destroy$))
78-
.subscribe(files => {
79-
this.chatFiles.set(files);
80-
});
81-
} else if (this.chatType === "direct") {
82-
// Загрузка файлов прямого чата
83-
const chatId = this.chat()?.id;
84-
if (chatId) {
85-
this.chatService
86-
.loadDirectChatFiles(chatId)
87-
.pipe(takeUntil(this.destroy$))
88-
.subscribe(
89-
files => {
90-
this.chatFiles.set(files);
91-
},
92-
error => {
93-
// Если метод не поддерживается на сервере, логируем ошибку
94-
console.warn("Failed to load direct chat files:", error);
95-
}
96-
);
97-
}
98-
}
73+
this.chatService
74+
.loadProjectFiles(Number(this.route.parent?.snapshot.paramMap.get("projectId")))
75+
.pipe(takeUntil(this.destroy$))
76+
.subscribe(files => {
77+
this.chatFiles.set(files);
78+
});
9979
}
10080

10181
private initializationProfile(): void {
@@ -138,7 +118,7 @@ export class ChatDirectInfoService {
138118
)
139119
: this.chatService
140120
.loadMessages(
141-
this.getChatId(),
121+
+this.getChatId(),
142122
this.messages().length > 0 ? this.messages().length : 0,
143123
this.chatDirectUIInfoService.messagesPerFetch
144124
)

projects/social_platform/src/app/api/chat/facedes/ui/chat-direct-ui-info.service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export class ChatDirectUIInfoService {
3636
/** Флаг процесса загрузки сообщений */
3737
readonly fetching = signal<boolean>(false);
3838

39+
readonly isAsideMobileShown = signal<boolean>(false);
40+
3941
/**
4042
* Количество сообщений, загружаемых за один запрос
4143
*/
@@ -96,4 +98,9 @@ export class ChatDirectUIInfoService {
9698
this.typingTimeouts.forEach(id => clearTimeout(id));
9799
this.typingTimeouts.clear();
98100
}
101+
102+
/** Переключение боковой панели на мобильных устройствах */
103+
onToggleMobileAside(): void {
104+
this.isAsideMobileShown.set(!this.isAsideMobileShown());
105+
}
99106
}

projects/social_platform/src/app/office/services/export-file.service.ts renamed to projects/social_platform/src/app/api/export-file/export-file.service.ts

File renamed without changes.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/** @format */
2+
3+
import { inject, Injectable, signal } from "@angular/core";
4+
import { ExportFileService } from "../export-file.service";
5+
import { saveFile } from "@utils/helpers/export-file";
6+
import { ProgramDetailMainUIInfoService } from "../../program/facades/detail/ui/program-detail-main-ui-info.service";
7+
import { Subject, takeUntil } from "rxjs";
8+
9+
@Injectable()
10+
export class ExportFileInfoService {
11+
private readonly exportFileService = inject(ExportFileService);
12+
private readonly programDetailMainUIInfoService = inject(ProgramDetailMainUIInfoService);
13+
14+
private readonly destroy$ = new Subject<void>();
15+
16+
private readonly program = this.programDetailMainUIInfoService.program;
17+
18+
readonly loadingExportProjects = signal<boolean>(false);
19+
readonly loadingExportSubmittedProjects = signal<boolean>(false);
20+
readonly loadingExportRates = signal<boolean>(false);
21+
readonly loadingExportCalculations = signal<boolean>(false);
22+
23+
destroy(): void {
24+
this.destroy$.next();
25+
this.destroy$.complete();
26+
}
27+
28+
downloadProjects(): void {
29+
this.loadingExportProjects.set(true);
30+
31+
this.exportFileService
32+
.exportAllProjects(this.program()!.id)
33+
.pipe(takeUntil(this.destroy$))
34+
.subscribe({
35+
next: blob => {
36+
saveFile(blob, "all", this.program()?.name);
37+
this.loadingExportProjects.set(false);
38+
},
39+
error: err => {
40+
console.error(err);
41+
this.loadingExportProjects.set(false);
42+
},
43+
});
44+
}
45+
46+
downloadSubmittedProjects(): void {
47+
this.loadingExportSubmittedProjects.set(true);
48+
49+
this.exportFileService
50+
.exportSubmittedProjects(this.program()!.id)
51+
.pipe(takeUntil(this.destroy$))
52+
.subscribe({
53+
next: blob => {
54+
saveFile(blob, "submitted", this.program()?.name);
55+
this.loadingExportSubmittedProjects.set(false);
56+
},
57+
error: () => {
58+
this.loadingExportSubmittedProjects.set(false);
59+
},
60+
});
61+
}
62+
63+
downloadRates(): void {
64+
this.loadingExportRates.set(true);
65+
66+
this.exportFileService
67+
.exportProgramRates(this.program()!.id)
68+
.pipe(takeUntil(this.destroy$))
69+
.subscribe({
70+
next: blob => {
71+
saveFile(blob, "rates", this.program()?.name);
72+
this.loadingExportRates.set(false);
73+
},
74+
error: () => {
75+
this.loadingExportRates.set(false);
76+
},
77+
});
78+
}
79+
80+
downloadCalculations(): void {}
81+
}

projects/social_platform/src/app/api/kanban/kanban-board-detail-info.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { computed, inject, Injectable, signal } from "@angular/core";
44
import { TaskDetail } from "../../domain/kanban/task.model";
55
import { User } from "projects/social_platform/src/app/domain/auth/user.model";
66
import { filter, Observable, of, Subject } from "rxjs";
7-
import { ProjectDataService } from "../project/project-data.service";
87
import { ActivatedRoute, Router } from "@angular/router";
98
import { AuthService } from "projects/social_platform/src/app/api/auth";
9+
import { ProjectsDetailUIInfoService } from "../project/facades/detail/ui/projects-detail-ui.service";
1010

1111
@Injectable({
1212
providedIn: "root",
@@ -58,7 +58,7 @@ export class KanbanBoardDetailInfoService {
5858
readonly currentUser = signal<User | null>(null);
5959

6060
private readonly authService = inject(AuthService);
61-
private readonly projectDataService = inject(ProjectDataService);
61+
private readonly projectsDetailUIInfoService = inject(ProjectsDetailUIInfoService);
6262
private readonly router = inject(Router);
6363
readonly route = inject(ActivatedRoute);
6464

@@ -74,8 +74,8 @@ export class KanbanBoardDetailInfoService {
7474
this.taskDetail.set(detail);
7575
}
7676

77-
leaderId = this.projectDataService.leaderId;
78-
collaborators = this.projectDataService.collaborators;
77+
leaderId = this.projectsDetailUIInfoService.leaderId;
78+
collaborators = this.projectsDetailUIInfoService.collaborators;
7979

8080
isLeader = computed(() => {
8181
const user = this.currentUser();

projects/social_platform/src/app/api/member/facades/members-info.service.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ import {
2222
import { MemberService } from "../member.service";
2323
import { AuthService } from "../../auth";
2424
import { User } from "../../../domain/auth/user.model";
25-
import { AbstractControl, FormGroup } from "@angular/forms";
25+
import { AbstractControl } from "@angular/forms";
2626
import { ApiPagination } from "projects/skills/src/models/api-pagination.model";
2727
import { MembersUIInfoService } from "./ui/members-ui-info.service";
2828
import { NavigationService } from "../../paths/navigation.service";
29+
import { ProjectsDetailUIInfoService } from "../../project/facades/detail/ui/projects-detail-ui.service";
2930

3031
@Injectable()
3132
export class MembersInfoService {
3233
private readonly route = inject(ActivatedRoute);
3334
private readonly router = inject(Router);
3435
private readonly navService = inject(NavService);
36+
private readonly projectsDetailUIInfoService = inject(ProjectsDetailUIInfoService);
3537
private readonly memberService = inject(MemberService);
3638
private readonly membersUIInfoService = inject(MembersUIInfoService);
3739
private readonly authService = inject(AuthService);
@@ -40,8 +42,8 @@ export class MembersInfoService {
4042
private readonly searchParams = signal<Record<string, string>>({}); // Signal для параметров поиска
4143

4244
private readonly membersTake = this.membersUIInfoService.membersTake; // Количество участников на странице
43-
readonly members = this.membersUIInfoService.members; // Массив участников для отображения
44-
private readonly profileId = this.membersUIInfoService.profileId;
45+
private readonly members = this.membersUIInfoService.members; // Массив участников для отображения
46+
private readonly profileId = this.projectsDetailUIInfoService.profileId;
4547

4648
private readonly searchForm = this.membersUIInfoService.searchForm;
4749
private readonly filterForm = this.membersUIInfoService.filterForm;
@@ -80,7 +82,7 @@ export class MembersInfoService {
8082
)
8183
.subscribe({
8284
next: user => {
83-
this.membersUIInfoService.applyProfileId(user);
85+
this.projectsDetailUIInfoService.applySetLoggedUserId("profile", user.id);
8486
},
8587
});
8688
}
@@ -214,12 +216,7 @@ export class MembersInfoService {
214216
* @returns Observable<User[]> - Массив участников
215217
*/
216218
private onFetch(skip: number, take: number, params?: Record<string, string | number | boolean>) {
217-
return this.memberService.getMembers(skip, take, params).pipe(
218-
takeUntil(this.destroy$),
219-
tap(members => {
220-
this.membersUIInfoService.applyMembersPagination(members);
221-
})
222-
);
219+
return this.memberService.getMembers(skip, take, params).pipe(takeUntil(this.destroy$));
223220
}
224221

225222
redirectToProfile(): void {

0 commit comments

Comments
 (0)