Merge pull request 'ts-82-author-overview-and-description' (#120) from ts-82-author-overview-and-description into dev
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
Reviewed-on: #120
This commit was merged in pull request #120.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { Injectable, signal, inject, computed } from '@angular/core';
|
||||
import { Router, RouterEvent, ActivatedRoute } from '@angular/router';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { ResolveEnd, ResolveStart } from '@angular/router';
|
||||
import {
|
||||
NavigationEnd,
|
||||
NavigationError,
|
||||
NavigationCancel,
|
||||
} from '@angular/router';
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ResolverStateService {
|
||||
private readonly router = inject(Router);
|
||||
|
||||
readonly resolvingUrl = signal<string | null>(null);
|
||||
readonly previousUrl = signal<string | null>(null);
|
||||
|
||||
readonly isResolving = computed(() => this.resolvingUrl() !== null);
|
||||
readonly isResolvingPersonsFromOutside = computed(() => {
|
||||
const from = this.previousUrl();
|
||||
const to = this.resolvingUrl();
|
||||
if (!to?.startsWith('/persons')) return false;
|
||||
return !from?.startsWith('/persons'); // came from outside
|
||||
});
|
||||
|
||||
constructor() {
|
||||
this.router.events.subscribe(event => {
|
||||
if (event instanceof ResolveStart) {
|
||||
this.previousUrl.set(this.router.url); // capture current before it changes
|
||||
this.resolvingUrl.set(event.url);
|
||||
}
|
||||
|
||||
if (
|
||||
event instanceof NavigationEnd ||
|
||||
event instanceof NavigationCancel ||
|
||||
event instanceof NavigationError
|
||||
) {
|
||||
this.resolvingUrl.set(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,12 @@
|
||||
</mat-toolbar>
|
||||
|
||||
<main class="content">
|
||||
<ng-content></ng-content>
|
||||
@if (resolverState.isResolvingPersonsFromOutside()) {
|
||||
<app-loading text="Personenliste wird geladen..." icon="group" size="200" diameter="200" ></app-loading>
|
||||
} @else {
|
||||
<ng-content></ng-content>
|
||||
}
|
||||
|
||||
</main>
|
||||
</mat-drawer-content>
|
||||
</mat-drawer-container>
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
ViewChild,
|
||||
inject
|
||||
} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
@@ -17,10 +18,11 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { CredentialService } from '../../services/credential.service';
|
||||
import { Location } from '@angular/common';
|
||||
import { AppSearchbarComponent } from "../app-searchbar/app-searchbar.component";
|
||||
|
||||
import { ResolverStateService } from '../../services/resolver-state.service';
|
||||
import { LoadingComponent } from "../loading/loading.component";
|
||||
@Component({
|
||||
selector: 'app-layout',
|
||||
imports: [CommonModule, MatToolbarModule, MatSidenavModule, MatButtonModule, MatIconModule, AppMenuComponent, MatTooltipModule, AppSearchbarComponent],
|
||||
imports: [CommonModule, MatToolbarModule, MatSidenavModule, MatButtonModule, MatIconModule, AppMenuComponent, MatTooltipModule, AppSearchbarComponent, LoadingComponent],
|
||||
templateUrl: './app-layout.component.html',
|
||||
styleUrl: './app-layout.component.scss',
|
||||
standalone: true,
|
||||
@@ -30,7 +32,7 @@ export class AppLayoutComponent implements OnInit, OnDestroy {
|
||||
drawer?: MatDrawer;
|
||||
|
||||
mediaQuery: MediaQueryList;
|
||||
|
||||
protected resolverState = inject(ResolverStateService)
|
||||
mediaQueryListener: () => void;
|
||||
|
||||
sideNavOpen = false;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<div class="loading-container">
|
||||
<div class="spinner-container" style="--spinner-size: {{size}}px">
|
||||
<mat-progress-spinner diameter={{diameter}}></mat-progress-spinner>
|
||||
<mat-icon class="spinner-icon" fontSet="material-symbols-outlined">
|
||||
{{icon}}
|
||||
</mat-icon>
|
||||
</div>
|
||||
<span>{{text}}</span>
|
||||
</div>
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
.loading-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 48px 0;
|
||||
}
|
||||
|
||||
.spinner-container {
|
||||
--spinner-size: 60px;
|
||||
|
||||
position: relative;
|
||||
width: var(--spinner-size);
|
||||
height: var(--spinner-size);
|
||||
}
|
||||
|
||||
.spinner-icon {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
margin: auto;
|
||||
|
||||
font-size: calc(var(--spinner-size) * 0.4);
|
||||
width: calc(var(--spinner-size) * 0.4);
|
||||
height: calc(var(--spinner-size) * 0.4);
|
||||
|
||||
animation: pulse 1.2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(1.2);
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Component,Input } from '@angular/core';
|
||||
import { MatProgressSpinner } from '@angular/material/progress-spinner';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
@Component({
|
||||
selector: 'app-loading',
|
||||
imports: [MatProgressSpinner,MatIcon],
|
||||
templateUrl: './loading.component.html',
|
||||
styleUrl: './loading.component.scss',
|
||||
})
|
||||
export class LoadingComponent {
|
||||
@Input() text = "Laden..."
|
||||
@Input() icon = "graph_3";
|
||||
@Input() size = "150";
|
||||
@Input() diameter = "150";
|
||||
}
|
||||
Reference in New Issue
Block a user