API Docs for:
Show:

ServiceModule Class

Module: topology.service
Parent Module: topology

Manage service rendering and events.

Emitted events:

  • clearState: clear all possible states that the environment view can be in as it pertains to actions (building a relation, viewing a service menu, etc.)
  • snapToService: fired when mousing over a service, causing the pending relation dragline to snap to the service rather than following the mouse.
  • snapOutOfService: fired when mousing out of a service, causing the pending relation line to follow the mouse again.
  • addRelationDrag:
  • addRelationDragStart:
  • addRelationDragEnd: fired when creating a relation through the long- click process, when moving the cursor over the environment, and when dropping the endpoint on a valid service.
  • cancelRelationBuild: fired when dropping a pending relation line started through the long-click method somewhere other than a valid service.
  • serviceMoved: fired when a service block is dragged so that relation endpoints can follow it.
  • navigateTo: fired when clicking the "View Service" menu item or when double-clicking a service.

Methods

_touchstartServiceClick

(
  • e
  • topo
)

Callback for the touchstart event handlers on the service svg elements

Parameters:

  • e Object

    event object from tap.

  • topo Object

    topography instance reference.

attachTouchstartEvents

(
  • data
  • node
)

Attaches the touchstart event handlers for the service elements. This is required because touchstart does not appear to bubble in Chrome for Android 4.2.2.

Parameters:

  • data Object

    D3 data object.

  • node DOM Element

    SVG DOM element.

backgroundClicked

() Undefined

The user clicked on the environment view background.

If we are in the middle of adding a relation, cancel the relation adding.

Returns:

Undefined: Side effects only.

canvasClick

()

If the user clicks on the background we cancel any active add relation.

clearStateHandler

() Undefined

Clear any stateful actions (menus, etc.) when a clearState event is received.

Returns:

Undefined: Side effects only.

createServiceNode

(
  • node
  • self
)
Null

Fill a service node with empty structures that will be filled out in the update stage.

Parameters:

  • node Object

    the node to construct.

  • self Object

    reference to the view instance.

Returns:

Null: side effects only.

destroyServiceClick

()

The user clicked on the "Destroy" menu item.

drag

(
  • d
  • self
  • pos
  • includeTransition
)

Specialized drag event handler when called as an event handler it Allows optional extra param, pos which when used overrides the mouse handling. This method can then be though of as 'drag to position'.

Parameters:

  • d Box

    viewModel BoundingBox.

  • self ServiceModule

    ServiceModule.

  • pos Object

    (optional) containing x/y numbers.

  • includeTransition Boolean

    (optional) Use transition to drag.

    [At the time of this writing useTransition works in practice but introduces a timing issue in the tests.]

dragstart

(
  • box
  • self
)
Undefined

Handle drag events for a service.

Parameters:

  • box Box

    A bounding box.

  • self Module

    Service Module.

Returns:

Undefined: Side effects only.

getServiceNode

() d3.selection

Get a d3 selected node for a given service by id.

Returns:

d3.selection: selection || null.

hideServiceMenu

(
  • box
)
Undefined

Hide the service menu.

Parameters:

  • box Object

    The presentation state for the service (unused).

Returns:

Undefined: Side effects only.

serviceClick

(
  • box
  • self
  • eType
)

Handles the click or tap on the service svg elements.

It is executed under the context of the clicked/tapped DOM element

Parameters:

  • box Object

    service object model instance.

  • self Object

    this service module instance.

  • eType String

    string representing if it's 'touch' or not.

serviceMouseMove

(
  • d
  • context
)
Undefined

Handle a mouse moving over a service.

Parameters:

  • d Object

    Unused.

  • context Object

    Unused.

Returns:

Undefined: Side effects only.

serviceStatusMouseOver

()

Handle mouseover service status

showServiceMenu

(
  • box
)
Undefined

Show the service menu.

Parameters:

  • box Object

    The presentation state for the service.

Returns:

Undefined: Side effects only.

toggleServiceMenu

(
  • box
)
Undefined

Show (if hidden) or hide (if shown) the service menu.

Parameters:

  • box Object

    The presentation state for the service.

Returns:

Undefined: Side effects only.

updateServiceNodes

(
  • node
)
Null

Fill the empty structures within a service node such that they match the db.

Parameters:

  • node Object

    the collection of nodes to update.

Returns:

Null: side effects only.

viewServiceClick

()

The user clicked on the "View" menu item.

Events

clearState

Clear view state as pertaining to services.

drag

Event fired while a service is being dragged or dragline being moved.

Event Payload:

  • box Object

    The service box that's being dragged.

  • self Object

    This class.

dragend

Event fired after a service is being dragged or dragline being moved.

Event Payload:

  • box Object

    The service box that's being dragged.

  • self Object

    This class.

dragstart

Start the service drag process or the add-relation dragline process.

Event Payload:

  • box Object

    The service box that's being dragged.

  • self Object

    This class.

fade

Fade a given service (set opacity to 0.2).

Event Payload:

  • An Object

    object with a d3 selection attribute.

hide

Hide a given service (set opacity to 0).

Event Payload:

  • An Object

    object with a d3 selection attribute.

hideServiceMenu

Hide a service's click-actions menu.

rescaled

Update the service menu location.

show

Show a hidden service (set opacity to 1.0).

Event Payload:

  • An Object

    object with a d3 selection attribute.