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
33dd880e
Unverified
Commit
33dd880e
authored
Dec 04, 2018
by
Torkel Ödegaard
Committed by
GitHub
Dec 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14295 from grafana/develop-visualization-search
Add VizPicker search
parents
fe9e4b51
bc5a0d91
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
8 deletions
+30
-8
public/app/features/dashboard/dashgrid/VizTypePicker.tsx
+30
-8
No files found.
public/app/features/dashboard/dashgrid/VizTypePicker.tsx
View file @
33dd880e
...
@@ -11,21 +11,22 @@ interface Props {
...
@@ -11,21 +11,22 @@ interface Props {
}
}
interface
State
{
interface
State
{
pluginList
:
PanelPlugin
[]
;
searchQuery
:
string
;
}
}
export
class
VizTypePicker
extends
PureComponent
<
Props
,
State
>
{
export
class
VizTypePicker
extends
PureComponent
<
Props
,
State
>
{
searchInput
:
HTMLElement
;
searchInput
:
HTMLElement
;
pluginList
=
this
.
getPanelPlugins
(
''
);
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
pluginList
:
this
.
getPanelPlugins
(
''
)
,
searchQuery
:
''
,
};
};
}
}
getPanelPlugins
(
filter
)
{
getPanelPlugins
(
filter
)
:
PanelPlugin
[]
{
const
panels
=
_
.
chain
(
config
.
panels
)
const
panels
=
_
.
chain
(
config
.
panels
)
.
filter
({
hideFromList
:
false
})
.
filter
({
hideFromList
:
false
})
.
map
(
item
=>
item
)
.
map
(
item
=>
item
)
...
@@ -35,7 +36,7 @@ export class VizTypePicker extends PureComponent<Props, State> {
...
@@ -35,7 +36,7 @@ export class VizTypePicker extends PureComponent<Props, State> {
return
_
.
sortBy
(
panels
,
'sort'
);
return
_
.
sortBy
(
panels
,
'sort'
);
}
}
renderVizPlugin
=
(
plugin
,
index
)
=>
{
renderVizPlugin
=
(
plugin
:
PanelPlugin
,
index
:
number
)
=>
{
const
cssClass
=
classNames
({
const
cssClass
=
classNames
({
'viz-picker__item'
:
true
,
'viz-picker__item'
:
true
,
'viz-picker__item--selected'
:
plugin
.
id
===
this
.
props
.
current
.
id
,
'viz-picker__item--selected'
:
plugin
.
id
===
this
.
props
.
current
.
id
,
...
@@ -55,7 +56,27 @@ export class VizTypePicker extends PureComponent<Props, State> {
...
@@ -55,7 +56,27 @@ export class VizTypePicker extends PureComponent<Props, State> {
},
300
);
},
300
);
}
}
renderFilters
()
{
getFilteredPluginList
=
():
PanelPlugin
[]
=>
{
const
{
searchQuery
}
=
this
.
state
;
const
regex
=
new
RegExp
(
searchQuery
,
'i'
);
const
pluginList
=
this
.
pluginList
;
const
filtered
=
pluginList
.
filter
(
item
=>
{
return
regex
.
test
(
item
.
name
);
});
return
filtered
;
};
onSearchQueryChange
=
evt
=>
{
const
value
=
evt
.
target
.
value
;
this
.
setState
(
prevState
=>
({
...
prevState
,
searchQuery
:
value
,
}));
};
renderFilters
=
()
=>
{
return
(
return
(
<>
<>
<
label
className=
"gf-form--has-input-icon"
>
<
label
className=
"gf-form--has-input-icon"
>
...
@@ -64,15 +85,16 @@ export class VizTypePicker extends PureComponent<Props, State> {
...
@@ -64,15 +85,16 @@ export class VizTypePicker extends PureComponent<Props, State> {
className=
"gf-form-input width-13"
className=
"gf-form-input width-13"
placeholder=
""
placeholder=
""
ref=
{
elem
=>
(
this
.
searchInput
=
elem
)
}
ref=
{
elem
=>
(
this
.
searchInput
=
elem
)
}
onChange=
{
this
.
onSearchQueryChange
}
/>
/>
<
i
className=
"gf-form-input-icon fa fa-search"
/>
<
i
className=
"gf-form-input-icon fa fa-search"
/>
</
label
>
</
label
>
</>
</>
);
);
}
}
;
render
()
{
render
()
{
const
{
pluginList
}
=
this
.
state
;
const
filteredPluginList
=
this
.
getFilteredPluginList
()
;
return
(
return
(
<>
<>
...
@@ -81,7 +103,7 @@ export class VizTypePicker extends PureComponent<Props, State> {
...
@@ -81,7 +103,7 @@ export class VizTypePicker extends PureComponent<Props, State> {
<
div
className=
"gf-form--grow"
/>
<
div
className=
"gf-form--grow"
/>
</
div
>
</
div
>
<
div
className=
"viz-picker"
>
{
p
luginList
.
map
(
this
.
renderVizPlugin
)
}
</
div
>
<
div
className=
"viz-picker"
>
{
filteredP
luginList
.
map
(
this
.
renderVizPlugin
)
}
</
div
>
</>
</>
);
);
}
}
...
...
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