Accès tablette : vérification du réseau et autorisation pare-feu en un clic
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 42s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 51s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Successful in 1m33s
Build & Push Images / build (brain) (push) Successful in 1m39s
Build & Push Images / build (web) (push) Successful in 2m3s
Build & Push Images / build-switcher (push) Successful in 25s
Build & Push Images / build (core) (push) Successful in 4m13s

Constat terrain : le téléphone chargeait sans fin — le pare-feu Windows
n'avait aucune règle pour DM Loremind (la fenêtre d'autorisation n'apparaît
pas toujours) et le Wi-Fi était classé « Public » par défaut.

- Bloc « Vérification du réseau » dans Paramètres > Accès depuis une
  tablette : lit le type des réseaux connectés et les règles entrantes du
  pare-feu visant l'appli (PowerShell, lecture seule, sans droits admin).
- Bouton « Autoriser dans le pare-feu » : confirmation administrateur
  Windows (UAC), règle limitée aux réseaux privés, blocages éventuels de
  l'appli retirés ; résultat affiché (appliqué / annulé / échec).
- Réseau classé « Public » : explication + bouton « Ouvrir les réglages
  réseau » (le profil réseau reste un choix de l'utilisateur).
- Textes et doc corrigés (fin de la consigne trompeuse « réseaux privés
  uniquement ») ; section « La tablette charge sans fin » avec la commande
  manuelle de secours.

Vérifié : core clean verify (1219 tests, dont une vraie lecture du système
sur Windows), web build + 337 vitest, lint sans erreur, bloc vérifié en mode
bureau isolé.
À redéployer : core + web (mode bureau ; aucune migration).
This commit is contained in:
2026-10-17 14:41:54 +02:00
parent d926545e3d
commit 8c6b642975
15 changed files with 782 additions and 7 deletions
@@ -30,6 +30,24 @@ export interface PairingCode {
expiresAt: string;
}
/** Une tablette peut-elle joindre ce PC ? (Windows : type de réseau + pare-feu) */
export interface NetworkReadiness {
supported: boolean;
ready: boolean;
/** Réseaux connectés classés « Public » que le pare-feu ne laisse pas passer. */
publicNetworks: string[];
firewallAllowed: boolean;
firewallBlocked: boolean;
program?: string | null;
}
export type FirewallFixOutcome = 'APPLIED' | 'CANCELLED' | 'FAILED' | 'UNSUPPORTED';
export interface FirewallFixResponse {
outcome: FirewallFixOutcome;
readiness: NetworkReadiness;
}
export interface RemoteSession {
/** Requête arrivée par le réseau local (tablette) plutôt que depuis le PC. */
remote: boolean;
@@ -65,6 +83,19 @@ export class RemoteAccessService {
return this.http.delete<void>(`${this.adminUrl}/devices/${deviceId}`);
}
networkCheck(): Observable<NetworkReadiness> {
return this.http.get<NetworkReadiness>(`${this.adminUrl}/network-check`);
}
/** Attend la réponse de l'utilisateur à la confirmation administrateur de Windows. */
allowThroughFirewall(): Observable<FirewallFixResponse> {
return this.http.post<FirewallFixResponse>(`${this.adminUrl}/firewall-rule`, {});
}
openNetworkSettings(): Observable<void> {
return this.http.post<void>(`${this.adminUrl}/open-network-settings`, {});
}
pair(code: string, deviceName: string): Observable<PairedDevice> {
return this.http.post<PairedDevice>('/api/remote-access/pair', { code, deviceName });
}
@@ -36,6 +36,48 @@
}
</div>
@if (network?.supported) {
<div class="remote-block network-check" [class.ok]="network!.ready">
<h3>{{ 'remoteAccess.network.title' | translate }}</h3>
@if (network!.ready) {
<p class="check-ok">
<lucide-icon [img]="CheckCircle2" [size]="16"></lucide-icon>
{{ 'remoteAccess.network.ready' | translate }}
</p>
} @else {
@if (network!.publicNetworks.length > 0) {
<div class="check-item">
<p class="check-problem">{{ 'remoteAccess.network.publicProblem' | translate: { names: network!.publicNetworks.join(', ') } }}</p>
<p class="note">{{ 'remoteAccess.network.publicHowTo' | translate }}</p>
<button type="button" class="btn-secondary" (click)="openNetworkSettings()">
<lucide-icon [img]="Settings2" [size]="15"></lucide-icon>
{{ 'remoteAccess.network.openSettings' | translate }}
</button>
</div>
}
@if (firewallNeedsFix) {
<div class="check-item">
<p class="check-problem">
{{ (network!.firewallBlocked ? 'remoteAccess.network.firewallBlocked' : 'remoteAccess.network.firewallMissing') | translate }}
</p>
<button type="button" class="btn-primary" (click)="allowFirewall()" [disabled]="fixing">
<lucide-icon [img]="ShieldCheck" [size]="16"></lucide-icon>
{{ (fixing ? 'remoteAccess.network.fixing' : 'remoteAccess.network.allowFirewall') | translate }}
</button>
<p class="note">{{ 'remoteAccess.network.uacNote' | translate }}</p>
</div>
}
}
@if (fixMessage) {
<p class="fix-message" role="status">{{ fixMessage }}</p>
}
<button type="button" class="btn-link" (click)="checkNetwork()" [disabled]="checking">
<lucide-icon [img]="RefreshCw" [size]="14"></lucide-icon>
{{ (checking ? 'remoteAccess.network.checking' : 'remoteAccess.network.recheck') | translate }}
</button>
</div>
}
<div class="remote-block">
<h3>{{ 'remoteAccess.settings.pairTitle' | translate }}</h3>
@if (pairing) {
@@ -171,3 +171,63 @@
color: white;
}
}
// --- Vérification du réseau (pare-feu / réseau public) ---------------------------------
.network-check {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.75rem;
padding: 0.9rem 1rem;
border-radius: 8px;
border: 1px solid rgba(245, 158, 11, 0.35);
background: rgba(245, 158, 11, 0.06);
&.ok {
border-color: rgba(34, 197, 94, 0.35);
background: rgba(34, 197, 94, 0.06);
}
}
.check-ok {
display: flex;
align-items: center;
gap: 0.45rem;
margin: 0;
color: #86efac;
font-size: 0.9rem;
}
.check-item {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
}
.check-problem {
margin: 0;
color: #fde68a;
font-size: 0.9rem;
line-height: 1.5;
}
.fix-message {
margin: 0;
font-size: 0.85rem;
color: rgba(255, 255, 255, 0.75);
}
.btn-link {
padding: 0;
border: none;
background: none;
color: #a5b4fc;
font-size: 0.85rem;
cursor: pointer;
min-height: 32px !important;
&:hover:not(:disabled) { text-decoration: underline; }
&:disabled { opacity: 0.6; cursor: wait; }
&:focus-visible { outline: 2px solid #6c63ff; border-radius: 4px; }
}
@@ -3,11 +3,11 @@ import { FormsModule } from '@angular/forms';
import { HttpErrorResponse } from '@angular/common/http';
import { ActivatedRoute } from '@angular/router';
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
import { LucideAngularModule, Tablet, Trash2, RefreshCw, AlertCircle, ShieldCheck } from 'lucide-angular';
import { LucideAngularModule, Tablet, Trash2, RefreshCw, AlertCircle, ShieldCheck, CheckCircle2, Settings2 } from 'lucide-angular';
import QRCode from 'qrcode';
import {
PairedDevice, PairingCode, RemoteAccessService, RemoteAccessStatus
NetworkReadiness, PairedDevice, PairingCode, RemoteAccessService, RemoteAccessStatus
} from '../../services/remote-access.service';
import { ConfirmDialogService } from '../../shared/confirm-dialog/confirm-dialog.service';
@@ -28,6 +28,8 @@ export class RemoteAccessSectionComponent implements OnInit, OnDestroy {
readonly RefreshCw = RefreshCw;
readonly AlertCircle = AlertCircle;
readonly ShieldCheck = ShieldCheck;
readonly CheckCircle2 = CheckCircle2;
readonly Settings2 = Settings2;
private readonly remoteAccess = inject(RemoteAccessService);
private readonly translate = inject(TranslateService);
@@ -41,6 +43,12 @@ export class RemoteAccessSectionComponent implements OnInit, OnDestroy {
busy = false;
error: string | null = null;
/** Pare-feu et type de réseau (Windows) : null tant que non vérifié ou accès fermé. */
network: NetworkReadiness | null = null;
checking = false;
fixing = false;
fixMessage: string | null = null;
pairing: PairingCode | null = null;
qrDataUrl: string | null = null;
secondsLeft = 0;
@@ -138,6 +146,50 @@ export class RemoteAccessSectionComponent implements OnInit, OnDestroy {
private apply(status: RemoteAccessStatus): void {
this.status = status;
this.port = status.port;
if (status.running) {
this.checkNetwork();
} else {
this.network = null;
this.fixMessage = null;
}
}
// --- Vérification du réseau (Windows) ----------------------------------------------
/** Sans règle de pare-feu, ou sur un réseau « Public », la tablette charge sans fin : on le dit. */
checkNetwork(): void {
if (this.checking) return;
this.checking = true;
this.remoteAccess.networkCheck().subscribe({
next: r => { this.checking = false; this.network = r; },
error: () => { this.checking = false; this.network = null; }
});
}
/** Windows affiche sa confirmation administrateur : la requête attend la réponse. */
allowFirewall(): void {
if (this.fixing) return;
this.fixing = true;
this.fixMessage = null;
this.remoteAccess.allowThroughFirewall().subscribe({
next: res => {
this.fixing = false;
this.network = res.readiness;
this.fixMessage = this.translate.instant(`remoteAccess.network.fix.${res.outcome}`);
},
error: () => {
this.fixing = false;
this.fixMessage = this.translate.instant('remoteAccess.network.fix.FAILED');
}
});
}
openNetworkSettings(): void {
this.remoteAccess.openNetworkSettings().subscribe({ error: () => undefined });
}
get firewallNeedsFix(): boolean {
return !!this.network && (!this.network.firewallAllowed || this.network.firewallBlocked);
}
/** Le QR code ouvre directement l'écran d'appairage avec le code pré-rempli. */