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
85603dbc
Commit
85603dbc
authored
Oct 04, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search data source types
parent
262fee0a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
6 deletions
+65
-6
public/app/features/datasources/NewDataSourcePage.tsx
+23
-3
public/app/features/datasources/state/actions.ts
+13
-1
public/app/features/datasources/state/reducers.ts
+4
-0
public/app/features/datasources/state/selectors.ts
+8
-0
public/app/types/datasources.ts
+1
-0
public/sass/components/_add_data_source.scss
+16
-2
No files found.
public/app/features/datasources/NewDataSourcePage.tsx
View file @
85603dbc
...
...
@@ -3,9 +3,10 @@ import { connect } from 'react-redux';
import
{
hot
}
from
'react-hot-loader'
;
import
PageHeader
from
'app/core/components/PageHeader/PageHeader'
;
import
{
NavModel
,
Plugin
}
from
'app/types'
;
import
{
addDataSource
,
loadDataSourceTypes
}
from
'./state/actions'
;
import
{
addDataSource
,
loadDataSourceTypes
,
setDataSourceTypeSearchQuery
}
from
'./state/actions'
;
import
{
updateLocation
}
from
'../../core/actions'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
getDataSourceTypes
}
from
'./state/selectors'
;
export
interface
Props
{
navModel
:
NavModel
;
...
...
@@ -13,6 +14,8 @@ export interface Props {
addDataSource
:
typeof
addDataSource
;
loadDataSourceTypes
:
typeof
loadDataSourceTypes
;
updateLocation
:
typeof
updateLocation
;
dataSourceTypeSearchQuery
:
string
;
setDataSourceTypeSearchQuery
:
typeof
setDataSourceTypeSearchQuery
;
}
class
NewDataSourcePage
extends
PureComponent
<
Props
>
{
...
...
@@ -24,14 +27,30 @@ class NewDataSourcePage extends PureComponent<Props> {
this
.
props
.
addDataSource
(
type
.
name
,
type
.
value
);
};
onSearchQueryChange
=
event
=>
{
this
.
props
.
setDataSourceTypeSearchQuery
(
event
.
target
.
value
);
};
render
()
{
const
{
navModel
,
dataSourceTypes
}
=
this
.
props
;
const
{
navModel
,
dataSourceTypes
,
dataSourceTypeSearchQuery
}
=
this
.
props
;
return
(
<
div
>
<
PageHeader
model=
{
navModel
}
/>
<
div
className=
"page-container page-body"
>
<
h3
className=
"add-data-source-header"
>
Choose data source type
</
h3
>
<
div
className=
"add-data-source-search"
>
<
label
className=
"gf-form--has-input-icon"
>
<
input
type=
"text"
className=
"gf-form-input width-20"
value=
{
dataSourceTypeSearchQuery
}
onChange=
{
this
.
onSearchQueryChange
}
placeholder=
"Filter by name or type"
/>
<
i
className=
"gf-form-input-icon fa fa-search"
/>
</
label
>
</
div
>
<
div
className=
"add-data-source-grid"
>
{
dataSourceTypes
.
map
((
type
,
index
)
=>
{
return
(
...
...
@@ -55,7 +74,7 @@ class NewDataSourcePage extends PureComponent<Props> {
function
mapStateToProps
(
state
)
{
return
{
navModel
:
getNavModel
(
state
.
navIndex
,
'datasources'
),
dataSourceTypes
:
state
.
dataSources
.
dataSourceTypes
,
dataSourceTypes
:
getDataSourceTypes
(
state
.
dataSources
)
,
};
}
...
...
@@ -63,6 +82,7 @@ const mapDispatchToProps = {
addDataSource
,
loadDataSourceTypes
,
updateLocation
,
setDataSourceTypeSearchQuery
,
};
export
default
hot
(
module
)(
connect
(
mapStateToProps
,
mapDispatchToProps
)(
NewDataSourcePage
));
public/app/features/datasources/state/actions.ts
View file @
85603dbc
...
...
@@ -10,6 +10,7 @@ export enum ActionTypes {
LoadDataSourceTypes
=
'LOAD_DATA_SOURCE_TYPES'
,
SetDataSourcesSearchQuery
=
'SET_DATA_SOURCES_SEARCH_QUERY'
,
SetDataSourcesLayoutMode
=
'SET_DATA_SOURCES_LAYOUT_MODE'
,
SetDataSourceTypeSearchQuery
=
'SET_DATA_SOURCE_TYPE_SEARCH_QUERY'
,
}
export
interface
LoadDataSourcesAction
{
...
...
@@ -32,6 +33,11 @@ export interface LoadDataSourceTypesAction {
payload
:
Plugin
[];
}
export
interface
SetDataSourceTypeSearchQueryAction
{
type
:
ActionTypes
.
SetDataSourceTypeSearchQuery
;
payload
:
string
;
}
const
dataSourcesLoaded
=
(
dataSources
:
DataSource
[]):
LoadDataSourcesAction
=>
({
type
:
ActionTypes
.
LoadDataSources
,
payload
:
dataSources
,
...
...
@@ -52,12 +58,18 @@ export const setDataSourcesLayoutMode = (layoutMode: LayoutMode): SetDataSources
payload
:
layoutMode
,
});
export
const
setDataSourceTypeSearchQuery
=
(
query
:
string
):
SetDataSourceTypeSearchQueryAction
=>
({
type
:
ActionTypes
.
SetDataSourceTypeSearchQuery
,
payload
:
query
,
});
export
type
Action
=
|
LoadDataSourcesAction
|
SetDataSourcesSearchQueryAction
|
SetDataSourcesLayoutModeAction
|
UpdateLocationAction
|
LoadDataSourceTypesAction
;
|
LoadDataSourceTypesAction
|
SetDataSourceTypeSearchQueryAction
;
type
ThunkResult
<
R
>
=
ThunkAction
<
R
,
StoreState
,
undefined
,
Action
>
;
...
...
public/app/features/datasources/state/reducers.ts
View file @
85603dbc
...
...
@@ -8,6 +8,7 @@ const initialState: DataSourcesState = {
searchQuery
:
''
,
dataSourcesCount
:
0
,
dataSourceTypes
:
[]
as
Plugin
[],
dataSourceTypeSearchQuery
:
''
,
};
export
const
dataSourcesReducer
=
(
state
=
initialState
,
action
:
Action
):
DataSourcesState
=>
{
...
...
@@ -23,6 +24,9 @@ export const dataSourcesReducer = (state = initialState, action: Action): DataSo
case
ActionTypes
.
LoadDataSourceTypes
:
return
{
...
state
,
dataSourceTypes
:
action
.
payload
};
case
ActionTypes
.
SetDataSourceTypeSearchQuery
:
return
{
...
state
,
dataSourceTypeSearchQuery
:
action
.
payload
};
}
return
state
;
...
...
public/app/features/datasources/state/selectors.ts
View file @
85603dbc
...
...
@@ -6,6 +6,14 @@ export const getDataSources = state => {
});
};
export
const
getDataSourceTypes
=
state
=>
{
const
regex
=
new
RegExp
(
state
.
dataSourceTypeSearchQuery
,
'i'
);
return
state
.
dataSourceTypes
.
filter
(
type
=>
{
return
regex
.
test
(
type
.
name
);
});
};
export
const
getDataSourcesSearchQuery
=
state
=>
state
.
searchQuery
;
export
const
getDataSourcesLayoutMode
=
state
=>
state
.
layoutMode
;
export
const
getDataSourcesCount
=
state
=>
state
.
dataSourcesCount
;
public/app/types/datasources.ts
View file @
85603dbc
...
...
@@ -21,6 +21,7 @@ export interface DataSource {
export
interface
DataSourcesState
{
dataSources
:
DataSource
[];
searchQuery
:
string
;
dataSourceTypeSearchQuery
:
string
;
layoutMode
:
LayoutMode
;
dataSourcesCount
:
number
;
dataSourceTypes
:
Plugin
[];
...
...
public/sass/components/_add_data_source.scss
View file @
85603dbc
.add-data-source-header
{
margin-bottom
:
20px
;
margin-bottom
:
$panel-margin
*
2
;
text-align
:
center
;
}
.add-data-source-search
{
display
:
flex
;
justify-content
:
center
;
margin-bottom
:
$panel-margin
*
6
;
}
.add-data-source-grid
{
display
:
grid
;
grid-template-columns
:
repeat
(
4
,
1fr
);
grid-template-columns
:
repeat
(
2
,
1fr
);
grid-row-gap
:
10px
;
grid-column-gap
:
10px
;
@include
media-breakpoint-up
(
md
)
{
grid-template-columns
:
repeat
(
3
,
1fr
);
}
@include
media-breakpoint-up
(
lg
)
{
grid-template-columns
:
repeat
(
4
,
1fr
);
}
}
.add-data-source-grid-item
{
...
...
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