control back button

This commit is contained in:
_Bastler
2021-09-08 11:09:26 +02:00
parent 258f253a14
commit 885c95e63b
3 changed files with 49 additions and 49 deletions
@@ -1,40 +1,40 @@
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import {environment} from '../../../environments/environment';
import { environment } from '../../../environments/environment';
@Component({
selector: 'app-form-login',
templateUrl: './form-login.component.html',
styleUrls: ['./form-login.component.scss']
styleUrls: [ './form-login.component.scss' ]
})
export class FormLoginComponent implements OnInit {
@ViewChild('loginForm') loginForm: ElementRef;
loginInvalid: boolean;
apiUrl = environment.apiUrl;
targetRoute : string;
targetRoute: string;
constructor(
private router: Router,
private route: ActivatedRoute) {}
private route: ActivatedRoute) { }
async ngOnInit() {
this.route.queryParams.subscribe(params => {
if(params['target']) {
this.targetRoute = params['target'];
this.router.navigate([], {queryParams: {target: null}, queryParamsHandling: 'merge'});
if (params[ 'target' ]) {
this.targetRoute = params[ 'target' ];
this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge', replaceUrl: true });
}
if(params['error'] || params['error'] == '') {
if (params[ 'error' ] || params[ 'error' ] == '') {
this.loginInvalid = true;
this.router.navigate([], {queryParams: {error: null}, queryParamsHandling: 'merge'});
this.router.navigate([], { queryParams: { error: null }, queryParamsHandling: 'merge', replaceUrl: true });
}
});
}
ngAfterViewInit(): void {
if(this.targetRoute) {
if (this.targetRoute) {
this.loginForm.nativeElement.action = this.loginForm.nativeElement.action + "?forward=" + window.location.origin + this.targetRoute;
}
}
@@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {Location} from '@angular/common'
import {Router, ActivatedRoute} from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common'
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-unavailable',
@@ -13,23 +13,23 @@ export class UnavailableComponent implements OnInit {
constructor(
private location: Location,
private router: Router,
private route: ActivatedRoute) {}
private route: ActivatedRoute) { }
ngOnInit(): void {
this.route.queryParams.subscribe(params => {
if(params['target']) {
this.targetRoute = params['target'];
this.router.navigate([], {queryParams: {target: null}, queryParamsHandling: 'merge'});
if (params[ 'target' ]) {
this.targetRoute = params[ 'target' ];
this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge', skipLocationChange: true });
}
});
}
retry() {
if(!this.targetRoute || this.targetRoute === "unavailable" || this.targetRoute === "/unavailable") {
if (!this.targetRoute || this.targetRoute === "unavailable" || this.targetRoute === "/unavailable") {
this.location.back;
} else {
this.router.navigate([this.targetRoute]);
this.router.navigate([ this.targetRoute ], { skipLocationChange: true });
}
}