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
ad4f3910
Commit
ad4f3910
authored
Dec 11, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap react select component in angular directive
parent
cfd1467a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
21 deletions
+86
-21
public/app/plugins/datasource/stackdriver/components/OptionPicker.tsx
+48
-0
public/app/plugins/datasource/stackdriver/partials/query.filter.html
+17
-17
public/app/plugins/datasource/stackdriver/query_ctrl.ts
+9
-0
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts
+12
-4
No files found.
public/app/plugins/datasource/stackdriver/components/OptionPicker.tsx
0 → 100644
View file @
ad4f3910
import
React
from
'react'
;
// import SimplePicker from 'app/core/components/Picker/SimplePicker';
import
Select
from
'react-select'
;
// import DescriptionPicker from 'app/core/components/Picker/DescriptionPicker';
import
DescriptionOption
from
'app/core/components/Picker/DescriptionOption'
;
import
IndicatorsContainer
from
'app/core/components/Picker/IndicatorsContainer'
;
import
ResetStyles
from
'app/core/components/Picker/ResetStyles'
;
import
NoOptionsMessage
from
'app/core/components/Picker/NoOptionsMessage'
;
import
_
from
'lodash'
;
export
interface
Props
{
onChange
:
(
value
:
string
)
=>
void
;
options
:
any
[];
selected
:
string
;
placeholder
?:
string
;
className
?:
string
;
}
export
class
OptionPicker
extends
React
.
Component
<
Props
,
any
>
{
constructor
(
props
)
{
super
(
props
);
}
render
()
{
const
{
onChange
,
options
,
selected
,
placeholder
,
className
}
=
this
.
props
;
const
selectedOption
=
options
.
find
(
metric
=>
metric
.
value
===
selected
);
return
(
<
Select
placeholder=
{
placeholder
}
classNamePrefix=
{
`gf-form-select-box`
}
className=
{
className
}
options=
{
options
}
components=
{
{
Option
:
DescriptionOption
,
IndicatorsContainer
,
NoOptionsMessage
,
}
}
styles=
{
ResetStyles
}
isDisabled=
{
false
}
onChange=
{
option
=>
onChange
(
option
.
value
)
}
getOptionValue=
{
i
=>
i
.
value
}
getOptionLabel=
{
i
=>
i
.
label
}
value=
{
selectedOption
}
noOptionsMessage=
{
()
=>
'No metrics found'
}
/>
);
}
}
public/app/plugins/datasource/stackdriver/partials/query.filter.html
View file @
ad4f3910
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-9 query-keyword"
>
Service
</span>
<select
class=
"gf-form-input width-12"
ng-model=
"ctrl.service"
ng-options=
"f.value as f.text for f in ctrl.services"
ng-change=
"ctrl.onServiceChange(ctrl.service)"
></select>
<option-picker
onChange=
"ctrl.handleServiceChange"
selected=
"ctrl.service"
options=
"ctrl.services"
placeholder=
"ctrl.defaultDropdownValue"
className=
"width-12"
></option-picker>
</div>
<div
class=
"gf-form gf-form--grow"
><div
class=
"gf-form-label gf-form-label--grow"
></div></div>
</div>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-9 query-keyword"
>
Metric
</span>
<gf-form-dropdown
model=
"ctrl.metricType"
get-options=
"ctrl.metrics"
class=
"min-width-20"
disabled
type=
"text"
allow-custom=
"true"
lookup-text=
"true"
css-class=
"min-width-12"
on-change=
"ctrl.onMetricTypeChange()"
></gf-form-dropdown>
<option-picker
onChange=
"ctrl.handleMetricTypeChange"
selected=
"ctrl.metricType"
options=
"ctrl.metrics"
placeholder=
"ctrl.defaultDropdownValue"
className=
"width-12"
></option-picker>
</div>
<div
class=
"gf-form gf-form--grow"
><div
class=
"gf-form-label gf-form-label--grow"
></div></div>
</div>
...
...
public/app/plugins/datasource/stackdriver/query_ctrl.ts
View file @
ad4f3910
...
...
@@ -2,6 +2,8 @@ import _ from 'lodash';
import
{
QueryCtrl
}
from
'app/plugins/sdk'
;
import
'./query_aggregation_ctrl'
;
import
'./query_filter_ctrl'
;
import
{
OptionPicker
}
from
'./components/OptionPicker'
;
import
{
react2AngularDirective
}
from
'app/core/utils/react2angular'
;
export
interface
QueryMeta
{
alignmentPeriod
:
string
;
...
...
@@ -64,6 +66,13 @@ export class StackdriverQueryCtrl extends QueryCtrl {
_
.
defaultsDeep
(
this
.
target
,
this
.
defaults
);
this
.
panelCtrl
.
events
.
on
(
'data-received'
,
this
.
onDataReceived
.
bind
(
this
),
$scope
);
this
.
panelCtrl
.
events
.
on
(
'data-error'
,
this
.
onDataError
.
bind
(
this
),
$scope
);
react2AngularDirective
(
'optionPicker'
,
OptionPicker
,
[
'options'
,
'onChange'
,
'selected'
,
'className'
,
'placeholder'
,
]);
}
onDataReceived
(
dataList
)
{
...
...
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts
View file @
ad4f3910
...
...
@@ -59,6 +59,13 @@ export class StackdriverFilterCtrl {
.
then
(
this
.
getLabels
.
bind
(
this
));
this
.
initSegments
(
$scope
.
hideGroupBys
);
this
.
handleMetricTypeChange
=
this
.
handleMetricTypeChange
.
bind
(
this
);
this
.
handleServiceChange
=
this
.
handleServiceChange
.
bind
(
this
);
}
handleMetricTypeChange
(
value
)
{
this
.
metricType
=
value
;
this
.
onMetricTypeChange
();
}
initSegments
(
hideGroupBys
:
boolean
)
{
...
...
@@ -110,7 +117,7 @@ export class StackdriverFilterCtrl {
const
services
=
this
.
metricDescriptors
.
map
(
m
=>
{
return
{
value
:
m
.
service
,
text
:
m
.
serviceShortName
,
label
:
m
.
serviceShortName
,
};
});
...
...
@@ -128,7 +135,8 @@ export class StackdriverFilterCtrl {
value
:
m
.
type
,
serviceShortName
:
m
.
serviceShortName
,
text
:
m
.
displayName
,
title
:
m
.
description
,
label
:
m
.
displayName
,
description
:
m
.
description
,
};
});
...
...
@@ -167,8 +175,8 @@ export class StackdriverFilterCtrl {
});
}
onServiceChange
(
)
{
this
.
target
.
service
=
this
.
service
;
handleServiceChange
(
service
)
{
this
.
target
.
service
=
this
.
service
=
service
;
this
.
metrics
=
this
.
getMetricsList
();
this
.
setMetricType
();
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