Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
6f7b6ba0
Commit
6f7b6ba0
authored
Jun 06, 2019
by
Sarah Yasonik
Committed by
Phil Hughes
Jun 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the selected time window for metrics dashboard
parent
3e07725f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
20 deletions
+57
-20
app/assets/javascripts/monitoring/components/dashboard.vue
app/assets/javascripts/monitoring/components/dashboard.vue
+1
-1
changelogs/unreleased/fix-time-window-default.yml
changelogs/unreleased/fix-time-window-default.yml
+5
-0
spec/javascripts/monitoring/dashboard_spec.js
spec/javascripts/monitoring/dashboard_spec.js
+51
-19
No files found.
app/assets/javascripts/monitoring/components/dashboard.vue
View file @
6f7b6ba0
...
...
@@ -172,7 +172,7 @@ export default {
if
(
!
this
.
hasMetrics
)
{
this
.
setGettingStartedEmptyState
();
}
else
{
this
.
fetchData
(
getTimeDiff
(
this
.
timeWindows
.
eightHours
));
this
.
fetchData
(
getTimeDiff
(
this
.
selectedTimeWindow
));
sidebarMutationObserver
=
new
MutationObserver
(
this
.
onSidebarMutation
);
sidebarMutationObserver
.
observe
(
document
.
querySelector
(
'
.layout-page
'
),
{
...
...
changelogs/unreleased/fix-time-window-default.yml
0 → 100644
View file @
6f7b6ba0
---
title
:
Use the selected time window for metrics dashboard
merge_request
:
29152
author
:
type
:
fixed
spec/javascripts/monitoring/dashboard_spec.js
View file @
6f7b6ba0
...
...
@@ -38,6 +38,7 @@ describe('Dashboard', () => {
let
DashboardComponent
;
let
mock
;
let
store
;
let
component
;
beforeEach
(()
=>
{
setFixtures
(
`
...
...
@@ -59,12 +60,13 @@ describe('Dashboard', () => {
});
afterEach
(()
=>
{
component
.
$destroy
();
mock
.
restore
();
});
describe
(
'
no metrics are available yet
'
,
()
=>
{
it
(
'
shows a getting started empty state when no metrics are present
'
,
()
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
showTimeWindowDropdown
:
false
},
store
,
...
...
@@ -81,7 +83,7 @@ describe('Dashboard', () => {
});
it
(
'
shows up a loading state
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showTimeWindowDropdown
:
false
},
store
,
...
...
@@ -94,7 +96,7 @@ describe('Dashboard', () => {
});
it
(
'
hides the legend when showLegend is false
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
...
...
@@ -114,7 +116,7 @@ describe('Dashboard', () => {
});
it
(
'
hides the group panels when showPanels is false
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
...
...
@@ -134,7 +136,7 @@ describe('Dashboard', () => {
});
it
(
'
renders the environments dropdown with a number of environments
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
...
...
@@ -165,7 +167,7 @@ describe('Dashboard', () => {
});
it
(
'
hides the environments dropdown list when there is no environments
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
...
...
@@ -195,7 +197,7 @@ describe('Dashboard', () => {
});
it
(
'
renders the environments dropdown with a single active element
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
...
...
@@ -228,7 +230,7 @@ describe('Dashboard', () => {
});
it
(
'
hides the dropdown
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
...
...
@@ -249,7 +251,7 @@ describe('Dashboard', () => {
});
it
(
'
does not show the time window dropdown when the feature flag is not set
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
...
...
@@ -270,7 +272,7 @@ describe('Dashboard', () => {
});
it
(
'
renders the time window dropdown with a set of options
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
...
...
@@ -295,10 +297,46 @@ describe('Dashboard', () => {
});
});
it
(
'
fetches the metrics data with proper time window
'
,
done
=>
{
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showPanels
:
false
,
showTimeWindowDropdown
:
true
,
},
store
,
});
spyOn
(
component
.
$store
,
'
dispatch
'
).
and
.
stub
();
const
getTimeDiffSpy
=
spyOnDependency
(
Dashboard
,
'
getTimeDiff
'
);
component
.
$store
.
commit
(
`monitoringDashboard/
${
types
.
SET_ENVIRONMENTS_ENDPOINT
}
`
,
'
/environments
'
,
);
component
.
$store
.
commit
(
`monitoringDashboard/
${
types
.
RECEIVE_ENVIRONMENTS_DATA_SUCCESS
}
`
,
environmentData
,
);
component
.
$mount
();
Vue
.
nextTick
()
.
then
(()
=>
{
expect
(
component
.
$store
.
dispatch
).
toHaveBeenCalled
();
expect
(
getTimeDiffSpy
).
toHaveBeenCalledWith
(
component
.
selectedTimeWindow
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
shows a specific time window selected from the url params
'
,
done
=>
{
spyOnDependency
(
Dashboard
,
'
getParameterValues
'
).
and
.
returnValue
([
'
thirtyMinutes
'
]);
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showTimeWindowDropdown
:
true
},
store
,
...
...
@@ -319,7 +357,7 @@ describe('Dashboard', () => {
'
<script>alert("XSS")</script>
'
,
]);
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showTimeWindowDropdown
:
true
},
store
,
...
...
@@ -344,7 +382,7 @@ describe('Dashboard', () => {
});
it
(
'
sets elWidth to page width when the sidebar is resized
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
...
...
@@ -374,16 +412,10 @@ describe('Dashboard', () => {
});
describe
(
'
external dashboard link
'
,
()
=>
{
let
component
;
beforeEach
(()
=>
{
mock
.
onGet
(
mockApiEndpoint
).
reply
(
200
,
metricsGroupsAPIResponse
);
});
afterEach
(()
=>
{
component
.
$destroy
();
});
describe
(
'
with feature flag enabled
'
,
()
=>
{
beforeEach
(()
=>
{
component
=
new
DashboardComponent
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment