From 5044aa757307a034771319e88960e949dad73d3d Mon Sep 17 00:00:00 2001 From: diallolatoile Date: Sat, 17 Jan 2026 11:36:05 +0000 Subject: [PATCH] feat: Add Health Check Endpoint --- .../core/services/HUB-DCB-APIs.code-workspace | 11 - .../models/dcb-reporting.models.ts | 15 +- .../services/dcb-reporting.service.ts | 49 ++-- .../modules/integrations/integrations.html | 1 - .../modules/integrations/integrations.spec.ts | 2 - src/app/modules/integrations/integrations.ts | 7 - .../services/integrations.service.ts | 8 - .../merchant-config/merchant-config.html | 254 +++++++----------- .../merchant-config.service.ts | 4 - .../merchant-config/merchant-config.ts | 87 +----- .../merchant-data-adapter.service.ts | 72 +---- src/app/modules/modules.routes.ts | 109 +------- .../notifications/actions/actions.html | 1 - .../notifications/actions/actions.spec.ts | 2 - .../modules/notifications/actions/actions.ts | 7 - .../notifications/filters/filters.html | 1 - .../notifications/filters/filters.spec.ts | 2 - .../modules/notifications/filters/filters.ts | 7 - src/app/modules/notifications/list/list.html | 1 - .../modules/notifications/list/list.spec.ts | 2 - src/app/modules/notifications/list/list.ts | 7 - .../modules/notifications/notifications.html | 1 - .../notifications/notifications.spec.ts | 2 - .../modules/notifications/notifications.ts | 7 - .../notifications/services/actions.service.ts | 8 - .../notifications/services/filters.service.ts | 8 - .../notifications/services/list.service.ts | 8 - .../services/notifications.service.ts | 55 ---- src/app/modules/operators/config/config.html | 1 - .../modules/operators/config/config.spec.ts | 2 - src/app/modules/operators/config/config.ts | 36 --- src/app/modules/operators/operators.html | 1 - src/app/modules/operators/operators.spec.ts | 2 - src/app/modules/operators/operators.ts | 7 - .../operators/services/config.service.ts | 8 - .../operators/services/operators.service.ts | 47 ---- .../operators/services/stats.service.ts | 44 --- src/app/modules/operators/stats/stats.html | 1 - src/app/modules/operators/stats/stats.spec.ts | 2 - src/app/modules/operators/stats/stats.ts | 7 - .../settings/services/settings.service.ts | 8 - src/app/modules/settings/settings.html | 1 - src/app/modules/settings/settings.routes.ts | 15 -- src/app/modules/settings/settings.spec.ts | 2 - src/app/modules/settings/settings.ts | 7 - src/app/modules/team/team.html | 1 - src/app/modules/team/team.spec.ts | 2 - src/app/modules/team/team.ts | 7 - src/app/modules/team/types.ts | 15 -- src/app/modules/webhooks/history/history.html | 1 - .../modules/webhooks/history/history.spec.ts | 2 - src/app/modules/webhooks/history/history.ts | 7 - src/app/modules/webhooks/retry/retry.html | 1 - src/app/modules/webhooks/retry/retry.spec.ts | 2 - src/app/modules/webhooks/retry/retry.ts | 7 - .../webhooks/services/history.service.ts | 8 - .../webhooks/services/retry.service.ts | 32 --- .../webhooks/services/status.service.ts | 8 - .../webhooks/services/webhooks.service.ts | 45 ---- src/app/modules/webhooks/status/status.html | 1 - .../modules/webhooks/status/status.spec.ts | 2 - src/app/modules/webhooks/status/status.ts | 7 - src/app/modules/webhooks/webhooks.html | 1 - src/app/modules/webhooks/webhooks.spec.ts | 2 - src/app/modules/webhooks/webhooks.ts | 7 - 65 files changed, 153 insertions(+), 934 deletions(-) delete mode 100644 src/app/core/services/HUB-DCB-APIs.code-workspace delete mode 100644 src/app/modules/integrations/integrations.html delete mode 100644 src/app/modules/integrations/integrations.spec.ts delete mode 100644 src/app/modules/integrations/integrations.ts delete mode 100644 src/app/modules/integrations/services/integrations.service.ts delete mode 100644 src/app/modules/notifications/actions/actions.html delete mode 100644 src/app/modules/notifications/actions/actions.spec.ts delete mode 100644 src/app/modules/notifications/actions/actions.ts delete mode 100644 src/app/modules/notifications/filters/filters.html delete mode 100644 src/app/modules/notifications/filters/filters.spec.ts delete mode 100644 src/app/modules/notifications/filters/filters.ts delete mode 100644 src/app/modules/notifications/list/list.html delete mode 100644 src/app/modules/notifications/list/list.spec.ts delete mode 100644 src/app/modules/notifications/list/list.ts delete mode 100644 src/app/modules/notifications/notifications.html delete mode 100644 src/app/modules/notifications/notifications.spec.ts delete mode 100644 src/app/modules/notifications/notifications.ts delete mode 100644 src/app/modules/notifications/services/actions.service.ts delete mode 100644 src/app/modules/notifications/services/filters.service.ts delete mode 100644 src/app/modules/notifications/services/list.service.ts delete mode 100644 src/app/modules/notifications/services/notifications.service.ts delete mode 100644 src/app/modules/operators/config/config.html delete mode 100644 src/app/modules/operators/config/config.spec.ts delete mode 100644 src/app/modules/operators/config/config.ts delete mode 100644 src/app/modules/operators/operators.html delete mode 100644 src/app/modules/operators/operators.spec.ts delete mode 100644 src/app/modules/operators/operators.ts delete mode 100644 src/app/modules/operators/services/config.service.ts delete mode 100644 src/app/modules/operators/services/operators.service.ts delete mode 100644 src/app/modules/operators/services/stats.service.ts delete mode 100644 src/app/modules/operators/stats/stats.html delete mode 100644 src/app/modules/operators/stats/stats.spec.ts delete mode 100644 src/app/modules/operators/stats/stats.ts delete mode 100644 src/app/modules/settings/services/settings.service.ts delete mode 100644 src/app/modules/settings/settings.html delete mode 100644 src/app/modules/settings/settings.routes.ts delete mode 100644 src/app/modules/settings/settings.spec.ts delete mode 100644 src/app/modules/settings/settings.ts delete mode 100644 src/app/modules/team/team.html delete mode 100644 src/app/modules/team/team.spec.ts delete mode 100644 src/app/modules/team/team.ts delete mode 100644 src/app/modules/team/types.ts delete mode 100644 src/app/modules/webhooks/history/history.html delete mode 100644 src/app/modules/webhooks/history/history.spec.ts delete mode 100644 src/app/modules/webhooks/history/history.ts delete mode 100644 src/app/modules/webhooks/retry/retry.html delete mode 100644 src/app/modules/webhooks/retry/retry.spec.ts delete mode 100644 src/app/modules/webhooks/retry/retry.ts delete mode 100644 src/app/modules/webhooks/services/history.service.ts delete mode 100644 src/app/modules/webhooks/services/retry.service.ts delete mode 100644 src/app/modules/webhooks/services/status.service.ts delete mode 100644 src/app/modules/webhooks/services/webhooks.service.ts delete mode 100644 src/app/modules/webhooks/status/status.html delete mode 100644 src/app/modules/webhooks/status/status.spec.ts delete mode 100644 src/app/modules/webhooks/status/status.ts delete mode 100644 src/app/modules/webhooks/webhooks.html delete mode 100644 src/app/modules/webhooks/webhooks.spec.ts delete mode 100644 src/app/modules/webhooks/webhooks.ts diff --git a/src/app/core/services/HUB-DCB-APIs.code-workspace b/src/app/core/services/HUB-DCB-APIs.code-workspace deleted file mode 100644 index 1926586..0000000 --- a/src/app/core/services/HUB-DCB-APIs.code-workspace +++ /dev/null @@ -1,11 +0,0 @@ -{ - "folders": [ - { - "path": "../../../../../dcb-user-service" - }, - { - "path": "../../../.." - } - ], - "settings": {} -} \ No newline at end of file diff --git a/src/app/modules/dcb-dashboard/models/dcb-reporting.models.ts b/src/app/modules/dcb-dashboard/models/dcb-reporting.models.ts index 8525af8..26a2445 100644 --- a/src/app/modules/dcb-dashboard/models/dcb-reporting.models.ts +++ b/src/app/modules/dcb-dashboard/models/dcb-reporting.models.ts @@ -68,13 +68,26 @@ export interface ReportParams { endDate?: string; merchantPartnerId?: number; } - export interface HealthCheckStatus { service: string; url: string; status: 'UP' | 'DOWN'; statusCode: number; checkedAt: string; + responseTime: string; + uptime?: number; + note?: string; + error?: string; +} + +export interface HealthCheckResponse { + summary: { + total: number; + up: number; + down: number; + timestamp: string; + }; + details: HealthCheckStatus[]; } // ChartDataNormalized : normalisation des données pour tous types de chart diff --git a/src/app/modules/dcb-dashboard/services/dcb-reporting.service.ts b/src/app/modules/dcb-dashboard/services/dcb-reporting.service.ts index edd5ee0..8ca1135 100644 --- a/src/app/modules/dcb-dashboard/services/dcb-reporting.service.ts +++ b/src/app/modules/dcb-dashboard/services/dcb-reporting.service.ts @@ -8,6 +8,7 @@ import { SubscriptionReport, SyncResponse, HealthCheckStatus, + HealthCheckResponse, ChartDataNormalized } from '../models/dcb-reporting.models'; import { environment } from '@environments/environment'; @@ -282,7 +283,7 @@ export class ReportService { } // --------------------- - // Health checks (rest of the code remains the same) + // Health checks // --------------------- private checkApiAvailability( @@ -316,6 +317,8 @@ export class ReportService { timeout(this.DEFAULT_TIMEOUT), map((resp: HttpResponse) => { const finalResponseTime = Date.now() - startTime; + const body: any = resp.body; + return { service, url, @@ -323,6 +326,7 @@ export class ReportService { statusCode: resp.status, checkedAt: new Date().toISOString(), responseTime: `${finalResponseTime}ms`, + uptime: body?.uptime, note: 'Used GET fallback' }; }), @@ -397,16 +401,17 @@ export class ReportService { /** * Health check global de toutes les APIs * Scanne chaque URL d'API directement - */ + */ + private buildHealthUrl(baseUrl: string): string { + return `${baseUrl.replace(/\/$/, '')}/health`; + } + globalHealthCheck(): Observable { - const healthChecks: Observable[] = []; - - // Vérifiez chaque service avec sa racine - Object.entries(this.apiEndpoints).forEach(([service, url]) => { - healthChecks.push(this.checkApiAvailability(service, url)); - }); - - return forkJoin(healthChecks); + return forkJoin( + Object.entries(this.apiEndpoints).map(([service, url]) => + this.checkApiAvailability(service, this.buildHealthUrl(url)) + ) + ); } /** @@ -438,10 +443,7 @@ export class ReportService { /** * Health check détaillé avec métriques */ - detailedHealthCheck(): Observable<{ - summary: { total: number; up: number; down: number; timestamp: string }; - details: HealthCheckStatus[]; - }> { + detailedHealthCheck(): Observable { return this.globalHealthCheck().pipe( map(results => { const adjustedResults = results.map(result => ({ @@ -462,7 +464,24 @@ export class ReportService { details: adjustedResults }; }), - catchError(err => this.handleError(err)) + catchError(err => this.handleHealthError(err)) ); } + + /** + * Gestion des erreurs + */ + private handleHealthError(error: any): Observable { + console.error('Health check error:', error); + + return of({ + summary: { + total: 0, + up: 0, + down: 0, + timestamp: new Date().toISOString() + }, + details: [] + }); + } } \ No newline at end of file diff --git a/src/app/modules/integrations/integrations.html b/src/app/modules/integrations/integrations.html deleted file mode 100644 index 7cb3d8b..0000000 --- a/src/app/modules/integrations/integrations.html +++ /dev/null @@ -1 +0,0 @@ -

