Mitglieder auf einem Server anzeigen #130 #206
@ -1,14 +1,21 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { PrimeNGConfig } from 'primeng/api';
|
||||
import { AuthService } from './services/auth/auth.service';
|
||||
import { SocketService } from './services/socket/socket.service';
|
||||
import { ThemeService } from './services/theme/theme.service';
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { PrimeNGConfig } from "primeng/api";
|
||||
import { AuthService } from "./services/auth/auth.service";
|
||||
import { SocketService } from "./services/socket/socket.service";
|
||||
import { ThemeService } from "./services/theme/theme.service";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { SpinnerService } from "./services/spinner/spinner.service";
|
||||
import { DataService } from "./services/data/data.service";
|
||||
import { SidebarService } from "./services/sidebar/sidebar.service";
|
||||
import { Server } from "./models/data/server.model";
|
||||
import { Queries } from "./models/graphql/queries.model";
|
||||
import { Query } from "./models/graphql/query.model";
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.scss']
|
||||
selector: "app-root",
|
||||
templateUrl: "./app.component.html",
|
||||
styleUrls: ["./app.component.scss"]
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
|
||||
@ -22,7 +29,7 @@ export class AppComponent implements OnInit {
|
||||
private themeService: ThemeService,
|
||||
private socket: SocketService,
|
||||
private translateService: TranslateService,
|
||||
private config: PrimeNGConfig
|
||||
private config: PrimeNGConfig,
|
||||
) {
|
||||
this.themeService.sidebarWidth$.subscribe(value => {
|
||||
this.sidebarWidth = value;
|
||||
@ -36,7 +43,7 @@ export class AppComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.translateService.setDefaultLang('en');
|
||||
this.translateService.setDefaultLang("en");
|
||||
|
||||
this.themeService.loadTheme();
|
||||
this.socket.startSocket();
|
||||
@ -45,7 +52,7 @@ export class AppComponent implements OnInit {
|
||||
loadLang(): void {
|
||||
let lang = localStorage.getItem(`default_lang`);
|
||||
if (!lang) {
|
||||
lang = 'en';
|
||||
lang = "en";
|
||||
this.setLang(lang);
|
||||
}
|
||||
this.translate(lang);
|
||||
@ -57,7 +64,7 @@ export class AppComponent implements OnInit {
|
||||
|
||||
translate(lang: string) {
|
||||
this.translateService.use(lang);
|
||||
this.translateService.get('primeng').subscribe(res => this.config.setTranslation(res));
|
||||
this.translateService.get("primeng").subscribe(res => this.config.setTranslation(res));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,10 +1,45 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Server } from "../../../../models/data/server.model";
|
||||
import { Queries } from "../../../../models/graphql/queries.model";
|
||||
import { Query } from "../../../../models/graphql/query.model";
|
||||
import { SpinnerService } from "../../../../services/spinner/spinner.service";
|
||||
import { DataService } from "../../../../services/data/data.service";
|
||||
import { SidebarService } from "../../../../services/sidebar/sidebar.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-profile',
|
||||
templateUrl: './profile.component.html',
|
||||
styleUrls: ['./profile.component.scss']
|
||||
selector: "app-profile",
|
||||
templateUrl: "./profile.component.html",
|
||||
styleUrls: ["./profile.component.scss"]
|
||||
})
|
||||
export class ProfileComponent {
|
||||
export class ProfileComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private spinner: SpinnerService,
|
||||
private data: DataService,
|
||||
private sidebar: SidebarService
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.spinner.showSpinner();
|
||||
if (!this.route.snapshot.params["serverId"]) {
|
||||
this.spinner.hideSpinner();
|
||||
this.router.navigate(['/dashboard']);
|
||||
return;
|
||||
}
|
||||
|
||||
this.data.query<Server>(Queries.serversQuery, {
|
||||
filter: { id: this.route.snapshot.params["serverId"] }
|
||||
},
|
||||
function(data: Query) {
|
||||
return data.servers.length > 0 ? data.servers[0] : null;
|
||||
}
|
||||
).subscribe(server => {
|
||||
this.sidebar.server$.next(server);
|
||||
this.spinner.hideSpinner();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ export class SidebarService {
|
||||
if (!(event instanceof NavigationEnd)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.url.startsWith('/server/')) {
|
||||
this.server$.next(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user