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
Léo-Paul Géneau
gitlab-ce
Commits
1dc051fb
Commit
1dc051fb
authored
Jan 08, 2018
by
Mike Greiling
Committed by
Tim Zallmann
Jan 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Add graph value to hover"
parent
78b044a1
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
364 additions
and
356 deletions
+364
-356
app/assets/javascripts/monitoring/components/graph.vue
app/assets/javascripts/monitoring/components/graph.vue
+28
-21
app/assets/javascripts/monitoring/components/graph/deployment.vue
...ts/javascripts/monitoring/components/graph/deployment.vue
+2
-127
app/assets/javascripts/monitoring/components/graph/flag.vue
app/assets/javascripts/monitoring/components/graph/flag.vue
+155
-50
app/assets/javascripts/monitoring/mixins/monitoring_mixins.js
...assets/javascripts/monitoring/mixins/monitoring_mixins.js
+4
-1
app/assets/javascripts/monitoring/utils/date_time_formatters.js
...sets/javascripts/monitoring/utils/date_time_formatters.js
+1
-1
app/assets/stylesheets/pages/environments.scss
app/assets/stylesheets/pages/environments.scss
+67
-0
changelogs/unreleased/38030-add-graph-value-to-hover.yml
changelogs/unreleased/38030-add-graph-value-to-hover.yml
+5
-0
spec/javascripts/monitoring/graph/deployment_spec.js
spec/javascripts/monitoring/graph/deployment_spec.js
+7
-137
spec/javascripts/monitoring/graph/flag_spec.js
spec/javascripts/monitoring/graph/flag_spec.js
+95
-19
No files found.
app/assets/javascripts/monitoring/components/graph.vue
View file @
1dc051fb
...
@@ -69,8 +69,8 @@
...
@@ -69,8 +69,8 @@
currentFlagPosition
:
0
,
currentFlagPosition
:
0
,
showFlag
:
false
,
showFlag
:
false
,
showFlagContent
:
false
,
showFlagContent
:
false
,
showDeployInfo
:
true
,
timeSeries
:
[],
timeSeries
:
[],
realPixelRatio
:
1
,
};
};
},
},
...
@@ -87,10 +87,7 @@
...
@@ -87,10 +87,7 @@
},
},
innerViewBox
()
{
innerViewBox
()
{
if
((
this
.
baseGraphWidth
-
150
)
>
0
)
{
return
`0 0
${
this
.
baseGraphWidth
-
150
}
${
this
.
baseGraphHeight
}
`
;
return
`0 0
${
this
.
baseGraphWidth
-
150
}
${
this
.
baseGraphHeight
}
`
;
}
return
'
0 0 0 0
'
;
},
},
axisTransform
()
{
axisTransform
()
{
...
@@ -102,6 +99,10 @@
...
@@ -102,6 +99,10 @@
paddingBottom
:
`
${(
Math
.
ceil
(
this
.
baseGraphHeight
*
100
)
/
this
.
baseGraphWidth
)
||
0
}
%`
,
paddingBottom
:
`
${(
Math
.
ceil
(
this
.
baseGraphHeight
*
100
)
/
this
.
baseGraphWidth
)
||
0
}
%`
,
};
};
},
},
deploymentFlagData
()
{
return
this
.
reducedDeploymentData
.
find
(
deployment
=>
deployment
.
showDeploymentFlag
);
},
},
},
methods
:
{
methods
:
{
...
@@ -122,6 +123,10 @@
...
@@ -122,6 +123,10 @@
this
.
graphHeight
=
this
.
graphHeight
-
this
.
margin
.
top
-
this
.
margin
.
bottom
;
this
.
graphHeight
=
this
.
graphHeight
-
this
.
margin
.
top
-
this
.
margin
.
bottom
;
this
.
baseGraphHeight
=
this
.
graphHeight
;
this
.
baseGraphHeight
=
this
.
graphHeight
;
this
.
baseGraphWidth
=
this
.
graphWidth
;
this
.
baseGraphWidth
=
this
.
graphWidth
;
// pixel offsets inside the svg and outside are not 1:1
this
.
realPixelRatio
=
(
this
.
$refs
.
baseSvg
.
clientWidth
/
this
.
baseGraphWidth
);
this
.
renderAxesPaths
();
this
.
renderAxesPaths
();
this
.
formatDeployments
();
this
.
formatDeployments
();
},
},
...
@@ -261,6 +266,11 @@
...
@@ -261,6 +266,11 @@
:line-color=
"path.lineColor"
:line-color=
"path.lineColor"
:area-color=
"path.areaColor"
:area-color=
"path.areaColor"
/>
/>
<graph-deployment
:deployment-data=
"reducedDeploymentData"
:graph-height=
"graphHeight"
:graph-height-offset=
"graphHeightOffset"
/>
<rect
<rect
class=
"prometheus-graph-overlay"
class=
"prometheus-graph-overlay"
:width=
"(graphWidth - 70)"
:width=
"(graphWidth - 70)"
...
@@ -269,24 +279,21 @@
...
@@ -269,24 +279,21 @@
ref=
"graphOverlay"
ref=
"graphOverlay"
@
mousemove=
"handleMouseOverGraph($event)"
>
@
mousemove=
"handleMouseOverGraph($event)"
>
</rect>
</rect>
<graph-deployment
</svg>
:show-deploy-info=
"showDeployInfo"
</svg>
:deployment-data=
"reducedDeploymentData"
:graph-width=
"graphWidth"
:graph-height=
"graphHeight"
:graph-height-offset=
"graphHeightOffset"
/>
<graph-flag
<graph-flag
v-if=
"showFlag
"
:real-pixel-ratio=
"realPixelRatio
"
:current-x-coordinate=
"currentXCoordinate"
:current-x-coordinate=
"currentXCoordinate"
:current-data=
"currentData"
:current-data=
"currentData"
:current-flag-position=
"currentFlagPosition"
:graph-height=
"graphHeight"
:graph-height=
"graphHeight"
:graph-height-offset=
"graphHeightOffset"
:graph-height-offset=
"graphHeightOffset"
:show-flag-content=
"showFlagContent"
:show-flag-content=
"showFlagContent"
:time-series=
"timeSeries"
:unit-of-display=
"unitOfDisplay"
:current-data-index=
"currentDataIndex"
:legend-title=
"legendTitle"
:deployment-flag-data=
"deploymentFlagData"
/>
/>
</svg>
</svg>
</div>
</div>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/monitoring/components/graph/deployment.vue
View file @
1dc051fb
<
script
>
<
script
>
import
{
dateFormatWithName
,
timeFormat
}
from
'
../../utils/date_time_formatters
'
;
import
Icon
from
'
../../../vue_shared/components/icon.vue
'
;
export
default
{
export
default
{
props
:
{
props
:
{
showDeployInfo
:
{
type
:
Boolean
,
required
:
true
,
},
deploymentData
:
{
deploymentData
:
{
type
:
Array
,
type
:
Array
,
required
:
true
,
required
:
true
,
...
@@ -20,14 +13,6 @@
...
@@ -20,14 +13,6 @@
type
:
Number
,
type
:
Number
,
required
:
true
,
required
:
true
,
},
},
graphWidth
:
{
type
:
Number
,
required
:
true
,
},
},
components
:
{
Icon
,
},
},
computed
:
{
computed
:
{
...
@@ -37,52 +22,17 @@
...
@@ -37,52 +22,17 @@
},
},
methods
:
{
methods
:
{
refText
(
d
)
{
return
d
.
tag
?
d
.
ref
:
d
.
sha
.
slice
(
0
,
8
);
},
formatTime
(
deploymentTime
)
{
return
timeFormat
(
deploymentTime
);
},
formatDate
(
deploymentTime
)
{
return
dateFormatWithName
(
deploymentTime
);
},
nameDeploymentClass
(
deployment
)
{
return
`deploy-info-
${
deployment
.
id
}
`
;
},
transformDeploymentGroup
(
deployment
)
{
transformDeploymentGroup
(
deployment
)
{
return
`translate(
${
Math
.
floor
(
deployment
.
xPos
)
+
1
}
, 20)`
;
return
`translate(
${
Math
.
floor
(
deployment
.
xPos
)
-
5
}
, 20)`
;
},
positionFlag
(
deployment
)
{
let
xPosition
=
3
;
if
(
deployment
.
xPos
>
(
this
.
graphWidth
-
225
))
{
xPosition
=
-
142
;
}
return
xPosition
;
},
svgContainerHeight
(
tag
)
{
let
svgHeight
=
80
;
if
(
!
tag
)
{
svgHeight
-=
20
;
}
return
svgHeight
;
},
},
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<g
<g
class=
"deploy-info"
>
class=
"deploy-info"
v-if=
"showDeployInfo"
>
<g
<g
v-for=
"(deployment, index) in deploymentData"
v-for=
"(deployment, index) in deploymentData"
:key=
"index"
:key=
"index"
:class=
"nameDeploymentClass(deployment)"
:transform=
"transformDeploymentGroup(deployment)"
>
:transform=
"transformDeploymentGroup(deployment)"
>
<rect
<rect
x=
"0"
x=
"0"
...
@@ -99,81 +49,6 @@
...
@@ -99,81 +49,6 @@
:y2=
"calculatedHeight"
:y2=
"calculatedHeight"
stroke=
"#000"
>
stroke=
"#000"
>
</line>
</line>
<svg
v-if=
"deployment.showDeploymentFlag"
class=
"js-deploy-info-box"
:x=
"positionFlag(deployment)"
y=
"0"
width=
"134"
:height=
"svgContainerHeight(deployment.tag)"
>
<rect
class=
"rect-text-metric deploy-info-rect rect-metric"
x=
"1"
y=
"1"
rx=
"2"
width=
"132"
:height=
"svgContainerHeight(deployment.tag) - 2"
>
</rect>
<text
class=
"deploy-info-text text-metric-bold"
transform=
"translate(5, 2)"
>
Deployed
</text>
<!--The date info-->
<g
transform=
"translate(5, 20)"
>
<text
class=
"deploy-info-text"
>
{{
formatDate
(
deployment
.
time
)
}}
</text>
<text
class=
"deploy-info-text text-metric-bold"
x=
"62"
>
{{
formatTime
(
deployment
.
time
)
}}
</text>
</g>
<line
class=
"divider-line"
x1=
"0"
y1=
"38"
x2=
"132"
:y2=
"38"
stroke=
"#000"
>
</line>
<!--Commit information-->
<g
transform=
"translate(5, 40)"
>
<icon
name=
"commit"
:width=
"12"
:height=
"12"
:y=
"3"
>
</icon>
<a
:xlink:href=
"deployment.commitUrl"
>
<text
class=
"deploy-info-text deploy-info-text-link"
transform=
"translate(20, 2)"
>
{{
refText
(
deployment
)
}}
</text>
</a>
</g>
<!--Tag information-->
<g
transform=
"translate(5, 55)"
v-if=
"deployment.tag"
>
<icon
name=
"label"
:width=
"12"
:height=
"12"
:y=
"5"
>
</icon>
<a
:xlink:href=
"deployment.tagUrl"
>
<text
class=
"deploy-info-text deploy-info-text-link"
transform=
"translate(20, 2)"
y=
"2"
>
{{
deployment
.
tag
}}
</text>
</a>
</g>
</svg>
</g>
</g>
<svg
<svg
height=
"0"
height=
"0"
...
...
app/assets/javascripts/monitoring/components/graph/flag.vue
View file @
1dc051fb
<
script
>
<
script
>
import
{
dateFormat
,
timeFormat
}
from
'
../../utils/date_time_formatters
'
;
import
{
dateFormat
,
timeFormat
}
from
'
../../utils/date_time_formatters
'
;
import
{
formatRelevantDigits
}
from
'
../../../lib/utils/number_utils
'
;
import
Icon
from
'
../../../vue_shared/components/icon.vue
'
;
export
default
{
export
default
{
props
:
{
props
:
{
...
@@ -7,14 +9,15 @@
...
@@ -7,14 +9,15 @@
type
:
Number
,
type
:
Number
,
required
:
true
,
required
:
true
,
},
},
currentFlagPosition
:
{
type
:
Number
,
required
:
true
,
},
currentData
:
{
currentData
:
{
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
deploymentFlagData
:
{
type
:
Object
,
required
:
false
,
default
:
null
,
},
graphHeight
:
{
graphHeight
:
{
type
:
Number
,
type
:
Number
,
required
:
true
,
required
:
true
,
...
@@ -23,71 +26,173 @@
...
@@ -23,71 +26,173 @@
type
:
Number
,
type
:
Number
,
required
:
true
,
required
:
true
,
},
},
realPixelRatio
:
{
type
:
Number
,
required
:
true
,
},
showFlagContent
:
{
showFlagContent
:
{
type
:
Boolean
,
type
:
Boolean
,
required
:
true
,
required
:
true
,
},
},
timeSeries
:
{
type
:
Array
,
required
:
true
,
},
unitOfDisplay
:
{
type
:
String
,
required
:
true
,
},
currentDataIndex
:
{
type
:
Number
,
required
:
true
,
},
legendTitle
:
{
type
:
String
,
required
:
true
,
},
},
},
data
()
{
components
:
{
return
{
Icon
,
circleColorRgb
:
'
#8fbce8
'
,
};
},
},
computed
:
{
computed
:
{
formatTime
()
{
formatTime
()
{
return
timeFormat
(
this
.
currentData
.
time
);
return
this
.
deploymentFlagData
?
timeFormat
(
this
.
deploymentFlagData
.
time
)
:
timeFormat
(
this
.
currentData
.
time
);
},
},
formatDate
()
{
formatDate
()
{
return
dateFormat
(
this
.
currentData
.
time
);
return
this
.
deploymentFlagData
?
dateFormat
(
this
.
deploymentFlagData
.
time
)
:
dateFormat
(
this
.
currentData
.
time
);
},
},
calculatedHeight
()
{
cursorStyle
()
{
return
this
.
graphHeight
-
this
.
graphHeightOffset
;
const
xCoordinate
=
this
.
deploymentFlagData
?
this
.
deploymentFlagData
.
xPos
:
this
.
currentXCoordinate
;
const
offsetTop
=
20
*
this
.
realPixelRatio
;
const
offsetLeft
=
(
70
+
xCoordinate
)
*
this
.
realPixelRatio
;
const
height
=
(
this
.
graphHeight
-
this
.
graphHeightOffset
)
*
this
.
realPixelRatio
;
return
{
top
:
`
${
offsetTop
}
px`
,
left
:
`
${
offsetLeft
}
px`
,
height
:
`
${
height
}
px`
,
};
},
flagOrientation
()
{
if
(
this
.
currentXCoordinate
*
this
.
realPixelRatio
>
120
)
{
return
'
left
'
;
}
return
'
right
'
;
},
},
methods
:
{
seriesMetricValue
(
series
)
{
const
index
=
this
.
deploymentFlagData
?
this
.
deploymentFlagData
.
seriesIndex
:
this
.
currentDataIndex
;
const
value
=
series
.
values
[
index
]
&&
series
.
values
[
index
].
value
;
if
(
isNaN
(
value
))
{
return
'
-
'
;
}
return
`
${
formatRelevantDigits
(
value
)}${
this
.
unitOfDisplay
}
`
;
},
seriesMetricLabel
(
index
,
series
)
{
if
(
this
.
timeSeries
.
length
<
2
)
{
return
this
.
legendTitle
;
}
if
(
series
.
metricTag
)
{
return
series
.
metricTag
;
}
return
`series
${
index
+
1
}
`
;
},
strokeDashArray
(
type
)
{
if
(
type
===
'
dashed
'
)
return
'
6, 3
'
;
if
(
type
===
'
dotted
'
)
return
'
3, 3
'
;
return
null
;
},
},
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<g
class=
"mouse-over-flag"
>
<div
class=
"prometheus-graph-cursor"
:style=
"cursorStyle"
>
<div
v-if=
"showFlagContent"
class=
"prometheus-graph-flag popover"
:class=
"flagOrientation"
>
<div
class=
"arrow"
></div>
<div
class=
"popover-title"
>
<h5
v-if=
"this.deploymentFlagData"
>
Deployed
</h5>
{{
formatDate
}}
at
<strong>
{{
formatTime
}}
</strong>
</div>
<div
v-if=
"this.deploymentFlagData"
class=
"popover-content deploy-meta-content"
>
<div>
<icon
name=
"commit"
:size=
"12"
>
</icon>
<a
:href=
"deploymentFlagData.commitUrl"
>
{{
deploymentFlagData
.
sha
.
slice
(
0
,
8
)
}}
</a>
</div>
<div
v-if=
"deploymentFlagData.tag"
>
<icon
name=
"label"
:size=
"12"
>
</icon>
<a
:href=
"deploymentFlagData.tagUrl"
>
{{
deploymentFlagData
.
ref
}}
</a>
</div>
</div>
<div
class=
"popover-content"
>
<table>
<tr
v-for=
"(series, index) in timeSeries"
:key=
"index"
>
<td>
<svg
width=
"15"
height=
"6"
>
<line
<line
class=
"selected-metric-line"
:stroke=
"series.lineColor"
:x1=
"currentXCoordinate"
:stroke-dasharray=
"strokeDashArray(series.lineStyle)"
:y1=
"0"
stroke-width=
"4"
:x2=
"currentXCoordinate"
x1=
"0"
:y2=
"calculatedHeight"
x2=
"15"
transform=
"translate(-5, 20)"
>
y1=
"2"
y2=
"2"
>
</line>
</line>
<svg
v-if=
"showFlagContent"
class=
"rect-text-metric"
:x=
"currentFlagPosition"
y=
"0"
>
<rect
class=
"rect-metric"
x=
"4"
y=
"1"
rx=
"2"
width=
"90"
height=
"40"
transform=
"translate(-3, 20)"
>
</rect>
<text
class=
"text-metric text-metric-bold"
x=
"16"
y=
"35"
transform=
"translate(-5, 20)"
>
{{
formatTime
}}
</text>
<text
class=
"text-metric"
x=
"16"
y=
"15"
transform=
"translate(-5, 20)"
>
{{
formatDate
}}
</text>
</svg>
</svg>
</g>
</td>
<td>
{{
seriesMetricLabel
(
index
,
series
)
}}
</td>
<td>
<strong>
{{
seriesMetricValue
(
series
)
}}
</strong>
</td>
</tr>
</table>
</div>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/monitoring/mixins/monitoring_mixins.js
View file @
1dc051fb
...
@@ -29,15 +29,18 @@ const mixins = {
...
@@ -29,15 +29,18 @@ const mixins = {
time
.
setSeconds
(
this
.
timeSeries
[
0
].
values
[
0
].
time
.
getSeconds
());
time
.
setSeconds
(
this
.
timeSeries
[
0
].
values
[
0
].
time
.
getSeconds
());
if
(
xPos
>=
0
)
{
if
(
xPos
>=
0
)
{
const
seriesIndex
=
bisectDate
(
this
.
timeSeries
[
0
].
values
,
time
,
1
);
deploymentDataArray
.
push
({
deploymentDataArray
.
push
({
id
:
deployment
.
id
,
id
:
deployment
.
id
,
time
,
time
,
sha
:
deployment
.
sha
,
sha
:
deployment
.
sha
,
commitUrl
:
`
${
this
.
projectPath
}
/commit/
${
deployment
.
sha
}
`
,
commitUrl
:
`
${
this
.
projectPath
}
/commit/
${
deployment
.
sha
}
`
,
tag
:
deployment
.
tag
,
tag
:
deployment
.
tag
,
tagUrl
:
`
${
this
.
tagsPath
}
/
${
deployment
.
tag
}
`
,
tagUrl
:
deployment
.
tag
?
`
${
this
.
tagsPath
}
/
${
deployment
.
ref
.
name
}
`
:
null
,
ref
:
deployment
.
ref
.
name
,
ref
:
deployment
.
ref
.
name
,
xPos
,
xPos
,
seriesIndex
,
showDeploymentFlag
:
false
,
showDeploymentFlag
:
false
,
});
});
}
}
...
...
app/assets/javascripts/monitoring/utils/date_time_formatters.js
View file @
1dc051fb
...
@@ -14,7 +14,7 @@ const d3 = {
...
@@ -14,7 +14,7 @@ const d3 = {
timeYear
,
timeYear
,
};
};
export
const
dateFormat
=
d3
.
time
(
'
%
b %-d, %Y
'
);
export
const
dateFormat
=
d3
.
time
(
'
%
a, %b %-d
'
);
export
const
timeFormat
=
d3
.
time
(
'
%-I:%M%p
'
);
export
const
timeFormat
=
d3
.
time
(
'
%-I:%M%p
'
);
export
const
dateFormatWithName
=
d3
.
time
(
'
%a, %b %-d
'
);
export
const
dateFormatWithName
=
d3
.
time
(
'
%a, %b %-d
'
);
export
const
bisectDate
=
d3
.
bisector
(
d
=>
d
.
time
).
left
;
export
const
bisectDate
=
d3
.
bisector
(
d
=>
d
.
time
).
left
;
...
...
app/assets/stylesheets/pages/environments.scss
View file @
1dc051fb
...
@@ -248,6 +248,73 @@
...
@@ -248,6 +248,73 @@
}
}
}
}
.prometheus-graph-cursor
{
position
:
absolute
;
background
:
$theme-gray-600
;
width
:
1px
;
}
.prometheus-graph-flag
{
display
:
block
;
min-width
:
160px
;
h5
{
padding
:
0
;
margin
:
0
;
font-size
:
14px
;
line-height
:
1
.2
;
}
table
{
border-collapse
:
collapse
;
padding
:
0
;
margin
:
0
;
}
td
{
vertical-align
:
middle
;
+
td
{
padding-left
:
5px
;
vertical-align
:
top
;
}
}
.deploy-meta-content
{
border-bottom
:
1px
solid
$white-dark
;
svg
{
height
:
15px
;
vertical-align
:
bottom
;
}
}
&
.popover
{
&
.left
{
left
:
auto
;
right
:
0
;
margin-right
:
10px
;
}
&
.right
{
left
:
0
;
right
:
auto
;
margin-left
:
10px
;
}
>
.arrow
{
top
:
40px
;
}
>
.popover-title
,
>
.popover-content
{
padding
:
5px
8px
;
font-size
:
12px
;
white-space
:
nowrap
;
}
}
}
.prometheus-svg-container
{
.prometheus-svg-container
{
position
:
relative
;
position
:
relative
;
height
:
0
;
height
:
0
;
...
...
changelogs/unreleased/38030-add-graph-value-to-hover.yml
0 → 100644
View file @
1dc051fb
---
title
:
Display graph values on hover within monitoring page
merge_request
:
16261
author
:
type
:
changed
spec/javascripts/monitoring/graph/deployment_spec.js
View file @
1dc051fb
...
@@ -11,168 +11,38 @@ const createComponent = (propsData) => {
...
@@ -11,168 +11,38 @@ const createComponent = (propsData) => {
};
};
describe
(
'
MonitoringDeployment
'
,
()
=>
{
describe
(
'
MonitoringDeployment
'
,
()
=>
{
const
reducedDeploymentData
=
[
deploymentData
[
0
]];
reducedDeploymentData
[
0
].
ref
=
reducedDeploymentData
[
0
].
ref
.
name
;
reducedDeploymentData
[
0
].
xPos
=
10
;
reducedDeploymentData
[
0
].
time
=
new
Date
(
reducedDeploymentData
[
0
].
created_at
);
describe
(
'
Methods
'
,
()
=>
{
describe
(
'
Methods
'
,
()
=>
{
it
(
'
refText shows the ref when a tag is available
'
,
()
=>
{
it
(
'
should contain a hidden gradient
'
,
()
=>
{
reducedDeploymentData
[
0
].
tag
=
'
1.0
'
;
const
component
=
createComponent
({
showDeployInfo
:
false
,
deploymentData
:
reducedDeploymentData
,
graphWidth
:
440
,
graphHeight
:
300
,
graphHeightOffset
:
120
,
});
expect
(
component
.
refText
(
reducedDeploymentData
[
0
]),
).
toEqual
(
reducedDeploymentData
[
0
].
ref
);
});
it
(
'
refText shows the sha when no tag is available
'
,
()
=>
{
reducedDeploymentData
[
0
].
tag
=
null
;
const
component
=
createComponent
({
showDeployInfo
:
false
,
deploymentData
:
reducedDeploymentData
,
graphHeight
:
300
,
graphWidth
:
440
,
graphHeightOffset
:
120
,
});
expect
(
component
.
refText
(
reducedDeploymentData
[
0
]),
).
toContain
(
'
f5bcd1
'
);
});
it
(
'
nameDeploymentClass creates a class with the prefix deploy-info-
'
,
()
=>
{
const
component
=
createComponent
({
const
component
=
createComponent
({
showDeployInfo
:
fals
e
,
showDeployInfo
:
tru
e
,
deploymentData
:
reducedDeploymentData
,
deploymentData
,
graphHeight
:
300
,
graphHeight
:
300
,
graphWidth
:
440
,
graphWidth
:
440
,
graphHeightOffset
:
120
,
graphHeightOffset
:
120
,
});
});
expect
(
expect
(
component
.
$el
.
querySelector
(
'
#shadow-gradient
'
)).
not
.
toBeNull
();
component
.
nameDeploymentClass
(
reducedDeploymentData
[
0
]),
).
toContain
(
'
deploy-info
'
);
});
});
it
(
'
transformDeploymentGroup translates an available deployment
'
,
()
=>
{
it
(
'
transformDeploymentGroup translates an available deployment
'
,
()
=>
{
const
component
=
createComponent
({
const
component
=
createComponent
({
showDeployInfo
:
false
,
showDeployInfo
:
false
,
deploymentData
:
reducedDeploymentData
,
deploymentData
,
graphHeight
:
300
,
graphHeight
:
300
,
graphWidth
:
440
,
graphWidth
:
440
,
graphHeightOffset
:
120
,
graphHeightOffset
:
120
,
});
});
expect
(
expect
(
component
.
transformDeploymentGroup
(
reducedDeploymentData
[
0
]
),
component
.
transformDeploymentGroup
(
{
xPos
:
16
}
),
).
toContain
(
'
translate(11, 20)
'
);
).
toContain
(
'
translate(11, 20)
'
);
});
});
it
(
'
hides the deployment flag
'
,
()
=>
{
reducedDeploymentData
[
0
].
showDeploymentFlag
=
false
;
const
component
=
createComponent
({
showDeployInfo
:
true
,
deploymentData
:
reducedDeploymentData
,
graphWidth
:
440
,
graphHeight
:
300
,
graphHeightOffset
:
120
,
});
expect
(
component
.
$el
.
querySelector
(
'
.js-deploy-info-box
'
)).
toBeNull
();
});
it
(
'
positions the flag to the left when the xPos is too far right
'
,
()
=>
{
reducedDeploymentData
[
0
].
showDeploymentFlag
=
false
;
reducedDeploymentData
[
0
].
xPos
=
250
;
const
component
=
createComponent
({
showDeployInfo
:
true
,
deploymentData
:
reducedDeploymentData
,
graphWidth
:
440
,
graphHeight
:
300
,
graphHeightOffset
:
120
,
});
expect
(
component
.
positionFlag
(
reducedDeploymentData
[
0
]),
).
toBeLessThan
(
0
);
});
it
(
'
shows the deployment flag
'
,
()
=>
{
reducedDeploymentData
[
0
].
showDeploymentFlag
=
true
;
const
component
=
createComponent
({
showDeployInfo
:
true
,
deploymentData
:
reducedDeploymentData
,
graphHeight
:
300
,
graphWidth
:
440
,
graphHeightOffset
:
120
,
});
expect
(
component
.
$el
.
querySelector
(
'
.js-deploy-info-box
'
).
style
.
display
,
).
not
.
toEqual
(
'
display: none;
'
);
});
it
(
'
contains date, refs and the "deployed" text
'
,
()
=>
{
reducedDeploymentData
[
0
].
showDeploymentFlag
=
true
;
const
component
=
createComponent
({
showDeployInfo
:
true
,
deploymentData
:
reducedDeploymentData
,
graphHeight
:
300
,
graphWidth
:
440
,
graphHeightOffset
:
120
,
});
expect
(
component
.
$el
.
querySelectorAll
(
'
.deploy-info-text
'
),
).
toContainText
(
'
Deployed
'
);
expect
(
component
.
$el
.
querySelectorAll
(
'
.deploy-info-text
'
),
).
toContainText
(
'
Wed, May 31
'
);
expect
(
component
.
$el
.
querySelectorAll
(
'
.deploy-info-text
'
),
).
toContainText
(
component
.
refText
(
reducedDeploymentData
[
0
]));
});
it
(
'
contains a link to the commit contents
'
,
()
=>
{
reducedDeploymentData
[
0
].
showDeploymentFlag
=
true
;
const
component
=
createComponent
({
showDeployInfo
:
true
,
deploymentData
:
reducedDeploymentData
,
graphHeight
:
300
,
graphWidth
:
440
,
graphHeightOffset
:
120
,
});
expect
(
component
.
$el
.
querySelectorAll
(
'
.deploy-info-text-link
'
)[
0
].
parentElement
.
getAttribute
(
'
xlink:href
'
),
).
not
.
toEqual
(
''
);
});
it
(
'
should contain a hidden gradient
'
,
()
=>
{
const
component
=
createComponent
({
showDeployInfo
:
true
,
deploymentData
:
reducedDeploymentData
,
graphHeight
:
300
,
graphWidth
:
440
,
graphHeightOffset
:
120
,
});
expect
(
component
.
$el
.
querySelector
(
'
#shadow-gradient
'
)).
not
.
toBeNull
();
});
describe
(
'
Computed props
'
,
()
=>
{
describe
(
'
Computed props
'
,
()
=>
{
it
(
'
calculatedHeight
'
,
()
=>
{
it
(
'
calculatedHeight
'
,
()
=>
{
const
component
=
createComponent
({
const
component
=
createComponent
({
showDeployInfo
:
true
,
showDeployInfo
:
true
,
deploymentData
:
reducedDeploymentData
,
deploymentData
,
graphHeight
:
300
,
graphHeight
:
300
,
graphWidth
:
440
,
graphWidth
:
440
,
graphHeightOffset
:
120
,
graphHeightOffset
:
120
,
...
...
spec/javascripts/monitoring/graph/flag_spec.js
View file @
1dc051fb
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
GraphFlag
from
'
~/monitoring/components/graph/flag.vue
'
;
import
GraphFlag
from
'
~/monitoring/components/graph/flag.vue
'
;
import
{
deploymentData
}
from
'
../mock_data
'
;
const
createComponent
=
(
propsData
)
=>
{
const
createComponent
=
(
propsData
)
=>
{
const
Component
=
Vue
.
extend
(
GraphFlag
);
const
Component
=
Vue
.
extend
(
GraphFlag
);
...
@@ -9,11 +10,6 @@ const createComponent = (propsData) => {
...
@@ -9,11 +10,6 @@ const createComponent = (propsData) => {
}).
$mount
();
}).
$mount
();
};
};
function
getCoordinate
(
component
,
selector
,
coordinate
)
{
const
coordinateVal
=
component
.
$el
.
querySelector
(
selector
).
getAttribute
(
coordinate
);
return
parseInt
(
coordinateVal
,
10
);
}
const
defaultValuesComponent
=
{
const
defaultValuesComponent
=
{
currentXCoordinate
:
200
,
currentXCoordinate
:
200
,
currentYCoordinate
:
100
,
currentYCoordinate
:
100
,
...
@@ -25,31 +21,111 @@ const defaultValuesComponent = {
...
@@ -25,31 +21,111 @@ const defaultValuesComponent = {
graphHeight
:
300
,
graphHeight
:
300
,
graphHeightOffset
:
120
,
graphHeightOffset
:
120
,
showFlagContent
:
true
,
showFlagContent
:
true
,
realPixelRatio
:
1
,
timeSeries
:
[{
values
:
[{
time
:
new
Date
(
'
2017-06-04T18:17:33.501Z
'
),
value
:
'
1.49609375
'
,
}],
}],
unitOfDisplay
:
'
ms
'
,
currentDataIndex
:
0
,
legendTitle
:
'
Average
'
,
};
const
deploymentFlagData
=
{
...
deploymentData
[
0
],
ref
:
deploymentData
[
0
].
ref
.
name
,
xPos
:
10
,
time
:
new
Date
(
deploymentData
[
0
].
created_at
),
};
};
describe
(
'
GraphFlag
'
,
()
=>
{
describe
(
'
GraphFlag
'
,
()
=>
{
it
(
'
has a line and a circle located at the currentXCoordinate and currentYCoordinate
'
,
()
=>
{
let
component
;
const
component
=
createComponent
(
defaultValuesComponent
);
it
(
'
has a line at the currentXCoordinate
'
,
()
=>
{
component
=
createComponent
(
defaultValuesComponent
);
expect
(
component
.
$el
.
style
.
left
)
.
toEqual
(
`
${
70
+
component
.
currentXCoordinate
}
px`
);
});
describe
(
'
Deployment flag
'
,
()
=>
{
it
(
'
shows a deployment flag when deployment data provided
'
,
()
=>
{
const
deploymentFlagComponent
=
createComponent
({
...
defaultValuesComponent
,
deploymentFlagData
,
});
expect
(
deploymentFlagComponent
.
$el
.
querySelector
(
'
.popover-title
'
),
).
toContainText
(
'
Deployed
'
);
});
it
(
'
contains the ref when a tag is available
'
,
()
=>
{
const
deploymentFlagComponent
=
createComponent
({
...
defaultValuesComponent
,
deploymentFlagData
:
{
...
deploymentFlagData
,
sha
:
'
f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187
'
,
tag
:
true
,
ref
:
'
1.0
'
,
},
});
expect
(
deploymentFlagComponent
.
$el
.
querySelector
(
'
.deploy-meta-content
'
),
).
toContainText
(
'
f5bcd1d9
'
);
expect
(
getCoordinate
(
component
,
'
.selected-metric-line
'
,
'
x1
'
))
expect
(
.
toEqual
(
component
.
currentXCoordinate
);
deploymentFlagComponent
.
$el
.
querySelector
(
'
.deploy-meta-content
'
),
expect
(
getCoordinate
(
component
,
'
.selected-metric-line
'
,
'
x2
'
))
).
toContainText
(
'
1.0
'
);
.
toEqual
(
component
.
currentXCoordinate
);
});
});
it
(
'
has a SVG with the class rect-text-metric at the currentFlagPosition
'
,
()
=>
{
it
(
'
does not contain the ref when a tag is unavailable
'
,
()
=>
{
const
component
=
createComponent
(
defaultValuesComponent
);
const
deploymentFlagComponent
=
createComponent
({
...
defaultValuesComponent
,
deploymentFlagData
:
{
...
deploymentFlagData
,
sha
:
'
f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187
'
,
tag
:
false
,
ref
:
'
1.0
'
,
},
});
const
svg
=
component
.
$el
.
querySelector
(
'
.rect-text-metric
'
);
expect
(
expect
(
svg
.
tagName
).
toEqual
(
'
svg
'
);
deploymentFlagComponent
.
$el
.
querySelector
(
'
.deploy-meta-content
'
),
expect
(
parseInt
(
svg
.
getAttribute
(
'
x
'
),
10
)).
toEqual
(
component
.
currentFlagPosition
);
).
toContainText
(
'
f5bcd1d9
'
);
expect
(
deploymentFlagComponent
.
$el
.
querySelector
(
'
.deploy-meta-content
'
),
).
not
.
toContainText
(
'
1.0
'
);
});
});
});
describe
(
'
Computed props
'
,
()
=>
{
describe
(
'
Computed props
'
,
()
=>
{
it
(
'
calculatedHeight
'
,
()
=>
{
beforeEach
(()
=>
{
const
component
=
createComponent
(
defaultValuesComponent
);
component
=
createComponent
(
defaultValuesComponent
);
});
it
(
'
formatTime
'
,
()
=>
{
expect
(
component
.
formatTime
).
toMatch
(
/
\d
:17PM/
);
});
it
(
'
formatDate
'
,
()
=>
{
expect
(
component
.
formatDate
).
toEqual
(
'
Sun, Jun 4
'
);
});
it
(
'
cursorStyle
'
,
()
=>
{
expect
(
component
.
cursorStyle
).
toEqual
({
top
:
'
20px
'
,
left
:
'
270px
'
,
height
:
'
180px
'
,
});
});
expect
(
component
.
calculatedHeight
).
toEqual
(
180
);
it
(
'
flagOrientation
'
,
()
=>
{
expect
(
component
.
flagOrientation
).
toEqual
(
'
left
'
);
});
});
});
});
});
});
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