Refactor application structure to use WorkspaceService for state management

- Removed direct state management from components and centralized it in WorkspaceService.
- Updated ApartmentsPage, TenantsPage, LeasesPage, and DashboardPage to utilize WorkspaceService for data handling.
- Introduced SessionService to manage user session state and authentication.
- Simplified component templates to reflect new service-based architecture.
- Removed unused ConfigService and its tests.
- Added lease.html template for lease document generation.
- Created app.routes.spec.ts for route mapping tests.
This commit is contained in:
nessar authored and Nessar committed 2026-08-17 14:18:15 +02:00
1 parent be1f680a62
commit 82f339e209
33 files changed
+292 -929

No files matched your search

@@ -1,5 +1,9 @@
import { Component, input, output } from '@angular/core';
import { Component, computed, inject, signal } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Router } from '@angular/router';
import { MatButtonModule } from '@angular/material/button';
import { SessionService } from '../../services/session.service';
import { WorkspaceService } from '../../services/workspace.service';
@Component({
selector: 'app-dashboard-page',
@@ -8,11 +12,21 @@ import { MatButtonModule } from '@angular/material/button';
styleUrl: './dashboard-page.css',
})
export class DashboardPage {
readonly username = input.required<string>();
readonly email = input.required<string>();
readonly userInitial = input.required<string>();
readonly apartmentCount = input.required<number>();
readonly helloMessage = input.required<string>();
readonly apartmentsRequested = output<void>();
readonly connectionCheckRequested = output<void>();
private readonly http = inject(HttpClient);
private readonly router = inject(Router);
readonly session = inject(SessionService);
readonly workspace = inject(WorkspaceService);
readonly userInitial = computed(() => this.session.username().charAt(0).toUpperCase());
readonly helloMessage = signal('');
constructor() { this.workspace.loadApartments(); }
checkConnection(): void {
this.http.get('/api/hello', { responseType: 'text' }).subscribe({
next: (message) => this.helloMessage.set(message),
error: (error) => this.helloMessage.set(`Failed to connect to backend: ${error.statusText}`),
});
}
showApartments(): void { this.router.navigateByUrl('/apartments'); }
}