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
268b727a
Commit
268b727a
authored
Mar 20, 2019
by
Jose Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify the service to support the extra parameters
Added the logic to allow the start and end dates to be created
parent
f77ff0c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
4 deletions
+61
-4
app/assets/javascripts/monitoring/components/dashboard.vue
app/assets/javascripts/monitoring/components/dashboard.vue
+20
-1
app/assets/javascripts/monitoring/constants.js
app/assets/javascripts/monitoring/constants.js
+2
-0
app/assets/javascripts/monitoring/services/monitoring_service.js
...ets/javascripts/monitoring/services/monitoring_service.js
+7
-3
app/assets/javascripts/monitoring/utils.js
app/assets/javascripts/monitoring/utils.js
+32
-0
No files found.
app/assets/javascripts/monitoring/components/dashboard.vue
View file @
268b727a
...
@@ -9,7 +9,8 @@ import MonitorAreaChart from './charts/area.vue';
...
@@ -9,7 +9,8 @@ import MonitorAreaChart from './charts/area.vue';
import
GraphGroup
from
'
./graph_group.vue
'
;
import
GraphGroup
from
'
./graph_group.vue
'
;
import
EmptyState
from
'
./empty_state.vue
'
;
import
EmptyState
from
'
./empty_state.vue
'
;
import
MonitoringStore
from
'
../stores/monitoring_store
'
;
import
MonitoringStore
from
'
../stores/monitoring_store
'
;
import
{
timeWindows
}
from
'
../constants
'
;
import
{
timeWindows
,
msPerMinute
}
from
'
../constants
'
;
import
{
getTimeDifferenceMinutes
}
from
'
../utils
'
;
const
sidebarAnimationDuration
=
150
;
const
sidebarAnimationDuration
=
150
;
let
sidebarMutationObserver
;
let
sidebarMutationObserver
;
...
@@ -107,6 +108,7 @@ export default {
...
@@ -107,6 +108,7 @@ export default {
this
.
timeWindows
=
timeWindows
;
this
.
timeWindows
=
timeWindows
;
this
.
selectedTimeWindow
=
this
.
timeWindows
.
eightHours
;
this
.
selectedTimeWindow
=
this
.
timeWindows
.
eightHours
;
this
.
msPerMinute
=
msPerMinute
;
},
},
beforeDestroy
()
{
beforeDestroy
()
{
if
(
sidebarMutationObserver
)
{
if
(
sidebarMutationObserver
)
{
...
@@ -167,6 +169,23 @@ export default {
...
@@ -167,6 +169,23 @@ export default {
},
},
getGraphsDataWithTime
(
timeFrame
)
{
getGraphsDataWithTime
(
timeFrame
)
{
this
.
selectedTimeWindow
=
this
.
timeWindows
[
timeFrame
];
this
.
selectedTimeWindow
=
this
.
timeWindows
[
timeFrame
];
this
.
state
=
'
loading
'
;
this
.
showEmptyState
=
true
;
const
end
=
Date
.
now
();
const
timeDifferenceMinutes
=
getTimeDifferenceMinutes
(
this
.
selectedTimeWindow
);
const
start
=
new
Date
(
end
-
timeDifferenceMinutes
*
this
.
msPerMinute
).
getTime
();
this
.
service
.
getGraphsData
({
start
,
end
,
})
.
then
(
data
=>
{
this
.
store
.
storeMetrics
(
data
);
this
.
showEmptyState
=
false
;
})
.
catch
(()
=>
{
this
.
state
=
'
unableToConnect
'
;
});
},
},
onSidebarMutation
()
{
onSidebarMutation
()
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
...
app/assets/javascripts/monitoring/constants.js
View file @
268b727a
...
@@ -16,3 +16,5 @@ export const timeWindows = {
...
@@ -16,3 +16,5 @@ export const timeWindows = {
threeDays
:
'
3 days
'
,
threeDays
:
'
3 days
'
,
oneWeek
:
'
1 week
'
,
oneWeek
:
'
1 week
'
,
};
};
export
const
msPerMinute
=
60000
;
app/assets/javascripts/monitoring/services/monitoring_service.js
View file @
268b727a
...
@@ -32,11 +32,15 @@ export default class MonitoringService {
...
@@ -32,11 +32,15 @@ export default class MonitoringService {
this
.
environmentsEndpoint
=
environmentsEndpoint
;
this
.
environmentsEndpoint
=
environmentsEndpoint
;
}
}
getGraphsData
()
{
getGraphsData
(
params
=
{})
{
return
backOffRequest
(()
=>
axios
.
get
(
this
.
metricsEndpoint
))
return
backOffRequest
(()
=>
axios
.
get
(
this
.
metricsEndpoint
,
{
params
:
{
...
params
}
}))
.
then
(
resp
=>
resp
.
data
)
.
then
(
resp
=>
resp
.
data
)
.
then
(
response
=>
{
.
then
(
response
=>
{
if
(
!
response
||
!
response
.
data
)
{
if
(
!
response
||
!
response
.
data
||
!
response
.
success
)
{
throw
new
Error
(
s__
(
'
Metrics|Unexpected metrics data response from prometheus endpoint
'
));
throw
new
Error
(
s__
(
'
Metrics|Unexpected metrics data response from prometheus endpoint
'
));
}
}
return
response
.
data
;
return
response
.
data
;
...
...
app/assets/javascripts/monitoring/utils.js
0 → 100644
View file @
268b727a
import
{
timeWindows
}
from
'
./constants
'
export
const
getTimeDifferenceMinutes
=
(
timeWindow
)
=>
{
let
timeDifferenceMinutes
;
switch
(
timeWindow
)
{
case
timeWindows
.
thirtyMinutes
:
timeDifferenceMinutes
=
30
;
break
;
case
timeWindows
.
threeHours
:
timeDifferenceMinutes
=
60
*
3
;
break
;
case
timeWindows
.
eightHours
:
timeDifferenceMinutes
=
60
*
8
;
break
;
case
timeWindows
.
oneDay
:
timeDifferenceMinutes
=
60
*
24
*
1
;
break
;
case
timeWindows
.
threeDays
:
timeDifferenceMinutes
=
60
*
24
*
3
;
break
;
case
timeWindows
.
oneWeek
:
timeDifferenceMinutes
=
60
*
24
*
7
*
1
;
break
;
default
:
timeDifferenceMinutes
=
60
*
8
;
break
;
}
return
timeDifferenceMinutes
;
};
export
default
{};
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