blob: 44d9e5ef4e02a5fdf59d4fd1fc250a0f72e05099 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { User } from './user';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/share';
import 'rxjs/add/operator/map';
import { environment } from '../../../../environments/environment';
@Injectable({
providedIn: 'root'
})
export class UserService {
user: User;
response:any;
results: Observable<any>;
constructor(private http:HttpClient) { }
data;
observable;
getFunctionalMenuStaticDetailSession2(){
return this.http.get(environment.getTopMenu,{ withCredentials: true })
.subscribe((results: Object) => {
this.user = new User(results);
});
}
public getFunctionalMenuStaticDetailSession(): Observable<User> {
return this.http
.get(environment.getTopMenu,{ withCredentials: true })
.map(response => {
return new User(response);
})
}
getFunctionalMenuStaticDetailSession1() {
if (this.data) {
return Observable.of(this.data);
} else if (this.observable) {
return this.observable;
} else {
this.observable = this.http.get(environment.getTopMenu, {
withCredentials: true,
observe: 'response'
})
.map(response => {
this.observable = null;
if (response.status === 400) {
return 'Request failed.';
} else if (response.status === 200) {
this.data = response.body;
return this.data;
}
})
.share();
return this.observable;
}
}
}
|