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
88f69cbd
Commit
88f69cbd
authored
Apr 21, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Used reduce over forEach
Moved shared date & time formats into constants
parent
d7154552
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
16 deletions
+24
-16
app/assets/javascripts/monitoring/constants.js
app/assets/javascripts/monitoring/constants.js
+4
-0
app/assets/javascripts/monitoring/deployments.js
app/assets/javascripts/monitoring/deployments.js
+14
-12
app/assets/javascripts/monitoring/prometheus_graph.js
app/assets/javascripts/monitoring/prometheus_graph.js
+6
-4
No files found.
app/assets/javascripts/monitoring/constants.js
0 → 100644
View file @
88f69cbd
import
d3
from
'
d3
'
;
export
const
dateFormat
=
d3
.
time
.
format
(
'
%b %d, %Y
'
);
export
const
timeFormat
=
d3
.
time
.
format
(
'
%H:%M%p
'
);
app/assets/javascripts/monitoring/deployments.js
View file @
88f69cbd
/* global Flash */
import
d3
from
'
d3
'
;
import
{
dateFormat
,
timeFormat
,
}
from
'
./constants
'
;
export
default
class
Deployments
{
constructor
(
width
,
height
)
{
this
.
width
=
width
;
this
.
height
=
height
;
this
.
data
=
[];
this
.
dateFormat
=
d3
.
time
.
format
(
'
%b %d, %Y
'
);
this
.
timeFormat
=
d3
.
time
.
format
(
'
%H:%M%p
'
);
this
.
endpoint
=
document
.
getElementById
(
'
js-metrics
'
).
dataset
.
deploymentEndpoint
;
...
...
@@ -29,15 +31,16 @@ export default class Deployments {
url
:
this
.
endpoint
,
dataType
:
'
JSON
'
,
})
.
fail
(()
=>
new
Flash
(
'
Error getting deployment information.
'
))
.
done
((
data
)
=>
{
data
.
deployments
.
forEach
((
deployment
)
=>
{
this
.
data
=
data
.
deployments
.
reduce
((
deploymentDataArray
,
deployment
)
=>
{
const
time
=
new
Date
(
deployment
.
created_at
);
const
xPos
=
Math
.
floor
(
this
.
x
(
time
));
time
.
setSeconds
(
this
.
chartData
[
0
].
time
.
getSeconds
());
if
(
xPos
>=
0
)
{
this
.
data
.
push
({
deploymentDataArray
.
push
({
id
:
deployment
.
id
,
time
,
sha
:
deployment
.
sha
,
...
...
@@ -46,7 +49,9 @@ export default class Deployments {
xPos
,
});
}
});
return
deploymentDataArray
;
},
[]);
this
.
plotData
();
});
...
...
@@ -162,14 +167,14 @@ export default class Deployments {
class
:
'
deploy-info-text
'
,
y
:
18
,
})
.
text
(
d
=>
this
.
dateFormat
(
d
.
time
))
.
text
(
d
=>
dateFormat
(
d
.
time
))
.
select
(
this
.
selectParentNode
)
.
append
(
'
text
'
)
.
attr
({
class
:
'
deploy-info-text text-metric-bold
'
,
y
:
38
,
})
.
text
(
d
=>
t
his
.
t
imeFormat
(
d
.
time
));
.
text
(
d
=>
timeFormat
(
d
.
time
));
}
static
toggleDeployTextbox
(
deploy
,
key
,
showInfoBox
)
{
...
...
@@ -201,9 +206,6 @@ export default class Deployments {
}
static
refText
(
d
)
{
const
isTag
=
d
.
tag
;
const
refText
=
isTag
?
d
.
ref
:
d
.
sha
.
slice
(
0
,
6
);
return
refText
;
return
d
.
tag
?
d
.
ref
:
d
.
sha
.
slice
(
0
,
6
);
}
}
app/assets/javascripts/monitoring/prometheus_graph.js
View file @
88f69cbd
...
...
@@ -7,14 +7,16 @@ import Deployments from './deployments';
import
'
../lib/utils/common_utils
'
;
import
{
formatRelevantDigits
}
from
'
../lib/utils/number_utils
'
;
import
'
../flash
'
;
import
{
dateFormat
,
timeFormat
,
}
from
'
./constants
'
;
const
prometheusContainer
=
'
.prometheus-container
'
;
const
prometheusParentGraphContainer
=
'
.prometheus-graphs
'
;
const
prometheusGraphsContainer
=
'
.prometheus-graph
'
;
const
prometheusStatesContainer
=
'
.prometheus-state
'
;
const
metricsEndpoint
=
'
metrics.json
'
;
const
timeFormat
=
d3
.
time
.
format
(
'
%H:%M%p
'
);
const
dayFormat
=
d3
.
time
.
format
(
'
%b %d, %Y
'
);
const
bisectDate
=
d3
.
bisector
(
d
=>
d
.
time
).
left
;
const
extraAddedWidthParent
=
100
;
...
...
@@ -256,7 +258,7 @@ class PrometheusGraph {
const
evalTime
=
timeValueOverlay
-
d0
.
time
>
d1
.
time
-
timeValueOverlay
;
const
currentData
=
evalTime
?
d1
:
d0
;
const
currentTimeCoordinate
=
Math
.
floor
(
currentGraphProps
.
xScale
(
currentData
.
time
));
const
currentDeployXPos
=
this
.
deployments
.
mouseOverDeployInfo
(
current
Time
Coordinate
,
key
);
const
currentDeployXPos
=
this
.
deployments
.
mouseOverDeployInfo
(
current
X
Coordinate
,
key
);
const
currentPrometheusGraphContainer
=
`
${
prometheusGraphsContainer
}
[graph-type=
${
key
}
]`
;
const
maxValueFromData
=
d3
.
max
(
currentGraphProps
.
data
.
map
(
metricValue
=>
metricValue
.
value
));
const
maxMetricValue
=
currentGraphProps
.
yScale
(
maxValueFromData
);
...
...
@@ -317,7 +319,7 @@ class PrometheusGraph {
x
:
8
,
y
:
15
,
})
.
text
(
da
y
Format
(
currentData
.
time
));
.
text
(
da
te
Format
(
currentData
.
time
));
let
currentMetricValue
=
formatRelevantDigits
(
currentData
.
value
);
if
(
key
===
'
cpu_values
'
)
{
...
...
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