diff --git a/src/app/components/summary/summary.component.html b/src/app/components/summary/summary.component.html index 0983ac6..3aae6c5 100644 --- a/src/app/components/summary/summary.component.html +++ b/src/app/components/summary/summary.component.html @@ -3,41 +3,39 @@ [title]="'Join 360'" [description]="'summary.headlineDescription' | translate" > + @if (!isLoading) {
- -
+ +
+ + @for (status of UPPER_STATUSES; track status) {
-
- -
+ + @if (status === 'todo') { + Todo + } @else { + Done + }
- {{ taskStatusCounts.get("todo") || 0 }} -

{{ "summary.todo" | translate }}

-
-
-
-
- -
-
- {{ taskStatusCounts.get("done") || 0 }} -

{{ "summary.done" | translate }}

+ {{ taskStatusCounts.get(status) || 0 }} +

{{ STATUS_LABELS[status] | translate }}

+ }
- -
+ +
{{ urgentTasks.length || 0 }} -

{{ "summary.urgent" | translate }}

+

{{ PRIORITY_LABELS[PRIORITIES[2]] | translate }}

@@ -58,8 +56,8 @@
- -
+ +
{{ totalTasks || 0 }} @@ -70,40 +68,32 @@

+ + + @for (status of LOWER_STATUSES; track status) {
- {{ taskStatusCounts.get("inprogress") || 0 }} + {{ taskStatusCounts.get(status) || 0 }}

- {{ "summary.taskProgress0" | translate }}
{{ - "summary.taskProgress1" | translate - }} -

-
-
-
-
- {{ taskStatusCounts.get("awaitfeedback") || 0 }} -

- {{ "summary.taskAwaitingFeedback0" | translate }}
{{ - "summary.taskAwaitingFeedback1" | translate - }} + {{ STATUS_LABELS[status] | translate }}

+ }
- +

{{ greeting }},

- @if (currentUser) { - {{ currentUser["firstName"] }}
- {{ currentUser["lastName"] }} + {{ currentUser!.firstName }}
+ {{ currentUser!.lastName }}
- }
+ + } @else {
diff --git a/src/app/components/summary/summary.component.scss b/src/app/components/summary/summary.component.scss index 9de32b4..a5ef5c8 100644 --- a/src/app/components/summary/summary.component.scss +++ b/src/app/components/summary/summary.component.scss @@ -37,8 +37,8 @@ height: 562px; } -.top-frame, -.bottom-frame { +.top-container, +.bottom-container { display: flex; justify-content: space-between; } diff --git a/src/app/components/summary/summary.component.ts b/src/app/components/summary/summary.component.ts index b6623d4..42e4c3c 100644 --- a/src/app/components/summary/summary.component.ts +++ b/src/app/components/summary/summary.component.ts @@ -5,10 +5,17 @@ import { Task } from '../../interfaces/task.interface'; import { TaskService } from '../../services/task.service'; import { LoadingSpinnerComponent } from '../../shared/components/loading-spinner/loading-spinner.component'; import { finalize, Subject, takeUntil } from 'rxjs'; - import { UserService } from '../../services/user.service'; import { User } from '../../interfaces/user.interface'; import { HeadlineComponent } from '../../shared/components/headline/headline.component'; +import { + STATUS_LABELS, + TaskStatus, +} from '../../constants/task-status.constants'; +import { + PRIORITIES, + PRIORITY_LABELS, +} from '../../constants/task-priority.constants'; @Component({ selector: 'app-summary', @@ -24,10 +31,15 @@ import { HeadlineComponent } from '../../shared/components/headline/headline.com }) export class SummaryComponent implements OnInit, OnDestroy { allTasks: Task[] = []; - nextUrgendTask: number[] = []; currentUser: User | null = null; isLoading = false; + readonly UPPER_STATUSES = [TaskStatus.TODO, TaskStatus.DONE]; + readonly LOWER_STATUSES = [TaskStatus.IN_PROGRESS, TaskStatus.AWAIT_FEEDBACK]; + readonly PRIORITIES = PRIORITIES; + readonly PRIORITY_LABELS = PRIORITY_LABELS; + readonly STATUS_LABELS = STATUS_LABELS; + private destroy$ = new Subject(); constructor( @@ -37,20 +49,26 @@ export class SummaryComponent implements OnInit, OnDestroy { ) {} /** - * This method loads all tasks from the TaskService. + * This method performs the following actions: + * - Calls the loadAllTasks method to load all tasks. + * - Calls the loadCurrentUser method to load the current user. */ ngOnInit(): void { this.loadAllTasks(); this.loadCurrentUser(); } + /** + * Emits a value to the `destroy$` subject and completes it to clean up + * subscriptions and prevent memory leaks. + */ ngOnDestroy(): void { this.destroy$.next(); this.destroy$.complete(); } /** - * Loads all tasks from the TaskService. + * Loads all tasks from the TaskService and sets them to the `allTasks` property. */ loadAllTasks(): void { this.isLoading = true; @@ -71,6 +89,9 @@ export class SummaryComponent implements OnInit, OnDestroy { }); } + /** + * Loads the current user from the UserService and sets it to the `currentUser` property. + */ loadCurrentUser(): void { this.userService .getCurrentUser()