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
27ddd2d6
Unverified
Commit
27ddd2d6
authored
Oct 03, 2019
by
kay delaney
Committed by
GitHub
Oct 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migration: Migrates Admin settings from angular to react (#19594)
parent
dafc9553
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
50 deletions
+88
-50
public/app/features/admin/AdminSettings.tsx
+79
-0
public/app/features/admin/ServerStats.tsx
+4
-9
public/app/features/admin/index.ts
+0
-15
public/app/features/admin/partials/settings.html
+0
-23
public/app/routes/routes.ts
+5
-3
No files found.
public/app/features/admin/AdminSettings.tsx
0 → 100644
View file @
27ddd2d6
import
React
from
'react'
;
import
{
connect
}
from
'react-redux'
;
import
{
hot
}
from
'react-hot-loader'
;
import
{
getBackendSrv
}
from
'@grafana/runtime'
;
import
{
NavModel
}
from
'@grafana/data'
;
import
{
StoreState
}
from
'app/types'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
Page
from
'app/core/components/Page/Page'
;
const
backendSrv
=
getBackendSrv
();
type
Settings
=
{
[
key
:
string
]:
{
[
key
:
string
]:
string
}
};
interface
Props
{
navModel
:
NavModel
;
}
interface
State
{
settings
:
Settings
;
isLoading
:
boolean
;
}
export
class
AdminSettings
extends
React
.
PureComponent
<
Props
,
State
>
{
state
:
State
=
{
settings
:
{},
isLoading
:
true
,
};
async
componentDidMount
()
{
const
settings
:
Settings
=
await
backendSrv
.
get
(
'/api/admin/settings'
);
this
.
setState
({
settings
,
isLoading
:
false
,
});
}
render
()
{
const
{
settings
,
isLoading
}
=
this
.
state
;
const
{
navModel
}
=
this
.
props
;
return
(
<
Page
navModel=
{
navModel
}
>
<
Page
.
Contents
isLoading=
{
isLoading
}
>
<
div
className=
"grafana-info-box span8"
style=
{
{
margin
:
'20px 0 25px 0'
}
}
>
These system settings are defined in grafana.ini or custom.ini (or overridden in ENV variables). To change
these you currently need to restart grafana.
</
div
>
<
table
className=
"filter-table"
>
<
tbody
>
{
Object
.
entries
(
settings
).
map
(([
sectionName
,
sectionSettings
],
i
)
=>
(
<
React
.
Fragment
key=
{
`section-${i}`
}
>
<
tr
>
<
td
className=
"admin-settings-section"
>
{
sectionName
}
</
td
>
<
td
/>
</
tr
>
{
Object
.
entries
(
sectionSettings
).
map
(([
settingName
,
settingValue
],
j
)
=>
(
<
tr
key=
{
`property-${j}`
}
>
<
td
style=
{
{
paddingLeft
:
'25px'
}
}
>
{
settingName
}
</
td
>
<
td
>
{
settingValue
}
</
td
>
</
tr
>
))
}
</
React
.
Fragment
>
))
}
</
tbody
>
</
table
>
</
Page
.
Contents
>
</
Page
>
);
}
}
const
mapStateToProps
=
(
state
:
StoreState
)
=>
({
navModel
:
getNavModel
(
state
.
navIndex
,
'server-settings'
),
});
export
default
hot
(
module
)(
connect
(
mapStateToProps
)(
AdminSettings
));
public/app/features/admin/ServerStats.tsx
View file @
27ddd2d6
...
...
@@ -18,18 +18,13 @@ interface State {
}
export
class
ServerStats
extends
PureComponent
<
Props
,
State
>
{
constructor
(
props
:
Props
)
{
super
(
props
);
this
.
state
=
{
stats
:
[],
isLoading
:
false
,
};
}
state
:
State
=
{
stats
:
[],
isLoading
:
true
,
};
async
componentDidMount
()
{
try
{
this
.
setState
({
isLoading
:
true
});
const
stats
=
await
this
.
props
.
getServerStats
();
this
.
setState
({
stats
,
isLoading
:
false
});
}
catch
(
error
)
{
...
...
public/app/features/admin/index.ts
View file @
27ddd2d6
...
...
@@ -5,22 +5,8 @@ import AdminEditOrgCtrl from './AdminEditOrgCtrl';
import
StyleGuideCtrl
from
'./StyleGuideCtrl'
;
import
coreModule
from
'app/core/core_module'
;
import
{
BackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
NavModelSrv
}
from
'app/core/core'
;
class
AdminSettingsCtrl
{
navModel
:
any
;
/** @ngInject */
constructor
(
$scope
:
any
,
backendSrv
:
BackendSrv
,
navModelSrv
:
NavModelSrv
)
{
this
.
navModel
=
navModelSrv
.
getNav
(
'admin'
,
'server-settings'
,
0
);
backendSrv
.
get
(
'/api/admin/settings'
).
then
((
settings
:
any
)
=>
{
$scope
.
settings
=
settings
;
});
}
}
class
AdminHomeCtrl
{
navModel
:
any
;
...
...
@@ -34,6 +20,5 @@ coreModule.controller('AdminListUsersCtrl', AdminListUsersCtrl);
coreModule
.
controller
(
'AdminEditUserCtrl'
,
AdminEditUserCtrl
);
coreModule
.
controller
(
'AdminListOrgsCtrl'
,
AdminListOrgsCtrl
);
coreModule
.
controller
(
'AdminEditOrgCtrl'
,
AdminEditOrgCtrl
);
coreModule
.
controller
(
'AdminSettingsCtrl'
,
AdminSettingsCtrl
);
coreModule
.
controller
(
'AdminHomeCtrl'
,
AdminHomeCtrl
);
coreModule
.
controller
(
'StyleGuideCtrl'
,
StyleGuideCtrl
);
public/app/features/admin/partials/settings.html
deleted
100644 → 0
View file @
dafc9553
<page-header
model=
"ctrl.navModel"
></page-header>
<div
class=
"page-container page-body"
>
<div
class=
"grafana-info-box span8"
style=
"margin: 20px 0 25px 0"
>
These system settings are defined in grafana.ini or custom.ini (or overridden in ENV variables).
To change these you currently need to restart grafana.
</div>
<table
class=
"filter-table"
>
<tr
ng-repeat-start=
"(secName, secValue) in settings"
>
<td
class=
"admin-settings-section"
>
{{secName}}
</td>
<td></td>
</tr>
<tr
ng-repeat=
"(keyName, keyValue) in secValue"
ng-repeat-end
>
<td
style=
"padding-left: 25px;"
>
{{keyName}}
</td>
<td>
{{keyValue}}
</td>
</tr>
</table>
</div>
public/app/routes/routes.ts
View file @
27ddd2d6
...
...
@@ -266,9 +266,11 @@ export function setupAngularRoutes($routeProvider: route.IRouteProvider, $locati
controllerAs
:
'ctrl'
,
})
.
when
(
'/admin/settings'
,
{
templateUrl
:
'public/app/features/admin/partials/settings.html'
,
controller
:
'AdminSettingsCtrl'
,
controllerAs
:
'ctrl'
,
template
:
'<react-container />'
,
resolve
:
{
component
:
()
=>
SafeDynamicImport
(
import
(
/* webpackChunkName: "AdminSettings" */
'app/features/admin/AdminSettings'
)),
},
})
.
when
(
'/admin/users'
,
{
templateUrl
:
'public/app/features/admin/partials/users.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