summaryrefslogtreecommitdiff
path: root/app/helpers/custom_metrics_helper.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 12:09:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 12:09:34 +0000
commit903ccf7c93eb9490c76857bffe744249cc07de09 (patch)
tree603a3162e91999160e4efc74f351f9405f422d61 /app/helpers/custom_metrics_helper.rb
parent41cb558299b483b44b45351730ee4c0e9fe4ca2c (diff)
downloadgitlab-ce-903ccf7c93eb9490c76857bffe744249cc07de09.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers/custom_metrics_helper.rb')
-rw-r--r--app/helpers/custom_metrics_helper.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/helpers/custom_metrics_helper.rb b/app/helpers/custom_metrics_helper.rb
new file mode 100644
index 00000000000..fbea6d2050f
--- /dev/null
+++ b/app/helpers/custom_metrics_helper.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module CustomMetricsHelper
+ def custom_metrics_data(project, metric)
+ custom_metrics_path = project.namespace.becomes(::Namespace)
+
+ {
+ 'custom-metrics-path' => url_for([custom_metrics_path, project, metric]),
+ 'metric-persisted' => metric.persisted?.to_s,
+ 'edit-project-service-path' => edit_project_service_path(project, PrometheusService),
+ 'validate-query-path' => validate_query_project_prometheus_metrics_path(project),
+ 'title' => metric.title.to_s,
+ 'query' => metric.query.to_s,
+ 'y-label' => metric.y_label.to_s,
+ 'unit' => metric.unit.to_s,
+ 'group' => metric.group.to_s,
+ 'legend' => metric.legend.to_s
+ }
+ end
+end