Frontend API
@Injectable() export class WorkspaceService
The workspace service manage the workspace’s data. Only one instance of the service can exists. It is used in order to remove the maximum amount of data in the view components, and centralize these data in one place, accessible from any view component.
A workspace is the same concept as the workspace in an IDE. So one workspace correspond to a project as a user point of view. It has a directory, and specifically to padins, it has a workflow. This workflow is the flow.json file in the root of the folder. Take a look the Flow.ts file to know more about it.
In this project, that is the client side of padins, the workspace class store the network connexion information, the running state and the id and name of the project.
Created by antoine on 17/07/17.
clear ()
Clear all the data of the service. Usually used to switch to another workspace.
setEventHub(hub: any)
Set the eventhub instance. The eventhub is a GoldenLayout component used as a hub to centralize the communication between the views.
- Parameters:
hub
— the new hub to use
setSocket (socket: SocketService)
Set the socket to use in order to communicate with the server.
- Parameters:
socket
— the new socket
setFlow (flow: Flow)
Set the flow instance. The flow is the object used to describe the simulation workflow.
- Parameters:
flow
— the new flow instance.
componentsReady ()
To inform this that the components have all been downloaded from the server.
setWorkspace(id: string)
Set the id of the workspace to use by this service.
- Parameters:
id
— id of the connected workspace
getComponents (): Map
Get the components that can be used to describe the workflow.
- Returns:
Map<string
— Component>} the components as a map(name -> component)
getNodes ()
Returns the set of nodes that are on the workflow.
- Returns:
Array<Node>
— all the nodes on the workflow.
getNode(id: string): Node
Returns a Node from its id.
- Parameters:
id
— the id of the node - Returns:
Node
— the Node with the given id, null if no Node exists with this id
getEdges ()
Returns the set of edges that are on the workflow.
- Returns:
Array<Edge>
— all the edges on the workflow
getEdge (id: string): Edge
Returns an Edge from its id
- Parameters:
id
— the id of the Edge - Returns:
Edge
— the Ede with the given id, null if no Edge exists with this id
addEdge (edge: Edge)
Add an Edge on the workflow.
- Parameters:
edge
— the edge to add
removeEdge (edge: Edge)
Remove an Edge from the workflow.
- Parameters:
edge
— the edge to remove
updateEdge (newEdge: Edge)
Update the data of an Edge. The Edge is identified with its id. All the other data can be changed.
- Parameters:
newEdge
— the new version of the edge
edgeExist (edge: Edge): boolean
Is the given edge existing on the workflow ?
- Parameters:
edge
— the edge to check - Returns:
boolean
— true if the edge is on the workflow
getPreviousNodes (node: Node): Array
Returns the set of nodes that are the dependencies of the given node. Those dependencies are the nodes that are directly connected on the inports of the given node.
- Parameters:
node
— the node to retrieve dependencies from - Returns:
Array<Node>
—
addComponent (component: Component)
Add a component to the list of available components.
- Parameters:
component
— the new component to add
addNode (node: Node)
Add a node on the workflow.
- Parameters:
node
— the node to add
removeNode (node: Node)
Remove an existing node from the workflow.
- Parameters:
node
— the node to remove
async broadcastFlowAndComponentsSetUp ()
Broadcast a “flow and components set up” message to all the view components.
- Returns:
Promise<void>
— -> unknown promise
subscribeToWorkspaceChanges (component: WorkspaceListener)
Add the given component to the list of components to notify when a change occurs on the workspace’s data.
- Parameters:
component
— the component to add to the lit
broadcastWorkspaceChanges ()
Broadcast the changed that occur on the workspace.
updateFileExplorerNodes (payload: Object)
Update the content of the file explorer with the given data
- Parameters:
payload
— payload received from the server message
sleep(ms: number)
Pause the execution of a function for the given amount of milliseconds.
- Parameters:
ms
— the duration of the sleep, in milliseconds - Returns:
Promise<T>
—