forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree_builder_chargeback_reports.rb
50 lines (44 loc) · 1.45 KB
/
tree_builder_chargeback_reports.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
class TreeBuilderChargebackReports < TreeBuilder
private
def tree_init_options(_tree_name)
{:full_ids => true, :leaf => "MiqReportResult"}
end
def set_locals_for_render
locals = super
locals.merge!(:autoload => true)
end
def root_options
{
:text => t = _("Saved Chargeback Reports"),
:tooltip => t
}
end
# Get root nodes count/array for explorer tree
def x_get_tree_roots(count_only, _options)
items = MiqReportResult.with_saved_chargeback_reports
.select_distinct_results
.group("miq_report_results.miq_report_id, miq_reports.name, miq_report_results.id, \
miq_reports.id")
if count_only
items.length
else
objects = []
items.each_with_index do |item, idx|
objects.push(
:id => "#{item.miq_report_id}-#{idx}",
:text => item.miq_report.name,
:icon => "fa fa-file-text-o",
:tip => item.name
)
end
objects
end
end
# Handle custom tree nodes (object is a Hash)
def x_get_tree_custom_kids(object, count_only, _options)
objects = MiqReportResult.with_saved_chargeback_reports(object[:id].split('-').first)
.select(:id, :miq_report_id, :name, :last_run_on, :miq_task_id)
.order(:last_run_on => :desc)
count_only_or_objects(count_only, objects, "name")
end
end