Skip to content

Commit 32177df

Browse files
committed
Fixed some subject/observer subscription process
1 parent d514b1f commit 32177df

File tree

10 files changed

+28
-8
lines changed

10 files changed

+28
-8
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<!doctype html><html><head><meta charset="utf-8"><title>Web UI</title><!-- Use This only when serving from SpringBoot
22
<base href="/webui/">
3-
--><!-- Use This when using ng serve --><base href="/"><meta name="viewport" content="width=device-width,initial-scale=1"><!-- link rel="icon" type="image/x-icon" href="favicon.ico" --><link rel="stylesheet" type="text/css" href="./assets/css/font-awesome.min.css"><link href="styles.9823ab1b736db3e9cff2.bundle.css" rel="stylesheet"/></head><body><app-root>Loading...</app-root><script type="text/javascript" src="inline.9a21fd36d580b81640e7.bundle.js"></script><script type="text/javascript" src="polyfills.4099be82af5f3ca64968.bundle.js"></script><script type="text/javascript" src="scripts.05c6a124eeea0f122a7b.bundle.js"></script><script type="text/javascript" src="main.1cbbdd22055428425b75.bundle.js"></script></body></html>
3+
--><!-- Use This when using ng serve --><base href="/"><meta name="viewport" content="width=device-width,initial-scale=1"><!-- link rel="icon" type="image/x-icon" href="favicon.ico" --><link rel="stylesheet" type="text/css" href="./assets/css/font-awesome.min.css"><link href="styles.9823ab1b736db3e9cff2.bundle.css" rel="stylesheet"/></head><body><app-root>Loading...</app-root><script type="text/javascript" src="inline.ea0d0509378aa3a4611b.bundle.js"></script><script type="text/javascript" src="polyfills.4099be82af5f3ca64968.bundle.js"></script><script type="text/javascript" src="scripts.05c6a124eeea0f122a7b.bundle.js"></script><script type="text/javascript" src="main.c520c6aca7c72a06796a.bundle.js"></script></body></html>

webui/dist/inline.9a21fd36d580b81640e7.bundle.js renamed to src/main/resources/public/inline.ea0d0509378aa3a4611b.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webui/dist/main.1cbbdd22055428425b75.bundle.js renamed to src/main/resources/public/main.c520c6aca7c72a06796a.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webui/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<!doctype html><html><head><meta charset="utf-8"><title>Web UI</title><!-- Use This only when serving from SpringBoot
22
<base href="/webui/">
3-
--><!-- Use This when using ng serve --><base href="/"><meta name="viewport" content="width=device-width,initial-scale=1"><!-- link rel="icon" type="image/x-icon" href="favicon.ico" --><link rel="stylesheet" type="text/css" href="./assets/css/font-awesome.min.css"><link href="styles.9823ab1b736db3e9cff2.bundle.css" rel="stylesheet"/></head><body><app-root>Loading...</app-root><script type="text/javascript" src="inline.9a21fd36d580b81640e7.bundle.js"></script><script type="text/javascript" src="polyfills.4099be82af5f3ca64968.bundle.js"></script><script type="text/javascript" src="scripts.05c6a124eeea0f122a7b.bundle.js"></script><script type="text/javascript" src="main.1cbbdd22055428425b75.bundle.js"></script></body></html>
3+
--><!-- Use This when using ng serve --><base href="/"><meta name="viewport" content="width=device-width,initial-scale=1"><!-- link rel="icon" type="image/x-icon" href="favicon.ico" --><link rel="stylesheet" type="text/css" href="./assets/css/font-awesome.min.css"><link href="styles.9823ab1b736db3e9cff2.bundle.css" rel="stylesheet"/></head><body><app-root>Loading...</app-root><script type="text/javascript" src="inline.ea0d0509378aa3a4611b.bundle.js"></script><script type="text/javascript" src="polyfills.4099be82af5f3ca64968.bundle.js"></script><script type="text/javascript" src="scripts.05c6a124eeea0f122a7b.bundle.js"></script><script type="text/javascript" src="main.c520c6aca7c72a06796a.bundle.js"></script></body></html>

webui/dist/inline.ea0d0509378aa3a4611b.bundle.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webui/dist/main.c520c6aca7c72a06796a.bundle.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"zone.js": "0.8.20"
3535
},
3636
"devDependencies": {
37-
"@angular/cli": "^1.6.3",
37+
"@angular/cli": "^1.6.6",
3838
"@angular/compiler-cli": "5.2.2",
3939
"@angular/language-service": "5.2.2",
4040
"@types/node": "~9.3.0",

webui/src/app/services/api/api-request.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable, Inject } from '@angular/core';
22
import { HttpClient, HttpHeaders, HttpResponse, HttpRequest, HttpParams } from '@angular/common/http';
33
import { Router } from '@angular/router';
4-
import { Observable, ReplaySubject, Subject } from 'rxjs';
4+
import { Observable} from 'rxjs';
55
import 'rxjs/add/operator/catch';
66
import { UserInfoService, LoginInfoInStorage} from '../user-info.service';
77
import { AppConfig } from '../../app-config';

webui/src/app/services/api/login.service.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable, Inject } from '@angular/core';
22
import { Router } from '@angular/router';
33

4-
import { Observable,Subject } from 'rxjs';
4+
import { Observable,Subject,BehaviorSubject } from 'rxjs';
55
import 'rxjs/add/operator/map';
66
import 'rxjs/add/operator/catch';
77
import { UserInfoService, LoginInfoInStorage} from '../user-info.service';
@@ -30,7 +30,17 @@ export class LoginService {
3030
"username": username,
3131
"password": password,
3232
}
33-
let loginDataSubject:Subject<any> = new Subject<any>(); // Will use this subject to emit data that we want after ajax login attempt
33+
/*
34+
Using BehaviorSubject instead of Subject
35+
In Angular services are initialized before the components, if any component is
36+
subscribing, it will only receive events which are executed after subscription.
37+
therefore if you put a syncronize next() in the service, the component wont get it.
38+
39+
A BehaviourSubject will always provide the values wheather the subscription happened after or before event
40+
41+
*/
42+
43+
let loginDataSubject:BehaviorSubject<any> = new BehaviorSubject<any>([]); // Will use this BehaviorSubject to emit data that we want after ajax login attempt
3444
let loginInfoReturn:LoginInfoInStorage; // Object that we want to send back to Login Page
3545

3646
this.apiRequest.post('session', bodyData)
@@ -61,6 +71,13 @@ export class LoginService {
6171
};
6272
}
6373
loginDataSubject.next(loginInfoReturn);
74+
},
75+
err => {
76+
loginInfoReturn = {
77+
"success": false,
78+
"message": err.url + " >>> " + err.statusText + "[" + err.status +"]",
79+
"landingPage": "/login"
80+
};
6481
});
6582

6683
return loginDataSubject;

webui/src/app/services/auth_guard.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class AuthGuard implements CanActivate, CanActivateChild {
2626
if (this.userInfoService.isLoggedIn()) {
2727
return true;
2828
}
29+
console.log("User is not logged - This routing guard prvents redirection to any routes that needs logging.");
2930
//Store the original url in login service and then redirect to login page
3031
this.loginService.landingPage = url;
3132
this.router.navigate(['login',]);

0 commit comments

Comments
 (0)