Browse Source

Fixed multiple HTTP requests

develop
Robin Thoni 6 years ago
parent
commit
eef898547c
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      frontend/SiteStatus/src/app/services/status.service.ts

+ 3
- 2
frontend/SiteStatus/src/app/services/status.service.ts View File

5
 import {AppStateService} from './app-state.service';
5
 import {AppStateService} from './app-state.service';
6
 import {VpnStatusModel} from '../models/vpn/vpn-status.model';
6
 import {VpnStatusModel} from '../models/vpn/vpn-status.model';
7
 import {DnsStatusModel} from '../models/dns/dns-status.model';
7
 import {DnsStatusModel} from '../models/dns/dns-status.model';
8
+import {share} from 'rxjs/operators';
8
 
9
 
9
 const httpPostOptions = {
10
 const httpPostOptions = {
10
     headers: new HttpHeaders({ 'Content-Type': 'application/json' })
11
     headers: new HttpHeaders({ 'Content-Type': 'application/json' })
17
     constructor(private http: HttpClient, private appStateService: AppStateService) { }
18
     constructor(private http: HttpClient, private appStateService: AppStateService) { }
18
 
19
 
19
         getVpnStatus(): Observable<ApiResultModel<VpnStatusModel>> {
20
         getVpnStatus(): Observable<ApiResultModel<VpnStatusModel>> {
20
-            const obs = this.http.get<ApiResultModel<VpnStatusModel>>(`${this.urlBase}/vpn`);
21
+            const obs = this.http.get<ApiResultModel<VpnStatusModel>>(`${this.urlBase}/vpn`).pipe(share());
21
             obs.subscribe(vpnStatus => {
22
             obs.subscribe(vpnStatus => {
22
                 this.appStateService.updateVpnStatus(vpnStatus.data);
23
                 this.appStateService.updateVpnStatus(vpnStatus.data);
23
             });
24
             });
25
         }
26
         }
26
 
27
 
27
         getDnsStatus(): Observable<ApiResultModel<DnsStatusModel>> {
28
         getDnsStatus(): Observable<ApiResultModel<DnsStatusModel>> {
28
-            const obs = this.http.get<ApiResultModel<DnsStatusModel>>(`${this.urlBase}/dns`);
29
+            const obs = this.http.get<ApiResultModel<DnsStatusModel>>(`${this.urlBase}/dns`).pipe(share());
29
             obs.subscribe(dnsStatus => {
30
             obs.subscribe(dnsStatus => {
30
                 this.appStateService.updateDnsStatus(dnsStatus.data);
31
                 this.appStateService.updateDnsStatus(dnsStatus.data);
31
             });
32
             });

Loading…
Cancel
Save