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 { FirebaseService } from '../../../../services/firebase.service';
import { CommonModule } from '@angular/common';
import { User } from '../../../../interfaces/user.interface';
@ -20,7 +19,7 @@ export class AssignedListComponent {
assigned: string[] = [];
currentUser: User | null = null;
constructor(public firebaseService: FirebaseService) {}
constructor() {}
ngOnInit() {
this.loadTaskAssignedData();

View file

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

View file

@ -2,7 +2,6 @@ import { CommonModule } from '@angular/common';
import { Component, HostListener, Input } from '@angular/core';
import { DragDropService } from '../../../services/drag-drop.service';
import { Task } from '../../../interfaces/task.interface';
import { FirebaseService } from '../../../services/firebase.service';
import { OverlayService } from '../../../services/overlay.service';
import { Router } from '@angular/router';
import { TaskMenuComponent } from './task-menu/task-menu.component';
@ -32,7 +31,6 @@ export class TaskComponent {
constructor(
public dragDropService: DragDropService,
public firebaseService: FirebaseService,
public overlayService: OverlayService,
public resizeService: ResizeService,
private router: Router
@ -146,46 +144,4 @@ export class TaskComponent {
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,
} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FirebaseService } from '../../../services/firebase.service';
import { TranslateModule } from '@ngx-translate/core';
import { UserService } from '../../../services/user.service';
import { finalize, lastValueFrom } from 'rxjs';
@ -33,7 +32,6 @@ export class ContactDetailComponent {
isMobileNavbarOpen: boolean = false;
constructor(
public firebaseService: FirebaseService,
private overlayService: OverlayService,
private userService: UserService,
private apiService: ApiService,

View file

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

View file

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

View file

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

View file

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

View file

@ -3,7 +3,6 @@ import { RouterModule } from '@angular/router';
import { NavbarComponent } from './navbar/navbar.component';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { FirebaseService } from '../../../services/firebase.service';
import { UserService } from '../../../services/user.service';
import { User } from '../../../interfaces/user.interface';
@ -19,10 +18,7 @@ export class HeaderComponent {
navbarLanguageVisible: boolean = false;
currentUser: User | null = null;
constructor(
public firebaseService: FirebaseService,
private userService: UserService
) {}
constructor(private userService: UserService) {}
/**
* 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 { TranslateModule } from '@ngx-translate/core';
import { LoginService } from '../../../../services/login.service';
import { FirebaseService } from '../../../../services/firebase.service';
import { AuthService } from '../../../../services/auth.service';
@Component({
@ -23,13 +22,11 @@ export class NavbarComponent {
constructor(
public langService: LanguageService,
private router: Router,
private authService: AuthService,
private loginService: LoginService,
private firebaseService: FirebaseService
private authService: AuthService
) {}
/**
* OnInit lifecycle hook.
* Lifecycle hook that is called after the component has been initialized.
*
* 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
* its argument. This will remove the user ID from the local storage and
* perform any other necessary cleanup operations.
*
* The user is then navigated to the login page.
* This will clear the user's authentication token and any associated session
* data, and navigate the user to the logout page.
*/
logout() {
this.authService.logout();

View file

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

View file

@ -10,8 +10,6 @@ import {
import { FormsModule, NgForm } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { FormBtnComponent } from '../../../buttons/form-btn/form-btn.component';
import { FirebaseService } from '../../../../../services/firebase.service';
import { ResizeService } from '../../../../../services/resize.service';
import { lastValueFrom } from 'rxjs';
import { ApiService } from '../../../../../services/api.service';
@ -35,7 +33,6 @@ export class ContactFormComponent implements OnInit, OnChanges {
@Output() closeDialogEmitter = new EventEmitter<string>();
constructor(
public firebaseService: FirebaseService,
public resizeService: ResizeService,
private apiService: ApiService,
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) {
return this.firebaseService
.getAllUsers()
.filter((user) => user.email === mail);
return false; //TODO
}
/**

View file

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

View file

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

View file

@ -1,5 +1,4 @@
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 { CommonModule } from '@angular/common';
import { OverlayService } from '../../../../services/overlay.service';
@ -30,7 +29,6 @@ export class TaskOverlayComponent implements OnInit {
currentUserId: string = '';
constructor(
public firebaseService: FirebaseService,
private overlayService: OverlayService,
private taskService: TaskService,
private authService: AuthService,