mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
shore: migrating config/settings.js to typescript
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
define([
|
||||
'app/core/settings',
|
||||
],
|
||||
function (Settings) {
|
||||
"use strict";
|
||||
|
||||
var bootData = window.grafanaBootData || { settings: {} };
|
||||
var options = bootData.settings;
|
||||
options.bootData = bootData;
|
||||
|
||||
return new Settings(options);
|
||||
|
||||
});
|
||||
38
public/app/core/config.ts
Normal file
38
public/app/core/config.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
class Settings {
|
||||
datasources: any;
|
||||
panels: any;
|
||||
appSubUrl: string;
|
||||
window_title_prefix: string;
|
||||
buildInfo: any;
|
||||
new_panel_title: string;
|
||||
bootData: any;
|
||||
externalUserMngLinkUrl: string;
|
||||
externalUserMngLinkName: string;
|
||||
externalUserMngInfo: string;
|
||||
allowOrgCreate: boolean;
|
||||
disableLoginForm: boolean;
|
||||
defaultDatasource: string;
|
||||
alertingEnabled: boolean;
|
||||
|
||||
constructor(options) {
|
||||
var defaults = {
|
||||
datasources: {},
|
||||
window_title_prefix: 'Grafana - ',
|
||||
panels: {},
|
||||
new_panel_title: 'Panel Title',
|
||||
playlist_timespan: "1m",
|
||||
unsaved_changes_warning: true,
|
||||
appSubUrl: ""
|
||||
};
|
||||
_.extend(this, defaults, options);
|
||||
}
|
||||
}
|
||||
|
||||
var bootData = (<any>window).grafanaBootData || { settings: {} };
|
||||
var options = bootData.settings;
|
||||
options.bootData = bootData;
|
||||
|
||||
const config = new Settings(options);
|
||||
export default config;
|
||||
@@ -6,6 +6,8 @@ define([
|
||||
function (angular, coreModule, config) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
|
||||
coreModule.default.controller('InvitedCtrl', function($scope, $routeParams, contextSrv, backendSrv) {
|
||||
contextSrv.sidemenu = false;
|
||||
$scope.formModel = {};
|
||||
|
||||
@@ -7,6 +7,8 @@ define([
|
||||
function (angular, _, coreModule, config) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
|
||||
coreModule.default.controller('LoginCtrl', function($scope, backendSrv, contextSrv, $location) {
|
||||
$scope.formModel = {
|
||||
user: '',
|
||||
|
||||
@@ -7,6 +7,8 @@ define([
|
||||
function(angular, $, coreModule, config) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
|
||||
coreModule.default.service('googleAnalyticsSrv', function($rootScope, $location) {
|
||||
|
||||
function gaInit() {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
define([
|
||||
'lodash',
|
||||
],
|
||||
function (_) {
|
||||
"use strict";
|
||||
|
||||
return function Settings (options) {
|
||||
var defaults = {
|
||||
datasources : {},
|
||||
window_title_prefix : 'Grafana - ',
|
||||
panels : {},
|
||||
new_panel_title: 'Panel Title',
|
||||
playlist_timespan: "1m",
|
||||
unsaved_changes_warning: true,
|
||||
appSubUrl: ""
|
||||
};
|
||||
|
||||
return _.extend({}, defaults, options);
|
||||
};
|
||||
});
|
||||
@@ -5,8 +5,7 @@ define([
|
||||
'jquery',
|
||||
'app/core/utils/kbn',
|
||||
'app/core/utils/datemath',
|
||||
'./impression_store',
|
||||
'app/core/config',
|
||||
'./impression_store'
|
||||
],
|
||||
function (angular, moment, _, $, kbn, dateMath, impressionStore) {
|
||||
'use strict';
|
||||
|
||||
@@ -7,6 +7,8 @@ define(['angular',
|
||||
function (angular, _, $, moment, config) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('ShareModalCtrl', function($scope, $rootScope, $location, $timeout, timeSrv, templateSrv, linkSrv) {
|
||||
|
||||
@@ -7,6 +7,7 @@ define([
|
||||
function (angular, _, $, config) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
var module = angular.module('grafana.services');
|
||||
|
||||
module.factory('dashboardViewStateSrv', function($location, $timeout) {
|
||||
|
||||
@@ -5,6 +5,8 @@ define([
|
||||
function (angular, config) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('ChangePasswordCtrl', function($scope, backendSrv, $location, navModelSrv) {
|
||||
|
||||
@@ -5,6 +5,8 @@ define([
|
||||
function (angular, config) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('NewOrgCtrl', function($scope, $http, backendSrv, navModelSrv) {
|
||||
|
||||
@@ -5,6 +5,8 @@ define([
|
||||
function (angular, config) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('SelectOrgCtrl', function($scope, backendSrv, contextSrv) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
define([
|
||||
'angular',
|
||||
'app/core/config',
|
||||
'lodash'
|
||||
],
|
||||
function (angular) {
|
||||
|
||||
@@ -8,6 +8,8 @@ define([
|
||||
function (angular, _, coreModule, config, pluginLoader) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
|
||||
coreModule.default.service('datasourceSrv', function($q, $injector, $rootScope, templateSrv) {
|
||||
var self = this;
|
||||
|
||||
|
||||
@@ -42,14 +42,14 @@
|
||||
<select class="input-small gf-form-input" ng-model="ctrl.panel.postfixFontSize" ng-options="f for f in ctrl.fontSizes" ng-change="ctrl.render()"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-6">Unit</label>
|
||||
<div class="gf-form-dropdown-typeahead width-18" ng-model="ctrl.panel.format" dropdown-typeahead2="ctrl.unitFormats" dropdown-typeahead-on-select="ctrl.setUnitFormat($subItem)"></div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-6">Decimals</label>
|
||||
<input type="number" class="gf-form-input width-18" placeholder="auto" data-placement="right" bs-tooltip="'Override automatic decimal precision for legend and tooltips'" ng-model="ctrl.panel.decimals" ng-change="ctrl.refresh()" ng-model-onblur>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-6">Unit</label>
|
||||
<div class="gf-form-dropdown-typeahead width-18" ng-model="ctrl.panel.format" dropdown-typeahead2="ctrl.unitFormats" dropdown-typeahead-on-select="ctrl.setUnitFormat($subItem)"></div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-6">Decimals</label>
|
||||
<input type="number" class="gf-form-input width-18" placeholder="auto" data-placement="right" bs-tooltip="'Override automatic decimal precision for legend and tooltips'" ng-model="ctrl.panel.decimals" ng-change="ctrl.refresh()" ng-model-onblur>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section gf-form-group">
|
||||
|
||||
@@ -5,6 +5,8 @@ define([
|
||||
], function(_, config, dateMath) {
|
||||
'use strict';
|
||||
|
||||
config = config.default;
|
||||
|
||||
function ControllerTestContext() {
|
||||
var self = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user