mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Kamera öffnet sich nur wenn man Online ist
This commit is contained in:
@@ -9,12 +9,20 @@ import { Config } from '@core/config';
|
||||
import { ComponentPortal } from '@angular/cdk/portal';
|
||||
import { ScanditOverlayComponent } from './scandit-overlay.component';
|
||||
import { EnvironmentService } from '@core/environment';
|
||||
import { injectNetworkStatus$ } from 'apps/isa-app/src/app/services/network-status.service';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Injectable()
|
||||
export class ScanditScanAdapter implements ScanAdapter {
|
||||
readonly name = 'Scandit';
|
||||
|
||||
constructor(private readonly _config: Config, private _overlay: Overlay, private _environmentService: EnvironmentService) {}
|
||||
private $networkStatus = toSignal(injectNetworkStatus$());
|
||||
|
||||
constructor(
|
||||
private readonly _config: Config,
|
||||
private _overlay: Overlay,
|
||||
private _environmentService: EnvironmentService,
|
||||
) {}
|
||||
|
||||
async init(): Promise<boolean> {
|
||||
if (this._environmentService.isTablet()) {
|
||||
@@ -30,6 +38,11 @@ export class ScanditScanAdapter implements ScanAdapter {
|
||||
|
||||
scan(): Observable<string> {
|
||||
return new Observable((observer) => {
|
||||
if (this.$networkStatus() === 'offline') {
|
||||
observer.error(new Error('No network connection'));
|
||||
return;
|
||||
}
|
||||
|
||||
const overlay = this.createOverlay();
|
||||
|
||||
const portal = this.createPortal();
|
||||
@@ -49,7 +62,7 @@ export class ScanditScanAdapter implements ScanAdapter {
|
||||
sub.add(
|
||||
overlay.backdropClick().subscribe(() => {
|
||||
complete();
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
ref.instance.onScan((code) => {
|
||||
|
||||
@@ -17,7 +17,10 @@ export class AuthService {
|
||||
|
||||
private _authConfig: AuthConfig;
|
||||
|
||||
constructor(private _config: Config, private readonly _oAuthService: OAuthService) {
|
||||
constructor(
|
||||
private _config: Config,
|
||||
private readonly _oAuthService: OAuthService,
|
||||
) {
|
||||
this._oAuthService.events?.subscribe((event) => {
|
||||
if (event.type === 'token_received') {
|
||||
console.log('SSO Token Expiration:', new Date(this._oAuthService.getAccessTokenExpiration()));
|
||||
@@ -45,6 +48,8 @@ export class AuthService {
|
||||
await this._oAuthService.loadDiscoveryDocumentAndTryLogin();
|
||||
} catch (error) {
|
||||
this.login();
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
this._initialized.next(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { AuthService } from '@core/auth';
|
||||
import { ScanAdapterService } from '@adapter/scan';
|
||||
import { AuthService as IsaAuthService } from '@swagger/isa';
|
||||
@@ -9,11 +9,12 @@ import { EnvironmentService } from '@core/environment';
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class IsAuthenticatedGuard {
|
||||
constructor(
|
||||
private _router: Router,
|
||||
private _authService: AuthService,
|
||||
private _scanService: ScanAdapterService,
|
||||
private _isaAuthService: IsaAuthService,
|
||||
private _modal: UiModalService,
|
||||
private _environmentService: EnvironmentService
|
||||
private _environmentService: EnvironmentService,
|
||||
) {}
|
||||
|
||||
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
|
||||
Reference in New Issue
Block a user