diff --git a/angular.json b/angular.json index f5cceaf..035e55d 100644 --- a/angular.json +++ b/angular.json @@ -47,13 +47,7 @@ "maximumError": "8kB" } ], - "outputHashing": "all", - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" - } - ] + "outputHashing": "all" }, "development": { "optimization": false, diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 32f15d7..0fc0674 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -4,6 +4,7 @@ import { AuthGuard } from './auth.guard'; import { Login } from './login/login'; export const routes: Routes = [ - { path: "home", component: Home, canActivate: [AuthGuard] }, - { path: "login", component: Login } + { path: "home", component: Home, canActivate: [AuthGuard], title: "MCSC | Home" }, + { path: "login", component: Login, title: "MCSC | Login" }, + { path: "**", redirectTo: "home"}, ]; diff --git a/src/app/app.ts b/src/app/app.ts index 525e654..9bcfdc3 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -1,8 +1,5 @@ -import { Component, signal, OnInit } from '@angular/core'; +import { Component, signal } from '@angular/core'; import { RouterOutlet } from '@angular/router'; -import { environment } from '../environments/environment'; - -const { API_URL } = environment; @Component({ selector: 'app-root', @@ -10,10 +7,6 @@ const { API_URL } = environment; templateUrl: './app.html', styleUrl: './app.scss', }) -export class App implements OnInit { - protected readonly title = signal('mc-server-starter-frontend'); - - ngOnInit() { - console.log(API_URL); - } +export class App { + protected readonly title = signal('MC Server Control'); } diff --git a/src/app/auth.service.ts b/src/app/auth.service.ts index 27d5e0e..e4f5902 100644 --- a/src/app/auth.service.ts +++ b/src/app/auth.service.ts @@ -1,9 +1,6 @@ import { inject, Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Router } from '@angular/router'; -import { environment } from '../environments/environment'; - -const { API_URL } = environment; @Injectable({ providedIn: 'root' }) export class AuthService { @@ -12,8 +9,8 @@ export class AuthService { private http: HttpClient = inject(HttpClient) private router: Router = inject(Router) - login(username: string, password: string) { - return this.http.post<{ token: string }>(`${API_URL}/login`, { username, password }); + login(username: string, password: string, url: string) { + return this.http.post<{ token: string }>(`${url}/login`, { username, password }); } saveToken(token: string) { @@ -25,7 +22,7 @@ export class AuthService { } isLoggedIn(): boolean { - return !!this.getToken(); + return !!this.getToken() && !!localStorage.getItem("serverIp"); } logout() { diff --git a/src/app/home/home.html b/src/app/home/home.html index ef90d35..a4ec335 100644 --- a/src/app/home/home.html +++ b/src/app/home/home.html @@ -1,23 +1,34 @@
+ Server is {{ running ? "RUNNING" : "STOPPED" }} +
+ } @else { +Status UNKNOWN
+ } @if (loading) { + + } + +