From 353f5464807048e2ea1064d8a032644c11a0cb8f Mon Sep 17 00:00:00 2001 From: loganhz Date: Sat, 16 Feb 2019 14:21:50 +0800 Subject: [PATCH] Support enable project monitoring only https://github.com/rancher/rancher/issues/18204 --- app/components/container/new-edit/template.hbs | 2 +- app/instance-initializers/nav.js | 3 --- .../addon/components/enable-monitoring/template.hbs | 10 +++++++++- lib/monitoring/translations/en-us.yaml | 5 ++++- lib/monitoring/translations/zh-hans.yaml | 5 ++++- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/components/container/new-edit/template.hbs b/app/components/container/new-edit/template.hbs index 5cbb81896..f48573afd 100644 --- a/app/components/container/new-edit/template.hbs +++ b/app/components/container/new-edit/template.hbs @@ -251,7 +251,7 @@ }} {{#unless isSidekick}} - {{#if scope.currentCluster.enableClusterMonitoring}} + {{#if scope.currentProject.enableProjectMonitoring}} {{container/form-custom-metrics classNames="accordion-wrapper" workload=service diff --git a/app/instance-initializers/nav.js b/app/instance-initializers/nav.js index 724363061..23db97c17 100644 --- a/app/instance-initializers/nav.js +++ b/app/instance-initializers/nav.js @@ -126,9 +126,6 @@ const rootNav = [ resourceScope: 'global', resource: [], ctx: [getProjectId], - condition() { - return get(this, 'cluster.enableClusterMonitoring') - } }, { id: 'tools-pipeline', diff --git a/lib/monitoring/addon/components/enable-monitoring/template.hbs b/lib/monitoring/addon/components/enable-monitoring/template.hbs index 07e4f34ec..1368d66ba 100644 --- a/lib/monitoring/addon/components/enable-monitoring/template.hbs +++ b/lib/monitoring/addon/components/enable-monitoring/template.hbs @@ -15,6 +15,14 @@ +{{#if (and (eq selected "prometheus") scope.currentProject.enableProjectMonitoring (not scope.currentCluster.enableClusterMonitoring))}} + {{#banner-message color="bg-warning"}} +

+ {{t "monitoringPage.clusterNotEnabled"}} +

+ {{/banner-message}} +{{/if}} + {{#banner-message color="bg-info"}}

{{#if (eq selected "none")}} @@ -24,7 +32,7 @@ {{t (concat "monitoringPage." level ".disabled")}} {{/if}} {{else if (eq selected "prometheus")}} - {{t (if enabled "monitoringPage.toUpdate" "monitoringPage.prometheus")}} + {{t (if enabled (concat "monitoringPage.toUpdate." level) "monitoringPage.prometheus")}} {{/if}}

{{/banner-message}} diff --git a/lib/monitoring/translations/en-us.yaml b/lib/monitoring/translations/en-us.yaml index f7c9aecfd..9fe50eb35 100644 --- a/lib/monitoring/translations/en-us.yaml +++ b/lib/monitoring/translations/en-us.yaml @@ -87,7 +87,10 @@ clusterDashboard: monitoringPage: update: Update configuration - toUpdate: Monitoring is enabled. + toUpdate: + cluster: Cluster level monitoring is enabled. + project: Project level monitoring is enabled. + clusterNotEnabled: Cluster level monitoring is not enabled. Only custom metrics will be collected. prometheus: Monitoring is not enabled yet, click the Save button below to enable it. config: types: diff --git a/lib/monitoring/translations/zh-hans.yaml b/lib/monitoring/translations/zh-hans.yaml index a052a15f8..ab058f906 100644 --- a/lib/monitoring/translations/zh-hans.yaml +++ b/lib/monitoring/translations/zh-hans.yaml @@ -80,7 +80,10 @@ clusterDashboard: monitoringPage: update: 更新监控配置 - toUpdate: 监控已启用。 + toUpdate: + cluster: 集群级别监控已启用。 + project: 项目级别监控已启用。 + clusterNotEnabled: 集群级别监控未启用。将只采集自定义指标。 prometheus: 监控尚未启用,点击下面的保存按钮去启用监控。 config: header: Prometheus配置