|
|
|
|
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
|
});
|