summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2019-02-06 09:41:59 +0000
committerPhil Hughes <me@iamphill.com>2019-02-06 09:41:59 +0000
commitcef60443c1010f35db87bbfb3bd1c8733d8880a1 (patch)
treed8f8e3b4745133ab86625590d10c92dfe6eebf7b
parent1c932a6113d7dd995b7cdcc7d16674415571e8df (diff)
parent7d92f4874193380774c26c0362c54636f0d1b0bf (diff)
downloadgitlab-ce-cef60443c1010f35db87bbfb3bd1c8733d8880a1.tar.gz
Merge branch 'adriel-add-metrics-chart-tooltips' into 'master'
Add metrics chart tooltips See merge request gitlab-org/gitlab-ce!24651
-rw-r--r--app/assets/javascripts/monitoring/components/charts/area.vue39
-rw-r--r--locale/gitlab.pot3
2 files changed, 39 insertions, 3 deletions
diff --git a/app/assets/javascripts/monitoring/components/charts/area.vue b/app/assets/javascripts/monitoring/components/charts/area.vue
index a0d6b91ff02..ec0e33a1927 100644
--- a/app/assets/javascripts/monitoring/components/charts/area.vue
+++ b/app/assets/javascripts/monitoring/components/charts/area.vue
@@ -3,12 +3,14 @@ import { GlAreaChart } from '@gitlab/ui/dist/charts';
import dateFormat from 'dateformat';
import { debounceByAnimationFrame } from '~/lib/utils/common_utils';
import { getSvgIconPathContent } from '~/lib/utils/icon_utils';
+import Icon from '~/vue_shared/components/icon.vue';
let debouncedResize;
export default {
components: {
GlAreaChart,
+ Icon,
},
inheritAttrs: false,
props: {
@@ -47,6 +49,12 @@ export default {
},
data() {
return {
+ tooltip: {
+ title: '',
+ content: '',
+ isDeployment: false,
+ sha: '',
+ },
width: 0,
height: 0,
scatterSymbol: undefined,
@@ -148,8 +156,17 @@ export default {
},
methods: {
formatTooltipText(params) {
- const [date, value] = params;
- return [dateFormat(date, 'dd mmm yyyy, h:MMtt'), value.toFixed(3)];
+ const [seriesData] = params.seriesData;
+ this.tooltip.isDeployment = seriesData.componentSubType === 'scatter';
+ this.tooltip.title = dateFormat(params.value, 'dd mmm yyyy, h:MMTT');
+ if (this.tooltip.isDeployment) {
+ const [deploy] = this.recentDeployments.filter(
+ deployment => deployment.createdAt === seriesData.value[0],
+ );
+ this.tooltip.sha = deploy.sha.substring(0, 8);
+ } else {
+ this.tooltip.content = `${this.yAxisLabel} ${seriesData.value[1].toFixed(3)}`;
+ }
},
getScatterSymbol() {
getSvgIconPathContent('rocket')
@@ -184,6 +201,22 @@ export default {
:thresholds="alertData"
:width="width"
:height="height"
- />
+ >
+ <template slot="tooltipTitle">
+ <div v-if="tooltip.isDeployment">
+ {{ __('Deployed') }}
+ </div>
+ {{ tooltip.title }}
+ </template>
+ <template slot="tooltipContent">
+ <div v-if="tooltip.isDeployment" class="d-flex align-items-center">
+ <icon name="commit" class="mr-2" />
+ {{ tooltip.sha }}
+ </div>
+ <template v-else>
+ {{ tooltip.content }}
+ </template>
+ </template>
+ </gl-area-chart>
</div>
</template>
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index d81ae2e728b..f2c0e96a9e1 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -2623,6 +2623,9 @@ msgstr ""
msgid "DeployTokens|Your new project deploy token has been created."
msgstr ""
+msgid "Deployed"
+msgstr ""
+
msgid "Deployed to"
msgstr ""