diff options
author | Jose Vargas <jvargas@gitlab.com> | 2019-03-12 12:55:43 -0600 |
---|---|---|
committer | Jose Vargas <jvargas@gitlab.com> | 2019-04-04 14:53:03 -0600 |
commit | f77ff0c7bdc0b3a18406bf256dc5814833c14d23 (patch) | |
tree | 474df9d2cde526a65b013785b0649ba08750cca1 /app | |
parent | 1ddd9eff6dd931b0689743d571b7bf3fccedb979 (diff) | |
download | gitlab-ce-f77ff0c7bdc0b3a18406bf256dc5814833c14d23.tar.gz |
Add support for time windows for the performance dashbooards
The performance dashboards will now display the data
from a set amount of time windows that are defined
on a constants file
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/monitoring/components/dashboard.vue | 58 | ||||
-rw-r--r-- | app/assets/javascripts/monitoring/constants.js | 9 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/environments.scss | 2 |
3 files changed, 54 insertions, 15 deletions
diff --git a/app/assets/javascripts/monitoring/components/dashboard.vue b/app/assets/javascripts/monitoring/components/dashboard.vue index ba6a17827f7..917dc1b73b5 100644 --- a/app/assets/javascripts/monitoring/components/dashboard.vue +++ b/app/assets/javascripts/monitoring/components/dashboard.vue @@ -9,6 +9,7 @@ import MonitorAreaChart from './charts/area.vue'; import GraphGroup from './graph_group.vue'; import EmptyState from './empty_state.vue'; import MonitoringStore from '../stores/monitoring_store'; +import { timeWindows } from '../constants'; const sidebarAnimationDuration = 150; let sidebarMutationObserver; @@ -94,6 +95,7 @@ export default { state: 'gettingStarted', showEmptyState: true, elWidth: 0, + selectedTimeWindow: '', }; }, created() { @@ -102,6 +104,9 @@ export default { deploymentEndpoint: this.deploymentEndpoint, environmentsEndpoint: this.environmentsEndpoint, }); + + this.timeWindows = timeWindows; + this.selectedTimeWindow = this.timeWindows.eightHours; }, beforeDestroy() { if (sidebarMutationObserver) { @@ -160,11 +165,17 @@ export default { this.state = 'unableToConnect'; }); }, + getGraphsDataWithTime(timeFrame) { + this.selectedTimeWindow = this.timeWindows[timeFrame]; + }, onSidebarMutation() { setTimeout(() => { this.elWidth = this.$el.clientWidth; }, sidebarAnimationDuration); }, + activeTimeWindow(key) { + return this.timeWindows[key] === this.selectedTimeWindow; + }, }, }; </script> @@ -172,21 +183,40 @@ export default { <template> <div v-if="!showEmptyState" class="prometheus-graphs prepend-top-default"> <div v-if="environmentsEndpoint" class="environments d-flex align-items-center"> - <strong>{{ s__('Metrics|Environment') }}</strong> - <gl-dropdown - class="prepend-left-10 js-environments-dropdown" - toggle-class="dropdown-menu-toggle" - :text="currentEnvironmentName" - :disabled="store.environmentsData.length === 0" - > - <gl-dropdown-item - v-for="environment in store.environmentsData" - :key="environment.id" - :active="environment.name === currentEnvironmentName" - active-class="is-active" - >{{ environment.name }}</gl-dropdown-item + <div class="d-flex align-items-center"> + <strong>{{ s__('Metrics|Environment') }}</strong> + <gl-dropdown + class="prepend-left-10 js-environments-dropdown" + toggle-class="dropdown-menu-toggle" + :text="currentEnvironmentName" + :disabled="store.environmentsData.length === 0" + > + <gl-dropdown-item + v-for="environment in store.environmentsData" + :key="environment.id" + :active="environment.name === currentEnvironmentName" + active-class="is-active" + >{{ environment.name }}</gl-dropdown-item + > + </gl-dropdown> + </div> + <div class="d-flex align-items-center"> + <span class="font-weight-bold">{{ s__('Metrics|Show Last') }}</span> + <gl-dropdown + id="time-window-dropdown" + class="prepend-left-10" + toggle-class="dropdown-menu-toggle" + :text="selectedTimeWindow" > - </gl-dropdown> + <gl-dropdown-item + v-for="(value, key) in timeWindows" + :key="key" + :active="activeTimeWindow(key)" + @click="getGraphsDataWithTime(key)" + >{{ value }}</gl-dropdown-item + > + </gl-dropdown> + </div> </div> <graph-group v-for="(groupData, index) in store.groups" diff --git a/app/assets/javascripts/monitoring/constants.js b/app/assets/javascripts/monitoring/constants.js index 55ecf3b5334..afa10e683ab 100644 --- a/app/assets/javascripts/monitoring/constants.js +++ b/app/assets/javascripts/monitoring/constants.js @@ -7,3 +7,12 @@ export const graphTypes = { export const lineTypes = { default: 'solid', }; + +export const timeWindows = { + thirtyMinutes: '30 minutes', + threeHours: '3 hours', + eightHours: '8 hours', + oneDay: '1 day', + threeDays: '3 days', + oneWeek: '1 week', +}; diff --git a/app/assets/stylesheets/pages/environments.scss b/app/assets/stylesheets/pages/environments.scss index 0eb854ecf98..8e1ee51628d 100644 --- a/app/assets/stylesheets/pages/environments.scss +++ b/app/assets/stylesheets/pages/environments.scss @@ -204,7 +204,7 @@ } .prometheus-graphs { - .environments { + .dropdowns { .dropdown-menu-toggle { svg { position: absolute; |