Files
zitadel/console/src/app/services/navigation.service.ts
T
08ae39ae19 feat: rehauled console (#3525)
* new console

* move npm ci to angular build

* rel path for assets

* local grpc copy

* login policy, rm clear views, features rel path

* lock

Co-authored-by: Livio Amstutz <[email protected]>
2022-04-28 10:35:02 +00:00

33 lines
764 B
TypeScript

import { Location } from '@angular/common';
import { Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
@Injectable({
providedIn: 'root',
})
export class NavigationService {
private history: string[] = [];
constructor(private router: Router, private location: Location) {
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.history.push(event.urlAfterRedirects);
}
});
}
public back(): void {
if (this.isBackPossible) {
this.location.back();
this.history.pop();
} else {
this.router.navigateByUrl('/');
this.history.pop();
}
}
public get isBackPossible(): boolean {
return this.history.length > 1;
}
}