home page
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
|
||||
import { Component, OnInit, OnDestroy, signal, ApplicationRef } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterOutlet } from '@angular/router';
|
||||
import { Router, RouterOutlet, NavigationEnd } from '@angular/router';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { HeaderComponent } from './components/header/header.component';
|
||||
import { FooterComponent } from './components/footer/footer.component';
|
||||
import { BackButtonComponent } from './components/back-button/back-button.component';
|
||||
import { ApiService } from './services';
|
||||
import { Subscription, interval, concat } from 'rxjs';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { filter, first } from 'rxjs/operators';
|
||||
import { environment } from '../environments/environment';
|
||||
import { SwUpdate } from '@angular/service-worker';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
imports: [RouterOutlet, HeaderComponent, FooterComponent, CommonModule],
|
||||
imports: [RouterOutlet, HeaderComponent, FooterComponent, BackButtonComponent, CommonModule],
|
||||
templateUrl: './app.html',
|
||||
styleUrl: './app.scss'
|
||||
})
|
||||
@@ -21,14 +22,17 @@ export class App implements OnInit, OnDestroy {
|
||||
protected title = environment.brandName;
|
||||
serverAvailable = signal(true);
|
||||
checkingServer = signal(true);
|
||||
isHomePage = signal(true);
|
||||
private pingSubscription?: Subscription;
|
||||
private updateSubscription?: Subscription;
|
||||
private routerSubscription?: Subscription;
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private titleService: Title,
|
||||
private swUpdate: SwUpdate,
|
||||
private appRef: ApplicationRef
|
||||
private appRef: ApplicationRef,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -36,6 +40,14 @@ export class App implements OnInit, OnDestroy {
|
||||
this.titleService.setTitle(`${environment.brandFullName} - Маркетплейс товаров и услуг`);
|
||||
this.checkServerHealth();
|
||||
this.setupAutoUpdates();
|
||||
|
||||
// Track route changes to show/hide back button
|
||||
this.routerSubscription = this.router.events
|
||||
.pipe(filter(event => event instanceof NavigationEnd))
|
||||
.subscribe((event) => {
|
||||
const url = (event as NavigationEnd).urlAfterRedirects || (event as NavigationEnd).url;
|
||||
this.isHomePage.set(url === '/' || url === '/home' || url === '');
|
||||
});
|
||||
}
|
||||
|
||||
checkServerHealth(): void {
|
||||
@@ -84,6 +96,7 @@ export class App implements OnInit, OnDestroy {
|
||||
ngOnDestroy(): void {
|
||||
this.pingSubscription?.unsubscribe();
|
||||
this.updateSubscription?.unsubscribe();
|
||||
this.routerSubscription?.unsubscribe();
|
||||
}
|
||||
|
||||
retryConnection(): void {
|
||||
|
||||
Reference in New Issue
Block a user