forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
From ManageIQ#19863 Related to: ManageIQ#19674 (missing ReportFormatter for backend workers) ManageIQ#19863 (move code from UI-classic that can be called from either the frontend or backend)
- Loading branch information
Showing
26 changed files
with
1,414 additions
and
1,298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# If code uses the old constant name: | ||
# * Rails will autoload it and start here. | ||
# * We assign the old toplevel constant to the new constant. | ||
# * We can't include rails deprecate_constant globally, so we use ruby's. | ||
Charting = ManageIQ::Reporting::Charting | ||
Object.deprecate_constant :Charting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,96 @@ | ||
class C3Charting < Charting | ||
# for Charting.detect_available_plugin | ||
def self.available? | ||
true | ||
end | ||
module ManageIQ | ||
module Reporting | ||
class C3Charting < ManageIQ::Reporting::Charting | ||
# for Charting.detect_available_plugin | ||
def self.available? | ||
true | ||
end | ||
|
||
# for Charting.detect_available_plugin | ||
def self.priority | ||
1000 | ||
end | ||
# for Charting.detect_available_plugin | ||
def self.priority | ||
1000 | ||
end | ||
|
||
# backend identifier | ||
def backend | ||
:c3 | ||
end | ||
# backend identifier | ||
def backend | ||
:c3 | ||
end | ||
|
||
# format for rails' render | ||
def render_format | ||
:json | ||
end | ||
# format for rails' render | ||
def render_format | ||
:json | ||
end | ||
|
||
# formatter for Rupport::Controller#render - see lib/report_formatter/... | ||
def format | ||
:c3 | ||
end | ||
# formatter for Rupport::Controller#render - see lib/report_formatter/... | ||
def format | ||
:c3 | ||
end | ||
|
||
# called from each ApplicationController instance | ||
def load_helpers(klass) | ||
klass.instance_eval do | ||
helper C3Helper | ||
end | ||
end | ||
# called from each ApplicationController instance | ||
def load_helpers(klass) | ||
klass.instance_eval do | ||
helper ManageIQ::Reporting::Formatter::C3Helper | ||
end | ||
end | ||
|
||
def data_ok?(data) | ||
obj = YAML.load(data) | ||
!!obj && obj.kind_of?(Hash) && !obj[:options] | ||
rescue Psych::SyntaxError, ArgumentError | ||
false | ||
end | ||
def data_ok?(data) | ||
obj = YAML.load(data) | ||
!!obj && obj.kind_of?(Hash) && !obj[:options] | ||
rescue Psych::SyntaxError, ArgumentError | ||
false | ||
end | ||
|
||
def sample_chart(_options, _report_theme) | ||
sample = { | ||
:data => { | ||
:axis => {}, | ||
:tooltip => {}, | ||
:columns => [ | ||
['data1', 30, 200, 100, 400, 150, 250], | ||
['data2', 50, 20, 10, 40, 15, 25], | ||
['data3', 10, 25, 10, 250, 10, 30] | ||
], | ||
}, | ||
:miqChart => _options[:graph_type], | ||
:miq => { :zoomed => false } | ||
} | ||
sample[:data][:groups] = [['data1','data2', 'data3']] if _options[:graph_type].include? 'Stacked' | ||
sample | ||
end | ||
def sample_chart(_options, _report_theme) | ||
sample = { | ||
:data => { | ||
:axis => {}, | ||
:tooltip => {}, | ||
:columns => [ | ||
['data1', 30, 200, 100, 400, 150, 250], | ||
['data2', 50, 20, 10, 40, 15, 25], | ||
['data3', 10, 25, 10, 250, 10, 30] | ||
], | ||
}, | ||
:miqChart => _options[:graph_type], | ||
:miq => { :zoomed => false } | ||
} | ||
sample[:data][:groups] = [['data1','data2', 'data3']] if _options[:graph_type].include? 'Stacked' | ||
sample | ||
end | ||
|
||
def js_load_statement(delayed = false) | ||
delayed ? 'setTimeout(function(){ load_c3_charts(); }, 100);' : 'load_c3_charts();' | ||
end | ||
def js_load_statement(delayed = false) | ||
delayed ? 'setTimeout(function(){ load_c3_charts(); }, 100);' : 'load_c3_charts();' | ||
end | ||
|
||
# list of available chart types - in options_for_select format | ||
def chart_names_for_select | ||
CHART_NAMES | ||
end | ||
# list of available chart types - in options_for_select format | ||
def chart_names_for_select | ||
CHART_NAMES | ||
end | ||
|
||
# list of themes - in options_for_select format | ||
def chart_themes_for_select | ||
[%w(Default default)] | ||
end | ||
# list of themes - in options_for_select format | ||
def chart_themes_for_select | ||
[%w(Default default)] | ||
end | ||
|
||
def serialized(data) | ||
data.try(:to_yaml) | ||
end | ||
def serialized(data) | ||
data.try(:to_yaml) | ||
end | ||
|
||
def deserialized(data) | ||
YAML.load(data) | ||
end | ||
def deserialized(data) | ||
YAML.load(data) | ||
end | ||
|
||
CHART_NAMES = [ | ||
["Bars (2D)", "Bar"], | ||
["Bars, Stacked (2D)", "StackedBar"], | ||
["Columns (2D)", "Column"], | ||
["Columns, Stacked (2D)", "StackedColumn"], | ||
["Donut (2D)", "Donut"], | ||
["Pie (2D)", "Pie"], | ||
["Line (2D)", "Line"], | ||
["Area (2D)", "Area"], | ||
["Area, Stacked (2D)", "StackedArea"], | ||
] | ||
CHART_NAMES = [ | ||
["Bars (2D)", "Bar"], | ||
["Bars, Stacked (2D)", "StackedBar"], | ||
["Columns (2D)", "Column"], | ||
["Columns, Stacked (2D)", "StackedColumn"], | ||
["Donut (2D)", "Donut"], | ||
["Pie (2D)", "Pie"], | ||
["Line (2D)", "Line"], | ||
["Area (2D)", "Area"], | ||
["Area, Stacked (2D)", "StackedArea"], | ||
] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,39 @@ | ||
include ActionView::Helpers::NumberHelper | ||
|
||
require 'report_formatter/report_renderer' | ||
require 'report_formatter/c3' | ||
require 'report_formatter/converter' | ||
require 'report_formatter/html' | ||
require 'report_formatter/text' | ||
require 'report_formatter/timeline' | ||
require_dependency 'manageiq/reporting/formatter/report_renderer' | ||
require_dependency 'manageiq/reporting/formatter/c3' | ||
require_dependency 'manageiq/reporting/formatter/converter' | ||
require_dependency 'manageiq/reporting/formatter/html' | ||
require_dependency 'manageiq/reporting/formatter/text' | ||
require_dependency 'manageiq/reporting/formatter/timeline' | ||
|
||
module ManageIQ | ||
module Reporting | ||
module Formatter | ||
BLANK_VALUE = "Unknown" # Chart constant for nil or blank key values | ||
CRLF = "\r\n" | ||
LEGEND_LENGTH = 11 # Top legend text limit | ||
LABEL_LENGTH = 21 # Chart label text limit | ||
end | ||
end | ||
end | ||
|
||
# Deprecate the constants within ReportFormatter with a helpful replacement. | ||
module ReportFormatter | ||
BLANK_VALUE = "Unknown" # Chart constant for nil or blank key values | ||
CRLF = "\r\n" | ||
LEGEND_LENGTH = 11 # Top legend text limit | ||
LABEL_LENGTH = 21 # Chart label text limit | ||
include ActiveSupport::Deprecation::DeprecatedConstantAccessor | ||
deprecate_constant 'BLANK_VALUE', 'ManageIQ::Reporting::Formatter::BLANK_VALUE' | ||
deprecate_constant 'CRLF', 'ManageIQ::Reporting::Formatter::CRLF' | ||
deprecate_constant 'LABEL_LENGTH', 'ManageIQ::Reporting::Formatter::LABEL_LENGTH' | ||
deprecate_constant 'LEGEND_LENGTH', 'ManageIQ::Reporting::Formatter::LEGEND_LENGTH' | ||
|
||
deprecate_constant 'C3Formatter', 'ManageIQ::Reporting::Formatter::C3' | ||
deprecate_constant 'C3Series', 'ManageIQ::Reporting::Formatter::C3Series' | ||
deprecate_constant 'C3Charting', 'ManageIQ::Reporting::Formatter::C3Charting' | ||
deprecate_constant 'ChartCommon', 'ManageIQ::Reporting::Formatter::ChartCommon' | ||
deprecate_constant 'Converter', 'ManageIQ::Reporting::Formatter::Converter' | ||
deprecate_constant 'ReportHTML', 'ManageIQ::Reporting::Formatter::HTML' | ||
deprecate_constant 'ReportRenderer', 'ManageIQ::Reporting::Formatter::ReportRenderer' | ||
deprecate_constant 'ReportText', 'ManageIQ::Reporting::Formatter::Text' | ||
deprecate_constant 'ReportTimeline', 'ManageIQ::Reporting::Formatter::Timeline' | ||
deprecate_constant 'TimelineMessage', 'ManageIQ::Reporting::Formatter::TimelineMessage' | ||
end |
Oops, something went wrong.