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
7a39e555
Commit
7a39e555
authored
Oct 02, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
view and route
parent
c3f87b56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
3 deletions
+115
-3
public/app/features/datasources/NewDataSourcePage.tsx
+110
-0
public/app/routes/routes.ts
+5
-3
No files found.
public/app/features/datasources/NewDataSourcePage.tsx
0 → 100644
View file @
7a39e555
import
React
,
{
PureComponent
}
from
'react'
;
import
{
connect
}
from
'react-redux'
;
import
{
hot
}
from
'react-hot-loader'
;
import
Select
from
'react-select'
;
import
PageHeader
from
'app/core/components/PageHeader/PageHeader'
;
import
{
NavModel
}
from
'app/types'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
export
interface
Props
{
navModel
:
NavModel
;
}
export
interface
State
{
name
:
string
;
type
:
string
;
dataSourceOptions
:
Array
<
{
value
:
string
;
label
:
string
}
>
;
}
class
NewDataSourcePage
extends
PureComponent
<
Props
,
State
>
{
state
=
{
name
:
''
,
type
:
''
,
dataSourceOptions
:
[
{
value
:
'prometheus'
,
label
:
'Prometheus'
},
{
value
:
'graphite'
,
label
:
'Graphite'
},
{
value
:
'mysql'
,
label
:
'MySql'
},
{
value
:
'influxdb'
,
label
:
'InfluxDB'
},
],
};
onChangeName
=
event
=>
{
this
.
setState
({
name
:
event
.
target
.
value
,
});
};
onTypeChanged
=
type
=>
{
this
.
setState
({
type
:
type
,
});
};
submitForm
=
()
=>
{
if
(
!
this
.
isFieldsEmpty
())
{
// post
}
};
isFieldsEmpty
=
()
=>
{
const
{
name
,
type
}
=
this
.
state
;
if
(
name
===
''
&&
type
===
''
)
{
return
true
;
}
else
if
(
name
!==
''
&&
type
===
''
)
{
return
true
;
}
else
{
return
name
===
''
&&
type
!==
''
;
}
};
render
()
{
const
{
navModel
}
=
this
.
props
;
const
{
dataSourceOptions
,
name
,
type
}
=
this
.
state
;
return
(
<
div
>
<
PageHeader
model=
{
navModel
}
/>
<
div
className=
"page-container page-body"
>
<
h3
className=
"page-sub-heading"
>
New Data source
</
h3
>
<
form
onSubmit=
{
this
.
submitForm
}
>
<
div
className=
"gf-form max-width-30"
>
<
span
className=
"gf-form-label width-7"
>
Name
</
span
>
<
input
className=
"gf-form-input max-width-23"
type=
"text"
value=
{
name
}
onChange=
{
this
.
onChangeName
}
placeholder=
"Name"
/>
</
div
>
<
div
className=
"gf-form max-width-30"
>
<
span
className=
"gf-form-label width-7"
>
Type
</
span
>
<
Select
options=
{
dataSourceOptions
}
value=
{
type
}
onChange=
{
this
.
onTypeChanged
}
autoSize=
{
true
}
className=
"width-23"
/>
</
div
>
<
div
className=
"gf-form-button-row"
>
<
button
type=
"submit"
className=
"btn btn-success"
disabled=
{
this
.
isFieldsEmpty
()
}
>
Create
</
button
>
<
button
className=
"btn btn-danger"
>
Cancel
</
button
>
</
div
>
</
form
>
</
div
>
</
div
>
);
}
}
function
mapStateToProps
(
state
)
{
return
{
navModel
:
getNavModel
(
state
.
navIndex
,
'datasources'
),
};
}
export
default
hot
(
module
)(
connect
(
mapStateToProps
)(
NewDataSourcePage
));
public/app/routes/routes.ts
View file @
7a39e555
...
@@ -10,6 +10,7 @@ import PluginListPage from 'app/features/plugins/PluginListPage';
...
@@ -10,6 +10,7 @@ import PluginListPage from 'app/features/plugins/PluginListPage';
import
FolderSettingsPage
from
'app/features/folders/FolderSettingsPage'
;
import
FolderSettingsPage
from
'app/features/folders/FolderSettingsPage'
;
import
FolderPermissions
from
'app/features/folders/FolderPermissions'
;
import
FolderPermissions
from
'app/features/folders/FolderPermissions'
;
import
DataSourcesListPage
from
'app/features/datasources/DataSourcesListPage'
;
import
DataSourcesListPage
from
'app/features/datasources/DataSourcesListPage'
;
import
NewDataSourcePage
from
'../features/datasources/NewDataSourcePage'
;
/** @ngInject */
/** @ngInject */
export
function
setupAngularRoutes
(
$routeProvider
,
$locationProvider
)
{
export
function
setupAngularRoutes
(
$routeProvider
,
$locationProvider
)
{
...
@@ -80,9 +81,10 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
...
@@ -80,9 +81,10 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
controllerAs
:
'ctrl'
,
controllerAs
:
'ctrl'
,
})
})
.
when
(
'/datasources/new'
,
{
.
when
(
'/datasources/new'
,
{
templateUrl
:
'public/app/features/plugins/partials/ds_edit.html'
,
template
:
'<react-container />'
,
controller
:
'DataSourceEditCtrl'
,
resolve
:
{
controllerAs
:
'ctrl'
,
component
:
()
=>
NewDataSourcePage
,
},
})
})
.
when
(
'/dashboards'
,
{
.
when
(
'/dashboards'
,
{
templateUrl
:
'public/app/features/manage-dashboards/partials/dashboard_list.html'
,
templateUrl
:
'public/app/features/manage-dashboards/partials/dashboard_list.html'
,
...
...
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