Class: Marty::ReportSelect

Inherits:
Form
  • Object
show all
Includes:
Extras::Layout
Defined in:
app/components/marty/report_select.rb

Constant Summary collapse

REPORT_ATTR_SET =

FIXME: should be in a library

Constants included from Extras::Layout

Extras::Layout::BOOL_MAP, Extras::Layout::MAP_BOOL

Constants included from Permissions

Permissions::ALL_ROLES, Permissions::REQ_ROLES

Instance Method Summary collapse

Methods included from Extras::Layout

#bool_getter, #bool_setter, #dispfield, #enum_array, #enum_column, #enum_setter, #fieldset, #hbox, #hspacer, #jsonb_field, #nullable_bool_column, #range_column, #range_field, #range_getter, #range_setter, #textarea_field, #vbox, #vspacer

Methods included from Permissions

#can_perform_action?, #can_perform_actions, #current_user_roles, #has_any_perm?, #has_marty_permissions

Instance Method Details

#configure(c) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/components/marty/report_select.rb', line 26

def configure(c)
  super

  c.items =
    [
     :tag_grid,
     :script_grid,
     fieldset(I18n.t("reporting.report_select"),
              {
                xtype:        :netzkeremotecombo,
                name:         "nodename",
                attr_type:    :string,
                virtual:      true,
                hide_label:   true,
                width:        200,
              },
              {},
              ),
    ]
  c.bbar = []
end

#node_listObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'app/components/marty/report_select.rb', line 100

def node_list
  sset = Marty::ScriptSet.new root_sess[:selected_tag_id]
  engine = sset.get_engine(root_sess[:selected_script_name])

  return [] unless engine

  nodes = engine.enumerate_nodes.select { |n|
    attrs = Set.new(engine.enumerate_attrs_by_node(n))
    attrs.superset? REPORT_ATTR_SET
  }

  nodes.map { |node|
    roles = engine.evaluate(node, "roles") rescue nil
    next if roles && !roles.any?{ |r| Marty::User.has_role(r) }

    begin
      title, format = engine.evaluate(node, ["title", "format"])
      format ? [node, "#{title} (#{format})"] : nil
    rescue
      [node, node]
    end
  }.compact.sort{ |a,b| a[1] <=> b[1]}
end