Module: MetricsDashboard

Extended by:
ActiveSupport::Concern
Includes:
ChecksCollaboration, EnvironmentsHelper, RenderServiceResults
Included in:
Clusters::ClustersController, Projects::EnvironmentsController, Projects::GrafanaApiController, Projects::Prometheus::AlertsController
Defined in:
app/controllers/concerns/metrics_dashboard.rb

Overview

Provides an action which fetches a metrics dashboard according to the parameters specified by the controller.

Instance Method Summary collapse

Methods included from EnvironmentsHelper

#can_destroy_environment?, #custom_metrics_available?, #environment_logs_data, #environments_folder_list_view_data, #environments_list_data, #metrics_data

Methods included from ChecksCollaboration

#can_collaborate_with_project?, #user_access

Methods included from RenderServiceResults

#continue_polling_response, #error_response, #success_response

Instance Method Details

#metrics_dashboardObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/concerns/metrics_dashboard.rb', line 12

def metrics_dashboard
  result = dashboard_finder.find(
    project_for_dashboard,
    current_user,
    decoded_params
  )

  if result
    result[:all_dashboards] = all_dashboards if include_all_dashboards?
    result[:metrics_data] = metrics_data(project_for_dashboard, environment_for_dashboard)
  end

  respond_to do |format|
    if result.nil?
      format.json { continue_polling_response }
    elsif result[:status] == :success
      format.json { render dashboard_success_response(result) }
    else
      format.json { render dashboard_error_response(result) }
    end
  end
end