2019-08-07 12:17:35 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Base class for embed services. Contains a few basic helper
|
|
|
|
# methods that the embed services share.
|
|
|
|
module Metrics
|
|
|
|
module Dashboard
|
|
|
|
class BaseEmbedService < ::Metrics::Dashboard::BaseService
|
2020-03-04 19:07:49 -05:00
|
|
|
def self.embedded?(embed_param)
|
|
|
|
ActiveModel::Type::Boolean.new.cast(embed_param)
|
|
|
|
end
|
|
|
|
|
2019-08-07 12:17:35 -04:00
|
|
|
def cache_key
|
|
|
|
"dynamic_metrics_dashboard_#{identifiers}"
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def dashboard_path
|
|
|
|
params[:dashboard_path].presence ||
|
2019-11-27 07:06:30 -05:00
|
|
|
::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH
|
2019-08-07 12:17:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def group
|
|
|
|
params[:group]
|
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
params[:title]
|
|
|
|
end
|
|
|
|
|
|
|
|
def y_label
|
|
|
|
params[:y_label]
|
|
|
|
end
|
|
|
|
|
|
|
|
def identifiers
|
|
|
|
[dashboard_path, group, title, y_label].join('|')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|