refactor(frontend): rename booklore-ui to frontend
- Frontend path: - rename the tracked Angular app tree from `booklore-ui/` to `frontend/` - preserve file contents during the move so this commit stays focused on the path change itself - Frontend docs: - update the moved frontend README and contribution guide where they refer to the renamed folder - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
import {environment} from '../../../environments/environment';
|
||||
|
||||
export const API_CONFIG = environment.API_CONFIG;
|
||||
@@ -0,0 +1,38 @@
|
||||
import {inject} from '@angular/core';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {firstValueFrom} from 'rxjs';
|
||||
import {AVAILABLE_LANGS} from './transloco-loader';
|
||||
|
||||
// TODO(grimmory-cleanup): Remove after the Booklore-to-Grimmory localStorage migration window closes.
|
||||
export const LEGACY_LANG_STORAGE_KEY = 'booklore-lang';
|
||||
export const LANG_STORAGE_KEY = 'grimmory-lang';
|
||||
|
||||
function detectLanguage(available: string[]): string {
|
||||
const saved = localStorage.getItem(LANG_STORAGE_KEY) ?? localStorage.getItem(LEGACY_LANG_STORAGE_KEY);
|
||||
if (saved && available.includes(saved)) {
|
||||
localStorage.setItem(LANG_STORAGE_KEY, saved);
|
||||
return saved;
|
||||
}
|
||||
|
||||
const browserLocale = navigator.language;
|
||||
if (browserLocale && available.includes(browserLocale)) {
|
||||
return browserLocale;
|
||||
}
|
||||
|
||||
const baseLang = browserLocale?.split('-')[0];
|
||||
if (baseLang && available.includes(baseLang)) {
|
||||
return baseLang;
|
||||
}
|
||||
|
||||
return 'en';
|
||||
}
|
||||
|
||||
export function initializeLanguage() {
|
||||
return () => {
|
||||
const translocoService = inject(TranslocoService);
|
||||
const lang = detectLanguage(AVAILABLE_LANGS);
|
||||
translocoService.setActiveLang(lang);
|
||||
localStorage.setItem(LANG_STORAGE_KEY, lang);
|
||||
return firstValueFrom(translocoService.load(lang));
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Translation, TranslocoLoader} from '@jsverse/transloco';
|
||||
import {from, of, Observable} from 'rxjs';
|
||||
import en from '../../../i18n/en';
|
||||
|
||||
export const EN_TRANSLATIONS: Translation = en;
|
||||
|
||||
// To add a new language: create src/i18n/<lang>/ with domain JSONs + index.ts, then add an entry here.
|
||||
const LAZY_LANG_LOADERS: Record<string, () => Promise<{default: Translation}>> = {
|
||||
es: () => import('../../../i18n/es'),
|
||||
it: () => import('../../../i18n/it'),
|
||||
de: () => import('../../../i18n/de'),
|
||||
fr: () => import('../../../i18n/fr'),
|
||||
nl: () => import('../../../i18n/nl'),
|
||||
pl: () => import('../../../i18n/pl'),
|
||||
pt: () => import('../../../i18n/pt'),
|
||||
ru: () => import('../../../i18n/ru'),
|
||||
hr: () => import('../../../i18n/hr'),
|
||||
sv: () => import('../../../i18n/sv'),
|
||||
zh: () => import('../../../i18n/zh'),
|
||||
ja: () => import('../../../i18n/ja'),
|
||||
hu: () => import('../../../i18n/hu'),
|
||||
sl: () => import('../../../i18n/sl'),
|
||||
sk: () => import('../../../i18n/sk'),
|
||||
uk: () => import('../../../i18n/uk'),
|
||||
id: () => import('../../../i18n/id'),
|
||||
da: () => import('../../../i18n/da'),
|
||||
};
|
||||
|
||||
export const AVAILABLE_LANGS = ['en', ...Object.keys(LAZY_LANG_LOADERS)];
|
||||
|
||||
export const LANG_LABELS: Record<string, string> = {
|
||||
en: 'English',
|
||||
es: 'Español',
|
||||
it: 'Italiano',
|
||||
de: 'Deutsch',
|
||||
fr: 'Français',
|
||||
nl: 'Nederlands',
|
||||
pl: 'Polski',
|
||||
pt: 'Português',
|
||||
ru: 'Русский',
|
||||
hr: 'Hrvatski',
|
||||
sv: 'Svenska',
|
||||
zh: '中文',
|
||||
ja: '日本語',
|
||||
hu: 'Magyar',
|
||||
sl: 'Slovenščina',
|
||||
sk: 'Slovenčina',
|
||||
uk: 'Українська',
|
||||
id: 'Bahasa Indonesia',
|
||||
da: 'Dansk',
|
||||
};
|
||||
|
||||
function deepMerge(base: Record<string, Translation>, override: Record<string, Translation>): Record<string, Translation> {
|
||||
const result = {...base};
|
||||
for (const key of Object.keys(override)) {
|
||||
if (override[key] && typeof override[key] === 'object' && !Array.isArray(override[key])
|
||||
&& base[key] && typeof base[key] === 'object' && !Array.isArray(base[key])) {
|
||||
result[key] = deepMerge(base[key], override[key]);
|
||||
} else if (override[key]) {
|
||||
result[key] = override[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class TranslocoInlineLoader implements TranslocoLoader {
|
||||
getTranslation(lang: string): Observable<Translation> {
|
||||
if (lang === 'en') {
|
||||
return of(EN_TRANSLATIONS);
|
||||
}
|
||||
const loader = LAZY_LANG_LOADERS[lang];
|
||||
if (loader) {
|
||||
return from(loader().then(m => deepMerge(EN_TRANSLATIONS, m.default)));
|
||||
}
|
||||
return of(EN_TRANSLATIONS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy} from '@angular/router';
|
||||
import {BookBrowserScrollService} from '../features/book/components/book-browser/book-browser-scroll.service';
|
||||
import {BookSelectionService} from '../features/book/components/book-browser/book-selection.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CustomReuseStrategy implements RouteReuseStrategy {
|
||||
private storedRoutes = new Map<string, DetachedRouteHandle>();
|
||||
private scrollService = inject(BookBrowserScrollService);
|
||||
private bookSelectionService = inject(BookSelectionService);
|
||||
|
||||
private readonly BOOK_BROWSER_PATHS = [
|
||||
'all-books',
|
||||
'unshelved-books',
|
||||
'library/:libraryId/books',
|
||||
'shelf/:shelfId/books',
|
||||
'magic-shelf/:magicShelfId/books',
|
||||
'authors',
|
||||
'series'
|
||||
];
|
||||
|
||||
private readonly BOOK_DETAILS_PATH = 'book/:bookId';
|
||||
|
||||
private getRouteKey(route: ActivatedRouteSnapshot): string {
|
||||
const path = route.routeConfig?.path || '';
|
||||
return this.scrollService.createKey(path, route.params);
|
||||
}
|
||||
|
||||
private isBookBrowserRoute(route: ActivatedRouteSnapshot): boolean {
|
||||
const path = route.routeConfig?.path;
|
||||
return this.BOOK_BROWSER_PATHS.includes(path || '');
|
||||
}
|
||||
|
||||
shouldDetach(route: ActivatedRouteSnapshot): boolean {
|
||||
return this.isBookBrowserRoute(route);
|
||||
}
|
||||
|
||||
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void {
|
||||
if (handle && this.isBookBrowserRoute(route)) {
|
||||
const key = this.getRouteKey(route);
|
||||
this.storedRoutes.set(key, handle);
|
||||
this.bookSelectionService.deselectAll();
|
||||
}
|
||||
}
|
||||
|
||||
shouldAttach(route: ActivatedRouteSnapshot): boolean {
|
||||
if (!this.isBookBrowserRoute(route)) {
|
||||
return false;
|
||||
}
|
||||
const key = this.getRouteKey(route);
|
||||
return this.storedRoutes.has(key);
|
||||
}
|
||||
|
||||
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null {
|
||||
const key = this.getRouteKey(route);
|
||||
const handle = this.storedRoutes.get(key) || null;
|
||||
|
||||
if (handle) {
|
||||
const savedPosition = this.scrollService.getPosition(key);
|
||||
if (savedPosition !== undefined) {
|
||||
setTimeout(() => {
|
||||
const scrollElement = document.querySelector('.virtual-scroller');
|
||||
if (scrollElement) {
|
||||
(scrollElement as HTMLElement).scrollTop = savedPosition;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
|
||||
return future.routeConfig === curr.routeConfig &&
|
||||
JSON.stringify(future.params) === JSON.stringify(curr.params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import {Injectable, signal} from '@angular/core';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class AuthInitializationService {
|
||||
private readonly _initialized = signal(false);
|
||||
readonly initialized = this._initialized.asReadonly();
|
||||
|
||||
markAsInitialized(): void {
|
||||
this._initialized.set(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {signal} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {initializeAuthFactory} from './auth-initializer';
|
||||
import {AuthInitializationService} from './auth-initialization-service';
|
||||
import {AuthService} from '../../shared/service/auth.service';
|
||||
import {AppSettingsService, PublicAppSettings} from '../../shared/service/app-settings.service';
|
||||
import {QueryClient, queryOptions} from '@tanstack/angular-query-experimental';
|
||||
|
||||
describe('initializeAuthFactory', () => {
|
||||
let authInitService: AuthInitializationService;
|
||||
let mockQueryClient: { fetchQuery: ReturnType<typeof vi.fn> };
|
||||
|
||||
const defaultPublicSettings: PublicAppSettings = {
|
||||
oidcEnabled: false,
|
||||
remoteAuthEnabled: false,
|
||||
oidcProviderDetails: null!,
|
||||
oidcForceOnlyMode: false,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
mockQueryClient = {
|
||||
fetchQuery: vi.fn().mockResolvedValue(defaultPublicSettings),
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
{provide: AuthService, useValue: {token: signal(null), getInternalAccessToken: vi.fn()}},
|
||||
{
|
||||
provide: AppSettingsService,
|
||||
useValue: {
|
||||
publicAppSettings: signal(null),
|
||||
getPublicSettingsQueryOptions: () => queryOptions({queryKey: ['public-settings'], queryFn: async () => defaultPublicSettings}),
|
||||
},
|
||||
},
|
||||
{provide: QueryClient, useValue: mockQueryClient},
|
||||
AuthInitializationService,
|
||||
]
|
||||
});
|
||||
|
||||
authInitService = TestBed.inject(AuthInitializationService);
|
||||
});
|
||||
|
||||
it('should proceed with auth initialization when navigator.onLine is false', async () => {
|
||||
const markSpy = vi.spyOn(authInitService, 'markAsInitialized');
|
||||
|
||||
Object.defineProperty(navigator, 'onLine', {value: false, configurable: true});
|
||||
|
||||
const factory = TestBed.runInInjectionContext(() => initializeAuthFactory());
|
||||
const initPromise = TestBed.runInInjectionContext(() => factory());
|
||||
|
||||
await initPromise;
|
||||
|
||||
expect(markSpy).toHaveBeenCalled();
|
||||
|
||||
Object.defineProperty(navigator, 'onLine', {value: true, configurable: true});
|
||||
});
|
||||
|
||||
it('should initialize normally when navigator.onLine is true', async () => {
|
||||
const markSpy = vi.spyOn(authInitService, 'markAsInitialized');
|
||||
|
||||
Object.defineProperty(navigator, 'onLine', {value: true, configurable: true});
|
||||
|
||||
const factory = TestBed.runInInjectionContext(() => initializeAuthFactory());
|
||||
const initPromise = TestBed.runInInjectionContext(() => factory());
|
||||
|
||||
await initPromise;
|
||||
|
||||
expect(markSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
import {inject} from '@angular/core';
|
||||
import {AuthService, websocketInitializer} from '../../shared/service/auth.service';
|
||||
import {AppSettingsService} from '../../shared/service/app-settings.service';
|
||||
import {AuthInitializationService} from './auth-initialization-service';
|
||||
import {QueryClient} from '@tanstack/angular-query-experimental';
|
||||
|
||||
const SETTINGS_TIMEOUT_MS = 10000;
|
||||
|
||||
export function initializeAuthFactory() {
|
||||
return () => {
|
||||
const appSettingsService = inject(AppSettingsService);
|
||||
const authService = inject(AuthService);
|
||||
const authInitService = inject(AuthInitializationService);
|
||||
const queryClient = inject(QueryClient);
|
||||
|
||||
const settingsPromise = queryClient.fetchQuery(appSettingsService.getPublicSettingsQueryOptions());
|
||||
const timeoutPromise = new Promise<null>(resolve =>
|
||||
setTimeout(() => resolve(null), SETTINGS_TIMEOUT_MS)
|
||||
);
|
||||
|
||||
return Promise.race([settingsPromise, timeoutPromise]).then(publicSettings => {
|
||||
if (!publicSettings) {
|
||||
console.warn('[Auth] Public settings fetch timed out, falling back to local auth');
|
||||
authInitService.markAsInitialized();
|
||||
return;
|
||||
}
|
||||
|
||||
if (publicSettings.remoteAuthEnabled) {
|
||||
return new Promise<void>(resolve => {
|
||||
authService.remoteLogin().subscribe({
|
||||
next: () => {
|
||||
authInitService.markAsInitialized();
|
||||
resolve();
|
||||
},
|
||||
error: err => {
|
||||
console.error('[Remote Login] failed:', err);
|
||||
authInitService.markAsInitialized();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (authService.getInternalAccessToken()) {
|
||||
websocketInitializer(authService)();
|
||||
}
|
||||
authInitService.markAsInitialized();
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import {HttpErrorResponse, HttpEvent, HttpHandlerFn, HttpInterceptorFn, HttpRequest} from '@angular/common/http';
|
||||
import {inject} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {catchError, filter, switchMap, take} from 'rxjs/operators';
|
||||
import {BehaviorSubject, Observable, throwError} from 'rxjs';
|
||||
import {AuthService} from '../../shared/service/auth.service';
|
||||
import {API_CONFIG} from '../config/api-config';
|
||||
|
||||
export const AuthInterceptorService: HttpInterceptorFn = (req, next: HttpHandlerFn) => {
|
||||
const authService = inject(AuthService);
|
||||
const router = inject(Router);
|
||||
|
||||
const token = authService.getInternalAccessToken();
|
||||
const isApiRequest = req.url.startsWith(`${API_CONFIG.BASE_URL}/api/`);
|
||||
|
||||
const authReq = (token && isApiRequest) ? req.clone({ setHeaders: { Authorization: `Bearer ${token}` } }) : req;
|
||||
|
||||
return next(authReq).pipe(
|
||||
catchError((error: HttpErrorResponse) => {
|
||||
if (error.status === 401) {
|
||||
return handle401Error(authService, authReq, next, router);
|
||||
}
|
||||
return throwError(() => error);
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
let isRefreshing = false;
|
||||
const refreshTokenSubject = new BehaviorSubject<string | null>(null);
|
||||
|
||||
function handle401Error(authService: AuthService, request: HttpRequest<unknown>, next: HttpHandlerFn, router: Router): Observable<HttpEvent<unknown>> {
|
||||
if (!isRefreshing) {
|
||||
isRefreshing = true;
|
||||
refreshTokenSubject.next(null);
|
||||
|
||||
return authService.internalRefreshToken().pipe(
|
||||
switchMap(response => {
|
||||
isRefreshing = false;
|
||||
const { accessToken, refreshToken } = response;
|
||||
if (accessToken && refreshToken) {
|
||||
authService.saveInternalTokens(accessToken, refreshToken);
|
||||
refreshTokenSubject.next(accessToken);
|
||||
}
|
||||
return next(request.clone({
|
||||
setHeaders: { Authorization: `Bearer ${accessToken}` }
|
||||
}));
|
||||
}),
|
||||
catchError(err => {
|
||||
isRefreshing = false;
|
||||
forceLogout(authService, router);
|
||||
return throwError(() => err);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return refreshTokenSubject.pipe(
|
||||
filter(token => token !== null),
|
||||
take(1),
|
||||
switchMap(token =>
|
||||
next(request.clone({
|
||||
setHeaders: { Authorization: `Bearer ${token}` }
|
||||
}))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function forceLogout(authService: AuthService, router: Router): void {
|
||||
authService.logout();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import {inject} from '@angular/core';
|
||||
import {CanActivateFn, Router} from '@angular/router';
|
||||
import {AuthService} from '../../shared/service/auth.service';
|
||||
|
||||
export const AuthGuard: CanActivateFn = (route, state) => {
|
||||
const router = inject(Router);
|
||||
const authService = inject(AuthService);
|
||||
|
||||
const internalAccessToken = authService.getInternalAccessToken();
|
||||
|
||||
if (internalAccessToken) {
|
||||
try {
|
||||
const payload = JSON.parse(atob(internalAccessToken.split('.')[1]));
|
||||
if (payload.exp && payload.exp * 1000 < Date.now()) {
|
||||
localStorage.removeItem('accessToken_Internal');
|
||||
return router.createUrlTree(['/login']);
|
||||
}
|
||||
if (payload.isDefaultPassword) {
|
||||
router.navigate(['/change-password']);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (e) {
|
||||
localStorage.removeItem('accessToken_Internal');
|
||||
router.navigate(['/login']);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
router.navigate(['/login']);
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject} from '@angular/core';
|
||||
import {CanActivateFn, Router} from '@angular/router';
|
||||
import {UserService} from '../../../features/settings/user-management/user.service';
|
||||
|
||||
export const BookdropGuard: CanActivateFn = () => {
|
||||
const userService = inject(UserService);
|
||||
const router = inject(Router);
|
||||
const user = userService.currentUser();
|
||||
|
||||
if (user && (user.permissions.admin || user.permissions.canAccessBookdrop)) {
|
||||
return true;
|
||||
}
|
||||
router.navigate(['/dashboard']);
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject} from '@angular/core';
|
||||
import {CanActivateFn, Router} from '@angular/router';
|
||||
import {UserService} from '../../../features/settings/user-management/user.service';
|
||||
|
||||
export const EditMetadataGuard: CanActivateFn = () => {
|
||||
const userService = inject(UserService);
|
||||
const router = inject(Router);
|
||||
const user = userService.currentUser();
|
||||
|
||||
if (user && (user.permissions.admin || user.permissions.canEditMetadata)) {
|
||||
return true;
|
||||
}
|
||||
router.navigate(['/dashboard']);
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject} from '@angular/core';
|
||||
import {CanActivateFn, Router} from '@angular/router';
|
||||
import {UserService} from '../../../features/settings/user-management/user.service';
|
||||
|
||||
export const LibraryStatsGuard: CanActivateFn = () => {
|
||||
const userService = inject(UserService);
|
||||
const router = inject(Router);
|
||||
const user = userService.currentUser();
|
||||
|
||||
if (user && (user.permissions.admin || user.permissions.canAccessLibraryStats)) {
|
||||
return true;
|
||||
}
|
||||
router.navigate(['/dashboard']);
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject} from '@angular/core';
|
||||
import {CanActivateFn, Router} from '@angular/router';
|
||||
import {UserService} from '../../../features/settings/user-management/user.service';
|
||||
|
||||
export const ManageLibraryGuard: CanActivateFn = () => {
|
||||
const userService = inject(UserService);
|
||||
const router = inject(Router);
|
||||
const user = userService.currentUser();
|
||||
|
||||
if (user && (user.permissions.admin || user.permissions.canManageLibrary)) {
|
||||
return true;
|
||||
}
|
||||
router.navigate(['/dashboard']);
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject} from '@angular/core';
|
||||
import {CanActivateFn, Router} from '@angular/router';
|
||||
import {UserService} from '../../../features/settings/user-management/user.service';
|
||||
|
||||
export const UserStatsGuard: CanActivateFn = () => {
|
||||
const userService = inject(UserService);
|
||||
const router = inject(Router);
|
||||
const user = userService.currentUser();
|
||||
|
||||
if (user && (user.permissions.admin || user.permissions.canAccessUserStats)) {
|
||||
return true;
|
||||
}
|
||||
router.navigate(['/dashboard']);
|
||||
return false;
|
||||
};
|
||||
+623
@@ -0,0 +1,623 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsAuth'">
|
||||
<div class="main-container">
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-key"></i>
|
||||
{{ t('title') }}
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
{{ t('description') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-shield"></i>
|
||||
{{ t('methods.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('methods.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="auth-methods-list">
|
||||
<div class="auth-method-item is-active is-locked">
|
||||
<div class="auth-method-content">
|
||||
<div class="auth-method-header">
|
||||
<div class="auth-method-icon">
|
||||
<i class="pi pi-user"></i>
|
||||
</div>
|
||||
<div class="auth-method-info">
|
||||
<span class="auth-method-label">{{ t('internal.label') }}</span>
|
||||
<span class="auth-method-status active">{{ t('internal.status') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="auth-method-description">
|
||||
{{ t('internal.description') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-checkbox
|
||||
[(ngModel)]="internalAuthEnabled"
|
||||
[binary]="true"
|
||||
[disabled]="true">
|
||||
</p-checkbox>
|
||||
</div>
|
||||
|
||||
<div class="auth-method-item" [class.is-active]="oidcEnabled">
|
||||
<div class="auth-method-content">
|
||||
<div class="auth-method-header">
|
||||
<div class="auth-method-icon oidc">
|
||||
<i class="pi pi-key"></i>
|
||||
</div>
|
||||
<div class="auth-method-info">
|
||||
<span class="auth-method-label">
|
||||
{{ t('oidc.label') }}
|
||||
</span>
|
||||
<span class="auth-method-status" [class.active]="oidcEnabled">
|
||||
{{ oidcEnabled ? t('oidc.enabled') : t('oidc.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="auth-method-description">
|
||||
{{ t('oidc.description') }}
|
||||
<app-external-doc-link docType="authentication"></app-external-doc-link>
|
||||
@if (!isOidcFormComplete() && !oidcEnabled) {
|
||||
<span class="config-hint">{{ t('oidc.configHint') }}</span>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="oidcEnabled"
|
||||
[disabled]="!isOidcFormComplete()"
|
||||
(onChange)="toggleOidcEnabled()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-cog"></i>
|
||||
{{ t('providerConfig.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('providerConfig.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="config-grid">
|
||||
<div class="config-item">
|
||||
<label for="providerName">{{ t('providerConfig.providerName') }}</label>
|
||||
<input
|
||||
pInputText
|
||||
pSize="small"
|
||||
id="providerName"
|
||||
[(ngModel)]="oidcProvider.providerName"
|
||||
[placeholder]="t('providerConfig.providerPlaceholder')"/>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<label for="clientId">{{ t('providerConfig.clientId') }}</label>
|
||||
<input
|
||||
pInputText
|
||||
pSize="small"
|
||||
id="clientId"
|
||||
[(ngModel)]="oidcProvider.clientId"
|
||||
[placeholder]="t('providerConfig.clientIdPlaceholder')"/>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<label for="clientSecret">{{ t('providerConfig.clientSecret') }}</label>
|
||||
<input
|
||||
pInputText
|
||||
pSize="small"
|
||||
id="clientSecret"
|
||||
type="password"
|
||||
[(ngModel)]="oidcProvider.clientSecret"
|
||||
[placeholder]="t('providerConfig.clientSecretPlaceholder')"/>
|
||||
<span class="field-hint">{{ t('providerConfig.clientSecretHint') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="config-item span-2">
|
||||
<label for="issuerUri">{{ t('providerConfig.issuerUri') }}</label>
|
||||
<input
|
||||
pInputText
|
||||
pSize="small"
|
||||
id="issuerUri"
|
||||
[(ngModel)]="oidcProvider.issuerUri"
|
||||
[placeholder]="t('providerConfig.issuerPlaceholder')"/>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<label for="scopes">{{ t('providerConfig.scope') }}</label>
|
||||
<input
|
||||
pInputText
|
||||
pSize="small"
|
||||
id="scopes"
|
||||
[(ngModel)]="oidcProvider.scopes"
|
||||
[placeholder]="'openid profile email groups offline_access'"/>
|
||||
<span class="field-hint">{{ t('providerConfig.scopeHint') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (oidcEnabled) {
|
||||
<div class="config-grid" style="margin-top: 0.75rem;">
|
||||
<div class="config-item">
|
||||
<label for="sessionDuration">{{ t('providerConfig.sessionDuration') }}</label>
|
||||
<p-inputNumber
|
||||
size="small"
|
||||
inputId="sessionDuration"
|
||||
[(ngModel)]="sessionDurationHours"
|
||||
[min]="1"
|
||||
[max]="8760"
|
||||
[showButtons]="true"
|
||||
[placeholder]="t('providerConfig.sessionDurationPlaceholder')"
|
||||
mode="decimal"
|
||||
[useGrouping]="false">
|
||||
</p-inputNumber>
|
||||
<span class="field-hint">{{ t('providerConfig.sessionDurationHint') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="claims-section">
|
||||
<h4 class="subsection-title">{{ t('providerConfig.claimMappings') }}</h4>
|
||||
<p class="subsection-description">
|
||||
{{ t('providerConfig.claimDesc') }}
|
||||
</p>
|
||||
<div class="claims-grid">
|
||||
<div class="config-item">
|
||||
<label for="claimUsername">{{ t('providerConfig.usernameClaim') }}</label>
|
||||
<input
|
||||
pInputText
|
||||
pSize="small"
|
||||
id="claimUsername"
|
||||
[(ngModel)]="oidcProvider.claimMapping.username"
|
||||
[placeholder]="t('providerConfig.usernamePlaceholder')"/>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<label for="claimEmail">{{ t('providerConfig.emailClaim') }}</label>
|
||||
<input
|
||||
pInputText
|
||||
pSize="small"
|
||||
id="claimEmail"
|
||||
[(ngModel)]="oidcProvider.claimMapping.email"
|
||||
[placeholder]="t('providerConfig.emailPlaceholder')"/>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<label for="claimName">{{ t('providerConfig.nameClaim') }}</label>
|
||||
<input
|
||||
pInputText
|
||||
pSize="small"
|
||||
id="claimName"
|
||||
[(ngModel)]="oidcProvider.claimMapping.name"
|
||||
[placeholder]="t('providerConfig.namePlaceholder')"/>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<label for="claimGroups">{{ t('providerConfig.groupsClaim') }}</label>
|
||||
<input
|
||||
pInputText
|
||||
pSize="small"
|
||||
id="claimGroups"
|
||||
[(ngModel)]="oidcProvider.claimMapping.groups"
|
||||
[placeholder]="t('providerConfig.groupsPlaceholder')"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="provider-actions-row">
|
||||
<div class="test-results-inline">
|
||||
@if (testConnectionResult) {
|
||||
<div class="test-results-toggle"
|
||||
[style.border-radius]="showTestDetails ? '6px 6px 0 0' : '6px'"
|
||||
(click)="showTestDetails = !showTestDetails">
|
||||
@if (testConnectionResult.success) {
|
||||
<i class="pi pi-check-circle" style="color: var(--p-green-500);"></i>
|
||||
<span>{{ t('testConnection.passed') }}</span>
|
||||
} @else {
|
||||
<i class="pi pi-times-circle" style="color: var(--p-red-500);"></i>
|
||||
<span>{{ t('testConnection.failed') }}</span>
|
||||
}
|
||||
<span style="color: var(--p-text-muted-color); font-size: 0.75rem;">
|
||||
({{ testConnectionResult.checks.length }} {{ t('testConnection.checks') }})
|
||||
</span>
|
||||
<i class="pi pi-chevron-right toggle-chevron" [class.expanded]="showTestDetails"></i>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="provider-action-buttons">
|
||||
<p-button
|
||||
[outlined]="true"
|
||||
[label]="t('testConnection.button')"
|
||||
[icon]="isTestingConnection ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
|
||||
severity="info"
|
||||
size="small"
|
||||
(click)="testConnection()"
|
||||
[disabled]="!oidcProvider.issuerUri || isTestingConnection">
|
||||
</p-button>
|
||||
<p-button
|
||||
[outlined]="true"
|
||||
[label]="'common.save' | transloco"
|
||||
icon="pi pi-save"
|
||||
severity="success"
|
||||
size="small"
|
||||
(click)="saveOidcProvider()"
|
||||
[disabled]="!isOidcFormComplete()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
@if (testConnectionResult && showTestDetails) {
|
||||
<div class="test-results-details">
|
||||
@for (check of testConnectionResult.checks; track check.name) {
|
||||
<div class="test-check-row">
|
||||
@switch (check.status) {
|
||||
@case ('PASS') {
|
||||
<i class="pi pi-check-circle" style="color: var(--p-green-500);"></i>
|
||||
}
|
||||
@case ('FAIL') {
|
||||
<i class="pi pi-times-circle" style="color: var(--p-red-500);"></i>
|
||||
}
|
||||
@case ('WARN') {
|
||||
<i class="pi pi-exclamation-triangle" style="color: var(--p-yellow-500);"></i>
|
||||
}
|
||||
@case ('SKIP') {
|
||||
<i class="pi pi-minus-circle" style="color: var(--p-surface-400);"></i>
|
||||
}
|
||||
}
|
||||
<span class="check-name">{{ check.name }}</span>
|
||||
<span class="check-message">{{ check.message }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('infoPanel.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('infoPanel.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<div class="info-panel-grid">
|
||||
@for (item of infoItems; track item.labelKey) {
|
||||
<div class="info-panel-item">
|
||||
<span class="info-panel-label">{{ t(item.labelKey) }}</span>
|
||||
<div class="info-panel-value-row">
|
||||
<code class="info-panel-value">{{ item.value }}</code>
|
||||
<p-button
|
||||
[outlined]="true"
|
||||
icon="pi pi-copy"
|
||||
severity="secondary"
|
||||
size="small"
|
||||
[style]="{'min-width': '2rem'}"
|
||||
(click)="copyToClipboard(item.value)">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (oidcEnabled) {
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-ban"></i>
|
||||
{{ t('oidcOnly.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('oidcOnly.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="provisioning-toggle">
|
||||
<div class="toggle-content">
|
||||
<div class="toggle-info">
|
||||
<span class="toggle-label">{{ t('oidcOnly.label') }}</span>
|
||||
<span class="toggle-status" [class.active]="oidcForceOnlyMode">
|
||||
{{ oidcForceOnlyMode ? t('oidcOnly.enabled') : t('oidcOnly.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="toggle-description">
|
||||
{{ t('oidcOnly.description') }}
|
||||
</p>
|
||||
@if (oidcForceOnlyMode) {
|
||||
<p class="toggle-description" style="color: var(--p-yellow-500); margin-top: 0.5rem;">
|
||||
<i class="pi pi-exclamation-triangle" style="margin-right: 0.25rem;"></i>
|
||||
{{ t('oidcOnly.backdoorHint') }}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="oidcForceOnlyMode"
|
||||
(onChange)="toggleOidcForceOnlyMode()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<div class="section-header-row">
|
||||
<div class="section-header-text">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-users"></i>
|
||||
{{ t('provisioning.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('provisioning.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="provisioning-toggle">
|
||||
<div class="toggle-content">
|
||||
<div class="toggle-info">
|
||||
<span class="toggle-label">{{ t('provisioning.autoLabel') }}</span>
|
||||
<span class="toggle-status" [class.active]="autoUserProvisioningEnabled">
|
||||
{{ autoUserProvisioningEnabled ? t('provisioning.autoEnabled') : t('provisioning.autoDisabled') }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="toggle-description">
|
||||
{{ t('provisioning.autoDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="autoUserProvisioningEnabled"
|
||||
inputId="autoProvision"
|
||||
(onChange)="saveOidcAutoProvisionSettings()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
|
||||
<div class="provisioning-toggle">
|
||||
<div class="toggle-content">
|
||||
<div class="toggle-info">
|
||||
<span class="toggle-label">{{ t('provisioning.linkLocalLabel') }}</span>
|
||||
<span class="toggle-status" [class.active]="allowLocalAccountLinking">
|
||||
{{ allowLocalAccountLinking ? t('provisioning.autoEnabled') : t('provisioning.autoDisabled') }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="toggle-description">
|
||||
{{ t('provisioning.linkLocalDesc') }}
|
||||
</p>
|
||||
@if (allowLocalAccountLinking) {
|
||||
<p class="toggle-description" style="color: var(--p-yellow-500); margin-top: 0.5rem;">
|
||||
<i class="pi pi-exclamation-triangle" style="margin-right: 0.25rem;"></i>
|
||||
{{ t('provisioning.linkLocalWarning') }}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="allowLocalAccountLinking"
|
||||
inputId="linkLocal"
|
||||
(onChange)="saveOidcAutoProvisionSettings()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
|
||||
@if (autoUserProvisioningEnabled) {
|
||||
<div class="default-settings">
|
||||
<div class="permissions-group">
|
||||
<h4 class="group-title">{{ t('provisioning.defaultPerms') }}</h4>
|
||||
<div class="permissions-grid">
|
||||
<div class="permission-item">
|
||||
<p-checkbox
|
||||
[binary]="true"
|
||||
[disabled]="true"
|
||||
[ngModel]="true"
|
||||
inputId="permissionRead">
|
||||
</p-checkbox>
|
||||
<label for="permissionRead">{{ t('provisioning.readBooks') }}</label>
|
||||
</div>
|
||||
@for (perm of availablePermissions; track perm) {
|
||||
<div class="permission-item">
|
||||
<p-checkbox
|
||||
[(ngModel)]="perm.selected"
|
||||
[binary]="true"
|
||||
[inputId]="perm.value">
|
||||
</p-checkbox>
|
||||
<label [for]="perm.value">{{ t(perm.translationKey) }}</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="libraries-group">
|
||||
<h4 class="group-title">{{ t('provisioning.defaultLibraryAccess') }}</h4>
|
||||
<div style="display: flex; align-items: center; gap: 0.5rem; justify-content: space-between;">
|
||||
<p-multiSelect
|
||||
[options]="allLibraries"
|
||||
optionLabel="name"
|
||||
optionValue="id"
|
||||
[(ngModel)]="editingLibraryIds"
|
||||
[placeholder]="t('provisioning.selectLibraries')"
|
||||
appendTo="body"
|
||||
class="libraries-select"
|
||||
style="flex: 1;">
|
||||
</p-multiSelect>
|
||||
<p-button
|
||||
icon="pi pi-save"
|
||||
[label]="'common.save' | transloco"
|
||||
[outlined]="true"
|
||||
severity="success"
|
||||
size="small"
|
||||
(click)="saveOidcAutoProvisionSettings()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<div class="section-header-row">
|
||||
<div class="section-header-text">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-sitemap"></i>
|
||||
{{ t('groupMapping.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('groupMapping.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-plus"
|
||||
[label]="t('groupMapping.addMapping')"
|
||||
[outlined]="true"
|
||||
severity="success"
|
||||
size="small"
|
||||
(click)="openNewGroupMapping()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="config-grid-2col" style="margin-bottom: 1rem;">
|
||||
<div class="config-item">
|
||||
<label for="groupSyncMode">{{ t('groupMapping.syncModeLabel') }}</label>
|
||||
<p-select
|
||||
inputId="groupSyncMode"
|
||||
[(ngModel)]="groupSyncMode"
|
||||
[options]="groupSyncModeOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
<span class="field-hint">{{ t('groupMapping.syncModeHint') }}</span>
|
||||
</div>
|
||||
<div class="config-item" style="display: flex; align-items: flex-end;">
|
||||
<p-button
|
||||
[outlined]="true"
|
||||
[label]="'common.save' | transloco"
|
||||
icon="pi pi-save"
|
||||
severity="success"
|
||||
size="small"
|
||||
(click)="saveGroupSyncMode()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (groupMappings.length > 0) {
|
||||
<p-table [value]="groupMappings" [tableStyle]="{'min-width': '100%'}" styleClass="p-datatable-sm">
|
||||
<ng-template #header>
|
||||
<tr>
|
||||
<th>{{ t('groupMapping.colGroupClaim') }}</th>
|
||||
<th>{{ t('groupMapping.colAdmin') }}</th>
|
||||
<th>{{ t('groupMapping.colPermissions') }}</th>
|
||||
<th>{{ t('groupMapping.colLibraries') }}</th>
|
||||
<th>{{ t('groupMapping.colDescription') }}</th>
|
||||
<th style="width: 8rem;"></th>
|
||||
</tr>
|
||||
</ng-template>
|
||||
<ng-template #body let-mapping>
|
||||
<tr>
|
||||
<td>{{ mapping.oidcGroupClaim }}</td>
|
||||
<td>
|
||||
@if (mapping.isAdmin) {
|
||||
<app-tag [rounded]="true" color="warning" size="2xs">Admin</app-tag>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@for (perm of mapping.permissions; track perm) {
|
||||
<app-tag [rounded]="true" color="info" size="2xs" style="margin-right: 0.25rem; margin-bottom: 0.25rem;">{{ perm }}</app-tag>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@for (libId of mapping.libraryIds; track libId) {
|
||||
<app-tag [rounded]="true" color="secondary" size="2xs" style="margin-right: 0.25rem; margin-bottom: 0.25rem;">{{ getLibraryName(libId) }}</app-tag>
|
||||
}
|
||||
</td>
|
||||
<td>{{ mapping.description }}</td>
|
||||
<td>
|
||||
<div style="display: flex; gap: 0.5rem;">
|
||||
<p-button icon="pi pi-pencil" [rounded]="true" [text]="true" severity="info" size="small" (click)="openEditGroupMapping(mapping)"></p-button>
|
||||
<p-button icon="pi pi-trash" [rounded]="true" [text]="true" severity="danger" size="small" (click)="deleteGroupMapping(mapping)"></p-button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
</p-table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-dialog
|
||||
[header]="editingGroupMapping.id ? t('groupMapping.editTitle') : t('groupMapping.addTitle')"
|
||||
[(visible)]="showGroupMappingDialog"
|
||||
[modal]="true"
|
||||
[style]="{width: '550px', maxWidth: '95vw'}"
|
||||
[dismissableMask]="true">
|
||||
<div class="config-grid" style="gap: 1rem;">
|
||||
<div class="config-item full-width">
|
||||
<label for="gmGroupClaim">{{ t('groupMapping.groupClaimLabel') }}</label>
|
||||
<input pInputText id="gmGroupClaim" [(ngModel)]="editingGroupMapping.oidcGroupClaim" [placeholder]="t('groupMapping.groupClaimPlaceholder')"/>
|
||||
</div>
|
||||
<div class="config-item full-width">
|
||||
<label for="gmDescription">{{ t('groupMapping.descriptionLabel') }}</label>
|
||||
<input pInputText id="gmDescription" [(ngModel)]="editingGroupMapping.description" [placeholder]="t('groupMapping.descriptionPlaceholder')"/>
|
||||
</div>
|
||||
<div class="config-item full-width">
|
||||
<div class="provisioning-toggle" style="padding: 0;">
|
||||
<div class="toggle-content">
|
||||
<span class="toggle-label">{{ t('groupMapping.adminLabel') }}</span>
|
||||
</div>
|
||||
<p-toggleswitch [(ngModel)]="editingGroupMapping.isAdmin"></p-toggleswitch>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item full-width">
|
||||
<h4 class="group-title">{{ t('groupMapping.permissionsLabel') }}</h4>
|
||||
<div class="permissions-grid">
|
||||
<div class="permission-item">
|
||||
<p-checkbox [binary]="true" [disabled]="true" [ngModel]="true" inputId="gmPermRead"></p-checkbox>
|
||||
<label for="gmPermRead">{{ t('provisioning.readBooks') }}</label>
|
||||
</div>
|
||||
@for (perm of editingGroupMappingPerms; track perm) {
|
||||
<div class="permission-item">
|
||||
<p-checkbox [(ngModel)]="perm.selected" [binary]="true" [inputId]="'gm_' + perm.value"></p-checkbox>
|
||||
<label [for]="'gm_' + perm.value">{{ t(perm.translationKey) }}</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item full-width">
|
||||
<h4 class="group-title">{{ t('groupMapping.librariesLabel') }}</h4>
|
||||
<p-multiSelect
|
||||
[options]="allLibraries"
|
||||
optionLabel="name"
|
||||
optionValue="id"
|
||||
[(ngModel)]="editingGroupMappingLibraryIds"
|
||||
[placeholder]="t('provisioning.selectLibraries')"
|
||||
appendTo="body"
|
||||
class="libraries-select">
|
||||
</p-multiSelect>
|
||||
</div>
|
||||
</div>
|
||||
<ng-template #footer>
|
||||
<p-button
|
||||
[label]="'common.save' | transloco"
|
||||
icon="pi pi-check"
|
||||
(click)="saveGroupMapping()"
|
||||
[disabled]="!editingGroupMapping.oidcGroupClaim">
|
||||
</p-button>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
}
|
||||
</div>
|
||||
</ng-container>
|
||||
+498
@@ -0,0 +1,498 @@
|
||||
@use '../../../shared/styles/settings-shared' as settings;
|
||||
|
||||
.main-container {
|
||||
@include settings.settings-page-container;
|
||||
}
|
||||
|
||||
@include settings.settings-page-header;
|
||||
|
||||
.settings-title {
|
||||
@include settings.settings-page-title;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
@include settings.settings-page-description;
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
@include settings.settings-card;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
@include settings.settings-section-header;
|
||||
}
|
||||
|
||||
.section-header-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
p-button {
|
||||
align-self: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section-header-text {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@include settings.settings-section-title;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
@include settings.settings-section-description;
|
||||
}
|
||||
|
||||
.section-body {
|
||||
@include settings.settings-section-body;
|
||||
}
|
||||
|
||||
// Authentication Methods List
|
||||
.auth-methods-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.auth-method-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-left: 3px solid var(--p-content-border-color);
|
||||
border-radius: 6px;
|
||||
padding: 1rem;
|
||||
transition: border-color 0.2s ease, background 0.2s ease;
|
||||
|
||||
&:hover:not(.is-locked) {
|
||||
background: color-mix(in srgb, var(--ground-background) 40%, var(--p-surface-800) 60%);
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
border-left-color: var(--p-green-500);
|
||||
}
|
||||
|
||||
&.is-locked {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.auth-method-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.auth-method-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.auth-method-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: color-mix(in srgb, var(--p-primary-color) 15%, transparent);
|
||||
color: var(--p-primary-color);
|
||||
border-radius: 8px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.pi {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
&.oidc {
|
||||
background: color-mix(in srgb, var(--p-orange-500) 15%, transparent);
|
||||
color: var(--p-orange-500);
|
||||
}
|
||||
}
|
||||
|
||||
.auth-method-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.auth-method-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-weight: 600;
|
||||
font-size: 0.9375rem;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
|
||||
.auth-method-status {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-muted-color);
|
||||
|
||||
&.active {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
}
|
||||
|
||||
.auth-method-description {
|
||||
font-size: 0.875rem;
|
||||
color: var(--p-text-muted-color);
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
padding-left: calc(36px + 0.75rem);
|
||||
|
||||
@media (max-width: 600px) {
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.config-hint {
|
||||
display: block;
|
||||
color: var(--p-orange-400);
|
||||
font-weight: 500;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
// Configuration Grid
|
||||
.config-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 900px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.config-grid-2col {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 600px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.config-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.375rem;
|
||||
|
||||
&.full-width {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
&.span-2 {
|
||||
grid-column: span 2;
|
||||
|
||||
@media (max-width: 600px) {
|
||||
grid-column: span 1;
|
||||
}
|
||||
}
|
||||
|
||||
label {
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.field-hint {
|
||||
font-size: 0.75rem;
|
||||
color: var(--p-text-muted-color);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
// Claims Section
|
||||
.claims-section {
|
||||
margin-top: 1rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px dashed var(--p-content-border-color);
|
||||
}
|
||||
|
||||
.subsection-title {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
margin: 0 0 0.25rem 0;
|
||||
}
|
||||
|
||||
.subsection-description {
|
||||
font-size: 0.75rem;
|
||||
color: var(--p-text-muted-color);
|
||||
line-height: 1.4;
|
||||
margin: 0 0 0.75rem 0;
|
||||
}
|
||||
|
||||
.claims-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 900px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
// Provider Actions Row
|
||||
.provider-actions-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
margin-top: 1rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px dashed var(--p-content-border-color);
|
||||
|
||||
@media (max-width: 600px) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
}
|
||||
|
||||
.test-results-inline {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.provider-action-buttons {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// Test Connection Results
|
||||
.test-results-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
border-radius: 6px;
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--p-text-color);
|
||||
transition: background 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--ground-background) 40%, var(--p-surface-800) 60%);
|
||||
}
|
||||
|
||||
.toggle-chevron {
|
||||
font-size: 0.75rem;
|
||||
color: var(--p-text-muted-color);
|
||||
transition: transform 0.2s ease;
|
||||
margin-left: auto;
|
||||
|
||||
&.expanded {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.test-results-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
padding: 0.5rem 0.875rem 0.625rem;
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-top: none;
|
||||
border-radius: 0 0 6px 6px;
|
||||
background: color-mix(in srgb, var(--ground-background) 60%, var(--p-surface-800) 40%);
|
||||
}
|
||||
|
||||
.test-check-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 0.5rem;
|
||||
padding: 0.1875rem 0;
|
||||
font-size: 0.8125rem;
|
||||
|
||||
.check-name {
|
||||
font-weight: 500;
|
||||
color: var(--p-text-color);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.check-message {
|
||||
color: var(--p-text-muted-color);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pi {
|
||||
font-size: 0.8125rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Provisioning Toggle
|
||||
.provisioning-toggle {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-left: 3px solid var(--p-primary-color);
|
||||
border-radius: 6px;
|
||||
padding: 1rem;
|
||||
|
||||
@media (max-width: 600px) {
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.toggle-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.toggle-label {
|
||||
font-weight: 600;
|
||||
font-size: 0.9375rem;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
|
||||
.toggle-status {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-muted-color);
|
||||
|
||||
&.active {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-description {
|
||||
font-size: 0.875rem;
|
||||
color: var(--p-text-muted-color);
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
// Default Settings (Permissions & Libraries)
|
||||
.default-settings {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
margin-top: 1rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px dashed var(--p-content-border-color);
|
||||
}
|
||||
|
||||
.permissions-group,
|
||||
.libraries-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.permissions-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
||||
gap: 0.625rem;
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
|
||||
.permission-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
|
||||
label {
|
||||
font-size: 0.875rem;
|
||||
color: var(--p-text-color);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.libraries-select {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
// Info Panel
|
||||
.info-panel-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.info-panel-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.info-panel-label {
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
|
||||
.info-panel-value-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.info-panel-value {
|
||||
flex: 1;
|
||||
font-size: 0.8125rem;
|
||||
padding: 0.375rem 0.625rem;
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 4px;
|
||||
color: var(--p-text-color);
|
||||
word-break: break-all;
|
||||
}
|
||||
+426
@@ -0,0 +1,426 @@
|
||||
import {Component, effect, inject} from '@angular/core';
|
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {InputNumber} from 'primeng/inputnumber';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {AppSettingsService} from '../../../shared/service/app-settings.service';
|
||||
import {AppSettingKey, AppSettings, OidcProviderDetails, OidcTestResult} from '../../../shared/model/app-settings.model';
|
||||
import {MultiSelect} from 'primeng/multiselect';
|
||||
import {LibraryService} from '../../../features/book/service/library.service';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
import {OidcGroupMapping} from '../../../shared/model/oidc-group-mapping.model';
|
||||
import {OidcGroupMappingService} from '../../../shared/service/oidc-group-mapping.service';
|
||||
import {Select} from 'primeng/select';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {Dialog} from 'primeng/dialog';
|
||||
import {TagComponent} from '../../../shared/components/tag/tag.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-authentication-settings',
|
||||
templateUrl: './authentication-settings.component.html',
|
||||
standalone: true,
|
||||
imports: [
|
||||
FormsModule,
|
||||
InputText,
|
||||
Checkbox,
|
||||
ToggleSwitch,
|
||||
Button,
|
||||
MultiSelect,
|
||||
InputNumber,
|
||||
ReactiveFormsModule,
|
||||
ExternalDocLinkComponent,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe,
|
||||
Select,
|
||||
TableModule,
|
||||
Dialog,
|
||||
TagComponent
|
||||
],
|
||||
styleUrls: ['./authentication-settings.component.scss']
|
||||
})
|
||||
export class AuthenticationSettingsComponent {
|
||||
availablePermissions = [
|
||||
{label: 'Upload Books', value: 'permissionUpload', selected: false, translationKey: 'perms.uploadBooks'},
|
||||
{label: 'Download Books', value: 'permissionDownload', selected: false, translationKey: 'perms.downloadBooks'},
|
||||
{label: 'Edit Book Metadata', value: 'permissionEditMetadata', selected: false, translationKey: 'perms.editMetadata'},
|
||||
{label: 'Manage Library', value: 'permissionManipulateLibrary', selected: false, translationKey: 'perms.manageLibrary'},
|
||||
{label: 'Email Book', value: 'permissionEmailBook', selected: false, translationKey: 'perms.emailBook'},
|
||||
{label: 'Delete Book', value: 'permissionDeleteBook', selected: false, translationKey: 'perms.deleteBook'},
|
||||
{label: 'KOReader Sync', value: 'permissionSyncKoreader', selected: false, translationKey: 'perms.koreaderSync'},
|
||||
{label: 'Kobo Sync', value: 'permissionSyncKobo', selected: false, translationKey: 'perms.koboSync'},
|
||||
{label: 'Access OPDS', value: 'permissionAccessOpds', selected: false, translationKey: 'perms.accessOpds'}
|
||||
];
|
||||
|
||||
internalAuthEnabled = true;
|
||||
autoUserProvisioningEnabled = false;
|
||||
allowLocalAccountLinking = true;
|
||||
selectedPermissions: string[] = [];
|
||||
oidcEnabled = false;
|
||||
|
||||
editingLibraryIds: number[] = [];
|
||||
sessionDurationHours: number | null = null;
|
||||
backchannelLogoutUri = `${window.location.origin}/api/v1/auth/oidc/backchannel-logout`;
|
||||
oidcForceOnlyMode = false;
|
||||
|
||||
infoItems = [
|
||||
{labelKey: 'infoPanel.redirectUri', value: `${window.location.origin}/oauth2-callback`},
|
||||
{labelKey: 'infoPanel.postLogoutRedirectUri', value: `${window.location.origin}/login`},
|
||||
{labelKey: 'infoPanel.backChannelLogoutUri', value: `${window.location.origin}/api/v1/auth/oidc/backchannel-logout`},
|
||||
{labelKey: 'infoPanel.requiredScopes', value: 'openid profile email groups offline_access'},
|
||||
{labelKey: 'infoPanel.pkceMethod', value: 'S256'},
|
||||
{labelKey: 'infoPanel.grantType', value: 'Authorization Code'},
|
||||
];
|
||||
|
||||
// Test connection
|
||||
isTestingConnection = false;
|
||||
testConnectionResult: OidcTestResult | null = null;
|
||||
showTestDetails = false;
|
||||
|
||||
// Group mapping
|
||||
groupSyncMode: string = 'DISABLED';
|
||||
groupSyncModeOptions = [
|
||||
{label: 'Disabled', value: 'DISABLED'},
|
||||
{label: 'On Login (Replace)', value: 'ON_LOGIN'},
|
||||
{label: 'On Login (Additive)', value: 'ON_LOGIN_ADDITIVE'}
|
||||
];
|
||||
groupMappings: OidcGroupMapping[] = [];
|
||||
showGroupMappingDialog = false;
|
||||
editingGroupMapping: OidcGroupMapping = this.emptyGroupMapping();
|
||||
editingGroupMappingPerms: {label: string; value: string; selected: boolean; translationKey: string}[] = [];
|
||||
editingGroupMappingLibraryIds: number[] = [];
|
||||
|
||||
oidcProvider: OidcProviderDetails = {
|
||||
providerName: '',
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
issuerUri: '',
|
||||
scopes: '',
|
||||
claimMapping: {
|
||||
username: '',
|
||||
email: '',
|
||||
name: '',
|
||||
groups: ''
|
||||
}
|
||||
};
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
private libraryService = inject(LibraryService);
|
||||
private groupMappingService = inject(OidcGroupMappingService);
|
||||
private t = inject(TranslocoService);
|
||||
get allLibraries() { return this.libraryService.libraries(); }
|
||||
|
||||
private readonly loadSettingsEffect = effect(() => {
|
||||
const settings = this.appSettingsService.appSettings();
|
||||
if (settings) {
|
||||
this.loadSettings(settings);
|
||||
}
|
||||
});
|
||||
|
||||
loadSettings(settings: AppSettings): void {
|
||||
this.oidcEnabled = settings.oidcEnabled;
|
||||
|
||||
const details = settings.oidcAutoProvisionDetails;
|
||||
|
||||
this.autoUserProvisioningEnabled = details?.enableAutoProvisioning ?? false;
|
||||
this.allowLocalAccountLinking = details?.allowLocalAccountLinking ?? true;
|
||||
this.selectedPermissions = details?.defaultPermissions ?? [];
|
||||
this.editingLibraryIds = details?.defaultLibraryIds ?? [];
|
||||
|
||||
const defaultClaimMapping = {
|
||||
username: 'preferred_username',
|
||||
email: 'email',
|
||||
name: 'given_name',
|
||||
groups: ''
|
||||
};
|
||||
|
||||
this.sessionDurationHours = settings.oidcSessionDurationHours ?? null;
|
||||
this.groupSyncMode = settings.oidcGroupSyncMode ?? 'DISABLED';
|
||||
this.oidcForceOnlyMode = settings.oidcForceOnlyMode ?? false;
|
||||
|
||||
this.oidcProvider = {
|
||||
providerName: settings.oidcProviderDetails?.providerName || '',
|
||||
clientId: settings.oidcProviderDetails?.clientId || '',
|
||||
issuerUri: settings.oidcProviderDetails?.issuerUri || '',
|
||||
scopes: settings.oidcProviderDetails?.scopes || '',
|
||||
claimMapping: settings.oidcProviderDetails?.claimMapping || defaultClaimMapping
|
||||
};
|
||||
|
||||
this.availablePermissions.forEach(perm => {
|
||||
perm.selected = this.selectedPermissions.includes(perm.value);
|
||||
});
|
||||
|
||||
if (this.oidcEnabled) {
|
||||
this.loadGroupMappings();
|
||||
}
|
||||
}
|
||||
|
||||
isOidcFormComplete(): boolean {
|
||||
const p = this.oidcProvider;
|
||||
return !!(p.providerName && p.clientId && p.issuerUri && p.claimMapping.name && p.claimMapping.email && p.claimMapping.username);
|
||||
}
|
||||
|
||||
toggleOidcEnabled(): void {
|
||||
if (!this.isOidcFormComplete()) return;
|
||||
this.appSettingsService.toggleOidcEnabled(this.oidcEnabled).subscribe({
|
||||
next: () => this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsAuth.toast.saved'),
|
||||
detail: this.t.translate('settingsAuth.toast.oidcUpdated')
|
||||
}),
|
||||
error: () => this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsAuth.toast.oidcError')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
saveOidcProvider(): void {
|
||||
const payload: {key: AppSettingKey; newValue: unknown}[] = [
|
||||
{
|
||||
key: AppSettingKey.OIDC_PROVIDER_DETAILS,
|
||||
newValue: this.oidcProvider
|
||||
}
|
||||
];
|
||||
if (this.oidcEnabled) {
|
||||
payload.push({
|
||||
key: AppSettingKey.OIDC_SESSION_DURATION_HOURS,
|
||||
newValue: this.sessionDurationHours
|
||||
});
|
||||
}
|
||||
this.appSettingsService.saveSettings(payload).subscribe({
|
||||
next: () => this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsAuth.toast.saved'),
|
||||
detail: this.t.translate('settingsAuth.toast.providerSaved')
|
||||
}),
|
||||
error: () => this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsAuth.toast.providerError')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
copyBackchannelUri(): void {
|
||||
this.copyToClipboard(this.backchannelLogoutUri);
|
||||
}
|
||||
|
||||
copyToClipboard(value: string): void {
|
||||
navigator.clipboard.writeText(value).then(() => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsAuth.toast.saved'),
|
||||
detail: this.t.translate('settingsAuth.toast.copiedToClipboard')
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
saveSessionDuration(): void {
|
||||
const payload = [
|
||||
{
|
||||
key: AppSettingKey.OIDC_SESSION_DURATION_HOURS,
|
||||
newValue: this.sessionDurationHours
|
||||
}
|
||||
];
|
||||
this.appSettingsService.saveSettings(payload).subscribe({
|
||||
next: () => this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsAuth.toast.saved'),
|
||||
detail: this.t.translate('settingsAuth.toast.sessionDurationSaved')
|
||||
}),
|
||||
error: () => this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsAuth.toast.sessionDurationError')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
saveOidcAutoProvisionSettings(): void {
|
||||
const provisionDetails = {
|
||||
enableAutoProvisioning: this.autoUserProvisioningEnabled,
|
||||
allowLocalAccountLinking: this.allowLocalAccountLinking,
|
||||
defaultPermissions: [
|
||||
'permissionRead',
|
||||
...this.availablePermissions.filter(p => p.selected).map(p => p.value)
|
||||
],
|
||||
defaultLibraryIds: this.editingLibraryIds
|
||||
};
|
||||
|
||||
const payload = [
|
||||
{
|
||||
key: AppSettingKey.OIDC_AUTO_PROVISION_DETAILS,
|
||||
newValue: provisionDetails
|
||||
}
|
||||
];
|
||||
|
||||
this.appSettingsService.saveSettings(payload).subscribe({
|
||||
next: () => this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsAuth.toast.saved'),
|
||||
detail: this.t.translate('settingsAuth.toast.provisionSaved')
|
||||
}),
|
||||
error: () => this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsAuth.toast.provisionError')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// Group mapping methods
|
||||
loadGroupMappings(): void {
|
||||
this.groupMappingService.getAll().subscribe(mappings => this.groupMappings = mappings);
|
||||
}
|
||||
|
||||
saveGroupSyncMode(): void {
|
||||
const payload = [
|
||||
{
|
||||
key: AppSettingKey.OIDC_GROUP_SYNC_MODE,
|
||||
newValue: this.groupSyncMode
|
||||
}
|
||||
];
|
||||
this.appSettingsService.saveSettings(payload).subscribe({
|
||||
next: () => this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsAuth.toast.saved'),
|
||||
detail: this.t.translate('settingsAuth.toast.syncModeSaved')
|
||||
}),
|
||||
error: () => this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsAuth.toast.syncModeError')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
openNewGroupMapping(): void {
|
||||
this.editingGroupMapping = this.emptyGroupMapping();
|
||||
this.initGroupMappingPerms([]);
|
||||
this.editingGroupMappingLibraryIds = [];
|
||||
this.showGroupMappingDialog = true;
|
||||
}
|
||||
|
||||
openEditGroupMapping(mapping: OidcGroupMapping): void {
|
||||
this.editingGroupMapping = {...mapping};
|
||||
this.initGroupMappingPerms(mapping.permissions);
|
||||
this.editingGroupMappingLibraryIds = [...mapping.libraryIds];
|
||||
this.showGroupMappingDialog = true;
|
||||
}
|
||||
|
||||
private initGroupMappingPerms(selectedPerms: string[]): void {
|
||||
this.editingGroupMappingPerms = this.availablePermissions.map(p => ({
|
||||
...p,
|
||||
selected: selectedPerms.includes(p.value)
|
||||
}));
|
||||
}
|
||||
|
||||
saveGroupMapping(): void {
|
||||
const mapping: OidcGroupMapping = {
|
||||
...this.editingGroupMapping,
|
||||
permissions: [
|
||||
'permissionRead',
|
||||
...this.editingGroupMappingPerms.filter(p => p.selected).map(p => p.value)
|
||||
],
|
||||
libraryIds: this.editingGroupMappingLibraryIds
|
||||
};
|
||||
|
||||
const obs = mapping.id
|
||||
? this.groupMappingService.update(mapping.id, mapping)
|
||||
: this.groupMappingService.create(mapping);
|
||||
|
||||
obs.subscribe({
|
||||
next: () => {
|
||||
this.showGroupMappingDialog = false;
|
||||
this.loadGroupMappings();
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsAuth.toast.saved'),
|
||||
detail: this.t.translate('settingsAuth.toast.groupMappingSaved')
|
||||
});
|
||||
},
|
||||
error: () => this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsAuth.toast.groupMappingError')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
deleteGroupMapping(mapping: OidcGroupMapping): void {
|
||||
if (!mapping.id) return;
|
||||
this.groupMappingService.delete(mapping.id).subscribe({
|
||||
next: () => {
|
||||
this.loadGroupMappings();
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsAuth.toast.saved'),
|
||||
detail: this.t.translate('settingsAuth.toast.groupMappingDeleted')
|
||||
});
|
||||
},
|
||||
error: () => this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsAuth.toast.groupMappingError')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
getLibraryName(id: number): string {
|
||||
return this.allLibraries.find(l => l.id === id)?.name ?? `#${id}`;
|
||||
}
|
||||
|
||||
testConnection(): void {
|
||||
this.isTestingConnection = true;
|
||||
this.testConnectionResult = null;
|
||||
this.appSettingsService.testOidcConnection(this.oidcProvider).subscribe({
|
||||
next: (result) => {
|
||||
this.testConnectionResult = result;
|
||||
this.showTestDetails = true;
|
||||
this.isTestingConnection = false;
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsAuth.testConnection.error')
|
||||
});
|
||||
this.isTestingConnection = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toggleOidcForceOnlyMode(): void {
|
||||
const payload = [
|
||||
{
|
||||
key: AppSettingKey.OIDC_FORCE_ONLY_MODE,
|
||||
newValue: this.oidcForceOnlyMode
|
||||
}
|
||||
];
|
||||
this.appSettingsService.saveSettings(payload).subscribe({
|
||||
next: () => this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsAuth.toast.saved'),
|
||||
detail: this.t.translate('settingsAuth.oidcOnly.saved')
|
||||
}),
|
||||
error: (err) => {
|
||||
this.oidcForceOnlyMode = !this.oidcForceOnlyMode;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: err?.error?.message || this.t.translate('settingsAuth.oidcOnly.error')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private emptyGroupMapping(): OidcGroupMapping {
|
||||
return {oidcGroupClaim: '', isAdmin: false, permissions: [], libraryIds: [], description: ''};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<div class="oidc-callback-loading">
|
||||
<i class="pi pi-spin pi-spinner"></i>
|
||||
<span>{{ 'auth.oidc.signingIn' | transloco }}</span>
|
||||
</div>
|
||||
@@ -0,0 +1,18 @@
|
||||
.oidc-callback-loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
gap: 1rem;
|
||||
color: var(--text-color);
|
||||
background: var(--ground-background);
|
||||
|
||||
i {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {TranslocoPipe} from '@jsverse/transloco';
|
||||
import {OidcService} from '../oidc.service';
|
||||
import {AuthService} from '../../../shared/service/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-oidc-callback',
|
||||
templateUrl: './oidc-callback.component.html',
|
||||
styleUrls: ['./oidc-callback.component.scss'],
|
||||
imports: [TranslocoPipe]
|
||||
})
|
||||
export class OidcCallbackComponent implements OnInit {
|
||||
private router = inject(Router);
|
||||
private oidcService = inject(OidcService);
|
||||
private authService = inject(AuthService);
|
||||
|
||||
ngOnInit(): void {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
|
||||
const error = params.get('error');
|
||||
if (error) {
|
||||
const description = params.get('error_description') || error;
|
||||
console.error('[OIDC Callback] Provider returned error:', error, description);
|
||||
this.router.navigate(['/login'], {queryParams: {oidcError: description}});
|
||||
return;
|
||||
}
|
||||
|
||||
const code = params.get('code');
|
||||
const returnedState = params.get('state');
|
||||
|
||||
if (!code || !returnedState) {
|
||||
console.error('[OIDC Callback] Missing code or state');
|
||||
this.router.navigate(['/login'], {queryParams: {oidcError: 'missing_code'}});
|
||||
return;
|
||||
}
|
||||
|
||||
const pkceState = this.oidcService.retrievePkceState(returnedState);
|
||||
if (!pkceState) {
|
||||
console.error('[OIDC Callback] No PKCE state found for state parameter');
|
||||
this.router.navigate(['/login'], {queryParams: {oidcError: 'missing_pkce_state'}});
|
||||
return;
|
||||
}
|
||||
|
||||
if (returnedState !== pkceState.state) {
|
||||
console.error('[OIDC Callback] State mismatch');
|
||||
this.router.navigate(['/login'], {queryParams: {oidcError: 'state_mismatch'}});
|
||||
return;
|
||||
}
|
||||
|
||||
this.oidcService.exchangeCode(code, pkceState.codeVerifier, pkceState.nonce, pkceState.state).subscribe({
|
||||
next: (response) => {
|
||||
sessionStorage.removeItem('oidc_redirect_count');
|
||||
this.authService.saveInternalTokens(response.accessToken, response.refreshToken);
|
||||
this.authService.initializeWebSocketConnection();
|
||||
if (response.isDefaultPassword === 'true') {
|
||||
this.router.navigate(['/change-password']);
|
||||
} else {
|
||||
this.router.navigate(['/dashboard']);
|
||||
}
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('[OIDC Callback] Token exchange failed', err);
|
||||
const errorMsg = err.error?.message || 'exchange_failed';
|
||||
this.router.navigate(['/login'], {queryParams: {oidcError: errorMsg}});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {firstValueFrom, Observable} from 'rxjs';
|
||||
import {API_CONFIG} from '../config/api-config';
|
||||
import {AppSettingsService, PublicAppSettings} from '../../shared/service/app-settings.service';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
|
||||
interface OidcPkceState {
|
||||
codeVerifier: string;
|
||||
state: string;
|
||||
nonce: string;
|
||||
}
|
||||
|
||||
interface OidcTokenResponse {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
isDefaultPassword: string;
|
||||
}
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class OidcService {
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
|
||||
async generatePkce(): Promise<{codeVerifier: string; codeChallenge: string}> {
|
||||
const array = new Uint8Array(32);
|
||||
crypto.getRandomValues(array);
|
||||
const codeVerifier = this.base64UrlEncode(array);
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
const hash = await crypto.subtle.digest('SHA-256', encoder.encode(codeVerifier));
|
||||
const codeChallenge = this.base64UrlEncode(new Uint8Array(hash));
|
||||
|
||||
return {codeVerifier, codeChallenge};
|
||||
}
|
||||
|
||||
generateRandomString(): string {
|
||||
const array = new Uint8Array(32);
|
||||
crypto.getRandomValues(array);
|
||||
return this.base64UrlEncode(array);
|
||||
}
|
||||
|
||||
buildAuthUrl(
|
||||
issuerUri: string,
|
||||
clientId: string,
|
||||
codeChallenge: string,
|
||||
state: string,
|
||||
nonce: string,
|
||||
authorizationEndpoint?: string,
|
||||
scopes?: string
|
||||
): Promise<string> {
|
||||
const redirectUri = `${window.location.origin}/oauth2-callback`;
|
||||
const scope = scopes?.trim() || 'openid profile email groups offline_access';
|
||||
|
||||
if (authorizationEndpoint) {
|
||||
return Promise.resolve(this.buildUrl(authorizationEndpoint, clientId, redirectUri, scope, codeChallenge, state, nonce));
|
||||
}
|
||||
|
||||
// Fetch from discovery if authorization_endpoint not provided
|
||||
return fetch(`${issuerUri.replace(/\/+$/, '')}/.well-known/openid-configuration`)
|
||||
.then(res => res.json())
|
||||
.then(doc => {
|
||||
const endpoint = doc.authorization_endpoint;
|
||||
if (!endpoint) {
|
||||
throw new Error('authorization_endpoint not found in discovery document');
|
||||
}
|
||||
return this.buildUrl(endpoint, clientId, redirectUri, scope, codeChallenge, state, nonce);
|
||||
});
|
||||
}
|
||||
|
||||
async fetchState(): Promise<string> {
|
||||
const response = await firstValueFrom(
|
||||
this.http.get<{state: string}>(`${API_CONFIG.BASE_URL}/api/v1/auth/oidc/state`)
|
||||
);
|
||||
return response.state;
|
||||
}
|
||||
|
||||
exchangeCode(code: string, codeVerifier: string, nonce: string, state: string): Observable<OidcTokenResponse> {
|
||||
const redirectUri = `${window.location.origin}/oauth2-callback`;
|
||||
return this.http.post<OidcTokenResponse>(`${API_CONFIG.BASE_URL}/api/v1/auth/oidc/callback`, {
|
||||
code,
|
||||
codeVerifier,
|
||||
redirectUri,
|
||||
nonce,
|
||||
state
|
||||
});
|
||||
}
|
||||
|
||||
storePkceState(pkceState: OidcPkceState): void {
|
||||
sessionStorage.setItem(`oidc_pkce_${pkceState.state}`, JSON.stringify(pkceState));
|
||||
}
|
||||
|
||||
retrievePkceState(state: string): OidcPkceState | null {
|
||||
const key = `oidc_pkce_${state}`;
|
||||
const stored = sessionStorage.getItem(key);
|
||||
sessionStorage.removeItem(key);
|
||||
if (!stored) return null;
|
||||
try {
|
||||
return JSON.parse(stored);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private buildUrl(
|
||||
endpoint: string,
|
||||
clientId: string,
|
||||
redirectUri: string,
|
||||
scope: string,
|
||||
codeChallenge: string,
|
||||
state: string,
|
||||
nonce: string
|
||||
): string {
|
||||
const params = new URLSearchParams({
|
||||
response_type: 'code',
|
||||
client_id: clientId,
|
||||
redirect_uri: redirectUri,
|
||||
scope,
|
||||
code_challenge: codeChallenge,
|
||||
code_challenge_method: 'S256',
|
||||
state,
|
||||
nonce,
|
||||
});
|
||||
return `${endpoint}?${params.toString()}`;
|
||||
}
|
||||
|
||||
private base64UrlEncode(bytes: Uint8Array): string {
|
||||
let binary = '';
|
||||
for (const byte of bytes) {
|
||||
binary += String.fromCharCode(byte);
|
||||
}
|
||||
return btoa(binary)
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/\//g, '_')
|
||||
.replace(/=/g, '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Pipe({
|
||||
name: 'secure',
|
||||
pure: true
|
||||
})
|
||||
export class SecurePipe implements PipeTransform {
|
||||
constructor(private http: HttpClient, private sanitizer: DomSanitizer) {}
|
||||
|
||||
transform(url: string): Observable<SafeUrl> {
|
||||
return this.http.get(url, { responseType: 'blob' }).pipe(
|
||||
map(blob => this.sanitizer.bypassSecurityTrustUrl(URL.createObjectURL(blob)))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Directive, ElementRef, Input, OnChanges, OnDestroy, inject, SimpleChanges } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
@Directive({
|
||||
selector: '[appSecureSrc]',
|
||||
standalone: true
|
||||
})
|
||||
export class SecureSrcDirective implements OnChanges, OnDestroy {
|
||||
@Input('appSecureSrc') src!: string;
|
||||
|
||||
private currentUrl: string | null = null;
|
||||
private subscription: Subscription | null = null;
|
||||
|
||||
private el = inject(ElementRef);
|
||||
private http = inject(HttpClient);
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['src']) {
|
||||
this.loadImage();
|
||||
}
|
||||
}
|
||||
|
||||
private loadImage(): void {
|
||||
this.cleanup();
|
||||
|
||||
if (!this.src) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.subscription = this.http.get(this.src, { responseType: 'blob' }).subscribe({
|
||||
next: (blob) => {
|
||||
this.currentUrl = URL.createObjectURL(blob);
|
||||
this.el.nativeElement.src = this.currentUrl;
|
||||
},
|
||||
error: (err) => {
|
||||
// Only log non-CORS errors to avoid console spam
|
||||
// CORS errors are expected in development and will be resolved by backend CORS config
|
||||
if (err.status !== 0 && err.status !== 403) {
|
||||
console.error('Error loading secure image:', err);
|
||||
}
|
||||
// Set a fallback placeholder image if available
|
||||
const fallbackSrc = this.el.nativeElement.getAttribute('data-fallback-src') || 'assets/images/missing-cover.jpg';
|
||||
this.el.nativeElement.src = fallbackSrc;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private cleanup(): void {
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
this.subscription = null;
|
||||
}
|
||||
if (this.currentUrl) {
|
||||
URL.revokeObjectURL(this.currentUrl);
|
||||
this.currentUrl = null;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.cleanup();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LoadingService {
|
||||
private activeLoaders: HTMLElement[] = [];
|
||||
|
||||
show(message: string = 'Loading...'): HTMLElement {
|
||||
const loader = document.createElement('div');
|
||||
loader.className = 'fullscreen-loader';
|
||||
loader.innerHTML = `
|
||||
<div class="loader-content">
|
||||
<i class="pi pi-spin pi-spinner" style="font-size: 3rem; color: var(--primary-color);"></i>
|
||||
<p style="margin-top: 1rem; color: var(--text-color);">${message}</p>
|
||||
</div>
|
||||
`;
|
||||
loader.style.cssText = `
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
backdrop-filter: blur(4px);
|
||||
`;
|
||||
|
||||
const content = loader.querySelector('.loader-content') as HTMLElement;
|
||||
if (content) {
|
||||
content.style.cssText = `
|
||||
text-align: center;
|
||||
background: var(--surface-card);
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||
`;
|
||||
}
|
||||
|
||||
document.body.appendChild(loader);
|
||||
document.body.style.cursor = 'wait';
|
||||
this.activeLoaders.push(loader);
|
||||
|
||||
return loader;
|
||||
}
|
||||
|
||||
hide(loader: HTMLElement): void {
|
||||
if (loader && loader.parentNode) {
|
||||
loader.parentNode.removeChild(loader);
|
||||
|
||||
const index = this.activeLoaders.indexOf(loader);
|
||||
if (index > -1) {
|
||||
this.activeLoaders.splice(index, 1);
|
||||
}
|
||||
|
||||
if (this.activeLoaders.length === 0) {
|
||||
document.body.style.cursor = 'default';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hideAll(): void {
|
||||
this.activeLoaders.forEach(loader => {
|
||||
if (loader && loader.parentNode) {
|
||||
loader.parentNode.removeChild(loader);
|
||||
}
|
||||
});
|
||||
this.activeLoaders = [];
|
||||
document.body.style.cursor = 'default';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable, of} from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PostLoginInitializerService {
|
||||
|
||||
initialize(): Observable<void> {
|
||||
return of(undefined);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import {TranslocoTestingModule, TranslocoTestingOptions} from '@jsverse/transloco';
|
||||
import {EN_TRANSLATIONS} from '../config/transloco-loader';
|
||||
|
||||
export function getTranslocoModule(options: TranslocoTestingOptions = {}) {
|
||||
return TranslocoTestingModule.forRoot({
|
||||
langs: {en: EN_TRANSLATIONS, ...options.langs},
|
||||
translocoConfig: {
|
||||
availableLangs: ['en'],
|
||||
defaultLang: 'en',
|
||||
...options.translocoConfig,
|
||||
},
|
||||
...options,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user