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.

setSocket (socket: SocketService)

Set the socket to use in order to communicate with the server.

setFlow (flow: Flow)

Set the flow instance. The flow is the object used to describe the simulation workflow.

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.

getComponents (): Map

Get the components that can be used to describe the workflow.

getNodes ()

Returns the set of nodes that are on the workflow.

getNode(id: string): Node

Returns a Node from its id.

getEdges ()

Returns the set of edges that are on the workflow.

getEdge (id: string): Edge

Returns an Edge from its id

addEdge (edge: Edge)

Add an Edge on the workflow.

removeEdge (edge: Edge)

Remove an Edge from the workflow.

updateEdge (newEdge: Edge)

Update the data of an Edge. The Edge is identified with its id. All the other data can be changed.

edgeExist (edge: Edge): boolean

Is the given edge existing 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.

addComponent (component: Component)

Add a component to the list of available components.

addNode (node: Node)

Add a node on the workflow.

removeNode (node: Node)

Remove an existing node from the workflow.

async broadcastFlowAndComponentsSetUp ()

Broadcast a “flow and components set up” message to all the view components.

subscribeToWorkspaceChanges (component: WorkspaceListener)

Add the given component to the list of components to notify when a change occurs on the workspace’s data.

broadcastWorkspaceChanges ()

Broadcast the changed that occur on the workspace.

updateFileExplorerNodes (payload: Object)

Update the content of the file explorer with the given data

sleep(ms: number)

Pause the execution of a function for the given amount of milliseconds.