-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(process-explorer-frontend): Add back mock processes
- Loading branch information
Showing
5 changed files
with
1,259 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 5 additions & 44 deletions
49
prototypes/process-explorer/js/src/app/services/mock-processes.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,13 @@ | ||
/* Morgan Stanley makes this available to you under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ | ||
import { Injectable } from '@angular/core'; | ||
import { SuperRPC } from 'super-rpc'; | ||
import { IProcessInfoAggregator } from '../DTOs/IProcessInfoAggregator'; | ||
import { ProcessInfo } from '../DTOs/ProcessInfo'; | ||
import { ServiceProcessObject } from '../main-view/processes/ServiceProcessObject'; | ||
import { Observable, of } from 'rxjs'; | ||
import { MockProcesses } from './mock-processes'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class MockProcessesService { | ||
|
||
private ws: WebSocket = new WebSocket('ws://localhost:5056/processes'); | ||
private rpc : SuperRPC; | ||
private process : ServiceProcessObject; | ||
private connected: any; | ||
private processController: IProcessInfoAggregator; | ||
|
||
constructor(){ | ||
this.process = new ServiceProcessObject(); | ||
this.connected = new Promise( (resolve, reject) => | ||
{ | ||
try{ | ||
this.ws.addEventListener('open', async() => { | ||
this.rpc = new SuperRPC( () => (Math.random()*1e17).toString(36)); | ||
this.rpc.connect({ | ||
sendAsync: (message) => this.ws.send(JSON.stringify(message)), | ||
receive: (callback) => { this.ws.addEventListener('message', (msg) => callback(JSON.parse(msg.data)))} | ||
}); | ||
this.rpc.registerHostObject('ServiceProcessObject', this.process, {functions:['AddProcesses', 'AddProcess', 'UpdateProcess', 'TerminateProcess', | ||
'AddRuntimeInfo', 'AddConnections', 'AddConnection', 'UpdateConnection', 'UpdateEnvironmentVariables','UpdateRegistrations', 'UpdateModules', 'AddRuntimeInfos']}); | ||
await this.rpc.requestRemoteDescriptors(); | ||
this.processController = this.rpc.getProxyObject('processController'); | ||
resolve(undefined); | ||
})}catch(ex){ | ||
reject(ex);} | ||
}); | ||
} | ||
|
||
public getProcessServiceObject() : ServiceProcessObject{ | ||
return this.process; | ||
} | ||
|
||
public getProcessServiceObjectsProcesses() : ProcessInfo[]{ | ||
return this.process.getProcesses(); | ||
} | ||
|
||
public KillProcessByID(pid: number) : void{ | ||
this.processController.RemoveProcessById(pid); | ||
public getData(tableName: string): Observable<any[]> { | ||
return of(MockProcesses[tableName]); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.