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
596a8340
Commit
596a8340
authored
Oct 24, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed routes and page
parent
8c742a95
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
60 deletions
+96
-60
public/app/features/datasources/DataSourceSettings.tsx
+86
-60
public/app/features/plugins/__mocks__/pluginMocks.ts
+2
-0
public/app/routes/routes.ts
+7
-0
public/app/types/plugins.ts
+1
-0
No files found.
public/app/features/datasources/DataSourceSettings.tsx
View file @
596a8340
import
React
,
{
createRef
,
PureComponent
}
from
'react'
;
import
{
connect
}
from
'react-redux'
;
import
{
DataSource
,
Plugin
}
from
'app/types'
;
import
{
DataSource
,
NavModel
,
Plugin
}
from
'app/types'
;
import
PageHeader
from
'../../core/components/PageHeader/PageHeader'
;
import
{
importPluginModule
}
from
'../plugins/plugin_loader'
;
import
{
loadDataSource
}
from
'./state/actions'
;
import
{
getNavModel
}
from
'../../core/selectors/navModel'
;
import
{
getRouteParamsId
}
from
'../../core/selectors/location'
;
export
interface
Props
{
navModel
:
NavModel
;
dataSource
:
DataSource
;
dataSourceMeta
:
Plugin
;
pageId
:
number
;
loadDataSource
:
typeof
loadDataSource
;
}
interface
State
{
name
:
string
;
...
...
@@ -24,10 +32,13 @@ export class DataSourceSettings extends PureComponent<Props, State> {
showNamePopover
:
false
,
};
componentDidMount
()
{
// importPluginModule(this.props.dataSourceMeta.module).then(pluginExports => {
// console.log(pluginExports);
// });
async
componentDidMount
()
{
const
{
loadDataSource
,
pageId
}
=
this
.
props
;
await
loadDataSource
(
pageId
);
importPluginModule
(
this
.
props
.
dataSourceMeta
.
module
).
then
(
pluginExports
=>
{
console
.
log
(
pluginExports
);
});
}
onNameChange
=
event
=>
{
...
...
@@ -84,75 +95,90 @@ export class DataSourceSettings extends PureComponent<Props, State> {
render
()
{
const
{
name
,
showNamePopover
}
=
this
.
state
;
console
.
log
(
this
.
props
);
return
(
<
div
>
<
form
onSubmit=
{
this
.
onSubmit
}
>
<
div
className=
"gf-form-group"
>
<
div
className=
"gf-form-inline"
>
<
div
className=
"gf-form max-width-30"
>
<
span
className=
"gf-form-label width-10"
>
Name
</
span
>
<
input
className=
"gf-form-input max-width-23"
type=
"text"
value=
{
name
}
placeholder=
"Name"
onChange=
{
this
.
onNameChange
}
required
/>
<
div
onClick=
{
this
.
onTogglePopover
}
>
<
i
className=
"fa fa-info-circle"
/>
</
div
>
{
showNamePopover
&&
(
<
div
style=
{
{
position
:
'absolute'
,
left
:
'450px'
,
top
:
'-20px'
,
padding
:
'10px'
,
backgroundColor
:
'black'
,
zIndex
:
2
,
width
:
'300px'
,
border
:
'1px solid gray'
,
borderRadius
:
'3px'
,
}
}
>
The name is used when you select the data source in panels. The
<
em
>
Default
</
em
>
data source is
preselected in new panels.
<
PageHeader
model=
{
this
.
props
.
navModel
}
/>
<
div
className=
"page-container page-body"
>
<
div
>
<
form
onSubmit=
{
this
.
onSubmit
}
>
<
div
className=
"gf-form-group"
>
<
div
className=
"gf-form-inline"
>
<
div
className=
"gf-form max-width-30"
>
<
span
className=
"gf-form-label width-10"
>
Name
</
span
>
<
input
className=
"gf-form-input max-width-23"
type=
"text"
value=
{
name
}
placeholder=
"Name"
onChange=
{
this
.
onNameChange
}
required
/>
<
div
onClick=
{
this
.
onTogglePopover
}
>
<
i
className=
"fa fa-info-circle"
/>
</
div
>
{
showNamePopover
&&
(
<
div
style=
{
{
position
:
'absolute'
,
left
:
'450px'
,
top
:
'-20px'
,
padding
:
'10px'
,
backgroundColor
:
'black'
,
zIndex
:
2
,
width
:
'300px'
,
border
:
'1px solid gray'
,
borderRadius
:
'3px'
,
}
}
>
The name is used when you select the data source in panels. The
<
em
>
Default
</
em
>
data source is
preselected in new panels.
</
div
>
)
}
</
div
>
)
}
</
div
>
</
div
>
</
div
>
</
div
>
{
this
.
shouldRenderInfoBox
()
&&
<
div
className=
"grafana-info-box"
>
{
this
.
getInfoText
()
}
</
div
>
}
{
this
.
isReadyOnly
()
&&
(
<
div
className=
"grafana-info-box span8"
>
This datasource was added by config and cannot be modified using the UI. Please contact your server admin
to update this datasource.
</
div
>
)
}
<
div
ref=
{
this
.
settingsElement
}
/
>
<
div
className=
"gf-form-button-row"
>
<
button
type=
"submit"
className=
"btn btn-success"
disabled=
{
this
.
isReadyOnly
()
}
onClick=
{
this
.
onSubmit
}
>
Save
&
Test
</
button
>
<
button
type=
"submit"
className=
"btn btn-danger"
disabled=
{
this
.
isReadyOnly
()
}
onClick=
{
this
.
onDelete
}
>
Delete
</
button
>
<
a
className=
"btn btn-inverse"
href=
"datasources"
>
Back
</
a
>
{
this
.
shouldRenderInfoBox
()
&&
<
div
className=
"grafana-info-box"
>
{
this
.
getInfoText
()
}
</
div
>
}
{
this
.
isReadyOnly
()
&&
(
<
div
className=
"grafana-info-box span8"
>
This datasource was added by config and cannot be modified using the UI. Please contact your server
admin to update this datasource.
</
div
>
)
}
<
div
ref=
{
this
.
settingsElement
}
/
>
<
div
className=
"gf-form-button-row"
>
<
button
type=
"submit"
className=
"btn btn-success"
disabled=
{
this
.
isReadyOnly
()
}
onClick=
{
this
.
onSubmit
}
>
Save
&
Test
</
button
>
<
button
type=
"submit"
className=
"btn btn-danger"
disabled=
{
this
.
isReadyOnly
()
}
onClick=
{
this
.
onDelete
}
>
Delete
</
button
>
<
a
className=
"btn btn-inverse"
href=
"datasources"
>
Back
</
a
>
</
div
>
</
form
>
</
div
>
</
form
>
</
div
>
</
div
>
);
}
}
function
mapStateToProps
(
state
)
{
const
pageId
=
getRouteParamsId
(
state
.
location
);
return
{
navModel
:
getNavModel
(
state
.
navIndex
,
`datasource-settings-
${
pageId
}
`
),
dataSource
:
state
.
dataSources
.
dataSource
,
dataSourceMeta
:
state
.
dataSources
.
dataSourceMeta
,
pageId
:
pageId
,
};
}
export
default
connect
(
mapStateToProps
)(
DataSourceSettings
);
const
mapDispatchToProps
=
{
loadDataSource
,
};
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
DataSourceSettings
);
public/app/features/plugins/__mocks__/pluginMocks.ts
View file @
596a8340
...
...
@@ -26,6 +26,7 @@ export const getMockPlugins = (amount: number): Plugin[] => {
pinned
:
false
,
state
:
''
,
type
:
''
,
module
:
{},
});
}
...
...
@@ -55,5 +56,6 @@ export const getMockPlugin = () => {
pinned
:
false
,
state
:
''
,
type
:
''
,
module
:
{},
};
};
public/app/routes/routes.ts
View file @
596a8340
...
...
@@ -14,6 +14,7 @@ import DataSourcesListPage from 'app/features/datasources/DataSourcesListPage';
import
NewDataSourcePage
from
'../features/datasources/NewDataSourcePage'
;
import
UsersListPage
from
'app/features/users/UsersListPage'
;
import
DataSourceDashboards
from
'app/features/datasources/DataSourceDashboards'
;
import
DataSourceSettings
from
'../features/datasources/DataSourceSettings'
;
/** @ngInject */
export
function
setupAngularRoutes
(
$routeProvider
,
$locationProvider
)
{
...
...
@@ -73,6 +74,12 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
component
:
()
=>
DataSourcesListPage
,
},
})
.
when
(
'/datasources/edit/:id/'
,
{
template
:
'<react-container />'
,
resolve
:
{
component
:
()
=>
DataSourceSettings
,
},
})
.
when
(
'/datasources/edit/:id/dashboards'
,
{
template
:
'<react-container />'
,
resolve
:
{
...
...
public/app/types/plugins.ts
View file @
596a8340
...
...
@@ -60,6 +60,7 @@ export interface Plugin {
pinned
:
boolean
;
state
:
string
;
type
:
string
;
module
:
any
;
}
export
interface
PluginDashboard
{
...
...
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