diff --git a/public/app/features/admin/AdminSettings.tsx b/public/app/features/admin/AdminSettings.tsx new file mode 100644 index 00000000000..d9c91e63e76 --- /dev/null +++ b/public/app/features/admin/AdminSettings.tsx @@ -0,0 +1,79 @@ +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 { + 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 ( + + +
+ 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. +
+ + + + {Object.entries(settings).map(([sectionName, sectionSettings], i) => ( + + + + + {Object.entries(sectionSettings).map(([settingName, settingValue], j) => ( + + + + + ))} + + ))} + +
{sectionName} +
{settingName}{settingValue}
+
+
+ ); + } +} + +const mapStateToProps = (state: StoreState) => ({ + navModel: getNavModel(state.navIndex, 'server-settings'), +}); + +export default hot(module)(connect(mapStateToProps)(AdminSettings)); diff --git a/public/app/features/admin/ServerStats.tsx b/public/app/features/admin/ServerStats.tsx index 934f563e693..dd9ee3b7a7c 100644 --- a/public/app/features/admin/ServerStats.tsx +++ b/public/app/features/admin/ServerStats.tsx @@ -18,18 +18,13 @@ interface State { } export class ServerStats extends PureComponent { - 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) { diff --git a/public/app/features/admin/index.ts b/public/app/features/admin/index.ts index e0d60a408b8..396653bfc24 100644 --- a/public/app/features/admin/index.ts +++ b/public/app/features/admin/index.ts @@ -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); diff --git a/public/app/features/admin/partials/settings.html b/public/app/features/admin/partials/settings.html deleted file mode 100644 index 918a0d90f6e..00000000000 --- a/public/app/features/admin/partials/settings.html +++ /dev/null @@ -1,23 +0,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. -
- - - - - - - - - - -
{{secName}}
{{keyName}}{{keyValue}}
-
- - - diff --git a/public/app/routes/routes.ts b/public/app/routes/routes.ts index 8d351b1cbb4..9c651cc2b02 100644 --- a/public/app/routes/routes.ts +++ b/public/app/routes/routes.ts @@ -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: '', + resolve: { + component: () => + SafeDynamicImport(import(/* webpackChunkName: "AdminSettings" */ 'app/features/admin/AdminSettings')), + }, }) .when('/admin/users', { templateUrl: 'public/app/features/admin/partials/users.html',