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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
648c3e38
Commit
648c3e38
authored
Sep 26, 2018
by
Jose Ivan Vargas
Committed by
Mike Greiling
Sep 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE - Fix monitoring dashboard not working properly
parent
372b4654
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
47 deletions
+66
-47
app/assets/javascripts/monitoring/components/dashboard.vue
app/assets/javascripts/monitoring/components/dashboard.vue
+20
-15
app/assets/javascripts/monitoring/components/graph.vue
app/assets/javascripts/monitoring/components/graph.vue
+0
-13
changelogs/unreleased/jivl-fix-monitoring-dashboard-resizing-navbar.yml
...eleased/jivl-fix-monitoring-dashboard-resizing-navbar.yml
+5
-0
spec/javascripts/monitoring/dashboard_spec.js
spec/javascripts/monitoring/dashboard_spec.js
+41
-1
spec/javascripts/monitoring/graph_spec.js
spec/javascripts/monitoring/graph_spec.js
+0
-18
No files found.
app/assets/javascripts/monitoring/components/dashboard.vue
View file @
648c3e38
...
...
@@ -109,28 +109,35 @@ export default {
store
:
new
MonitoringStore
(),
state
:
'
gettingStarted
'
,
showEmptyState
:
true
,
updateAspectRatio
:
false
,
updatedAspectRatios
:
0
,
hoverData
:
{},
resizeThrottled
:
{}
,
elWidth
:
0
,
};
},
computed
:
{
forceRedraw
()
{
return
this
.
elWidth
;
},
},
created
()
{
this
.
service
=
new
MonitoringService
({
metricsEndpoint
:
this
.
metricsEndpoint
,
deploymentEndpoint
:
this
.
deploymentEndpoint
,
environmentsEndpoint
:
this
.
environmentsEndpoint
,
});
eventHub
.
$on
(
'
toggleAspectRatio
'
,
this
.
toggleAspectRatio
);
this
.
mutationObserverConfig
=
{
attributes
:
true
,
childList
:
false
,
subtree
:
false
,
};
eventHub
.
$on
(
'
hoverChanged
'
,
this
.
hoverChanged
);
},
beforeDestroy
()
{
eventHub
.
$off
(
'
toggleAspectRatio
'
,
this
.
toggleAspectRatio
);
eventHub
.
$off
(
'
hoverChanged
'
,
this
.
hoverChanged
);
window
.
removeEventListener
(
'
resize
'
,
this
.
resizeThrottled
,
false
);
this
.
sidebarMutationObserver
.
disconnect
();
},
mounted
()
{
this
.
resizeThrottled
=
_
.
throttle
(
this
.
resize
,
6
00
);
this
.
resizeThrottled
=
_
.
debounce
(
this
.
resize
,
1
00
);
this
.
servicePromises
=
[
this
.
service
.
getGraphsData
()
...
...
@@ -152,6 +159,11 @@ export default {
}
this
.
getGraphsData
();
window
.
addEventListener
(
'
resize
'
,
this
.
resizeThrottled
,
false
);
const
sidebarEl
=
document
.
querySelector
(
'
.nav-sidebar
'
);
// The sidebar listener
this
.
sidebarMutationObserver
=
new
MutationObserver
(
this
.
resizeThrottled
);
this
.
sidebarMutationObserver
.
observe
(
sidebarEl
,
this
.
mutationObserverConfig
);
}
},
methods
:
{
...
...
@@ -171,14 +183,7 @@ export default {
});
},
resize
()
{
this
.
updateAspectRatio
=
true
;
},
toggleAspectRatio
()
{
this
.
updatedAspectRatios
+=
1
;
if
(
this
.
store
.
getMetricsCount
()
===
this
.
updatedAspectRatios
)
{
this
.
updateAspectRatio
=
!
this
.
updateAspectRatio
;
this
.
updatedAspectRatios
=
0
;
}
this
.
elWidth
=
this
.
$el
.
clientWidth
;
},
hoverChanged
(
data
)
{
this
.
hoverData
=
data
;
...
...
@@ -190,6 +195,7 @@ export default {
<
template
>
<div
v-if=
"!showEmptyState"
:key=
"updateDashboardKey"
class=
"prometheus-graphs prepend-top-default"
>
<div
...
...
@@ -239,7 +245,6 @@ export default {
:key=
"graphIndex"
:graph-data=
"graphData"
:hover-data=
"hoverData"
:update-aspect-ratio=
"updateAspectRatio"
:deployment-data=
"store.deploymentData"
:project-path=
"projectPath"
:tags-path=
"tagsPath"
...
...
app/assets/javascripts/monitoring/components/graph.vue
View file @
648c3e38
...
...
@@ -32,10 +32,6 @@ export default {
type
:
Object
,
required
:
true
,
},
updateAspectRatio
:
{
type
:
Boolean
,
required
:
true
,
},
deploymentData
:
{
type
:
Array
,
required
:
true
,
...
...
@@ -110,15 +106,6 @@ export default {
},
},
watch
:
{
updateAspectRatio
()
{
if
(
this
.
updateAspectRatio
)
{
this
.
graphHeight
=
450
;
this
.
graphWidth
=
600
;
this
.
measurements
=
measurements
.
large
;
this
.
draw
();
eventHub
.
$emit
(
'
toggleAspectRatio
'
);
}
},
hoverData
()
{
this
.
positionFlag
();
},
...
...
changelogs/unreleased/jivl-fix-monitoring-dashboard-resizing-navbar.yml
0 → 100644
View file @
648c3e38
---
title
:
Fix resizing of monitoring dashboard
merge_request
:
21730
author
:
type
:
fixed
spec/javascripts/monitoring/dashboard_spec.js
View file @
648c3e38
...
...
@@ -25,7 +25,10 @@ describe('Dashboard', () => {
};
beforeEach
(()
=>
{
setFixtures
(
'
<div class="prometheus-graphs"></div>
'
);
setFixtures
(
`
<div class="prometheus-graphs"></div>
<div class="nav-sidebar"></div>
`
);
DashboardComponent
=
Vue
.
extend
(
Dashboard
);
});
...
...
@@ -145,4 +148,41 @@ describe('Dashboard', () => {
});
});
});
describe
(
'
when the window resizes
'
,
()
=>
{
let
mock
;
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
mockApiEndpoint
).
reply
(
200
,
metricsGroupsAPIResponse
);
jasmine
.
clock
().
install
();
});
afterEach
(()
=>
{
mock
.
restore
();
jasmine
.
clock
().
uninstall
();
});
it
(
'
rerenders the dashboard when the sidebar is resized
'
,
done
=>
{
const
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showPanels
:
false
},
});
expect
(
component
.
forceRedraw
).
toEqual
(
0
);
const
navSidebarEl
=
document
.
querySelector
(
'
.nav-sidebar
'
);
navSidebarEl
.
classList
.
add
(
'
nav-sidebar-collapsed
'
);
Vue
.
nextTick
()
.
then
(()
=>
{
jasmine
.
clock
().
tick
(
1000
);
return
Vue
.
nextTick
();
})
.
then
(()
=>
{
expect
(
component
.
forceRedraw
).
toEqual
(
component
.
elWidth
);
done
();
})
.
catch
(
done
.
fail
);
});
});
});
spec/javascripts/monitoring/graph_spec.js
View file @
648c3e38
import
Vue
from
'
vue
'
;
import
Graph
from
'
~/monitoring/components/graph.vue
'
;
import
MonitoringMixins
from
'
~/monitoring/mixins/monitoring_mixins
'
;
import
eventHub
from
'
~/monitoring/event_hub
'
;
import
{
deploymentData
,
convertDatesMultipleSeries
,
...
...
@@ -69,23 +68,6 @@ describe('Graph', () => {
});
});
it
(
'
sends an event to the eventhub when it has finished resizing
'
,
done
=>
{
const
component
=
createComponent
({
graphData
:
convertedMetrics
[
1
],
updateAspectRatio
:
false
,
deploymentData
,
tagsPath
,
projectPath
,
});
spyOn
(
eventHub
,
'
$emit
'
);
component
.
updateAspectRatio
=
true
;
Vue
.
nextTick
(()
=>
{
expect
(
eventHub
.
$emit
).
toHaveBeenCalled
();
done
();
});
});
it
(
'
has a title for the y-axis and the chart legend that comes from the backend
'
,
()
=>
{
const
component
=
createComponent
({
graphData
:
convertedMetrics
[
1
],
...
...
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