Class: OMF::Web::Widget::DataWidget
- Inherits:
-
AbstractWidget
- Object
- Erector::Widget
- AbstractWidget
- OMF::Web::Widget::DataWidget
- Defined in:
- lib/omf-web/widget/data_widget.rb
Overview
Supports widgets which visualize the content of a Table
which may also dynamically change.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
depends_on :css, “/resource/css/graph.css”.
-
#opts ⇒ Object
readonly
depends_on :css, “/resource/css/graph.css”.
Attributes inherited from AbstractWidget
Instance Method Summary collapse
-
#collect_data_sources(ds_set) ⇒ Object
end.
- #content ⇒ Object
-
#dom_id ⇒ Object
This is the DOM id which should be used by the renderer for this widget.
-
#initialize(opts = {}) ⇒ DataWidget
constructor
opts :data_sources ..
Methods inherited from AbstractWidget
#layout?, #mime_type, #title, #tools_menu, #widget_info
Methods included from Common::Loggable
#_logger, #debug, #error, #fatal, #info, init_log, logger, set_environment, #warn
Constructor Details
#initialize(opts = {}) ⇒ DataWidget
opts
:data_sources .. Either a single table, or a hash of 'name' => table.
:js_class .. Javascript class used for visualizing data
:wopts .. options sent to the javascript instance
:js_url .. URL where +jsVizClass+ can be loaded from
:dynamic .. update the widget when the data_table is changing
:updateInterval .. if web sockets aren't used, check every :updateInterval sec [3]
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/omf-web/widget/data_widget.rb', line 22 def initialize(opts = {}) opts = opts.dup # not sure why we may need to this. Is this hash used anywhere wlse? unless vizType = opts[:type].split('/')[-1] raise "Missing widget option ':viz_type' for widget '#{name}' (#{opts.inspect})" end name = opts[:name] ||= 'Unknown' opts[:js_url] = "graph/js/#{vizType}.js" opts[:js_class] = "OML.#{vizType}" opts[:base_el] = "\##{dom_id}" super opts if (ds = opts.delete(:data_source)) # single source data_sources = {:default => ds} end unless data_sources ||= opts.delete(:data_sources) raise "Missing option ':data_sources' for widget '#{name}'" end unless data_sources.kind_of? Hash data_sources = {:default => data_sources} end opts[:data_sources] = data_sources.collect do |name, ds_descr| unless ds_descr.is_a? Hash ds_descr = {:name => ds_descr} end ds_descr[:alias] = "#{name}_#{self.object_id}" {:stream => ds_descr, :name => name} end #puts "DTA_WIDGTE>>> #{opts[:data_sources].inspect}" end |
Instance Attribute Details
#name ⇒ Object (readonly)
depends_on :css, “/resource/css/graph.css”
11 12 13 |
# File 'lib/omf-web/widget/data_widget.rb', line 11 def name @name end |
#opts ⇒ Object (readonly)
depends_on :css, “/resource/css/graph.css”
11 12 13 |
# File 'lib/omf-web/widget/data_widget.rb', line 11 def opts @opts end |
Instance Method Details
#collect_data_sources(ds_set) ⇒ Object
end
98 99 100 101 102 103 104 |
# File 'lib/omf-web/widget/data_widget.rb', line 98 def collect_data_sources(ds_set) #puts "DATA_SOURCES>>>> #{@data_sources.values.inspect}" @opts[:data_sources].each do |ds| ds_set.add(ds[:stream]) end ds_set end |
#content ⇒ Object
61 62 63 64 |
# File 'lib/omf-web/widget/data_widget.rb', line 61 def content() OMF::Web::Theme.require 'data_renderer' OMF::Web::Theme::DataRenderer.new(self, @opts) end |
#dom_id ⇒ Object
This is the DOM id which should be used by the renderer for this widget. We need to keep this here as various renderes at various levels may need to get a reference to it to allow for such functionalities as hiding, stacking, …
57 58 59 |
# File 'lib/omf-web/widget/data_widget.rb', line 57 def dom_id "w#{object_id.abs}" end |