Sha256: 02765fd1453cfae7d3f7857d10007f134aea449960540eaeeb6a154d895b505f

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

class Dashing.NagiosList extends Dashing.Widget
  @accessor 'hasCritical', ->
    if (@get('critical').length > 0) then true else false
  @accessor 'hasWarning', ->
    if (@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 = {}
    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

5 entries across 5 versions & 1 rubygems

Version Path
dashing-contrib-0.1.4 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.3 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.2 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.1 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
dashing-contrib-0.1.0 lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee