Update menu when server is selected #72
This commit is contained in:
@@ -8,6 +8,7 @@ import { ServerDTO } from 'src/app/models/discord/server.dto';
|
||||
import { ServerSelectCriterion } from 'src/app/models/selection/server/server-select-criterion.dto';
|
||||
import { ConfirmationDialogService } from 'src/app/services/confirmation-dialog/confirmation-dialog.service';
|
||||
import { DataService } from 'src/app/services/data/data.service';
|
||||
import { ServerService } from 'src/app/services/data/server.service';
|
||||
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
||||
import { ToastService } from 'src/app/services/toast/toast.service';
|
||||
|
||||
@@ -41,7 +42,8 @@ export class DashboardComponent implements OnInit {
|
||||
private confirmDialog: ConfirmationDialogService,
|
||||
private fb: FormBuilder,
|
||||
private translate: TranslateService,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
private serverService: ServerService
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -106,7 +108,8 @@ export class DashboardComponent implements OnInit {
|
||||
}
|
||||
|
||||
selectServer(server: ServerDTO) {
|
||||
this.router.navigate(['/server', server.serverId]);
|
||||
this.serverService.server$.next(server);
|
||||
this.router.navigate(['/server']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { catchError, throwError } from 'rxjs';
|
||||
import { ServerDTO } from 'src/app/models/discord/server.dto';
|
||||
import { DataService } from 'src/app/services/data/data.service';
|
||||
import { ServerService } from 'src/app/services/data/server.service';
|
||||
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
||||
|
||||
@Component({
|
||||
@@ -19,27 +19,20 @@ export class ServerDashboardComponent implements OnInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private data: DataService,
|
||||
private spinner: SpinnerService
|
||||
private spinner: SpinnerService,
|
||||
private serverService: ServerService
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.params.subscribe(params => {
|
||||
this.id = +params['id'];
|
||||
this.spinner.showSpinner();
|
||||
if (!this.serverService.server$.value) {
|
||||
this.spinner.hideSpinner();
|
||||
this.router.navigate(['/dashboard']);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.id) {
|
||||
this.router.navigate(['/dashboard']);
|
||||
return;
|
||||
}
|
||||
|
||||
this.spinner.showSpinner();
|
||||
this.data.getServerByID(this.id).pipe(catchError(err => {
|
||||
this.spinner.hideSpinner();
|
||||
return throwError(() => err);
|
||||
})).subscribe(server => {
|
||||
this.server = server;
|
||||
this.spinner.hideSpinner();
|
||||
});
|
||||
});
|
||||
this.server = this.serverService.server$.value;
|
||||
this.spinner.hideSpinner();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,8 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
|
||||
import { ServerDashboardComponent } from './server-dashboard/server-dashboard.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: ServerDashboardComponent },
|
||||
{ path: ':id', component: ServerDashboardComponent }
|
||||
{ path: '', component: ServerDashboardComponent }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
Reference in New Issue
Block a user