Integrations

\ No newline at end of file diff --git a/src/app/modules/integrations/integrations.spec.ts b/src/app/modules/integrations/integrations.spec.ts deleted file mode 100644 index 2ee83c7..0000000 --- a/src/app/modules/integrations/integrations.spec.ts +++ /dev/null @@ -1,2 +0,0 @@ -import { Integrations } from './integrations'; -describe('Integrations', () => {}); \ No newline at end of file diff --git a/src/app/modules/integrations/integrations.ts b/src/app/modules/integrations/integrations.ts deleted file mode 100644 index b487ec3..0000000 --- a/src/app/modules/integrations/integrations.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-integrations', - templateUrl: './integrations.html', -}) -export class Integrations {} \ No newline at end of file diff --git a/src/app/modules/integrations/services/integrations.service.ts b/src/app/modules/integrations/services/integrations.service.ts deleted file mode 100644 index ace495a..0000000 --- a/src/app/modules/integrations/services/integrations.service.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable({ - providedIn: 'root' -}) -export class IntegrationsService { - constructor() {} -} \ No newline at end of file diff --git a/src/app/modules/merchant-config/merchant-config.html b/src/app/modules/merchant-config/merchant-config.html index 3169679..ff7aa24 100644 --- a/src/app/modules/merchant-config/merchant-config.html +++ b/src/app/modules/merchant-config/merchant-config.html @@ -730,105 +730,81 @@ - -
+ +
-
+
- Configurations Techniques + Configurations
- + {{ selectedMerchantForEdit.configs.length || 0 }} config(s)
@if (!selectedMerchantForEdit.configs || selectedMerchantForEdit.configs.length === 0) {
-
- - Au moins une configuration est requise +
+ + Aucune configuration disponible
} - - @for (config of selectedMerchantForEdit.configs; track trackByConfigId($index, config); let i = $index) { + + @for (config of selectedMerchantForEdit.configs; track config.id || $index; let i = $index) {
-
+
- + Configuration {{ i + 1 }}
- @if (selectedMerchantForEdit.configs.length > 1) { - + @if (config.name.includes('SECRET') || config.name.includes('KEY') || config.value.includes('password')) { + + + Sensible + }
+
- - -
-
- - -
-
- - - @if (isSensitiveConfig(config)) { -
- - Cette configuration contient des informations sensibles +
+ Type +
+ + + {{ config.name || 'Non spécifié' }} +
- } +
+
+ + +
+
+ Opérateur ID +
+ + + {{ config.operatorId || 'Non spécifié' }} + +
+
+
+ + +
+
+ Valeur +
+
+        {{ config.value || 'Aucune valeur' }}
+                          
+
+
@@ -837,23 +813,15 @@ }
- -
+ +
-
+
Contacts Techniques
- + {{ selectedMerchantForEdit.technicalContacts.length || 0 }} contact(s)
@@ -861,89 +829,69 @@
- Au moins un contact technique est requis + Aucun contact technique défini
} - - - @for (contact of selectedMerchantForEdit.technicalContacts; track trackByContactId($index, contact); let i = $index) { -
-
-
+ + @for (contact of selectedMerchantForEdit.technicalContacts; track contact.id || $index; let i = $index) { +
+
+
Contact {{ i + 1 }}
- @if (selectedMerchantForEdit.technicalContacts.length > 1) { - - }
-
-
- - + +
+ Nom complet +
+ + + {{ contact.firstName || '' }} {{ contact.lastName || '' }} + @if (!contact.firstName && !contact.lastName) { + Non spécifié + } +
-
- - +
+ + +
+ Téléphone +
+ + @if (contact.phone) { + + {{ contact.phone }} + + } @else { + Non spécifié + }
-
- - -
-
- - +
+ + +
+ Email +
+ + @if (contact.email) { + + {{ contact.email }} + + } @else { + Non spécifié + }
} -
- +