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
7fd7406d
Commit
7fd7406d
authored
Jul 05, 2019
by
Sarah Yasonik
Committed by
Phil Hughes
Jul 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix alert creation dropdown menu
parent
80886b6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
app/assets/javascripts/monitoring/stores/utils.js
app/assets/javascripts/monitoring/stores/utils.js
+14
-3
spec/javascripts/monitoring/store/utils_spec.js
spec/javascripts/monitoring/store/utils_spec.js
+37
-0
No files found.
app/assets/javascripts/monitoring/stores/utils.js
View file @
7fd7406d
...
@@ -36,15 +36,26 @@ function removeTimeSeriesNoData(queries) {
...
@@ -36,15 +36,26 @@ function removeTimeSeriesNoData(queries) {
// { metricId: 2, ...query2Attrs }] },
// { metricId: 2, ...query2Attrs }] },
// { title: 'new title', y_label: 'MB', queries: [{ metricId: 3, ...query3Attrs }]}
// { title: 'new title', y_label: 'MB', queries: [{ metricId: 3, ...query3Attrs }]}
// ]
// ]
function
groupQueriesByChartInfo
(
metrics
)
{
export
function
groupQueriesByChartInfo
(
metrics
)
{
const
metricsByChart
=
metrics
.
reduce
((
accumulator
,
metric
)
=>
{
const
metricsByChart
=
metrics
.
reduce
((
accumulator
,
metric
)
=>
{
const
{
queries
,
...
chart
}
=
metric
;
const
{
queries
,
...
chart
}
=
metric
;
const
metricId
=
chart
.
id
?
chart
.
id
.
toString
()
:
null
;
const
chartKey
=
`
${
chart
.
title
}
|
${
chart
.
y_label
}
`
;
const
chartKey
=
`
${
chart
.
title
}
|
${
chart
.
y_label
}
`
;
accumulator
[
chartKey
]
=
accumulator
[
chartKey
]
||
{
...
chart
,
queries
:
[]
};
accumulator
[
chartKey
]
=
accumulator
[
chartKey
]
||
{
...
chart
,
queries
:
[]
};
queries
.
forEach
(
queryAttrs
=>
accumulator
[
chartKey
].
queries
.
push
({
metricId
,
...
queryAttrs
}));
queries
.
forEach
(
queryAttrs
=>
{
let
metricId
;
if
(
chart
.
id
)
{
metricId
=
chart
.
id
.
toString
();
}
else
if
(
queryAttrs
.
metric_id
)
{
metricId
=
queryAttrs
.
metric_id
.
toString
();
}
else
{
metricId
=
null
;
}
accumulator
[
chartKey
].
queries
.
push
({
metricId
,
...
queryAttrs
});
});
return
accumulator
;
return
accumulator
;
},
{});
},
{});
...
...
spec/javascripts/monitoring/store/utils_spec.js
0 → 100644
View file @
7fd7406d
import
{
groupQueriesByChartInfo
}
from
'
~/monitoring/stores/utils
'
;
describe
(
'
groupQueriesByChartInfo
'
,
()
=>
{
let
input
;
let
output
;
it
(
'
groups metrics with the same chart title and y_axis label
'
,
()
=>
{
input
=
[
{
title
:
'
title
'
,
y_label
:
'
MB
'
,
queries
:
[{}]
},
{
title
:
'
title
'
,
y_label
:
'
MB
'
,
queries
:
[{}]
},
{
title
:
'
new title
'
,
y_label
:
'
MB
'
,
queries
:
[{}]
},
];
output
=
[
{
title
:
'
title
'
,
y_label
:
'
MB
'
,
queries
:
[{
metricId
:
null
},
{
metricId
:
null
}]
},
{
title
:
'
new title
'
,
y_label
:
'
MB
'
,
queries
:
[{
metricId
:
null
}]
},
];
expect
(
groupQueriesByChartInfo
(
input
)).
toEqual
(
output
);
});
// Functionality associated with the /additional_metrics endpoint
it
(
"
associates a chart's stringified metric_id with the metric
"
,
()
=>
{
input
=
[{
id
:
3
,
title
:
'
new title
'
,
y_label
:
'
MB
'
,
queries
:
[{}]
}];
output
=
[{
id
:
3
,
title
:
'
new title
'
,
y_label
:
'
MB
'
,
queries
:
[{
metricId
:
'
3
'
}]
}];
expect
(
groupQueriesByChartInfo
(
input
)).
toEqual
(
output
);
});
// Functionality associated with the /metrics_dashboard endpoint
it
(
'
aliases a stringified metrics_id on the metric to the metricId key
'
,
()
=>
{
input
=
[{
title
:
'
new title
'
,
y_label
:
'
MB
'
,
queries
:
[{
metric_id
:
3
}]
}];
output
=
[{
title
:
'
new title
'
,
y_label
:
'
MB
'
,
queries
:
[{
metricId
:
'
3
'
,
metric_id
:
3
}]
}];
expect
(
groupQueriesByChartInfo
(
input
)).
toEqual
(
output
);
});
});
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