Class: ForestAdminAgent::Routes::Charts::ApiChartDatasource
Instance Method Summary
collapse
#build, #format_attributes, #redacted_full_projection, #redacted_projection_with_pks
#add_route, #build, #routes
Constructor Details
Returns a new instance of ApiChartDatasource.
8
9
10
11
12
|
# File 'lib/forest_admin_agent/routes/charts/api_chart_datasource.rb', line 8
def initialize(chart_name)
@chart_name = chart_name
super()
end
|
Instance Method Details
#handle_api_chart(args = {}) ⇒ Object
#handle_smart_chart(args = {}) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/forest_admin_agent/routes/charts/api_chart_datasource.rb', line 54
def handle_smart_chart(args = {})
context = build(args)
parameters = Utils::QueryStringParser.parse_chart_parameters(args)
{
content: context.datasource.render_chart(
context.caller,
@chart_name,
parameters
)
}
end
|
#setup_routes ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/forest_admin_agent/routes/charts/api_chart_datasource.rb', line 14
def setup_routes
slug = @chart_name.parameterize
add_route(
"forest_chart_get_#{slug}",
'get',
"/_charts/#{slug}",
proc { |args| handle_smart_chart(args) }
)
add_route(
"forest_chart_post_#{slug}",
'post',
"/_charts/#{slug}",
proc { |args| handle_api_chart(args) }
)
unless Facades::Container.cache(:is_production)
Facades::Container.logger.log('Debug', "Chart #{@chart_name} was mounted at /forest/_charts/#{slug}")
end
self
end
|