Sha256: d75149e686d36acbb57840c99efdb68cfa6597de772bc479d397ce2a079720c9

Contents?: true

Size: 1.17 KB

Versions: 19

Compression:

Stored size: 1.17 KB

Contents

class Dashing.NagiosList extends Dashing.Widget
  @accessor 'hasCritical', ->
    if (@get('critical') && @get('critical').length > 0) then true else false
  @accessor 'hasWarning', ->
    if (@get('warning') && @get('warning').length > 0) then true else false

  @accessor 'criticalMap', ->
    @_groupBy(@get('critical'))

  @accessor 'warningMap', ->
    @_groupBy(@get('warning'))

  @accessor 'okMap', ->
    @_groupBy(@get('ok'))

  ready: ->
    node = $(@node)
    style = 'overflow': 'hidden'
    node.parent().css(style)

  clear: ->


  _groupBy: (items) ->
    maps = {}
    items = items || []
    for item, index in items
      item.last_check = @_parseTime(item.last_check)
      if !maps[item.host]
        maps[item.host] = [item]
      else
        maps[item.host] = maps[item.host].concat item

    results = []
    for key, item of maps
      node = host: key, checks: item
      results = results.concat node

    return results

  _parseTime: (timestamp) ->
    time = new Date(timestamp)
    return "#{@_toTwoDigits(time.getHours())}:#{@_toTwoDigits(time.getMinutes())}"

  _toTwoDigits: (val) ->
    val = val + ''
    if val.length == 1
      return "0#{val}"

    return val

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
dashing-contrib-0.2.9 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.2.8 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.2.7 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.2.6 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.2.5 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.2.4 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.2.3 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.2.2 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.2.1 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.2.0 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.14 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.12 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.11 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.10 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.9 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.8 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.7 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.6 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.5 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee