refactor: removed FirebaseService from components migrated to Django Rest

This commit is contained in:
Chneemann 2025-04-03 04:06:08 +02:00
parent 2a50d716f1
commit 94049f889d
15 changed files with 14 additions and 111 deletions

View file

@ -1,5 +1,4 @@
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FirebaseService } from '../../../../services/firebase.service';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { User } from '../../../../interfaces/user.interface'; import { User } from '../../../../interfaces/user.interface';
@ -20,7 +19,7 @@ export class AssignedListComponent {
assigned: string[] = []; assigned: string[] = [];
currentUser: User | null = null; currentUser: User | null = null;
constructor(public firebaseService: FirebaseService) {} constructor() {}
ngOnInit() { ngOnInit() {
this.loadTaskAssignedData(); this.loadTaskAssignedData();

View file

@ -1,5 +1,4 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { FirebaseService } from '../../../../services/firebase.service';
@Component({ @Component({
selector: 'app-task-menu', selector: 'app-task-menu',
@ -12,7 +11,7 @@ export class TaskMenuComponent {
@Input() taskId: string = ''; @Input() taskId: string = '';
@Input() boardTaskStatus: string = ''; @Input() boardTaskStatus: string = '';
constructor(private firebaseService: FirebaseService) {} constructor() {}
/** /**
* Moves the task to a specified status. * Moves the task to a specified status.
@ -25,18 +24,6 @@ export class TaskMenuComponent {
* @param moveTo - The new status to move the task to. * @param moveTo - The new status to move the task to.
*/ */
moveTask(moveTo: string) { moveTask(moveTo: string) {
const index = this.firebaseService.allTasks.findIndex( // TODO
(task) => task.id === this.taskId
);
const filteredIndex = this.firebaseService.filteredTasks.findIndex(
(task) => task.id === this.taskId
);
if (index !== -1) {
this.firebaseService.allTasks[index].status = moveTo;
if (filteredIndex !== -1) {
this.firebaseService.filteredTasks[filteredIndex].status = moveTo;
}
this.firebaseService.updateTask(this.taskId, index);
}
} }
} }

View file

@ -2,7 +2,6 @@ import { CommonModule } from '@angular/common';
import { Component, HostListener, Input } from '@angular/core'; import { Component, HostListener, Input } from '@angular/core';
import { DragDropService } from '../../../services/drag-drop.service'; import { DragDropService } from '../../../services/drag-drop.service';
import { Task } from '../../../interfaces/task.interface'; import { Task } from '../../../interfaces/task.interface';
import { FirebaseService } from '../../../services/firebase.service';
import { OverlayService } from '../../../services/overlay.service'; import { OverlayService } from '../../../services/overlay.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { TaskMenuComponent } from './task-menu/task-menu.component'; import { TaskMenuComponent } from './task-menu/task-menu.component';
@ -32,7 +31,6 @@ export class TaskComponent {
constructor( constructor(
public dragDropService: DragDropService, public dragDropService: DragDropService,
public firebaseService: FirebaseService,
public overlayService: OverlayService, public overlayService: OverlayService,
public resizeService: ResizeService, public resizeService: ResizeService,
private router: Router private router: Router
@ -146,46 +144,4 @@ export class TaskComponent {
return (completedSubtasksCount / this.task.subtasks.length) * 100; return (completedSubtasksCount / this.task.subtasks.length) * 100;
} }
// Assigned
/**
* Returns the initials of the user
* @param id the id of the user
* @returns the initials of the user as a string
*/
userBadged(id: string) {
const userId = String(id);
const user = this.firebaseService
.getAllUsers()
.find((user) => user.id === userId);
if (user) {
if (user.firstName === 'Guest') {
return user.firstName.charAt(0);
} else {
const firstNameLetter = user.firstName.charAt(0);
const lastNameLetter = user.lastName.charAt(0);
return firstNameLetter + lastNameLetter;
}
} else {
return;
}
}
/**
* Returns the color of the user with the given id
* @param id the id of the user
* @returns the color of the user as a string
*/
userBadgedColor(id: string) {
const userId = String(id);
const user = this.firebaseService
.getAllUsers()
.find((user) => user.id === userId);
if (user) {
return user.color;
} else {
return;
}
}
} }

View file

@ -6,7 +6,6 @@ import {
SimpleChanges, SimpleChanges,
} from '@angular/core'; } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { FirebaseService } from '../../../services/firebase.service';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { UserService } from '../../../services/user.service'; import { UserService } from '../../../services/user.service';
import { finalize, lastValueFrom } from 'rxjs'; import { finalize, lastValueFrom } from 'rxjs';
@ -33,7 +32,6 @@ export class ContactDetailComponent {
isMobileNavbarOpen: boolean = false; isMobileNavbarOpen: boolean = false;
constructor( constructor(
public firebaseService: FirebaseService,
private overlayService: OverlayService, private overlayService: OverlayService,
private userService: UserService, private userService: UserService,
private apiService: ApiService, private apiService: ApiService,

View file

@ -2,7 +2,6 @@ import { Component, HostListener } from '@angular/core';
import { User } from '../../interfaces/user.interface'; import { User } from '../../interfaces/user.interface';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ContactDetailComponent } from './contact-detail/contact-detail.component'; import { ContactDetailComponent } from './contact-detail/contact-detail.component';
import { FirebaseService } from '../../services/firebase.service';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { UserService } from '../../services/user.service'; import { UserService } from '../../services/user.service';
import { finalize, firstValueFrom, Subject, takeUntil } from 'rxjs'; import { finalize, firstValueFrom, Subject, takeUntil } from 'rxjs';
@ -26,7 +25,6 @@ export class ContactsComponent {
isLoading: boolean = false; isLoading: boolean = false;
constructor( constructor(
public firebaseService: FirebaseService,
private userService: UserService, private userService: UserService,
private overlayService: OverlayService, private overlayService: OverlayService,
private updateNotifierService: UpdateNotifierService private updateNotifierService: UpdateNotifierService

View file

@ -75,8 +75,7 @@
!checkIfUserEmailIsValid(registerData.mail.toLowerCase()) && !checkIfUserEmailIsValid(registerData.mail.toLowerCase()) &&
!isButtonDisabled()) { !isButtonDisabled()) {
<p>{{ "register.errorMail1" | translate }}</p> <p>{{ "register.errorMail1" | translate }}</p>
} @else { @if } @else { @if (existEmailOnServer(registerData.mail.toLowerCase()) &&
(existEmailOnServer(registerData.mail.toLowerCase()).length > 0 &&
!isButtonDisabled()) { !isButtonDisabled()) {
<p>{{ "register.errorMail2" | translate }}</p> <p>{{ "register.errorMail2" | translate }}</p>
} } } } } }

View file

@ -4,7 +4,6 @@ import { FooterComponent } from '../footer/footer.component';
import { FormsModule, NgForm } from '@angular/forms'; import { FormsModule, NgForm } from '@angular/forms';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { FormBtnComponent } from '../../../shared/components/buttons/form-btn/form-btn.component'; import { FormBtnComponent } from '../../../shared/components/buttons/form-btn/form-btn.component';
import { FirebaseService } from '../../../services/firebase.service';
import { LoginService } from '../../../services/login.service'; import { LoginService } from '../../../services/login.service';
import { BtnBackComponent } from '../../../shared/components/buttons/btn-back/btn-back.component'; import { BtnBackComponent } from '../../../shared/components/buttons/btn-back/btn-back.component';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
@ -41,7 +40,6 @@ export class RegisterComponent {
}; };
constructor( constructor(
private firebaseService: FirebaseService,
public loginService: LoginService, public loginService: LoginService,
public translateService: TranslateService, public translateService: TranslateService,
private buttonStateService: ButtonStateService private buttonStateService: ButtonStateService
@ -66,9 +64,7 @@ export class RegisterComponent {
} }
existEmailOnServer(mail: string) { existEmailOnServer(mail: string) {
return this.firebaseService return false; //TODO
.getAllUsers()
.filter((user) => user.email === mail);
} }
checkIfUserEmailIsValid(emailValue: string) { checkIfUserEmailIsValid(emailValue: string) {

View file

@ -1,7 +1,6 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { FirebaseService } from '../../services/firebase.service';
import { Task } from '../../interfaces/task.interface'; import { Task } from '../../interfaces/task.interface';
import { TaskService } from '../../services/task.service'; import { TaskService } from '../../services/task.service';
import { LoadingSpinnerComponent } from '../../shared/components/loading-spinner/loading-spinner.component'; import { LoadingSpinnerComponent } from '../../shared/components/loading-spinner/loading-spinner.component';
@ -25,7 +24,6 @@ export class SummaryComponent {
isLoading = false; isLoading = false;
constructor( constructor(
public firebaseService: FirebaseService,
private translateService: TranslateService, private translateService: TranslateService,
private userService: UserService, private userService: UserService,
private taskService: TaskService private taskService: TaskService

View file

@ -3,7 +3,6 @@ import { RouterModule } from '@angular/router';
import { NavbarComponent } from './navbar/navbar.component'; import { NavbarComponent } from './navbar/navbar.component';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { FirebaseService } from '../../../services/firebase.service';
import { UserService } from '../../../services/user.service'; import { UserService } from '../../../services/user.service';
import { User } from '../../../interfaces/user.interface'; import { User } from '../../../interfaces/user.interface';
@ -19,10 +18,7 @@ export class HeaderComponent {
navbarLanguageVisible: boolean = false; navbarLanguageVisible: boolean = false;
currentUser: User | null = null; currentUser: User | null = null;
constructor( constructor(private userService: UserService) {}
public firebaseService: FirebaseService,
private userService: UserService
) {}
/** /**
* Loads the current user data by calling the loadCurrentUser method. * Loads the current user data by calling the loadCurrentUser method.

View file

@ -4,7 +4,6 @@ import { LanguageService } from '../../../../services/language.service';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { LoginService } from '../../../../services/login.service'; import { LoginService } from '../../../../services/login.service';
import { FirebaseService } from '../../../../services/firebase.service';
import { AuthService } from '../../../../services/auth.service'; import { AuthService } from '../../../../services/auth.service';
@Component({ @Component({
@ -23,13 +22,11 @@ export class NavbarComponent {
constructor( constructor(
public langService: LanguageService, public langService: LanguageService,
private router: Router, private router: Router,
private authService: AuthService, private authService: AuthService
private loginService: LoginService,
private firebaseService: FirebaseService
) {} ) {}
/** /**
* OnInit lifecycle hook. * Lifecycle hook that is called after the component has been initialized.
* *
* Sets the currentRoute property to the current route's url. * Sets the currentRoute property to the current route's url.
*/ */
@ -38,13 +35,10 @@ export class NavbarComponent {
} }
/** /**
* Logs out the current user and navigates to the login page. * Logs out the current user by calling the logout method of the AuthService.
* *
* The logout method of the LoginService is called with the current user ID as * This will clear the user's authentication token and any associated session
* its argument. This will remove the user ID from the local storage and * data, and navigate the user to the logout page.
* perform any other necessary cleanup operations.
*
* The user is then navigated to the login page.
*/ */
logout() { logout() {
this.authService.logout(); this.authService.logout();

View file

@ -95,7 +95,7 @@
} @else { @if (email.touched && } @else { @if (email.touched &&
!checkIfUserEmailIsValid(contactData.email)) { !checkIfUserEmailIsValid(contactData.email)) {
<p>{{ "contactDialogForm.invalidMail1" | translate }}</p> <p>{{ "contactDialogForm.invalidMail1" | translate }}</p>
} @else { @if (existEmailOnServer(contactData.email).length > 0 && } @else { @if (existEmailOnServer(contactData.email) &&
!contactData.email) { !contactData.email) {
<p>{{ "contactDialogForm.invalidMail2" | translate }}</p> <p>{{ "contactDialogForm.invalidMail2" | translate }}</p>
} } } } } }

View file

@ -10,8 +10,6 @@ import {
import { FormsModule, NgForm } from '@angular/forms'; import { FormsModule, NgForm } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { FormBtnComponent } from '../../../buttons/form-btn/form-btn.component'; import { FormBtnComponent } from '../../../buttons/form-btn/form-btn.component';
import { FirebaseService } from '../../../../../services/firebase.service';
import { ResizeService } from '../../../../../services/resize.service'; import { ResizeService } from '../../../../../services/resize.service';
import { lastValueFrom } from 'rxjs'; import { lastValueFrom } from 'rxjs';
import { ApiService } from '../../../../../services/api.service'; import { ApiService } from '../../../../../services/api.service';
@ -35,7 +33,6 @@ export class ContactFormComponent implements OnInit, OnChanges {
@Output() closeDialogEmitter = new EventEmitter<string>(); @Output() closeDialogEmitter = new EventEmitter<string>();
constructor( constructor(
public firebaseService: FirebaseService,
public resizeService: ResizeService, public resizeService: ResizeService,
private apiService: ApiService, private apiService: ApiService,
private toastNotificationService: ToastNotificationService, private toastNotificationService: ToastNotificationService,
@ -182,16 +179,8 @@ export class ContactFormComponent implements OnInit, OnChanges {
} }
} }
/**
* Returns an array of users that have the same email address as the given argument.
* This is used to check for duplicate email addresses when adding or editing a contact.
* @param {string} mail - The email address to check.
* @return {User[]} An array of users with the same email address.
*/
existEmailOnServer(mail: string) { existEmailOnServer(mail: string) {
return this.firebaseService return false; //TODO
.getAllUsers()
.filter((user) => user.email === mail);
} }
/** /**

View file

@ -4,7 +4,6 @@ import { ContactFormComponent } from './contact-form/contact-form.component';
import { BtnCloseComponent } from '../../buttons/btn-close/btn-close.component'; import { BtnCloseComponent } from '../../buttons/btn-close/btn-close.component';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { ColorPickerModule } from 'ngx-color-picker'; import { ColorPickerModule } from 'ngx-color-picker';
import { FirebaseService } from '../../../../services/firebase.service';
@Component({ @Component({
selector: 'app-contact-overlay', selector: 'app-contact-overlay',
@ -28,7 +27,7 @@ export class ContactOverlayComponent implements OnInit {
userInitials: string = ''; userInitials: string = '';
newColor: string = ''; newColor: string = '';
constructor(public firebaseService: FirebaseService) {} constructor() {}
ngOnInit() {} ngOnInit() {}

View file

@ -1,12 +1,9 @@
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FirebaseService } from '../../../../services/firebase.service';
import { BtnCloseComponent } from '../../buttons/btn-close/btn-close.component'; import { BtnCloseComponent } from '../../buttons/btn-close/btn-close.component';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { AssignedComponent } from '../../../../components/add-task/assigned/assigned.component';
import { AddTaskComponent } from '../../../../components/add-task/add-task.component'; import { AddTaskComponent } from '../../../../components/add-task/add-task.component';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { BtnBackComponent } from '../../buttons/btn-back/btn-back.component';
import { ApiService } from '../../../../services/api.service'; import { ApiService } from '../../../../services/api.service';
@Component({ @Component({
@ -24,7 +21,6 @@ export class TaskEditOverlayComponent {
overlayMobile: boolean = false; overlayMobile: boolean = false;
constructor( constructor(
public firebaseService: FirebaseService,
private apiService: ApiService, private apiService: ApiService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router private router: Router

View file

@ -1,5 +1,4 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FirebaseService } from '../../../../services/firebase.service';
import { BtnCloseComponent } from '../../buttons/btn-close/btn-close.component'; import { BtnCloseComponent } from '../../buttons/btn-close/btn-close.component';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { OverlayService } from '../../../../services/overlay.service'; import { OverlayService } from '../../../../services/overlay.service';
@ -30,7 +29,6 @@ export class TaskOverlayComponent implements OnInit {
currentUserId: string = ''; currentUserId: string = '';
constructor( constructor(
public firebaseService: FirebaseService,
private overlayService: OverlayService, private overlayService: OverlayService,
private taskService: TaskService, private taskService: TaskService,
private authService: AuthService, private authService: AuthService,