Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | 3x 3x 3x 3x 3x | import { HttpClient, HttpResponse } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import { JsonSimpleValue, NetworkAttributes } from '@reflex/shared-types';
import { Observable } from 'rxjs';
import { LogService } from 'src/app/log/log.service';
import { BASE_URL } from 'src/shared/tokens/base-url.token';
import { SignalRBaseService } from './signalR.base.service';
@Injectable({
providedIn: 'root'
})
export class NetworkingService extends SignalRBaseService<string> {
private readonly http = inject(HttpClient);
private readonly baseUrl: string;
private readonly networkingRoute = 'api/Network/';
private readonly getStatusRoute = `${this.networkingRoute}Status`;
private readonly getAddressRoute = `${this.networkingRoute}GetAddress`;
private readonly getPortRoute = `${this.networkingRoute}GetPort`;
private readonly getEndpointRoute = `${this.networkingRoute}GetEndpoint`;
private readonly setAddressRoute = `${this.networkingRoute}SetAddress`;
private readonly setPortRoute = `${this.networkingRoute}SetPort`;
private readonly setEndpointRoute = `${this.networkingRoute}SetEndpoint`;
private readonly getSelectedNetworkTypeRoute = `${this.networkingRoute}GetNetworkType`;
private readonly selectNetworkTypeRoute = `${this.networkingRoute}SelectNetworkType`;
private readonly getNetworkTypesRoute = `${this.networkingRoute}GetNetworkTypes`;
private readonly toggleNetworkingRoute = `${this.networkingRoute}ToggleNetworking`;
private readonly saveNetworkingSettingsRoute = `${this.networkingRoute}Save`;
public constructor() {
const baseUrl = inject(BASE_URL);
const logService = inject(LogService);
super(`${baseUrl}nethub`, 'networkingState', logService);
this.baseUrl = baseUrl;
}
public getStatusValues(): Observable<NetworkAttributes> {
return this.http.get<NetworkAttributes>(
this.baseUrl + this.getStatusRoute,
{ headers: this.headers }
);
}
public getAddress(): Observable<string> {
return this.http.get(this.baseUrl + this.getAddressRoute, {
responseType: 'text'
});
}
public getPort(): Observable<number> {
return this.http.get<number>(this.baseUrl + this.getPortRoute, {
headers: this.headers
});
}
public getEndpoint(): Observable<string> {
return this.http.get(this.baseUrl + this.getEndpointRoute, {
responseType: 'text'
});
}
public getNetworkInterfaces(): Observable<Array<string>> {
return this.http.get<Array<string>>(
this.baseUrl + this.getNetworkTypesRoute,
{ headers: this.headers }
);
}
public getSelectedNetworkInterface(): Observable<number> {
return this.http.get<number>(
this.baseUrl + this.getSelectedNetworkTypeRoute,
{ headers: this.headers }
);
}
public setAddress(
address: string
): Observable<HttpResponse<JsonSimpleValue>> {
const args: JsonSimpleValue = { name: 'Address', value: address };
return this.http.post<JsonSimpleValue>(
this.baseUrl + this.setAddressRoute,
args,
{ observe: 'response' }
);
}
public setPort(port: number): Observable<HttpResponse<JsonSimpleValue>> {
const args: JsonSimpleValue = { name: 'Port', value: port };
return this.http.post<JsonSimpleValue>(
this.baseUrl + this.setPortRoute,
args,
{ observe: 'response' }
);
}
public setEndpoint(
endpoint: string
): Observable<HttpResponse<JsonSimpleValue>> {
const args: JsonSimpleValue = { name: 'Endpoint', value: endpoint };
return this.http.post<JsonSimpleValue>(
this.baseUrl + this.setEndpointRoute,
args,
{ observe: 'response' }
);
}
public setNetworkInterface(
observerType: string
): Observable<HttpResponse<JsonSimpleValue>> {
const args: JsonSimpleValue = { name: 'NetworkType', value: observerType };
return this.http.post<JsonSimpleValue>(
this.baseUrl + this.selectNetworkTypeRoute,
args,
{ observe: 'response' }
);
}
public toggleBroadcasting(): Observable<HttpResponse<JsonSimpleValue>> {
return this.http.put<JsonSimpleValue>(
this.baseUrl + this.toggleNetworkingRoute,
{ headers: this.headers },
{ observe: 'response' }
);
}
public saveSettings(): Observable<HttpResponse<JsonSimpleValue>> {
return this.http.put<JsonSimpleValue>(
this.baseUrl + this.saveNetworkingSettingsRoute,
{ headers: this.headers },
{ observe: 'response' }
);
}
}
|