Sha256: a5988ed5024c5bc4ac11c7c6d684286d103849e5cf2b2457060b3485572e34f4

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

namespace "SensuDashboard.Views.Checks", (exports) ->

  class exports.List extends SensuDashboard.Views.List

    name: "checks/list"

    initialize: ->
      @autocomplete_view = @options.autocomplete_view
      @autocomplete_view.delegate = this
      super

    itemClass: ->
      exports.ListItem

    resolvedCollection: ->
      resolved = @collection.chain()
      for token in @autocomplete_view.tokens
        resolved = if _.isString(token.object)
          resolved.filter (record) =>
            result = @matchForKeys(token.object, record,
              { key: "interval", threshold: 1 },
              { key: "name", threshold: 0.92 }
            )
            result || _.detect(record.get("subscribers"), (sub) =>
              liquidMetal.score(sub, token.object) > 0.96) != undefined

      resolved

    matchForKeys: (q, record, args...) ->
      result = _.detect args, (options) =>
        value = record.get(options.key).toString()
        score = liquidMetal.score(value, q)
        score >= (options.threshold || 0.7)

      !(result is undefined)

    renderCollection: ->
      super(_(@resolvedCollection().map().value()))

    renderEmpty: ->
      super(_(@resolvedCollection().map().value()))

    #
    # Autocomplete delegate
    #

    filtersUpdated: ->
      @render()

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sensu-dashboard-0.10.4 lib/sensu-dashboard/assets/javascripts/views/checks/list.coffee
sensu-dashboard-0.10.3 lib/sensu-dashboard/assets/javascripts/views/checks/list.coffee
sensu-dashboard-0.10.2 lib/sensu-dashboard/assets/javascripts/views/checks/list.coffee
sensu-dashboard-0.10.1 lib/sensu-dashboard/assets/javascripts/views/checks/list.coffee
sensu-dashboard-0.10.0 lib/sensu-dashboard/assets/javascripts/views/checks/list.coffee
sensu-dashboard-0.9.9 lib/sensu-dashboard/assets/javascripts/views/checks/list.coffee