style(frontend): applique prettier aux fichiers du tableau de bord

Les onze fichiers non conformes au .prettierrc du projet etaient exactement
ceux introduits ou modifies par cette branche ; les vingt-deux autres du
frontend etaient deja propres.

Aucune modification de comportement : indentation, virgules finales et
longueur de ligne a 100 caracteres.
This commit is contained in:
Johan LEROY
2026-09-16 09:20:40 +02:00
parent 0259f66b62
commit da97e6aa8b
11 changed files with 82 additions and 43 deletions
+2 -1
View File
@@ -6,7 +6,8 @@ import {provideHttpClient, withInterceptors} from '@angular/common/http';
export const appConfig: ApplicationConfig = { export const appConfig: ApplicationConfig = {
providers: [ providers: [
provideBrowserGlobalErrorListeners(), provideRouter(routes), provideBrowserGlobalErrorListeners(),
provideRouter(routes),
provideHttpClient(withInterceptors([mockApiInterceptor])), provideHttpClient(withInterceptors([mockApiInterceptor])),
], ],
}; };
+4 -1
View File
@@ -2,5 +2,8 @@ import { Routes } from '@angular/router';
export const routes: Routes = [ export const routes: Routes = [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' }, { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', loadComponent: () => import('./features/dashboard/dashboard').then(m => m.Dashboard) }, {
path: 'dashboard',
loadComponent: () => import('./features/dashboard/dashboard').then((m) => m.Dashboard),
},
]; ];
@@ -33,7 +33,7 @@ describe('mockApiInterceptor', () => {
httpMock.expectNone(`${environment.apiUrl}/stats/summary`); httpMock.expectNone(`${environment.apiUrl}/stats/summary`);
expect((result as typeof STATS_SUMMARY_FIXTURE).total_sites).toBe( expect((result as typeof STATS_SUMMARY_FIXTURE).total_sites).toBe(
STATS_SUMMARY_FIXTURE.total_sites STATS_SUMMARY_FIXTURE.total_sites,
); );
}); });
@@ -18,7 +18,7 @@ export const STATS_SUMMARY_FIXTURE: StatsSummary = {
{ {
site_id: 'SITE002', site_id: 'SITE002',
site_name: 'Usine Lyon Vénissieux', site_name: 'Usine Lyon Vénissieux',
current_consumption_kw: 542.10, current_consumption_kw: 542.1,
capacity_kw: 1000, capacity_kw: 1000,
load_percent: 54.2, load_percent: 54.2,
data_quality: 'good', data_quality: 'good',
@@ -12,8 +12,14 @@
<section class="overview"> <section class="overview">
<div class="card card--gauge"> <div class="card card--gauge">
<span class="card__label">Consommation vs capacité</span> <span class="card__label">Consommation vs capacité</span>
<app-consumption-gauge [consumption]="s.total_consumption_kw" [capacity]="s.total_capacity_kw" /> <app-consumption-gauge
<span class="card__value">{{ s.total_consumption_kw | number:'1.0-1' }} / {{ s.total_capacity_kw | number }} kW</span> [consumption]="s.total_consumption_kw"
[capacity]="s.total_capacity_kw"
/>
<span class="card__value"
>{{ s.total_consumption_kw | number: '1.0-1' }} /
{{ s.total_capacity_kw | number }} kW</span
>
</div> </div>
<div class="card"> <div class="card">
@@ -131,9 +131,15 @@ h2 {
flex-shrink: 0; flex-shrink: 0;
} }
.alert-item--high .alert-item__badge { background: var(--color-degraded); } .alert-item--high .alert-item__badge {
.alert-item--medium .alert-item__badge { background: var(--color-partial); } background: var(--color-degraded);
.alert-item--low .alert-item__badge { background: var(--color-good); } }
.alert-item--medium .alert-item__badge {
background: var(--color-partial);
}
.alert-item--low .alert-item__badge {
background: var(--color-good);
}
.alert-item__message { .alert-item__message {
font-size: 0.9rem; font-size: 0.9rem;
@@ -43,7 +43,7 @@ describe('Dashboard', () => {
expect(fixture.componentInstance.error()).toBeNull(); expect(fixture.componentInstance.error()).toBeNull();
}); });
it('signale l\'indisponibilité puis repart au rafraîchissement suivant', () => { it("signale l'indisponibilité puis repart au rafraîchissement suivant", () => {
vi.useFakeTimers(); vi.useFakeTimers();
const statsMock = { const statsMock = {
getSummary: vi getSummary: vi
@@ -40,9 +40,9 @@ export class Dashboard implements OnInit {
timer(0, REFRESH_INTERVAL_MS) timer(0, REFRESH_INTERVAL_MS)
.pipe( .pipe(
switchMap(() => switchMap(() =>
this.statsService.getSummary().pipe(catchError(() => this.reportUnavailable())) this.statsService.getSummary().pipe(catchError(() => this.reportUnavailable())),
), ),
takeUntilDestroyed(this.destroyRef) takeUntilDestroyed(this.destroyRef),
) )
.subscribe((stats) => { .subscribe((stats) => {
this.error.set(null); this.error.set(null);
@@ -28,7 +28,14 @@ describe('SiteLoadChart', () => {
TestBed.configureTestingModule({ imports: [SiteLoadChart] }); TestBed.configureTestingModule({ imports: [SiteLoadChart] });
const fixture = TestBed.createComponent(SiteLoadChart); const fixture = TestBed.createComponent(SiteLoadChart);
fixture.componentRef.setInput('sites', [ fixture.componentRef.setInput('sites', [
{ site_id: 'S1', site_name: 'Test', current_consumption_kw: 50, capacity_kw: 100, load_percent: 50, data_quality: 'good' }, {
site_id: 'S1',
site_name: 'Test',
current_consumption_kw: 50,
capacity_kw: 100,
load_percent: 50,
data_quality: 'good',
},
]); ]);
expect(() => fixture.detectChanges()).not.toThrow(); expect(() => fixture.detectChanges()).not.toThrow();
}); });
@@ -36,12 +43,26 @@ describe('SiteLoadChart', () => {
TestBed.configureTestingModule({ imports: [SiteLoadChart] }); TestBed.configureTestingModule({ imports: [SiteLoadChart] });
const fixture = TestBed.createComponent(SiteLoadChart); const fixture = TestBed.createComponent(SiteLoadChart);
fixture.componentRef.setInput('sites', [ fixture.componentRef.setInput('sites', [
{ site_id: 'S1', site_name: 'A', current_consumption_kw: 50, capacity_kw: 100, load_percent: 50, data_quality: 'good' }, {
site_id: 'S1',
site_name: 'A',
current_consumption_kw: 50,
capacity_kw: 100,
load_percent: 50,
data_quality: 'good',
},
]); ]);
fixture.detectChanges(); // déclenche ngAfterViewInit, this.chart existe désormais fixture.detectChanges(); // déclenche ngAfterViewInit, this.chart existe désormais
fixture.componentRef.setInput('sites', [ fixture.componentRef.setInput('sites', [
{ site_id: 'S2', site_name: 'B', current_consumption_kw: 80, capacity_kw: 100, load_percent: 80, data_quality: 'critical' }, {
site_id: 'S2',
site_name: 'B',
current_consumption_kw: 80,
capacity_kw: 100,
load_percent: 80,
data_quality: 'critical',
},
]); ]);
fixture.detectChanges(); // ré-exécute l'effect, cette fois avec this.chart défini fixture.detectChanges(); // ré-exécute l'effect, cette fois avec this.chart défini
@@ -37,7 +37,9 @@ export class SiteLoadChart implements AfterViewInit, OnDestroy {
if (this.chart) { if (this.chart) {
this.chart.data.labels = sites.map((s) => s.site_name); this.chart.data.labels = sites.map((s) => s.site_name);
this.chart.data.datasets[0].data = sites.map((s) => s.load_percent ?? 0); this.chart.data.datasets[0].data = sites.map((s) => s.load_percent ?? 0);
this.chart.data.datasets[0].backgroundColor = sites.map((s) => QUALITY_COLORS[s.data_quality]); this.chart.data.datasets[0].backgroundColor = sites.map(
(s) => QUALITY_COLORS[s.data_quality],
);
this.chart.update('none'); this.chart.update('none');
} }
}); });