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
406c0d15
Commit
406c0d15
authored
Dec 12, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove redundant default value
parent
b5d6cd1c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
44 deletions
+53
-44
public/app/plugins/datasource/stackdriver/datasource.ts
+1
-0
public/app/plugins/datasource/stackdriver/partials/query.editor.html
+1
-2
public/app/plugins/datasource/stackdriver/partials/query.filter.html
+6
-6
public/app/plugins/datasource/stackdriver/query_ctrl.ts
+2
-5
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts
+43
-29
public/app/plugins/datasource/stackdriver/specs/query_filter_ctrl.test.ts
+0
-2
No files found.
public/app/plugins/datasource/stackdriver/datasource.ts
View file @
406c0d15
...
...
@@ -274,6 +274,7 @@ export default class StackdriverDatasource {
m
.
service
=
service
;
m
.
serviceShortName
=
serviceShortName
;
m
.
displayName
=
m
.
displayName
||
m
.
type
;
return
m
;
});
}
...
...
public/app/plugins/datasource/stackdriver/partials/query.editor.html
View file @
406c0d15
<query-editor-row
query-ctrl=
"ctrl"
has-text-edit-mode=
"false"
>
<stackdriver-filter
target=
"ctrl.target"
refresh=
"ctrl.refresh()"
datasource=
"ctrl.datasource"
default-dropdown-value=
"ctrl.defaultDropdownValue"
default-service-value=
"ctrl.defaultServiceValue"
></stackdriver-filter>
<stackdriver-filter
target=
"ctrl.target"
refresh=
"ctrl.refresh()"
datasource=
"ctrl.datasource"
></stackdriver-filter>
<stackdriver-aggregation
target=
"ctrl.target"
alignment-period=
"ctrl.lastQueryMeta.alignmentPeriod"
refresh=
"ctrl.refresh()"
></stackdriver-aggregation>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
...
...
public/app/plugins/datasource/stackdriver/partials/query.filter.html
View file @
406c0d15
...
...
@@ -6,8 +6,8 @@
selected=
"ctrl.service"
options=
"ctrl.services"
searchable=
"false"
placeholder=
"
ctrl.defaultServiceValue
"
className=
"
"width-15"
"
placeholder=
"
'Select Services'
"
className=
"
'width-15'
"
></option-picker>
</div>
<div
class=
"gf-form gf-form--grow"
><div
class=
"gf-form-label gf-form-label--grow"
></div></div>
...
...
@@ -17,11 +17,11 @@
<span
class=
"gf-form-label width-9 query-keyword"
>
Metric
</span>
<option-group-picker
onChange=
"ctrl.handleMetricTypeChange"
selected=
"ctrl.metricType"
groups=
"ctrl.
insertTemplateVariables(ctrl.defaultServiceValue !== ctrl.service ? ctrl.metrics : ctrl.metricGroups
)"
selected=
"ctrl.
target.
metricType"
groups=
"ctrl.
getMetricGroups(
)"
searchable=
"true"
placeholder=
"
ctrl.defaultDropdownValue
"
className=
"
"width-15"
"
placeholder=
"
'Select Metric'
"
className=
"
'width-15'
"
></option-group-picker>
</div>
<div
class=
"gf-form gf-form--grow"
><div
class=
"gf-form-label gf-form-label--grow"
></div></div>
...
...
public/app/plugins/datasource/stackdriver/query_ctrl.ts
View file @
406c0d15
...
...
@@ -34,13 +34,10 @@ export class StackdriverQueryCtrl extends QueryCtrl {
valueType
:
any
;
};
defaultDropdownValue
=
'Select Metric'
;
defaultServiceValue
=
'All Services'
;
defaults
=
{
defaultProject
:
'loading project...'
,
metricType
:
this
.
defaultDropdownValue
,
service
:
this
.
defaultServiceValue
,
metricType
:
''
,
service
:
''
,
metric
:
''
,
unit
:
''
,
aggregation
:
{
...
...
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts
View file @
406c0d15
...
...
@@ -15,8 +15,6 @@ export class StackdriverFilter {
target
:
'='
,
datasource
:
'='
,
refresh
:
'&'
,
defaultDropdownValue
:
'<'
,
defaultServiceValue
:
'<'
,
hideGroupBys
:
'<'
,
},
};
...
...
@@ -48,9 +46,6 @@ export class StackdriverFilterCtrl {
constructor
(
private
$scope
,
private
uiSegmentSrv
,
private
templateSrv
,
private
$rootScope
)
{
this
.
datasource
=
$scope
.
datasource
;
this
.
target
=
$scope
.
target
;
this
.
metricType
=
$scope
.
defaultDropdownValue
;
this
.
service
=
$scope
.
defaultServiceValue
;
this
.
metricDescriptors
=
[];
this
.
metrics
=
[];
this
.
metricGroups
=
[];
...
...
@@ -66,7 +61,7 @@ export class StackdriverFilterCtrl {
}
handleMetricTypeChange
(
value
)
{
this
.
metricType
=
value
;
this
.
target
.
metricType
=
value
;
this
.
onMetricTypeChange
();
}
...
...
@@ -116,7 +111,6 @@ export class StackdriverFilterCtrl {
}
getServicesList
()
{
const
defaultValue
=
{
value
:
this
.
$scope
.
defaultServiceValue
,
label
:
this
.
$scope
.
defaultServiceValue
};
const
services
=
this
.
metricDescriptors
.
map
(
m
=>
{
return
{
value
:
m
.
service
,
...
...
@@ -128,10 +122,10 @@ export class StackdriverFilterCtrl {
this
.
service
=
this
.
target
.
service
;
}
return
services
.
length
>
0
?
[
defaultValue
,
...
_
.
uniqBy
(
services
,
'value'
)]
:
[];
return
services
.
length
>
0
?
_
.
uniqBy
(
services
,
'value'
)
:
[];
}
getMetricGroups
()
{
getMetricGroups
Old
()
{
return
this
.
metrics
.
reduce
((
acc
,
curr
)
=>
{
const
group
=
acc
.
find
(
group
=>
group
.
service
===
curr
.
service
);
if
(
group
)
{
...
...
@@ -150,6 +144,27 @@ export class StackdriverFilterCtrl {
},
[]);
}
getMetricGroups
()
{
return
[
this
.
getTemplateVariablesGroup
(),
{
label
:
'Metrics'
,
options
:
this
.
metrics
,
},
];
}
getTemplateVariablesGroup
()
{
return
{
label
:
'Template Variables'
,
options
:
this
.
templateSrv
.
variables
.
map
(
v
=>
({
label
:
`$
${
v
.
name
}
`
,
value
:
`$
${
v
.
name
}
`
,
description
:
`$
${
v
.
definition
}
`
,
})),
};
}
insertTemplateVariables
(
options
)
{
const
templateVariables
=
{
label
:
'Template Variables'
,
...
...
@@ -174,29 +189,28 @@ export class StackdriverFilterCtrl {
};
});
let
result
;
if
(
this
.
target
.
service
===
this
.
$scope
.
defaultServiceValue
)
{
result
=
metrics
.
map
(
m
=>
({
...
m
,
text
:
`
${
m
.
service
}
-
${
m
.
text
}
`
}));
}
else
{
result
=
metrics
.
filter
(
m
=>
m
.
service
===
this
.
target
.
service
);
const
metricsByService
=
metrics
.
filter
(
m
=>
m
.
service
===
this
.
target
.
service
);
if
(
metricsByService
.
length
>
0
&&
!
metricsByService
.
some
(
m
=>
m
.
value
===
this
.
templateSrv
.
replace
(
this
.
target
.
metricType
))
)
{
this
.
target
.
metricType
=
metricsByService
[
0
].
value
;
}
if
(
result
.
find
(
m
=>
m
.
value
===
this
.
templateSrv
.
replace
(
this
.
target
.
metricType
)))
{
this
.
metricType
=
this
.
target
.
metricType
;
}
else
if
(
result
.
length
>
0
)
{
this
.
metricType
=
this
.
target
.
metricType
=
result
[
0
].
value
;
}
return
result
;
return
metricsByService
;
}
async
getLabels
()
{
this
.
loadLabelsPromise
=
new
Promise
(
async
resolve
=>
{
try
{
const
{
meta
}
=
await
this
.
datasource
.
getLabels
(
this
.
target
.
metricType
,
this
.
target
.
refId
);
this
.
metricLabels
=
meta
.
metricLabels
;
this
.
resourceLabels
=
meta
.
resourceLabels
;
this
.
resourceTypes
=
meta
.
resourceTypes
;
resolve
();
if
(
this
.
target
.
metricType
)
{
const
{
meta
}
=
await
this
.
datasource
.
getLabels
(
this
.
target
.
metricType
,
this
.
target
.
refId
);
this
.
metricLabels
=
meta
.
metricLabels
;
this
.
resourceLabels
=
meta
.
resourceLabels
;
this
.
resourceTypes
=
meta
.
resourceTypes
;
resolve
();
}
else
{
resolve
();
}
}
catch
(
error
)
{
if
(
error
.
data
&&
error
.
data
.
message
)
{
console
.
log
(
error
.
data
.
message
);
...
...
@@ -216,7 +230,7 @@ export class StackdriverFilterCtrl {
this
.
setMetricType
();
this
.
getLabels
();
if
(
!
this
.
metrics
.
find
(
m
=>
m
.
value
===
this
.
target
.
metricType
))
{
this
.
target
.
metricType
=
this
.
$scope
.
defaultDropdownValue
;
this
.
target
.
metricType
=
''
;
}
else
{
this
.
$scope
.
refresh
();
}
...
...
@@ -229,9 +243,9 @@ export class StackdriverFilterCtrl {
}
setMetricType
()
{
this
.
target
.
metricType
=
this
.
metricType
;
//
this.target.metricType = this.metricType;
const
{
valueType
,
metricKind
,
unit
}
=
this
.
metricDescriptors
.
find
(
m
=>
m
.
type
===
this
.
templateSrv
.
replace
(
this
.
metricType
)
m
=>
m
.
type
===
this
.
templateSrv
.
replace
(
this
.
target
.
metricType
)
);
this
.
target
.
unit
=
unit
;
this
.
target
.
valueType
=
valueType
;
...
...
public/app/plugins/datasource/stackdriver/specs/query_filter_ctrl.test.ts
View file @
406c0d15
...
...
@@ -409,8 +409,6 @@ function createCtrlWithFakes(existingFilters?: string[]) {
return
'project'
;
},
},
defaultDropdownValue
:
'Select Metric'
,
defaultServiceValue
:
'All Services'
,
refresh
:
()
=>
{},
};
...
...
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