Class: Tiler::Widgets::Table

Inherits:
Tiler::Widget show all
Defined in:
lib/tiler/widgets/table.rb

Instance Attribute Summary

Attributes inherited from Tiler::Widget

#config, #panel

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tiler::Widget

#data, #initialize, #label, #partial, #query_class, supports_color_config?, supports_palette_config?

Constructor Details

This class inherits a constructor from Tiler::Widget

Class Method Details

.example_configObject



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/tiler/widgets/table.rb', line 81

def self.example_config
  {
    "group_by"    => "endpoint",
    "time_window" => "24h",
    "limit"       => 20,
    "columns" => [
      { "label" => "p50", "column" => "p50", "num" => true, "agg" => "avg" },
      { "label" => "p95", "column" => "p95", "num" => true, "agg" => "avg" },
      { "label" => "rpm", "column" => "rpm", "num" => true, "agg" => "sum" }
    ]
  }
end

.example_payloadObject



94
95
96
# File 'lib/tiler/widgets/table.rb', line 94

def self.example_payload
  { "endpoint" => "/api/users", "p50" => 22, "p95" => 142, "rpm" => 842 }
end

.example_previewObject



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/tiler/widgets/table.rb', line 98

def self.example_preview
  {
    "columns" => [
      { "label" => "Endpoint", "num" => false },
      { "label" => "p50",      "num" => true  },
      { "label" => "p95",      "num" => true  },
      { "label" => "rpm",      "num" => true  }
    ],
    "rows" => [
      [ "/api/users",   "22ms",  "142ms", "842" ],
      [ "/api/orders",  "34ms",  "198ms", "561" ],
      [ "/api/search",  "110ms", "680ms", "410" ],
      [ "/auth/login",  "18ms",  "88ms",  "298" ]
    ],
    "total" => 4, "limit" => 20
  }
end

Instance Method Details

#empty?(data) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
79
# File 'lib/tiler/widgets/table.rb', line 76

def empty?(data)
  return true if super
  data.nil? || data[:rows].blank?
end