refactor: remove unused code and apply minor optimizations
This commit is contained in:
parent
37cdddab1a
commit
239c4f59e1
9 changed files with 14 additions and 163 deletions
|
|
@ -52,7 +52,6 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.routeParams();
|
|
||||||
this.deleteTokens();
|
this.deleteTokens();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,17 +60,6 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
routeParams() {
|
|
||||||
this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
|
||||||
if (params['id'] && params['id'] === 'pw-send') {
|
|
||||||
this.overlayService.setOverlayData('dialog', 'pw-send');
|
|
||||||
}
|
|
||||||
if (params['id'] && params['id'] === 'pw-change') {
|
|
||||||
this.overlayService.setOverlayData('dialog', 'pw-change');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
isButtonDisabled() {
|
isButtonDisabled() {
|
||||||
return this.buttonStateService.isButtonDisabled;
|
return this.buttonStateService.isButtonDisabled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
<div class="date">
|
<div class="date">
|
||||||
<div>
|
<div>
|
||||||
@if (urgentTasks.length) {
|
@if (urgentTasks.length) {
|
||||||
<span>{{ nextUrgentTask }}</span>
|
<span>{{ nextUrgentTask | date }}</span>
|
||||||
<p class="spacer">
|
<p class="spacer">
|
||||||
{{ "summary.upcomingDeadline" | translate }}
|
{{ "summary.upcomingDeadline" | translate }}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,13 @@ import {
|
||||||
PRIORITIES,
|
PRIORITIES,
|
||||||
PRIORITY_LABELS,
|
PRIORITY_LABELS,
|
||||||
} from '../../constants/task-priority.constants';
|
} from '../../constants/task-priority.constants';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-summary',
|
selector: 'app-summary',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
|
CommonModule,
|
||||||
RouterModule,
|
RouterModule,
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
LoadingSpinnerComponent,
|
LoadingSpinnerComponent,
|
||||||
|
|
@ -49,9 +51,8 @@ export class SummaryComponent implements OnInit, OnDestroy {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method performs the following actions:
|
* Loads all tasks and the current user. Initializes the component
|
||||||
* - Calls the loadAllTasks method to load all tasks.
|
* by fetching necessary data from the TaskService and UserService.
|
||||||
* - Calls the loadCurrentUser method to load the current user.
|
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.loadAllTasks();
|
this.loadAllTasks();
|
||||||
|
|
@ -132,31 +133,12 @@ export class SummaryComponent implements OnInit, OnDestroy {
|
||||||
* Retrieves the date of the next urgent task.
|
* Retrieves the date of the next urgent task.
|
||||||
* @returns {string | null} The date of the next urgent task formatted as a string, or null if no urgent tasks exist.
|
* @returns {string | null} The date of the next urgent task formatted as a string, or null if no urgent tasks exist.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
get nextUrgentTask(): string | null {
|
get nextUrgentTask(): string | null {
|
||||||
if (this.urgentTasks.length === 0) return null;
|
return this.urgentTasks.length
|
||||||
|
? this.urgentTasks.reduce((a, b) =>
|
||||||
const nextTask = this.urgentTasks.reduce((earliest, current) => {
|
Date.parse(a.date) < Date.parse(b.date) ? a : b
|
||||||
return Date.parse(current.date) < Date.parse(earliest.date)
|
).date
|
||||||
? current
|
: null;
|
||||||
: earliest;
|
|
||||||
});
|
|
||||||
|
|
||||||
return this.timeConverter(nextTask.date);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a date string to a human-readable format.
|
|
||||||
* @param dateString - The date string to convert.
|
|
||||||
* @returns A string representing the date in the format "MMM. DD, YYYY".
|
|
||||||
*/
|
|
||||||
timeConverter(dateString: string): string {
|
|
||||||
const date = new Date(dateString);
|
|
||||||
return date.toLocaleDateString('en-US', {
|
|
||||||
month: 'short',
|
|
||||||
day: 'numeric',
|
|
||||||
year: 'numeric',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -164,14 +146,9 @@ export class SummaryComponent implements OnInit, OnDestroy {
|
||||||
* @returns a localized greeting string.
|
* @returns a localized greeting string.
|
||||||
*/
|
*/
|
||||||
get greeting(): string {
|
get greeting(): string {
|
||||||
const currentHour = new Date().getHours();
|
const hour = new Date().getHours();
|
||||||
|
const key =
|
||||||
if (currentHour >= 5 && currentHour < 12) {
|
hour < 5 || hour >= 18 ? 'evening' : hour < 12 ? 'morning' : 'afternoon';
|
||||||
return this.translateService.instant('summary.morning');
|
return this.translateService.instant(`summary.${key}`);
|
||||||
}
|
|
||||||
if (currentHour >= 12 && currentHour < 18) {
|
|
||||||
return this.translateService.instant('summary.afternoon');
|
|
||||||
}
|
|
||||||
return this.translateService.instant('summary.evening');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
<section>
|
|
||||||
<div class="header">
|
|
||||||
<div class="headline">{{ "msgDialog.noticeHeadline" | translate }}</div>
|
|
||||||
<app-btn-close (click)="closeOverlay()"></app-btn-close>
|
|
||||||
</div>
|
|
||||||
<p>
|
|
||||||
@if (overlayData === "pw-send") { {{ "msgDialog.pwSend" | translate }} }
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
@if (overlayData === "pw-change") { {{ "msgDialog.pwChange" | translate }} }
|
|
||||||
</p>
|
|
||||||
</section>
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
section {
|
|
||||||
width: 500px;
|
|
||||||
height: fit-content;
|
|
||||||
padding: 24px;
|
|
||||||
border-radius: 24px;
|
|
||||||
background-color: var(--white);
|
|
||||||
box-shadow: 4px 4px 4px 0px rgba(0, 0, 0, 0.1);
|
|
||||||
p {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 21px;
|
|
||||||
font-weight: 500;
|
|
||||||
padding-bottom: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding-bottom: 18px;
|
|
||||||
.headline {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------- RESPONSIVE -------------*/
|
|
||||||
|
|
||||||
@media screen and (max-width: 600px) {
|
|
||||||
section {
|
|
||||||
width: calc(100vw - 96px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 450px) {
|
|
||||||
section {
|
|
||||||
p {
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { DialogOverlayComponent } from './dialog-overlay.component';
|
|
||||||
|
|
||||||
describe('DialogOverlayComponent', () => {
|
|
||||||
let component: DialogOverlayComponent;
|
|
||||||
let fixture: ComponentFixture<DialogOverlayComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
imports: [DialogOverlayComponent]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(DialogOverlayComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
||||||
import { BtnCloseComponent } from '../../buttons/btn-close/btn-close.component';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-dialog-overlay',
|
|
||||||
standalone: true,
|
|
||||||
imports: [BtnCloseComponent, TranslateModule],
|
|
||||||
templateUrl: './dialog-overlay.component.html',
|
|
||||||
styleUrl: './dialog-overlay.component.scss',
|
|
||||||
})
|
|
||||||
export class DialogOverlayComponent {
|
|
||||||
@Input() overlayData: string = '';
|
|
||||||
@Input() overlayType: string = '';
|
|
||||||
@Output() closeDialogEmitter = new EventEmitter<boolean>();
|
|
||||||
|
|
||||||
constructor(private router: Router) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Navigates to the login route and emits an empty string via the
|
|
||||||
* "closeDialogEmitter" output event, which can be used to close the overlay
|
|
||||||
* from the parent component.
|
|
||||||
*/
|
|
||||||
closeOverlay() {
|
|
||||||
this.router.navigate(['/login']);
|
|
||||||
this.closeDialogEmitter.emit(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -21,12 +21,6 @@
|
||||||
[overlayType]="overlayType"
|
[overlayType]="overlayType"
|
||||||
(closeDialogEmitter)="onCloseOverlay()"
|
(closeDialogEmitter)="onCloseOverlay()"
|
||||||
></app-task-edit-overlay>
|
></app-task-edit-overlay>
|
||||||
} @case ('dialogOverlay') {
|
|
||||||
<app-dialog-overlay
|
|
||||||
[overlayData]="overlayData"
|
|
||||||
[overlayType]="overlayType"
|
|
||||||
(closeDialogEmitter)="onCloseOverlay()"
|
|
||||||
></app-dialog-overlay>
|
|
||||||
} @case ('contactOverlay') {
|
} @case ('contactOverlay') {
|
||||||
<app-contact-overlay
|
<app-contact-overlay
|
||||||
[overlayData]="overlayData"
|
[overlayData]="overlayData"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import { OverlayService } from '../../../services/overlay.service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { TaskOverlayComponent } from './task-overlay/task-overlay.component';
|
import { TaskOverlayComponent } from './task-overlay/task-overlay.component';
|
||||||
import { TaskEditOverlayComponent } from './task-edit-overlay/task-edit-overlay.component';
|
import { TaskEditOverlayComponent } from './task-edit-overlay/task-edit-overlay.component';
|
||||||
import { DialogOverlayComponent } from './dialog-overlay/dialog-overlay.component';
|
|
||||||
import { ContactOverlayComponent } from './contact-overlay/contact-overlay.component';
|
import { ContactOverlayComponent } from './contact-overlay/contact-overlay.component';
|
||||||
import { Subject, takeUntil } from 'rxjs';
|
import { Subject, takeUntil } from 'rxjs';
|
||||||
|
|
||||||
|
|
@ -15,7 +14,6 @@ import { Subject, takeUntil } from 'rxjs';
|
||||||
TaskOverlayComponent,
|
TaskOverlayComponent,
|
||||||
TaskEditOverlayComponent,
|
TaskEditOverlayComponent,
|
||||||
ContactOverlayComponent,
|
ContactOverlayComponent,
|
||||||
DialogOverlayComponent,
|
|
||||||
],
|
],
|
||||||
templateUrl: './overlay.component.html',
|
templateUrl: './overlay.component.html',
|
||||||
styleUrl: './overlay.component.scss',
|
styleUrl: './overlay.component.scss',
|
||||||
|
|
@ -25,7 +23,6 @@ export class OverlayComponent implements OnInit, OnDestroy {
|
||||||
| 'taskOverlay'
|
| 'taskOverlay'
|
||||||
| 'taskOverlayEdit'
|
| 'taskOverlayEdit'
|
||||||
| 'newTaskOverlay'
|
| 'newTaskOverlay'
|
||||||
| 'dialogOverlay'
|
|
||||||
| 'contactOverlay'
|
| 'contactOverlay'
|
||||||
| null = null;
|
| null = null;
|
||||||
overlayData: any = null;
|
overlayData: any = null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue