Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
1a91e0ba
Commit
1a91e0ba
authored
Sep 26, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: update aggregation and alignment before refreshing when changing metric
parent
508601c2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
25 deletions
+34
-25
public/app/plugins/datasource/stackdriver/partials/query.aggregation.html
+2
-2
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
+31
-23
public/app/plugins/datasource/stackdriver/query_ctrl.ts
+1
-0
No files found.
public/app/plugins/datasource/stackdriver/partials/query.aggregation.html
View file @
1a91e0ba
...
...
@@ -2,7 +2,7 @@
<div
class=
"gf-form"
>
<label
class=
"gf-form-label query-keyword width-9"
>
Aggregation
</label>
<div
class=
"gf-form-select-wrapper gf-form-select-wrapper--caret-indent"
>
<select
class=
"gf-form-input width-12"
ng-model=
"target.aggregation.crossSeriesReducer"
ng-options=
"f.value as f.text for f in
getAggOptions()
"
<select
class=
"gf-form-input width-12"
ng-model=
"target.aggregation.crossSeriesReducer"
ng-options=
"f.value as f.text for f in
aggOptions
"
ng-change=
"onAggregationChange(target.aggregation.crossSeriesReducer)"
></select>
</div>
</div>
...
...
@@ -20,7 +20,7 @@
<div
class=
"gf-form offset-width-9"
>
<label
class=
"gf-form-label query-keyword width-12"
>
Aligner
</label>
<div
class=
"gf-form-select-wrapper gf-form-select-wrapper--caret-indent"
>
<select
class=
"gf-form-input width-14"
ng-model=
"target.aggregation.perSeriesAligner"
ng-options=
"f.value as f.text for f in
getAlignOptions()
"
<select
class=
"gf-form-input width-14"
ng-model=
"target.aggregation.perSeriesAligner"
ng-options=
"f.value as f.text for f in
alignOptions
"
ng-change=
"onAlignmentChange(target.aggregation.perSeriesAligner)"
></select>
</div>
...
...
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
View file @
1a91e0ba
...
...
@@ -20,57 +20,65 @@ export class StackdriverAggregationCtrl {
target
:
any
;
alignOptions
:
any
[];
aggOptions
:
any
[];
refresh
:
()
=>
void
;
constructor
(
$scope
)
{
this
.
aggOptions
=
options
.
aggOptions
;
this
.
alignOptions
=
options
.
alignOptions
;
$scope
.
alignmentPeriods
=
options
.
alignmentPeriods
;
$scope
.
getAlignOptions
=
this
.
getAlignOptions
;
$scope
.
getAggOptions
=
this
.
getAggOptions
;
$scope
.
onAlignmentChange
=
this
.
onAlignmentChange
;
$scope
.
onAggregationChange
=
this
.
onAggregationChange
;
this
.
refresh
=
$scope
.
refresh
;
constructor
(
private
$scope
)
{
$scope
.
aggOptions
=
options
.
aggOptions
;
this
.
setAggOptions
();
this
.
setAlignOptions
();
$scope
.
onAlignmentChange
=
this
.
onAlignmentChange
.
bind
(
this
);
$scope
.
onAggregationChange
=
this
.
onAggregationChange
.
bind
(
this
);
$scope
.
$on
(
'metricTypeChange'
,
this
.
setAlignOptions
.
bind
(
this
));
}
onAlignmentChange
(
newVal
:
string
)
{
if
(
newVal
===
'ALIGN_NONE'
)
{
this
.
target
.
aggregation
.
crossSeriesReducer
=
'REDUCE_NONE'
;
this
.
$scope
.
target
.
aggregation
.
crossSeriesReducer
=
'REDUCE_NONE'
;
}
this
.
refresh
();
this
.
$scope
.
refresh
();
}
onAggregationChange
(
newVal
:
string
)
{
if
(
newVal
!==
'REDUCE_NONE'
&&
this
.
target
.
aggregation
.
perSeriesAligner
===
'ALIGN_NONE'
)
{
if
(
newVal
!==
'REDUCE_NONE'
&&
this
.
$scope
.
target
.
aggregation
.
perSeriesAligner
===
'ALIGN_NONE'
)
{
const
newAlignmentOption
=
options
.
alignOptions
.
find
(
o
=>
o
.
value
!==
'ALIGN_NONE'
&&
o
.
valueTypes
.
indexOf
(
this
.
target
.
valueType
)
!==
-
1
&&
o
.
metricKinds
.
indexOf
(
this
.
target
.
metricKind
)
!==
-
1
o
.
valueTypes
.
indexOf
(
this
.
$scope
.
target
.
valueType
)
!==
-
1
&&
o
.
metricKinds
.
indexOf
(
this
.
$scope
.
target
.
metricKind
)
!==
-
1
);
this
.
target
.
aggregation
.
perSeriesAligner
=
newAlignmentOption
?
newAlignmentOption
.
value
:
''
;
this
.
$scope
.
target
.
aggregation
.
perSeriesAligner
=
newAlignmentOption
?
newAlignmentOption
.
value
:
''
;
}
this
.
refresh
();
this
.
$scope
.
refresh
();
}
g
etAlignOptions
()
{
return
!
this
.
target
.
valueType
s
etAlignOptions
()
{
this
.
$scope
.
alignOptions
=
!
this
.
$scope
.
target
.
valueType
?
[]
:
options
.
alignOptions
.
filter
(
i
=>
{
return
(
i
.
valueTypes
.
indexOf
(
this
.
target
.
valueType
)
!==
-
1
&&
i
.
metricKinds
.
indexOf
(
this
.
target
.
metricKind
)
!==
-
1
i
.
valueTypes
.
indexOf
(
this
.
$scope
.
target
.
valueType
)
!==
-
1
&&
i
.
metricKinds
.
indexOf
(
this
.
$scope
.
target
.
metricKind
)
!==
-
1
);
});
if
(
!
this
.
$scope
.
alignOptions
.
find
(
o
=>
o
.
value
===
this
.
$scope
.
target
.
aggregation
.
perSeriesAligner
))
{
const
newValue
=
this
.
$scope
.
alignOptions
.
find
(
o
=>
o
.
value
!==
'ALIGN_NONE'
);
this
.
$scope
.
target
.
aggregation
.
perSeriesAligner
=
newValue
?
newValue
.
value
:
''
;
}
}
g
etAggOptions
()
{
return
!
this
.
target
.
metricKind
s
etAggOptions
()
{
this
.
$scope
.
aggOptions
=
!
this
.
$scope
.
target
.
metricKind
?
[]
:
options
.
aggOptions
.
filter
(
i
=>
{
return
(
i
.
valueTypes
.
indexOf
(
this
.
target
.
valueType
)
!==
-
1
&&
i
.
metricKinds
.
indexOf
(
this
.
target
.
metricKind
)
!==
-
1
i
.
valueTypes
.
indexOf
(
this
.
$scope
.
target
.
valueType
)
!==
-
1
&&
i
.
metricKinds
.
indexOf
(
this
.
$scope
.
target
.
metricKind
)
!==
-
1
);
});
if
(
!
this
.
$scope
.
aggOptions
.
find
(
o
=>
o
.
value
===
this
.
$scope
.
target
.
aggregation
.
crossSeriesReducer
))
{
const
newValue
=
this
.
$scope
.
aggOptions
.
find
(
o
=>
o
.
value
!==
'REDUCE_NONE'
);
this
.
$scope
.
target
.
aggregation
.
crossSeriesReducer
=
newValue
?
newValue
.
value
:
''
;
}
}
}
...
...
public/app/plugins/datasource/stackdriver/query_ctrl.ts
View file @
1a91e0ba
...
...
@@ -194,6 +194,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
const
{
valueType
,
metricKind
}
=
this
.
metricDescriptors
.
find
(
m
=>
m
.
type
===
this
.
target
.
metricType
);
this
.
target
.
valueType
=
valueType
;
this
.
target
.
metricKind
=
metricKind
;
this
.
$scope
.
$broadcast
(
'metricTypeChange'
);
this
.
refresh
();
this
.
getLabels
();
}
...
...
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