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 | 1x | import { Inject, Injectable } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { fromEventPattern, Observable, using } from 'rxjs'; import { SignalRBaseService } from './signalR.base.service'; import { LogService } from 'src/app/log/log.service'; import { Interaction, InteractionFrame, InteractionHistory, JsonSimpleValue, RemoteProcessingServiceSettings } from '@reflex/shared-types'; @Injectable({ providedIn: 'root' }) export class ProcessingService extends SignalRBaseService<string> { private readonly processingRoute = 'api/Processing/'; private readonly isLoopRunningRoute = `${this.processingRoute}IsLoopRunning/`; private readonly getIntervalRoute = `${this.processingRoute}GetInterval/`; private readonly getRemoteProcessorSettingsRoute = `${this.processingRoute}GetRemoteProcessorSettings/`; private readonly getObserverTypesRoute = `${this.processingRoute}GetObserverTypes/`; private readonly getSelectedObserverTypeRoute = `${this.processingRoute}GetObserverType/`; private readonly setIntervalRoute = `${this.processingRoute}SetUpdateInterval`; private readonly setRemoteProcessorSettingsRoute = `${this.processingRoute}SetRemoteProcessorSettings/`; private readonly setObserverTypeRoute = `${this.processingRoute}SelectObserverType`; private readonly toggleInteractionProcessingRoute = `${this.processingRoute}ToggleInteractionProcessing/`; // eslint-disable-next-line new-cap public constructor(private readonly http: HttpClient, @Inject('BASE_URL') private readonly baseUrl: string, logService: LogService) { super(`${baseUrl}prochub`, 'processingState', logService); } public getIsLoopRunning(): Observable<HttpResponse<JsonSimpleValue>> { return this.http.get<HttpResponse<JsonSimpleValue>>(this.baseUrl + this.isLoopRunningRoute); } public getInterval(): Observable<number> { return this.http.get<number>(this.baseUrl + this.getIntervalRoute); } public getRemoteProcessorSettings(): Observable<RemoteProcessingServiceSettings> { return this.http.get<RemoteProcessingServiceSettings>(this.baseUrl + this.getRemoteProcessorSettingsRoute); } public getObserverTypes(): Observable<Array<string>> { return this.http.get<Array<string>>(this.baseUrl + this.getObserverTypesRoute); } public getSelectedObserverType(): Observable<number> { return this.http.get<number>(this.baseUrl + this.getSelectedObserverTypeRoute); } public setInterval(interval: number): Observable<HttpResponse<JsonSimpleValue>> { const args: JsonSimpleValue = { name: 'UpdateInterval', value: interval }; return this.http.post<JsonSimpleValue>(this.baseUrl + this.setIntervalRoute, args, { observe: 'response' }); } public setRemoteProcessorSettings(settings: RemoteProcessingServiceSettings): Observable<HttpResponse<RemoteProcessingServiceSettings>> { return this.http.post<RemoteProcessingServiceSettings>(this.baseUrl + this.setRemoteProcessorSettingsRoute, settings, { observe: 'response' }); } public setObserverType(observerType: string): Observable<HttpResponse<JsonSimpleValue>> { const args: JsonSimpleValue = { name: 'ObserverType', value: observerType }; return this.http.post<JsonSimpleValue>(this.baseUrl + this.setObserverTypeRoute, args, { observe: 'response' }); } public toggleProcessing(): Observable<HttpResponse<JsonSimpleValue>> { return this.http.put<JsonSimpleValue>(this.baseUrl + this.toggleInteractionProcessingRoute, { headers: this.headers }, { observe: 'response' }); } public getInteractions(): Observable<Array<Interaction>> { const interactions$ = fromEventPattern<Array<Interaction>>( (handler) => this.connection.on('interactions', handler), (handler) => this.connection.off('interactions', handler) ); return using(() => { this.connection.send('StartInteractions').catch((error) => { console.error(error); this.logService.sendErrorLog(`${error}`); }); // eslint-disable-next-line @typescript-eslint/no-misused-promises return { unsubscribe: async () => this.connection.send('StopInteractions').catch((error) => { console.error(error); this.logService.sendErrorLog(`${error}`); }) }; }, () => interactions$); } public getFrames(): Observable<Array<InteractionFrame>> { const frames$ = fromEventPattern<Array<InteractionFrame>>( (handler) => this.connection.on('frames', handler), (handler) => this.connection.off('frames', handler) ); return using(() => { this.connection.send('StartInteractionFrames').catch((error) => { console.error(error); this.logService.sendErrorLog(`${error}`); }); // eslint-disable-next-line @typescript-eslint/no-misused-promises return { unsubscribe: async () => this.connection.send('StopInteractionFrames').catch((error) => { console.error(error); this.logService.sendErrorLog(`${error}`); }) }; }, () => frames$); } public getHistory(): Observable<Array<InteractionHistory>> { const history$ = fromEventPattern<Array<InteractionHistory>>( (handler) => this.connection.on('history', handler), (handler) => this.connection.off('history', handler) ); return using(() => { this.connection.send('StartInteractionHistory').catch((error) => { console.error(error); this.logService.sendErrorLog(`${error}`); }); // eslint-disable-next-line @typescript-eslint/no-misused-promises return { unsubscribe: async () => this.connection.send('StopInteractionHistory').catch((error) => { console.error(error); this.logService.sendErrorLog(`${error}`); }) }; }, () => history$); } } |