Sha256: dac0ebe687a284ae53688fe4f30cb49101f871990058a548ba696ca6c5aa7e4a

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

namespace "SensuDashboard.Models", (exports) ->

  class exports.Info extends Backbone.Model

    defaults:
      sensu:
        version: null
      dashboard:
        version: null
      rabbitmq:
        keepalives:
          messages: 0
          consumers: 0
        results:
          messages: 0
          consumers: 0
        connected: false
      redis:
        connected: false
      sensu_dashboard:
        version: null
        poll_frequency: 10

    url: "/info"

    initialize: ->
      @setRMQStatus   @get("rabbitmq").connected
      @setRedisStatus @get("redis").connected

    setRMQStatus: (status) ->
      @set { rmq_status: @_onlineStatus(status) }

    setRedisStatus: (status) ->
      @set { redis_status: @_onlineStatus(status) }

# Private
    _onlineStatus: (status) ->
      if status then "Online" else "Offline"

    longPolling: false

    intervalSeconds: 10

    startLongPolling: (intervalSeconds) =>
      @longPolling = true
      @intervalSeconds = intervalSeconds if intervalSeconds
      @executeLongPolling()

    stopLongPolling: =>
      @longPolling = false

    executeLongPolling: =>
      @fetch
        success: =>
          @onFetch()

    onFetch: =>
      setTimeout(@executeLongPolling, 1000 * @intervalSeconds) if @longPolling

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sensu-dashboard-0.10.4 lib/sensu-dashboard/assets/javascripts/models/info.coffee
sensu-dashboard-0.10.3 lib/sensu-dashboard/assets/javascripts/models/info.coffee
sensu-dashboard-0.10.2 lib/sensu-dashboard/assets/javascripts/models/info.coffee
sensu-dashboard-0.10.1 lib/sensu-dashboard/assets/javascripts/models/info.coffee
sensu-dashboard-0.10.0 lib/sensu-dashboard/assets/javascripts/models/info.coffee
sensu-dashboard-0.9.9 lib/sensu-dashboard/assets/javascripts/models/info.coffee