|
1 |
| -import { Component, OnInit } from '@angular/core'; |
2 |
| -import { Observable } from 'rxjs'; |
| 1 | +import { Component, OnInit } from '@angular/core' |
| 2 | +import { Observable } from 'rxjs' |
3 | 3 |
|
4 |
| -import { WSSEService } from '../wsse.service'; |
5 |
| -import { HttpErrorResponse } from '@angular/common/http'; |
6 |
| -import { Router } from '@angular/router'; |
7 |
| -import { TokenService } from '../token.service'; |
| 4 | +import { WSSEService } from '../wsse.service' |
| 5 | +import { HttpErrorResponse } from '@angular/common/http' |
| 6 | +import { Router } from '@angular/router' |
| 7 | +import { TokenService } from '../token.service' |
8 | 8 |
|
9 | 9 | @Component({
|
10 | 10 | selector: 'app-hello',
|
11 | 11 | templateUrl: './hello.component.html',
|
12 | 12 | styleUrls: ['./hello.component.css']
|
13 | 13 | })
|
14 | 14 | export class HelloComponent implements OnInit {
|
| 15 | + $hello: Observable<{ hello?: string }> |
| 16 | + helloMessage: string |
15 | 17 |
|
16 |
| - $hello: Observable<{ hello?: string }>; |
17 |
| - helloMessage: string; |
18 |
| - |
19 |
| - constructor( |
| 18 | + constructor ( |
20 | 19 | private wsseService: WSSEService,
|
21 | 20 | private tokenService: TokenService,
|
22 |
| - private router: Router, |
23 |
| - ) { } |
| 21 | + private router: Router |
| 22 | + ) {} |
24 | 23 |
|
25 |
| - ngOnInit() { |
| 24 | + ngOnInit () { |
26 | 25 | // Example API call showing an Hello World
|
27 |
| - this.$hello = this.wsseService.getHello(); |
| 26 | + this.$hello = this.wsseService.getHello() |
28 | 27 |
|
29 | 28 | this.$hello.subscribe(
|
30 | 29 | // Show API response
|
31 | 30 | ({ hello }) => {
|
32 |
| - console.log(`Received from server ${hello}`); |
33 |
| - this.helloMessage = hello; |
| 31 | + console.log(`Received from server ${hello}`) |
| 32 | + this.helloMessage = hello |
34 | 33 | },
|
35 | 34 | // Log error message and redirect to login
|
36 | 35 | (error: HttpErrorResponse) => {
|
37 |
| - console.error(error); |
| 36 | + console.error(error) |
38 | 37 | if (error.status === 401) {
|
39 |
| - return this.router.navigate(['']); |
| 38 | + return this.router.navigate(['']) |
40 | 39 | }
|
41 |
| - }); |
| 40 | + } |
| 41 | + ) |
42 | 42 | }
|
43 | 43 |
|
44 |
| - onGoBack() { |
45 |
| - return this.router.navigate(['']); |
| 44 | + onGoBack () { |
| 45 | + return this.router.navigate(['']) |
46 | 46 | }
|
47 |
| - |
48 | 47 | }
|
0 commit comments