Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions webapp/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { NavbarComponent } from './components/navbar/navbar.component';
import { RouterOutlet } from '@angular/router';
import { RouterOutlet, ActivatedRoute } from '@angular/router';
import { PubsubService } from './services/pubsub.service';

@Component({
selector: 'app-root',
Expand All @@ -9,6 +10,17 @@ import { RouterOutlet } from '@angular/router';
standalone: true,
imports: [NavbarComponent, RouterOutlet]
})
export class AppComponent {
export class AppComponent implements OnInit {
title = 'webapp';
private route = inject(ActivatedRoute);
private pubsub = inject(PubsubService);

ngOnInit(): void {
this.route.queryParamMap.subscribe(params => {
const host = params.get('host');
if (host) {
this.pubsub.setHost(host);
}
});
}
}
8 changes: 7 additions & 1 deletion webapp/src/app/components/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PubsubService } from 'src/app/services/pubsub.service';
import { InputDialogComponent } from '../input-dialog/input-dialog.component';
import { MatToolbar } from '@angular/material/toolbar';
import { MatIconButton } from '@angular/material/button';
import { RouterLink } from '@angular/router';
import { RouterLink, Router } from '@angular/router';
import { MatIcon } from '@angular/material/icon';
import { AsyncPipe } from '@angular/common';

Expand All @@ -19,6 +19,7 @@ import { AsyncPipe } from '@angular/common';
export class NavbarComponent implements OnInit {
private pubsub = inject(PubsubService);
private dialog = inject(MatDialog);
private router = inject(Router);


currentHost: Observable<string>
Expand All @@ -36,6 +37,11 @@ export class NavbarComponent implements OnInit {
ref.afterClosed().pipe(filter(result => !!result))
.subscribe((result: { user_input: string }) => {
this.pubsub.setHost(result.user_input)

this.router.navigate([], {
queryParams: { host: result.user_input },
queryParamsHandling: 'merge'
});
})
}

Expand Down