From b93e27b46fa8fa87b039c2545a094a69784929ad Mon Sep 17 00:00:00 2001 From: Alexandre Pion Date: Mon, 25 Jul 2022 11:12:30 +0200 Subject: [PATCH 01/11] Deprecate "/domain_check" route New route "/check" Redirect "/domain_check" to "/check" --- src/app/app.module.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 48cee7c3..c9e88336 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -48,15 +48,15 @@ class MyTranslationLoader extends TranslateLoader { } const appRoutes: Routes = [ - { path: 'domain_check', component: DomainComponent }, + { path: 'check', component: DomainComponent }, { path: 'result/:resultID', component: ResultComponent }, { path: 'test/:resultID', component: ResultComponent }, { path: 'history', component: HistoryComponent }, { path: 'faq', component: FaqComponent }, - { path: '', - redirectTo: 'domain_check', - pathMatch: 'full' - }, + + { path: 'domain_check', redirectTo: 'check', pathMatch: 'full' }, + { path: '', redirectTo: 'check', pathMatch: 'full' }, + { path: '**', component: PageNotFoundComponent } ]; From 8a5b8df4eca0ea2166ca9cf05a72f0ffff2efb76 Mon Sep 17 00:00:00 2001 From: Alexandre Pion Date: Mon, 25 Jul 2022 11:09:56 +0200 Subject: [PATCH 02/11] Use route redirection for "/test/" Redirect to "/result/" --- src/app/app.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c9e88336..5fe9f969 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -50,11 +50,11 @@ class MyTranslationLoader extends TranslateLoader { const appRoutes: Routes = [ { path: 'check', component: DomainComponent }, { path: 'result/:resultID', component: ResultComponent }, - { path: 'test/:resultID', component: ResultComponent }, { path: 'history', component: HistoryComponent }, { path: 'faq', component: FaqComponent }, { path: 'domain_check', redirectTo: 'check', pathMatch: 'full' }, + { path: 'test/:resultID', redirectTo: 'result/:resultID', pathMatch: 'full' }, { path: '', redirectTo: 'check', pathMatch: 'full' }, { path: '**', component: PageNotFoundComponent } From 9a55f7941be27e26f948e9600d656c03d98111c7 Mon Sep 17 00:00:00 2001 From: Alexandre Pion Date: Mon, 18 Jul 2022 20:45:27 +0200 Subject: [PATCH 03/11] Fetch domain name from URL route parameter --- src/app/app.module.ts | 1 + src/app/components/form/form.component.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5fe9f969..38dfa790 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -48,6 +48,7 @@ class MyTranslationLoader extends TranslateLoader { } const appRoutes: Routes = [ + { path: 'check/:domain', component: DomainComponent }, { path: 'check', component: DomainComponent }, { path: 'result/:resultID', component: ResultComponent }, { path: 'history', component: HistoryComponent }, diff --git a/src/app/components/form/form.component.ts b/src/app/components/form/form.component.ts index 44842877..dec44234 100644 --- a/src/app/components/form/form.component.ts +++ b/src/app/components/form/form.component.ts @@ -7,6 +7,7 @@ import { Validators, AbstractControl} from '@angular/forms'; import { Title } from '@angular/platform-browser'; +import { ActivatedRoute, Params, Router } from '@angular/router'; import { LangChangeEvent, TranslateService } from '@ngx-translate/core'; import { Subscription } from 'rxjs'; @@ -51,14 +52,27 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { private _showProgressBar: boolean; private langChangeSubscription: Subscription; + private domainName: string; + private routeParamsSubscription: Subscription; + public history = {}; public test = {}; public disable_check_button = false; public form: FormGroup; - constructor(private formBuilder: FormBuilder, private translateService: TranslateService, private titleService: Title) {} + constructor(private activatedRoute: ActivatedRoute, + private formBuilder: FormBuilder, + private translateService: TranslateService, + private titleService: Title) {} ngOnInit() { + this.routeParamsSubscription = this.activatedRoute.params.subscribe((params: Params) => { + if ( params['domain'] ) { + this.domainName = params['domain']; + console.log(this.domainName); + } + }); + this.langChangeSubscription = this.translateService.onLangChange.subscribe((_: LangChangeEvent) => { if (this.form.touched) { this.runDomainCheck(false); @@ -76,6 +90,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ngOnDestroy() { this.langChangeSubscription.unsubscribe(); + if ( this.routeParamsSubscription ) { + this.routeParamsSubscription.unsubscribe(); + } } private static atLeastOneProtocolValidator(control: AbstractControl) { From a4c5a5fd79f82365ce6c224a09173f17bbcec7bb Mon Sep 17 00:00:00 2001 From: Alexandre Pion Date: Mon, 18 Jul 2022 20:47:29 +0200 Subject: [PATCH 04/11] Populate form input with domain from URL --- src/app/components/form/form.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/form/form.component.ts b/src/app/components/form/form.component.ts index dec44234..c29f412e 100644 --- a/src/app/components/form/form.component.ts +++ b/src/app/components/form/form.component.ts @@ -52,7 +52,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { private _showProgressBar: boolean; private langChangeSubscription: Subscription; - private domainName: string; + private domainName: string = ''; private routeParamsSubscription: Subscription; public history = {}; @@ -141,7 +141,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { public generate_form() { this.form = new FormGroup({ - domain: new FormControl('', Validators.required), + domain: new FormControl(this.domainName, Validators.required), disable_ipv4: new FormControl(false), disable_ipv6: new FormControl(false), profile: new FormControl(this.profiles[0] || 'default'), From f296c3668553b5a10e02acf5812fa30ab3069df3 Mon Sep 17 00:00:00 2001 From: Alexandre Pion Date: Mon, 18 Jul 2022 21:12:44 +0200 Subject: [PATCH 05/11] Automatically run the test if a domain is provided --- src/app/components/form/form.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/components/form/form.component.ts b/src/app/components/form/form.component.ts index c29f412e..98f8dd55 100644 --- a/src/app/components/form/form.component.ts +++ b/src/app/components/form/form.component.ts @@ -69,7 +69,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { this.routeParamsSubscription = this.activatedRoute.params.subscribe((params: Params) => { if ( params['domain'] ) { this.domainName = params['domain']; - console.log(this.domainName); } }); @@ -78,8 +77,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { this.runDomainCheck(false); } }); + this.generate_form(); this.titleService.setTitle('Zonemaster'); + + if ( this.domainName ) { + this.runDomainCheck(); + } } ngOnChanges(changes: { [property: string]: SimpleChange }) { From cc67b607b57bde5de3ea2ee4d0d3c7978c5eb039 Mon Sep 17 00:00:00 2001 From: Alexandre Pion Date: Mon, 25 Jul 2022 11:48:59 +0200 Subject: [PATCH 06/11] Update href to new /check path --- src/app/components/navigation/navigation.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/navigation/navigation.component.html b/src/app/components/navigation/navigation.component.html index 42e304f8..c61ffcb5 100644 --- a/src/app/components/navigation/navigation.component.html +++ b/src/app/components/navigation/navigation.component.html @@ -14,7 +14,7 @@