Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
6f7b6ba0
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6f7b6ba0
编写于
6月 06, 2019
作者:
S
Sarah Yasonik
提交者:
Phil Hughes
6月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use the selected time window for metrics dashboard
上级
3e07725f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
57 addition
and
20 deletion
+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
未找到文件。
app/assets/javascripts/monitoring/components/dashboard.vue
浏览文件 @
6f7b6ba0
...
@@ -172,7 +172,7 @@ export default {
...
@@ -172,7 +172,7 @@ export default {
if
(
!
this
.
hasMetrics
)
{
if
(
!
this
.
hasMetrics
)
{
this
.
setGettingStartedEmptyState
();
this
.
setGettingStartedEmptyState
();
}
else
{
}
else
{
this
.
fetchData
(
getTimeDiff
(
this
.
timeWindows
.
eightHours
));
this
.
fetchData
(
getTimeDiff
(
this
.
selectedTimeWindow
));
sidebarMutationObserver
=
new
MutationObserver
(
this
.
onSidebarMutation
);
sidebarMutationObserver
=
new
MutationObserver
(
this
.
onSidebarMutation
);
sidebarMutationObserver
.
observe
(
document
.
querySelector
(
'
.layout-page
'
),
{
sidebarMutationObserver
.
observe
(
document
.
querySelector
(
'
.layout-page
'
),
{
...
...
changelogs/unreleased/fix-time-window-default.yml
0 → 100644
浏览文件 @
6f7b6ba0
---
title
:
Use the selected time window for metrics dashboard
merge_request
:
29152
author
:
type
:
fixed
spec/javascripts/monitoring/dashboard_spec.js
浏览文件 @
6f7b6ba0
...
@@ -38,6 +38,7 @@ describe('Dashboard', () => {
...
@@ -38,6 +38,7 @@ describe('Dashboard', () => {
let
DashboardComponent
;
let
DashboardComponent
;
let
mock
;
let
mock
;
let
store
;
let
store
;
let
component
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
setFixtures
(
`
setFixtures
(
`
...
@@ -59,12 +60,13 @@ describe('Dashboard', () => {
...
@@ -59,12 +60,13 @@ describe('Dashboard', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
component
.
$destroy
();
mock
.
restore
();
mock
.
restore
();
});
});
describe
(
'
no metrics are available yet
'
,
()
=>
{
describe
(
'
no metrics are available yet
'
,
()
=>
{
it
(
'
shows a getting started empty state when no metrics are present
'
,
()
=>
{
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
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
showTimeWindowDropdown
:
false
},
propsData
:
{
...
propsData
,
showTimeWindowDropdown
:
false
},
store
,
store
,
...
@@ -81,7 +83,7 @@ describe('Dashboard', () => {
...
@@ -81,7 +83,7 @@ describe('Dashboard', () => {
});
});
it
(
'
shows up a loading state
'
,
done
=>
{
it
(
'
shows up a loading state
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showTimeWindowDropdown
:
false
},
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showTimeWindowDropdown
:
false
},
store
,
store
,
...
@@ -94,7 +96,7 @@ describe('Dashboard', () => {
...
@@ -94,7 +96,7 @@ describe('Dashboard', () => {
});
});
it
(
'
hides the legend when showLegend is false
'
,
done
=>
{
it
(
'
hides the legend when showLegend is false
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
propsData
:
{
...
propsData
,
...
propsData
,
...
@@ -114,7 +116,7 @@ describe('Dashboard', () => {
...
@@ -114,7 +116,7 @@ describe('Dashboard', () => {
});
});
it
(
'
hides the group panels when showPanels is false
'
,
done
=>
{
it
(
'
hides the group panels when showPanels is false
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
propsData
:
{
...
propsData
,
...
propsData
,
...
@@ -134,7 +136,7 @@ describe('Dashboard', () => {
...
@@ -134,7 +136,7 @@ describe('Dashboard', () => {
});
});
it
(
'
renders the environments dropdown with a number of environments
'
,
done
=>
{
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
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
propsData
:
{
...
propsData
,
...
propsData
,
...
@@ -165,7 +167,7 @@ describe('Dashboard', () => {
...
@@ -165,7 +167,7 @@ describe('Dashboard', () => {
});
});
it
(
'
hides the environments dropdown list when there is no environments
'
,
done
=>
{
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
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
propsData
:
{
...
propsData
,
...
propsData
,
...
@@ -195,7 +197,7 @@ describe('Dashboard', () => {
...
@@ -195,7 +197,7 @@ describe('Dashboard', () => {
});
});
it
(
'
renders the environments dropdown with a single active element
'
,
done
=>
{
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
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
propsData
:
{
...
propsData
,
...
propsData
,
...
@@ -228,7 +230,7 @@ describe('Dashboard', () => {
...
@@ -228,7 +230,7 @@ describe('Dashboard', () => {
});
});
it
(
'
hides the dropdown
'
,
done
=>
{
it
(
'
hides the dropdown
'
,
done
=>
{
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
propsData
:
{
...
propsData
,
...
propsData
,
...
@@ -249,7 +251,7 @@ describe('Dashboard', () => {
...
@@ -249,7 +251,7 @@ describe('Dashboard', () => {
});
});
it
(
'
does not show the time window dropdown when the feature flag is not set
'
,
done
=>
{
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
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
propsData
:
{
...
propsData
,
...
propsData
,
...
@@ -270,7 +272,7 @@ describe('Dashboard', () => {
...
@@ -270,7 +272,7 @@ describe('Dashboard', () => {
});
});
it
(
'
renders the time window dropdown with a set of options
'
,
done
=>
{
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
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
propsData
:
{
...
propsData
,
...
propsData
,
...
@@ -295,10 +297,46 @@ describe('Dashboard', () => {
...
@@ -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
=>
{
it
(
'
shows a specific time window selected from the url params
'
,
done
=>
{
spyOnDependency
(
Dashboard
,
'
getParameterValues
'
).
and
.
returnValue
([
'
thirtyMinutes
'
]);
spyOnDependency
(
Dashboard
,
'
getParameterValues
'
).
and
.
returnValue
([
'
thirtyMinutes
'
]);
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showTimeWindowDropdown
:
true
},
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showTimeWindowDropdown
:
true
},
store
,
store
,
...
@@ -319,7 +357,7 @@ describe('Dashboard', () => {
...
@@ -319,7 +357,7 @@ describe('Dashboard', () => {
'
<script>alert("XSS")</script>
'
,
'
<script>alert("XSS")</script>
'
,
]);
]);
co
nst
co
mponent
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showTimeWindowDropdown
:
true
},
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
showTimeWindowDropdown
:
true
},
store
,
store
,
...
@@ -344,7 +382,7 @@ describe('Dashboard', () => {
...
@@ -344,7 +382,7 @@ describe('Dashboard', () => {
});
});
it
(
'
sets elWidth to page width when the sidebar is resized
'
,
done
=>
{
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
'
),
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
propsData
:
{
propsData
:
{
...
propsData
,
...
propsData
,
...
@@ -374,16 +412,10 @@ describe('Dashboard', () => {
...
@@ -374,16 +412,10 @@ describe('Dashboard', () => {
});
});
describe
(
'
external dashboard link
'
,
()
=>
{
describe
(
'
external dashboard link
'
,
()
=>
{
let
component
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
mockApiEndpoint
).
reply
(
200
,
metricsGroupsAPIResponse
);
mock
.
onGet
(
mockApiEndpoint
).
reply
(
200
,
metricsGroupsAPIResponse
);
});
});
afterEach
(()
=>
{
component
.
$destroy
();
});
describe
(
'
with feature flag enabled
'
,
()
=>
{
describe
(
'
with feature flag enabled
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
component
=
new
DashboardComponent
({
component
=
new
DashboardComponent
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录