suppression de la partie patreon

This commit is contained in:
2026-10-29 09:28:48 +01:00
parent 1898e8b1ae
commit bf606c23d1
58 changed files with 627 additions and 2596 deletions
-134
View File
@@ -1,134 +0,0 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, catchError, map, of } from 'rxjs';
/**
* Reflet de LicenseStatus (enum cote backend).
*/
export type LicenseStatus = 'NONE' | 'VALID' | 'GRACE' | 'EXPIRED' | 'UNVERIFIABLE';
export interface LicenseStatusDTO {
enabled: boolean;
status: LicenseStatus;
patreonUserId: string | null;
tierId: string | null;
instanceId: string | null;
expiresAt: string | null;
lastRefreshAttemptAt: string | null;
lastRefreshSucceeded: boolean | null;
betaChannelEnabled: boolean;
}
/**
* Etat du canal courant + dernier resultat de bascule (cf. ChannelStatusDTO cote backend).
*/
export type ChannelName = 'stable' | 'beta';
export type SwitchStatus = 'IN_PROGRESS' | 'SUCCESS' | 'ERROR';
export interface ChannelStatusDTO {
currentChannel: ChannelName;
switcherAvailable: boolean;
lastSwitch: {
id: string;
status: SwitchStatus;
channel: ChannelName;
message: string;
completedAt: string;
} | null;
}
/**
* Reflet de UpdateCheckService.BetaStatus.
*/
export interface BetaStatusDTO {
enabled: boolean;
updateAvailable: boolean;
anyUnknown: boolean;
images: {
image: string;
localVersion: string | null;
remoteVersion: string | null;
status: 'UP_TO_DATE' | 'UPDATE_AVAILABLE' | 'UNKNOWN';
updateAvailable: boolean;
}[];
checkedAt: string;
disabledReason: string | null;
}
/**
* Service Angular pour la gestion de la licence Patreon.
* Tous les endpoints sont proteges par HTTP Basic (admin).
*/
@Injectable({ providedIn: 'root' })
export class LicenseService {
private readonly apiUrl = '/api/license';
private readonly authOptions = { withCredentials: true };
constructor(private http: HttpClient) {}
getStatus(): Observable<LicenseStatusDTO | null> {
return this.http.get<LicenseStatusDTO>(this.apiUrl, this.authOptions).pipe(
catchError(() => of(null))
);
}
getConnectUrl(): Observable<{ url: string } | null> {
return this.http.get<{ url: string }>(`${this.apiUrl}/connect-url`, this.authOptions).pipe(
catchError(() => of(null))
);
}
install(jwt: string): Observable<LicenseStatusDTO | { error: string }> {
return this.http.post<LicenseStatusDTO>(`${this.apiUrl}/install`, { jwt }, this.authOptions).pipe(
catchError((err) => of({ error: err?.error?.error ?? 'Echec de l\'installation' }))
);
}
disconnect(): Observable<boolean> {
return this.http.delete<void>(this.apiUrl, this.authOptions).pipe(
// Convertit en boolean : true = succes, false = erreur.
// (Avant : le cast `as unknown as` masquait l'absence de map() — le
// succes emettait `undefined`, donc falsy. Consommateur actuel ignore
// la valeur, mais le type est desormais honnete.)
map(() => true),
catchError(() => of(false))
);
}
refresh(): Observable<LicenseStatusDTO | null> {
return this.http.post<LicenseStatusDTO>(`${this.apiUrl}/refresh`, null, this.authOptions).pipe(
catchError(() => of(null))
);
}
setBetaChannel(enabled: boolean): Observable<LicenseStatusDTO | null> {
return this.http.put<LicenseStatusDTO>(`${this.apiUrl}/beta-channel`, { enabled }, this.authOptions).pipe(
catchError(() => of(null))
);
}
checkBeta(): Observable<BetaStatusDTO | null> {
return this.http.get<BetaStatusDTO>('/api/admin/updates/check-beta', this.authOptions).pipe(
catchError(() => of(null))
);
}
/** Etat du canal courant et dernier resultat de switch (pour polling UI). */
getChannelStatus(): Observable<ChannelStatusDTO | null> {
return this.http.get<ChannelStatusDTO>(`${this.apiUrl}/channel`, this.authOptions).pipe(
catchError(() => of(null))
);
}
/**
* Declenche un switch de canal. 202 + { id, channel } si accepte,
* sinon erreur (403 = pas de licence, 503 = sidecar indispo, etc.).
*/
switchChannel(channel: ChannelName): Observable<{ id: string; channel: ChannelName } | { error: string }> {
return this.http.post<{ id: string; channel: ChannelName }>(
`${this.apiUrl}/channel/switch`, { channel }, this.authOptions
).pipe(
catchError((err) => of({ error: err?.error?.error ?? 'Echec du switch de canal' }))
);
}
}
+49
View File
@@ -32,6 +32,32 @@ export interface UpdateStatus {
checkedAt: string;
}
/** Canal courant + dernier resultat de bascule (cf. ChannelStatusDTO cote backend). */
export type ChannelName = 'stable' | 'beta';
export type SwitchStatus = 'IN_PROGRESS' | 'SUCCESS' | 'ERROR';
export interface ChannelStatusDTO {
currentChannel: ChannelName;
switcherAvailable: boolean;
lastSwitch: {
id: string;
status: SwitchStatus;
channel: ChannelName;
message: string;
completedAt: string;
} | null;
}
/** Reflet de UpdateCheckService.BetaStatus (images beta publiques, verifiees en beta). */
export interface BetaStatusDTO {
enabled: boolean;
updateAvailable: boolean;
anyUnknown: boolean;
images: ImageStatus[];
checkedAt: string;
disabledReason: string | null;
}
/**
* Service de detection / declenchement des mises a jour des conteneurs
* LoreMind. Endpoints proteges par HTTP Basic (admin) — withCredentials
@@ -72,4 +98,27 @@ export class UpdatesService {
catchError(() => of(null))
);
}
/** Nouvelle beta disponible ? (seulement quand l'instance tourne sur le canal beta). */
checkBeta(): Observable<BetaStatusDTO | null> {
return this.http.get<BetaStatusDTO>(`${this.apiUrl}/check-beta`, this.authOptions).pipe(
catchError(() => of(null))
);
}
/** Canal courant et dernier resultat de bascule (pour le polling de l'UI). */
getChannelStatus(): Observable<ChannelStatusDTO | null> {
return this.http.get<ChannelStatusDTO>(`${this.apiUrl}/channel`, this.authOptions).pipe(
catchError(() => of(null))
);
}
/** Demande une bascule de canal : 202 + { id, channel }, sinon { error } (503 = sidecar absent…). */
switchChannel(channel: ChannelName): Observable<{ id: string; channel: ChannelName } | { error: string }> {
return this.http.post<{ id: string; channel: ChannelName }>(
`${this.apiUrl}/channel/switch`, { channel }, this.authOptions
).pipe(
catchError((err) => of({ error: err?.error?.error ?? 'Echec du switch de canal' }))
);
}
}
+1 -1
View File
@@ -379,7 +379,7 @@
</section>
}
<!-- Mises a jour conteneurs + licence Patreon + canal beta (sous-composant) -->
<!-- Mises a jour conteneurs + canal beta (sous-composant) -->
<app-settings-updates-section></app-settings-updates-section>
<!-- Sauvegarde / Restauration des donnees (export & import) -->
+1 -47
View File
@@ -456,53 +456,7 @@
gap: 6px;
}
// --- Section Patreon / canal beta ---------------------------------------
.license-info {
list-style: none;
margin: 12px 0 16px;
padding: 0;
display: flex;
flex-direction: column;
gap: 6px;
li {
font-size: 0.9rem;
padding: 6px 10px;
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 4px;
strong {
color: #c4b8e0;
margin-right: 6px;
}
}
}
.form-row-inline {
display: flex;
align-items: center;
gap: 12px;
margin-top: 12px;
}
.form-row-actions {
display: flex;
gap: 10px;
margin-top: 12px;
flex-wrap: wrap;
}
.btn-secondary.btn-danger {
border-color: rgba(220, 80, 80, 0.4);
color: #ff7878;
&:hover {
background: rgba(220, 80, 80, 0.12);
border-color: rgba(220, 80, 80, 0.6);
}
}
// --- Canal beta -----------------------------------------------------------
.beta-status {
margin-top: 16px;
+1 -1
View File
@@ -22,7 +22,7 @@ import { RemoteAccessService } from '../services/remote-access.service';
* cles API, embeddings RAG, fenetre de contexte, import PDF) + sa sauvegarde.
*
* Les responsabilites voisines sont des sous-composants standalone :
* - UpdatesSectionComponent : mises a jour conteneurs + licence Patreon + canal beta ;
* - UpdatesSectionComponent : mises a jour conteneurs + canal beta ;
* - OllamaModelManagerComponent : pull/suppression des modeles Ollama.
*
* Les modifications sont persistees cote Brain dans data/settings.json
@@ -1,14 +1,9 @@
<!-- Bloc Mises a jour (canal stable + canal beta Patreon fusionnes) -->
@if (config.updateCheckEnabled || licenseStatus?.enabled) {
<!-- Bloc Mises a jour (canal stable + canal beta) : Docker uniquement. En mode bureau,
ni Watchtower ni sidecar switcher : la section reste masquee. -->
@if (config.updateCheckEnabled || channelStatus?.switcherAvailable) {
<section class="card">
<h2>{{ 'updatesSection.title' | translate }}</h2>
<p class="hint">{{ 'updatesSection.hint' | translate }}</p>
@if (licenseSuccess) {
<div class="alert alert-success">
<lucide-icon [img]="Check" [size]="16"></lucide-icon>
<span>{{ licenseSuccess }}</span>
</div>
}
<!-- ====================================================== -->
<!-- Sous-section : canal stable -->
<!-- ====================================================== -->
@@ -64,201 +59,103 @@
</div>
}
<!-- ====================================================== -->
<!-- Sous-section : canal beta (Patreon) -->
<!-- Sous-section : canal beta (libre) -->
<!-- ====================================================== -->
@if (licenseStatus?.enabled) {
@if (channelStatus) {
<div class="channel-block">
<h3 class="channel-title">
<lucide-icon [img]="Heart" [size]="16"></lucide-icon>
<lucide-icon [img]="FlaskConical" [size]="16"></lucide-icon>
{{ 'updatesSection.betaChannelTitle' | translate }}
</h3>
<p class="hint" [innerHTML]="'updatesSection.betaChannelIntro' | translate"></p>
<!-- Pas de licence installee -->
@if (licenseStatus?.status === 'NONE') {
<div class="form-row">
<button type="button" class="btn-primary" (click)="connectPatreon()">
<lucide-icon [img]="Link2" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.connectPatreon' | translate }}</span>
</button>
</div>
<p class="hint">{{ 'updatesSection.connectInstructions' | translate }}</p>
<div class="form-row">
<label for="license-jwt">{{ 'updatesSection.patreonToken' | translate }}</label>
<input
id="license-jwt"
type="text"
[(ngModel)]="licenseJwtInput"
placeholder="eyJhbGciOiJFZERTQS..."
autocomplete="off"
>
</div>
<div class="form-row">
<button type="button" class="btn-primary" (click)="installLicense()" [disabled]="!licenseJwtInput.trim()">
<lucide-icon [img]="Check" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.activateLicense' | translate }}</span>
</button>
</div>
@if (licenseError) {
<div class="alert alert-error">
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
<span>{{ licenseError }}</span>
</div>
}
}
<!-- Licence installee (VALID / GRACE / EXPIRED / UNVERIFIABLE) -->
@if (licenseStatus && licenseStatus.status !== 'NONE') {
@if (licenseStatus.status === 'VALID') {
<div class="alert alert-success">
<lucide-icon [img]="Check" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.licenseValid' | translate:{ tier: tierLabel(licenseStatus.tierId) } }}</span>
</div>
}
@if (licenseStatus.status === 'GRACE') {
<div class="alert alert-warn">
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.licenseGrace' | translate }}</span>
</div>
}
@if (licenseStatus.status === 'EXPIRED') {
<div class="alert alert-error">
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.licenseExpired' | translate }}</span>
</div>
}
@if (licenseStatus.status === 'UNVERIFIABLE') {
<div class="alert alert-error">
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.licenseUnverifiable' | translate }}</span>
</div>
}
<ul class="license-info">
@if (licenseStatus.tierId) {
<li [innerHTML]="'updatesSection.infoTier' | translate:{ tier: tierLabel(licenseStatus.tierId) }"></li>
<p class="hint">{{ 'updatesSection.betaChannelIntro' | translate }}</p>
<!-- En beta : une beta plus recente existe-t-elle ? -->
@if (channelStatus.currentChannel === 'beta') {
<div class="beta-status">
@if (betaChecking) {
<div class="hint">{{ 'updatesSection.checkingBetaImages' | translate }}</div>
}
@if (licenseStatus.expiresAt) {
<li>
<span [innerHTML]="'updatesSection.infoValidity' | translate:{ date: formatDate(licenseStatus.expiresAt) }"></span>
@if (daysUntilExpiry !== null && daysUntilExpiry > 0) {
<span>
{{ (daysUntilExpiry > 1 ? 'updatesSection.renewalDays' : 'updatesSection.renewalDay') | translate:{ n: daysUntilExpiry } }}
</span>
}
</li>
}
@if (licenseStatus.lastRefreshAttemptAt) {
<li>
<span [innerHTML]="'updatesSection.infoLastRefresh' | translate:{ date: formatDate(licenseStatus.lastRefreshAttemptAt) }"></span>
@if (licenseStatus.lastRefreshSucceeded === true) {
<span class="badge-ok">{{ 'updatesSection.refreshOk' | translate }}</span>
}
@if (licenseStatus.lastRefreshSucceeded === false) {
<span class="badge-warn">{{ 'updatesSection.refreshFailed' | translate }}</span>
}
</li>
}
</ul>
<div class="form-row form-row-inline">
<label class="checkbox">
<input
type="checkbox"
[checked]="licenseStatus.betaChannelEnabled"
(change)="toggleBetaChannel(!licenseStatus.betaChannelEnabled)"
[disabled]="licenseStatus.status !== 'VALID' && licenseStatus.status !== 'GRACE'"
>
<span>{{ 'updatesSection.enableBetaChannel' | translate }}</span>
</label>
</div>
<div class="form-row form-row-actions">
<button type="button" class="btn-secondary" (click)="refreshLicense()" [disabled]="licenseLoading">
<lucide-icon [img]="RefreshCw" [size]="14"></lucide-icon>
<span>{{ (licenseLoading ? 'updatesSection.checking' : 'updatesSection.checkNow') | translate }}</span>
</button>
<button type="button" class="btn-secondary btn-danger" (click)="disconnectPatreon()">
<lucide-icon [img]="Unlink" [size]="14"></lucide-icon>
<span>{{ 'updatesSection.disconnectPatreon' | translate }}</span>
</button>
</div>
<!-- Etat du canal beta -->
@if (licenseStatus.betaChannelEnabled) {
<div class="beta-status">
@if (betaChecking) {
<div class="hint">{{ 'updatesSection.checkingBetaImages' | translate }}</div>
}
@if (!betaChecking && betaStatus && !betaStatus.enabled) {
<div class="hint">
{{ 'updatesSection.betaUnavailable' | translate:{ reason: betaStatus.disabledReason } }}
@if (!betaChecking && betaStatus?.enabled) {
@if (betaStatus?.updateAvailable) {
<div class="alert alert-success">
<lucide-icon [img]="Download" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.betaUpdateAvailable' | translate }}</span>
</div>
}
@if (!betaChecking && betaStatus?.enabled) {
<div>
@if (betaStatus?.anyUnknown) {
<div class="alert alert-warn">
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.betaCheckImpossible' | translate }}</span>
</div>
}
</div>
}
</div>
}
<!-- Bascule de canal (stable <-> beta) via sidecar switcher -->
@if (channelStatus) {
<div class="channel-switch">
<div class="channel-current">
<span class="channel-label">{{ 'updatesSection.currentChannel' | translate }}</span>
<span class="channel-badge"
[class.channel-stable]="channelStatus.currentChannel === 'stable'"
[class.channel-beta]="channelStatus.currentChannel === 'beta'">
{{ (channelStatus.currentChannel === 'beta' ? 'updatesSection.channelBeta' : 'updatesSection.channelStable') | translate }}
</span>
</div>
<!-- Sidecar dispo : boutons d'action -->
@if (channelStatus.switcherAvailable) {
<!-- On stable -> proposer passage beta (uniquement si licence active) -->
@if (channelStatus.currentChannel === 'stable') {
<button
type="button" class="btn-primary"
[disabled]="switchInFlight"
(click)="requestChannelSwitch('beta')">
<lucide-icon [img]="Download" [size]="14"></lucide-icon>
<span>{{ (switchInFlight ? 'updatesSection.switching' : 'updatesSection.switchToBeta') | translate }}</span>
</button>
}
<!-- On beta -> proposer retour stable -->
@if (channelStatus.currentChannel === 'beta') {
<button
type="button" class="btn-secondary"
[disabled]="switchInFlight"
(click)="requestChannelSwitch('stable')">
<lucide-icon [img]="ArrowLeft" [size]="14"></lucide-icon>
<span>{{ (switchInFlight ? 'updatesSection.switching' : 'updatesSection.switchToStable') | translate }}</span>
</button>
}
<!-- Switch en cours : on prévient que la page va se rendre injoignable -->
@if (switchInFlight) {
<div class="alert alert-warn">
<lucide-icon [img]="RefreshCw" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.switchInProgressNotice' | translate }}</span>
@if (config.updateCheckEnabled) {
<div class="form-row">
<button type="button" class="btn-primary" (click)="applyUpdate()" [disabled]="updateApplying">
<lucide-icon [img]="Download" [size]="16"></lucide-icon>
<span>{{ (updateApplying ? 'updatesSection.applying' : 'updatesSection.applyNow') | translate }}</span>
</button>
</div>
}
<!-- Erreur eventuelle remontee par le sidecar -->
@if (switchError && !switchInFlight) {
<div class="alert alert-error">
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
<span>{{ switchError }}</span>
</div>
}
}
<!-- Sidecar PAS dispo : fallback instructions manuelles (vieilles installs) -->
@if (!channelStatus.switcherAvailable) {
} @else if (betaStatus?.anyUnknown) {
<div class="alert alert-warn">
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
<span [innerHTML]="'updatesSection.switcherUnavailable' | translate"></span>
<span>{{ 'updatesSection.betaCheckImpossible' | translate }}</span>
</div>
} @else {
<div class="hint">
{{ 'updatesSection.betaUpToDate' | translate:{ date: (betaStatus?.checkedAt | date:'short') } }}
</div>
}
}
</div>
}
<!-- Bascule de canal (stable <-> beta) via sidecar switcher -->
<div class="channel-switch">
<div class="channel-current">
<span class="channel-label">{{ 'updatesSection.currentChannel' | translate }}</span>
<span class="channel-badge"
[class.channel-stable]="channelStatus.currentChannel === 'stable'"
[class.channel-beta]="channelStatus.currentChannel === 'beta'">
{{ (channelStatus.currentChannel === 'beta' ? 'updatesSection.channelBeta' : 'updatesSection.channelStable') | translate }}
</span>
</div>
<!-- Sidecar dispo : boutons d'action -->
@if (channelStatus.switcherAvailable) {
<!-- On stable -> proposer passage beta -->
@if (channelStatus.currentChannel === 'stable') {
<button
type="button" class="btn-primary"
[disabled]="switchInFlight"
(click)="requestChannelSwitch('beta')">
<lucide-icon [img]="Download" [size]="14"></lucide-icon>
<span>{{ (switchInFlight ? 'updatesSection.switching' : 'updatesSection.switchToBeta') | translate }}</span>
</button>
}
<!-- On beta -> proposer retour stable -->
@if (channelStatus.currentChannel === 'beta') {
<button
type="button" class="btn-secondary"
[disabled]="switchInFlight"
(click)="requestChannelSwitch('stable')">
<lucide-icon [img]="ArrowLeft" [size]="14"></lucide-icon>
<span>{{ (switchInFlight ? 'updatesSection.switching' : 'updatesSection.switchToStable') | translate }}</span>
</button>
}
<!-- Switch en cours : on prévient que la page va se rendre injoignable -->
@if (switchInFlight) {
<div class="alert alert-warn">
<lucide-icon [img]="RefreshCw" [size]="16"></lucide-icon>
<span>{{ 'updatesSection.switchInProgressNotice' | translate }}</span>
</div>
}
<!-- Erreur eventuelle remontee par le sidecar -->
@if (switchError && !switchInFlight) {
<div class="alert alert-error">
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
<span>{{ switchError }}</span>
</div>
}
}
<!-- Sidecar PAS dispo : fallback instructions manuelles (vieilles installs) -->
@if (!channelStatus.switcherAvailable) {
<div class="alert alert-warn">
<lucide-icon [img]="AlertCircle" [size]="16"></lucide-icon>
<span [innerHTML]="'updatesSection.switcherUnavailable' | translate"></span>
</div>
}
}
</div>
</div>
}
</section>
@@ -2,11 +2,10 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
import { interval, switchMap, Subscription } from 'rxjs';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { LucideAngularModule, ArrowLeft, RefreshCw, Check, AlertCircle, Download, Heart, Link2, Unlink } from 'lucide-angular';
import { LucideAngularModule, ArrowLeft, RefreshCw, Check, AlertCircle, Download, FlaskConical } from 'lucide-angular';
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
import { UpdatesService, UpdateStatus } from '../../services/updates.service';
import { UpdatesService, UpdateStatus, BetaStatusDTO, ChannelStatusDTO, ChannelName } from '../../services/updates.service';
import { ConfigService } from '../../services/config.service';
import { LicenseService, LicenseStatusDTO, BetaStatusDTO, ChannelStatusDTO, ChannelName } from '../../services/license.service';
import { ConfirmDialogService } from '../../shared/confirm-dialog/confirm-dialog.service';
/**
@@ -14,8 +13,7 @@ import { ConfirmDialogService } from '../../shared/confirm-dialog/confirm-dialog
*
* Responsabilite unique : tout ce qui touche au CYCLE DE VIE des conteneurs —
* - canal stable : verification + application des mises a jour (Watchtower) ;
* - licence Patreon : connexion OAuth, installation du JWT, refresh, deconnexion ;
* - canal beta : activation + verification des images beta ;
* - canal beta (libre) : verification des images beta quand on y tourne ;
* - bascule de canal stable <-> beta via le sidecar switcher (avec polling).
*
* Autonome : injecte ses propres services, aucun @Input/@Output — le parent
@@ -36,19 +34,9 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
readonly Check = Check;
readonly AlertCircle = AlertCircle;
readonly Download = Download;
readonly Heart = Heart;
readonly Link2 = Link2;
readonly Unlink = Unlink;
readonly FlaskConical = FlaskConical;
// --- Licence Patreon (canal beta) ---
licenseStatus: LicenseStatusDTO | null = null;
licenseLoading = false;
licenseError = '';
/** Message de succes local a la section (connexion/deconnexion Patreon). */
licenseSuccess = '';
/** Token JWT colle par l'utilisateur apres OAuth. */
licenseJwtInput = '';
/** Etat du canal beta (digests des images privees). */
/** Nouvelle beta disponible ? (verifie seulement quand l'instance tourne en beta). */
betaStatus: BetaStatusDTO | null = null;
betaChecking = false;
@@ -72,7 +60,6 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
constructor(
private updatesService: UpdatesService,
public config: ConfigService,
private licenseService: LicenseService,
private confirmDialog: ConfirmDialogService,
private translate: TranslateService
) {}
@@ -81,7 +68,6 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
if (this.config.updateCheckEnabled) {
this.checkUpdates();
}
this.loadLicense();
this.loadChannelStatus();
}
@@ -89,103 +75,9 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
this.stopSwitchPolling();
}
// --- Licence Patreon ---------------------------------------------------
loadLicense(): void {
this.licenseLoading = true;
this.licenseService.getStatus().subscribe({
next: (s) => {
this.licenseStatus = s;
this.licenseLoading = false;
if (s?.enabled && (s.status === 'VALID' || s.status === 'GRACE') && s.betaChannelEnabled) {
this.checkBeta();
}
},
error: () => { this.licenseLoading = false; }
});
}
/**
* Ouvre la page OAuth Patreon dans une nouvelle fenetre.
* L'utilisateur copie ensuite le JWT et le colle dans l'input ci-dessous.
*/
connectPatreon(): void {
this.licenseError = '';
this.licenseService.getConnectUrl().subscribe({
next: (r) => {
if (!r?.url) {
this.licenseError = this.translate.instant('updatesSection.connectUrlError');
return;
}
window.open(r.url, '_blank', 'noopener');
}
});
}
installLicense(): void {
const jwt = this.licenseJwtInput.trim();
if (!jwt) {
this.licenseError = this.translate.instant('updatesSection.pasteTokenFirst');
return;
}
this.licenseError = '';
this.licenseService.install(jwt).subscribe((res) => {
// install() renvoie une union typée : le garde `in` suffit à discriminer.
if ('error' in res) {
this.licenseError = res.error;
return;
}
this.licenseStatus = res;
this.licenseJwtInput = '';
this.licenseSuccess = this.translate.instant('updatesSection.patreonConnectedSuccess');
if (this.licenseStatus.betaChannelEnabled) {
this.checkBeta();
}
});
}
refreshLicense(): void {
this.licenseLoading = true;
this.licenseService.refresh().subscribe({
next: (s) => {
this.licenseStatus = s;
this.licenseLoading = false;
},
error: () => { this.licenseLoading = false; }
});
}
disconnectPatreon(): void {
this.confirmDialog.confirm({
title: this.translate.instant('updatesSection.disconnectTitle'),
message: this.translate.instant('updatesSection.disconnectMessage'),
details: [this.translate.instant('updatesSection.disconnectDetail')],
confirmLabel: this.translate.instant('updatesSection.disconnectConfirm'),
variant: 'warning'
}).then(ok => {
if (!ok) return;
this.licenseService.disconnect().subscribe(() => {
this.licenseStatus = null;
this.betaStatus = null;
this.licenseSuccess = this.translate.instant('updatesSection.patreonDisconnected');
this.loadLicense();
});
});
}
toggleBetaChannel(enabled: boolean): void {
this.licenseService.setBetaChannel(enabled).subscribe({
next: (s) => {
if (s) this.licenseStatus = s;
if (enabled) this.checkBeta();
else this.betaStatus = null;
}
});
}
checkBeta(): void {
this.betaChecking = true;
this.licenseService.checkBeta().subscribe({
this.updatesService.checkBeta().subscribe({
next: (s) => {
this.betaStatus = s;
this.betaChecking = false;
@@ -197,11 +89,11 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
// --- Bascule de canal stable <-> beta --------------------------------------
loadChannelStatus(): void {
this.licenseService.getChannelStatus().subscribe({
this.updatesService.getChannelStatus().subscribe({
next: (s) => {
this.channelStatus = s;
// Si on revient sur l'ecran apres un reload (post-switch reussi),
// on affiche le dernier resultat eventuel jusqu'a interaction utilisateur.
// En beta, on verifie aussi s'il existe une beta plus recente.
if (s?.currentChannel === 'beta') this.checkBeta();
},
error: () => { this.channelStatus = null; }
});
@@ -210,8 +102,8 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
/**
* Declenche un switch de canal. La sequence cote UI :
* 1. Confirm modal (action destructrice : recreate des containers)
* 2. POST /api/license/channel/switch -> 202 avec l'ID de la commande
* 3. Polling /api/license/channel toutes les 2s jusqu'a status != IN_PROGRESS
* 2. POST /api/admin/updates/channel/switch -> 202 avec l'ID de la commande
* 3. Polling /api/admin/updates/channel toutes les 2s jusqu'a status != IN_PROGRESS
* 4. Si SUCCESS : la page va se rendre injoignable (Core recree). On affiche
* "Recharge la page dans quelques secondes" et on essaie de poll quand
* meme — au retour de Core, on detectera SUCCESS et on rechargera auto.
@@ -244,7 +136,7 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
private doChannelSwitch(target: ChannelName): void {
this.switchInFlight = true;
this.switchError = '';
this.licenseService.switchChannel(target).subscribe((res) => {
this.updatesService.switchChannel(target).subscribe((res) => {
if ('error' in res) {
this.switchError = res.error;
this.switchInFlight = false;
@@ -256,14 +148,14 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
}
/**
* Poll /api/license/channel toutes les 2s. S'arrete quand on detecte un
* Poll /api/admin/updates/channel toutes les 2s. S'arrete quand on detecte un
* resultat avec un ID >= a celui qu'on a soumis (le sidecar le met a jour
* a la fin de son traitement).
*/
private startSwitchPolling(): void {
this.stopSwitchPolling();
this.switchPollSub = interval(2000).pipe(
switchMap(() => this.licenseService.getChannelStatus())
switchMap(() => this.updatesService.getChannelStatus())
).subscribe((status) => {
if (!status) return;
this.channelStatus = status;
@@ -291,40 +183,6 @@ export class UpdatesSectionComponent implements OnInit, OnDestroy {
}
}
/**
* Mapping tier_id Patreon → nom lisible. Les IDs viennent du dashboard
* Patreon de LoreMind (Settings -> Tiers). Sans entree dans la map, on
* affiche l'ID brut pour rester debuggable.
*
* Si tu ajoutes un nouveau tier Patreon, complete cette map et redeploie.
* (Pas besoin de toucher au backend — c'est juste un libelle d'UI.)
*/
private static readonly TIER_LABELS: Record<string, string> = {
'28448887': 'Compagnon',
// '0000000': 'Aventurier',
// '0000000': 'Heros',
};
/** Libelle lisible d'un tier Patreon, fallback sur l'ID brut. */
tierLabel(tierId: string | null | undefined): string {
if (!tierId) return '';
return UpdatesSectionComponent.TIER_LABELS[tierId] ?? tierId;
}
/** Format human-readable des dates renvoyees par le backend. */
formatDate(iso: string | null | undefined): string {
if (!iso) return '';
try { return new Date(iso).toLocaleString(); } catch { return iso; }
}
/** Nombre de jours restants avant expiration JWT (peut etre negatif). */
get daysUntilExpiry(): number | null {
if (!this.licenseStatus?.expiresAt) return null;
const exp = new Date(this.licenseStatus.expiresAt).getTime();
const now = Date.now();
return Math.ceil((exp - now) / (1000 * 60 * 60 * 24));
}
// --- Mises a jour conteneurs (canal stable) -----------------------------
checkUpdates(): void {
+5 -29
View File
@@ -1331,27 +1331,9 @@
"upToDate": "Everything is up to date (checked on {{date}}).",
"applying": "Updating...",
"applyNow": "Update now",
"betaChannelTitle": "Beta channel — patrons only",
"betaChannelIntro": "Support LoreMind on Patreon to access new features in preview. The <strong>Compagnon</strong> tier (€7/month) or higher unlocks this channel.",
"connectPatreon": "Connect my Patreon account",
"connectInstructions": "A new window will open to Patreon. After authorizing, copy the displayed token and paste it below.",
"patreonToken": "Patreon token",
"activateLicense": "Activate license",
"licenseValid": "Patreon account connected. Tier {{tier}} active.",
"licenseGrace": "Patreon connection expired, but beta access is maintained during the grace period. Make sure your Patreon subscription is still active and click \"Check now\".",
"licenseExpired": "Patreon connection expired too long ago. Reconnect to regain beta access.",
"licenseUnverifiable": "The installed token can no longer be verified. Reconnect.",
"infoTier": "<strong>Tier:</strong> {{tier}}",
"infoValidity": "<strong>Validity:</strong> until {{date}}",
"renewalDay": "(renews in {{n}} day)",
"renewalDays": "(renews in {{n}} days)",
"infoLastRefresh": "<strong>Last refresh:</strong> {{date}}",
"refreshOk": "OK",
"refreshFailed": "failed",
"enableBetaChannel": "Enable beta channel",
"disconnectPatreon": "Disconnect Patreon",
"betaChannelTitle": "Beta channel",
"betaChannelIntro": "New features ahead of time, free and for everyone. A beta may contain bugs: your data is kept and you can go back to the stable channel at any time.",
"checkingBetaImages": "Checking beta images...",
"betaUnavailable": "Unavailable: {{reason}}",
"betaCheckImpossible": "Beta check failed (beta registry unreachable or baseline missing).",
"currentChannel": "Current channel:",
"channelBeta": "Beta",
@@ -1361,14 +1343,6 @@
"switching": "Switching...",
"switchInProgressNotice": "Switching in progress. The application will be unavailable for 10 to 30 seconds — the page will reload automatically once the new Core is ready.",
"switcherUnavailable": "The channel switcher sidecar is not installed. To benefit from automatic switching, fetch the latest <code>docker-compose.yml</code> from the repo and run <code>docker compose pull &amp;&amp; docker compose up -d</code> once. Otherwise, switch manually by editing <code>IMAGE_NAMESPACE</code> in your <code>.env</code> (<code>igmlcreation/loremind-</code> for stable, <code>igmlcreation/loremind-beta-</code> for beta).",
"connectUrlError": "Unable to generate the connection URL. Check your config.",
"pasteTokenFirst": "First paste the token received after connecting with Patreon.",
"patreonConnectedSuccess": "Patreon account connected. Beta access is active.",
"disconnectTitle": "Disconnect Patreon",
"disconnectMessage": "Disconnect your Patreon account?",
"disconnectDetail": "You will lose access to the beta channel.",
"disconnectConfirm": "Disconnect",
"patreonDisconnected": "Patreon account disconnected.",
"switchToBetaMessage": "Switch LoreMind to the beta channel? The core/brain/web containers will be recreated with the beta images. The application will be unavailable for 10-30 seconds.",
"switchToStableMessage": "Switch LoreMind back to the stable channel? The core/brain/web containers will be recreated with the stable images. The application will be unavailable for 10-30 seconds.",
"switchToBetaTitle": "Switch to beta?",
@@ -1382,7 +1356,9 @@
"applyMessage": "Download and restart the containers now?",
"applyDetail": "The app will be unavailable for a few seconds.",
"applyConfirm": "Update",
"applyTriggered": "Update triggered. Reload the page in 30s."
"applyTriggered": "Update triggered. Reload the page in 30s.",
"betaUpdateAvailable": "A new beta is available.",
"betaUpToDate": "Beta up to date (checked on {{date}})."
},
"itemCatalogEdit": {
"editTitle": "Edit catalog",
+5 -29
View File
@@ -1331,27 +1331,9 @@
"upToDate": "Tout est à jour (vérifié le {{date}}).",
"applying": "Mise à jour en cours...",
"applyNow": "Mettre à jour maintenant",
"betaChannelTitle": "Canal beta — réservé aux patrons",
"betaChannelIntro": "Soutiens LoreMind sur Patreon pour accéder aux nouvelles features en avant-première. Le tier <strong>Compagnon</strong> (7€/mois) ou supérieur débloque ce canal.",
"connectPatreon": "Connecter mon compte Patreon",
"connectInstructions": "Une nouvelle fenêtre va s'ouvrir vers Patreon. Après autorisation, copie le token affiché et colle-le ci-dessous.",
"patreonToken": "Token Patreon",
"activateLicense": "Activer la licence",
"licenseValid": "Compte Patreon connecté. Tier {{tier}} actif.",
"licenseGrace": "Connexion Patreon expirée, mais accès beta maintenu pendant la période de tolérance. Vérifie que ton abonnement Patreon est toujours actif et clique sur \"Vérifier maintenant\".",
"licenseExpired": "Connexion Patreon expirée depuis trop longtemps. Reconnecte-toi pour retrouver l'accès beta.",
"licenseUnverifiable": "Le token installé ne peut plus être vérifié. Reconnecte-toi.",
"infoTier": "<strong>Tier :</strong> {{tier}}",
"infoValidity": "<strong>Validité :</strong> jusqu'au {{date}}",
"renewalDay": "(renouvellement dans {{n}} jour)",
"renewalDays": "(renouvellement dans {{n}} jours)",
"infoLastRefresh": "<strong>Dernier refresh :</strong> {{date}}",
"refreshOk": "OK",
"refreshFailed": "échec",
"enableBetaChannel": "Activer le canal beta",
"disconnectPatreon": "Déconnecter Patreon",
"betaChannelTitle": "Canal bêta",
"betaChannelIntro": "Les nouveautés en avant-première, gratuitement et pour tout le monde. Une bêta peut contenir des bugs : tes données sont conservées et tu peux revenir au canal stable à tout moment.",
"checkingBetaImages": "Vérification des images beta...",
"betaUnavailable": "Indisponible : {{reason}}",
"betaCheckImpossible": "Vérification beta impossible (registry beta injoignable ou baseline absente).",
"currentChannel": "Canal actuel :",
"channelBeta": "Bêta",
@@ -1361,14 +1343,6 @@
"switching": "Bascule en cours...",
"switchInProgressNotice": "Bascule en cours. L'application va être indisponible 10 à 30 secondes — la page se rechargera automatiquement quand le nouveau Core sera prêt.",
"switcherUnavailable": "Le sidecar de bascule n'est pas installé. Pour bénéficier du switch automatique, récupère le dernier <code>docker-compose.yml</code> du repo et fais <code>docker compose pull &amp;&amp; docker compose up -d</code> une fois. Sinon, bascule manuellement en éditant <code>IMAGE_NAMESPACE</code> dans ton <code>.env</code> (<code>igmlcreation/loremind-</code> pour stable, <code>igmlcreation/loremind-beta-</code> pour beta).",
"connectUrlError": "Impossible de générer l'URL de connexion. Vérifie ta config.",
"pasteTokenFirst": "Colle d'abord le token reçu après connexion Patreon.",
"patreonConnectedSuccess": "Compte Patreon connecté. L'accès beta est actif.",
"disconnectTitle": "Déconnecter Patreon",
"disconnectMessage": "Déconnecter ton compte Patreon ?",
"disconnectDetail": "Tu perdras l'accès au canal beta.",
"disconnectConfirm": "Déconnecter",
"patreonDisconnected": "Compte Patreon déconnecté.",
"switchToBetaMessage": "Basculer LoreMind sur le canal beta ? Les containers core/brain/web vont être recréés avec les images beta. L'application sera indisponible 10-30 secondes.",
"switchToStableMessage": "Repasser LoreMind sur le canal stable ? Les containers core/brain/web vont être recréés avec les images stables. L'application sera indisponible 10-30 secondes.",
"switchToBetaTitle": "Passer en beta ?",
@@ -1382,7 +1356,9 @@
"applyMessage": "Télécharger et redémarrer les conteneurs maintenant ?",
"applyDetail": "L'app sera indisponible quelques secondes.",
"applyConfirm": "Mettre à jour",
"applyTriggered": "Mise à jour déclenchée. Rechargez la page dans 30s."
"applyTriggered": "Mise à jour déclenchée. Rechargez la page dans 30s.",
"betaUpdateAvailable": "Une nouvelle bêta est disponible.",
"betaUpToDate": "Bêta à jour (vérifiée le {{date}})."
},
"itemCatalogEdit": {
"editTitle": "Éditer le catalogue",
@@ -95,28 +95,12 @@
"upToDate": "Everything is up to date (checked on {{date}}).",
"applying": "Updating...",
"applyNow": "Update now",
"betaChannelTitle": "Beta channel — patrons only",
"betaChannelIntro": "Support LoreMind on Patreon to access new features in preview. The <strong>Compagnon</strong> tier (€7/month) or higher unlocks this channel.",
"connectPatreon": "Connect my Patreon account",
"connectInstructions": "A new window will open to Patreon. After authorizing, copy the displayed token and paste it below.",
"patreonToken": "Patreon token",
"activateLicense": "Activate license",
"licenseValid": "Patreon account connected. Tier {{tier}} active.",
"licenseGrace": "Patreon connection expired, but beta access is maintained during the grace period. Make sure your Patreon subscription is still active and click \"Check now\".",
"licenseExpired": "Patreon connection expired too long ago. Reconnect to regain beta access.",
"licenseUnverifiable": "The installed token can no longer be verified. Reconnect.",
"infoTier": "<strong>Tier:</strong> {{tier}}",
"infoValidity": "<strong>Validity:</strong> until {{date}}",
"renewalDay": "(renews in {{n}} day)",
"renewalDays": "(renews in {{n}} days)",
"infoLastRefresh": "<strong>Last refresh:</strong> {{date}}",
"refreshOk": "OK",
"refreshFailed": "failed",
"enableBetaChannel": "Enable beta channel",
"disconnectPatreon": "Disconnect Patreon",
"betaChannelTitle": "Beta channel",
"betaChannelIntro": "New features ahead of time, free and for everyone. A beta may contain bugs: your data is kept and you can go back to the stable channel at any time.",
"checkingBetaImages": "Checking beta images...",
"betaUnavailable": "Unavailable: {{reason}}",
"betaCheckImpossible": "Beta check failed (beta registry unreachable or baseline missing).",
"betaUpdateAvailable": "A new beta is available.",
"betaUpToDate": "Beta up to date (checked on {{date}}).",
"currentChannel": "Current channel:",
"channelBeta": "Beta",
"channelStable": "Stable",
@@ -125,14 +109,6 @@
"switching": "Switching...",
"switchInProgressNotice": "Switching in progress. The application will be unavailable for 10 to 30 seconds — the page will reload automatically once the new Core is ready.",
"switcherUnavailable": "The channel switcher sidecar is not installed. To benefit from automatic switching, fetch the latest <code>docker-compose.yml</code> from the repo and run <code>docker compose pull &amp;&amp; docker compose up -d</code> once. Otherwise, switch manually by editing <code>IMAGE_NAMESPACE</code> in your <code>.env</code> (<code>igmlcreation/loremind-</code> for stable, <code>igmlcreation/loremind-beta-</code> for beta).",
"connectUrlError": "Unable to generate the connection URL. Check your config.",
"pasteTokenFirst": "First paste the token received after connecting with Patreon.",
"patreonConnectedSuccess": "Patreon account connected. Beta access is active.",
"disconnectTitle": "Disconnect Patreon",
"disconnectMessage": "Disconnect your Patreon account?",
"disconnectDetail": "You will lose access to the beta channel.",
"disconnectConfirm": "Disconnect",
"patreonDisconnected": "Patreon account disconnected.",
"switchToBetaMessage": "Switch LoreMind to the beta channel? The core/brain/web containers will be recreated with the beta images. The application will be unavailable for 10-30 seconds.",
"switchToStableMessage": "Switch LoreMind back to the stable channel? The core/brain/web containers will be recreated with the stable images. The application will be unavailable for 10-30 seconds.",
"switchToBetaTitle": "Switch to beta?",
@@ -95,28 +95,12 @@
"upToDate": "Tout est à jour (vérifié le {{date}}).",
"applying": "Mise à jour en cours...",
"applyNow": "Mettre à jour maintenant",
"betaChannelTitle": "Canal beta — réservé aux patrons",
"betaChannelIntro": "Soutiens LoreMind sur Patreon pour accéder aux nouvelles features en avant-première. Le tier <strong>Compagnon</strong> (7€/mois) ou supérieur débloque ce canal.",
"connectPatreon": "Connecter mon compte Patreon",
"connectInstructions": "Une nouvelle fenêtre va s'ouvrir vers Patreon. Après autorisation, copie le token affiché et colle-le ci-dessous.",
"patreonToken": "Token Patreon",
"activateLicense": "Activer la licence",
"licenseValid": "Compte Patreon connecté. Tier {{tier}} actif.",
"licenseGrace": "Connexion Patreon expirée, mais accès beta maintenu pendant la période de tolérance. Vérifie que ton abonnement Patreon est toujours actif et clique sur \"Vérifier maintenant\".",
"licenseExpired": "Connexion Patreon expirée depuis trop longtemps. Reconnecte-toi pour retrouver l'accès beta.",
"licenseUnverifiable": "Le token installé ne peut plus être vérifié. Reconnecte-toi.",
"infoTier": "<strong>Tier :</strong> {{tier}}",
"infoValidity": "<strong>Validité :</strong> jusqu'au {{date}}",
"renewalDay": "(renouvellement dans {{n}} jour)",
"renewalDays": "(renouvellement dans {{n}} jours)",
"infoLastRefresh": "<strong>Dernier refresh :</strong> {{date}}",
"refreshOk": "OK",
"refreshFailed": "échec",
"enableBetaChannel": "Activer le canal beta",
"disconnectPatreon": "Déconnecter Patreon",
"betaChannelTitle": "Canal bêta",
"betaChannelIntro": "Les nouveautés en avant-première, gratuitement et pour tout le monde. Une bêta peut contenir des bugs : tes données sont conservées et tu peux revenir au canal stable à tout moment.",
"checkingBetaImages": "Vérification des images beta...",
"betaUnavailable": "Indisponible : {{reason}}",
"betaCheckImpossible": "Vérification beta impossible (registry beta injoignable ou baseline absente).",
"betaUpdateAvailable": "Une nouvelle bêta est disponible.",
"betaUpToDate": "Bêta à jour (vérifiée le {{date}}).",
"currentChannel": "Canal actuel :",
"channelBeta": "Bêta",
"channelStable": "Stable",
@@ -125,14 +109,6 @@
"switching": "Bascule en cours...",
"switchInProgressNotice": "Bascule en cours. L'application va être indisponible 10 à 30 secondes — la page se rechargera automatiquement quand le nouveau Core sera prêt.",
"switcherUnavailable": "Le sidecar de bascule n'est pas installé. Pour bénéficier du switch automatique, récupère le dernier <code>docker-compose.yml</code> du repo et fais <code>docker compose pull &amp;&amp; docker compose up -d</code> une fois. Sinon, bascule manuellement en éditant <code>IMAGE_NAMESPACE</code> dans ton <code>.env</code> (<code>igmlcreation/loremind-</code> pour stable, <code>igmlcreation/loremind-beta-</code> pour beta).",
"connectUrlError": "Impossible de générer l'URL de connexion. Vérifie ta config.",
"pasteTokenFirst": "Colle d'abord le token reçu après connexion Patreon.",
"patreonConnectedSuccess": "Compte Patreon connecté. L'accès beta est actif.",
"disconnectTitle": "Déconnecter Patreon",
"disconnectMessage": "Déconnecter ton compte Patreon ?",
"disconnectDetail": "Tu perdras l'accès au canal beta.",
"disconnectConfirm": "Déconnecter",
"patreonDisconnected": "Compte Patreon déconnecté.",
"switchToBetaMessage": "Basculer LoreMind sur le canal beta ? Les containers core/brain/web vont être recréés avec les images beta. L'application sera indisponible 10-30 secondes.",
"switchToStableMessage": "Repasser LoreMind sur le canal stable ? Les containers core/brain/web vont être recréés avec les images stables. L'application sera indisponible 10-30 secondes.",
"switchToBetaTitle": "Passer en beta ?",