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
2342f60a
Commit
2342f60a
authored
Oct 31, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added actions
parent
1656f03a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
7 deletions
+46
-7
public/app/features/datasources/settings/ButtonRow.tsx
+2
-2
public/app/features/datasources/settings/DataSourceSettings.tsx
+23
-5
public/app/features/datasources/state/actions.ts
+18
-0
public/app/features/datasources/state/reducers.ts
+3
-0
No files found.
public/app/features/datasources/settings/ButtonRow.tsx
View file @
2342f60a
...
...
@@ -2,7 +2,7 @@ import React, { SFC } from 'react';
export
interface
Props
{
isReadOnly
:
boolean
;
onDelete
:
(
event
)
=>
void
;
onDelete
:
()
=>
void
;
onSubmit
:
(
event
)
=>
void
;
}
...
...
@@ -12,7 +12,7 @@ const ButtonRow: SFC<Props> = ({ isReadOnly, onDelete, onSubmit }) => {
<
button
type=
"submit"
className=
"btn btn-success"
disabled=
{
isReadOnly
}
onClick=
{
event
=>
onSubmit
(
event
)
}
>
Save
&
Test
</
button
>
<
button
type=
"submit"
className=
"btn btn-danger"
disabled=
{
isReadOnly
}
onClick=
{
event
=>
onDelete
(
event
)
}
>
<
button
type=
"submit"
className=
"btn btn-danger"
disabled=
{
isReadOnly
}
onClick=
{
onDelete
}
>
Delete
</
button
>
<
a
className=
"btn btn-inverse"
href=
"/datasources"
>
...
...
public/app/features/datasources/settings/DataSourceSettings.tsx
View file @
2342f60a
...
...
@@ -7,18 +7,21 @@ import PageLoader from '../../../core/components/PageLoader/PageLoader';
import
PluginSettings
from
'./PluginSettings'
;
import
BasicSettings
from
'./BasicSettings'
;
import
ButtonRow
from
'./ButtonRow'
;
import
{
loadDataSource
,
setDataSourceNam
e
}
from
'../state/actions'
;
import
{
deleteDataSource
,
loadDataSource
,
setDataSourceName
,
updateDataSourc
e
}
from
'../state/actions'
;
import
{
getNavModel
}
from
'../../../core/selectors/navModel'
;
import
{
getRouteParamsId
}
from
'../../../core/selectors/location'
;
import
{
getDataSource
,
getDataSourceMeta
}
from
'../state/selectors'
;
import
appEvents
from
'../../../core/app_events'
;
export
interface
Props
{
navModel
:
NavModel
;
dataSource
:
DataSource
;
dataSourceMeta
:
Plugin
;
pageId
:
number
;
deleteDataSource
:
typeof
deleteDataSource
;
loadDataSource
:
typeof
loadDataSource
;
setDataSourceName
:
typeof
setDataSourceName
;
updateDataSource
:
typeof
updateDataSource
;
}
interface
State
{
name
:
string
;
...
...
@@ -39,11 +42,24 @@ export class DataSourceSettings extends PureComponent<Props, State> {
onSubmit
=
event
=>
{
event
.
preventDefault
();
console
.
log
(
event
);
this
.
props
.
updateDataSource
();
};
onDelete
=
()
=>
{
appEvents
.
emit
(
'confirm-modal'
,
{
title
:
'Delete'
,
text
:
'Are you sure you want to delete this data source?'
,
yesText
:
'Delete'
,
icon
:
'fa-trash'
,
onConfirm
:
()
=>
{
this
.
confirmDelete
();
},
});
};
onDelete
=
event
=>
{
console
.
log
(
event
);
confirmDelete
=
()
=>
{
this
.
props
.
deleteDataSource
(
);
};
isReadOnly
()
{
...
...
@@ -111,7 +127,7 @@ export class DataSourceSettings extends PureComponent<Props, State> {
<
ButtonRow
onSubmit=
{
event
=>
this
.
onSubmit
(
event
)
}
isReadOnly=
{
this
.
isReadOnly
()
}
onDelete=
{
event
=>
this
.
onDelete
(
event
)
}
onDelete=
{
this
.
onDelete
}
/>
</
form
>
</
div
>
...
...
@@ -135,8 +151,10 @@ function mapStateToProps(state) {
}
const
mapDispatchToProps
=
{
deleteDataSource
,
loadDataSource
,
setDataSourceName
,
updateDataSource
,
};
export
default
hot
(
module
)(
connect
(
mapStateToProps
,
mapDispatchToProps
)(
DataSourceSettings
));
public/app/features/datasources/state/actions.ts
View file @
2342f60a
...
...
@@ -157,6 +157,24 @@ export function loadDataSourceTypes(): ThunkResult<void> {
};
}
export
function
updateDataSource
():
ThunkResult
<
void
>
{
return
async
(
dispatch
,
getStore
)
=>
{
const
dataSource
=
getStore
().
dataSources
.
dataSource
;
await
getBackendSrv
().
put
(
`/api/datasources/
${
dataSource
.
id
}
`
,
dataSource
);
dispatch
(
loadDataSource
(
dataSource
.
id
));
};
}
export
function
deleteDataSource
():
ThunkResult
<
void
>
{
return
async
(
dispatch
,
getStore
)
=>
{
const
dataSource
=
getStore
().
dataSources
.
dataSource
;
await
getBackendSrv
().
delete
(
`/api/datasources/
${
dataSource
.
id
}
`
);
dispatch
(
updateLocation
({
path
:
'/datasources'
}));
};
}
export
function
nameExits
(
dataSources
,
name
)
{
return
(
dataSources
.
filter
(
dataSource
=>
{
...
...
public/app/features/datasources/state/reducers.ts
View file @
2342f60a
...
...
@@ -36,6 +36,9 @@ export const dataSourcesReducer = (state = initialState, action: Action): DataSo
case
ActionTypes
.
LoadDataSourceMeta
:
return
{
...
state
,
dataSourceMeta
:
action
.
payload
};
case
ActionTypes
.
SetDataSourceName
:
return
{
...
state
,
dataSource
:
{
...
state
.
dataSource
,
name
:
action
.
payload
}
};
}
return
state
;
...
...
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