mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
committed by
Hugo Häggmark
parent
1db7913a1c
commit
aa4b593dfa
@@ -17,12 +17,13 @@ import 'vendor/angular-other/angular-strap';
|
||||
import $ from 'jquery';
|
||||
import angular from 'angular';
|
||||
import config from 'app/core/config';
|
||||
// @ts-ignore ignoring this for now, otherwise we would have to extend _ interface with move
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
import { addClassIfNoOverlayScrollbar } from 'app/core/utils/scrollbar';
|
||||
|
||||
// add move to lodash for backward compatabiltiy
|
||||
_.move = (array, fromIndex, toIndex) => {
|
||||
_.move = (array: [], fromIndex: number, toIndex: number) => {
|
||||
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);
|
||||
return array;
|
||||
};
|
||||
@@ -36,7 +37,7 @@ import 'app/features/all';
|
||||
|
||||
// import symlinked extensions
|
||||
const extensionsIndex = (require as any).context('.', true, /extensions\/index.ts/);
|
||||
extensionsIndex.keys().forEach(key => {
|
||||
extensionsIndex.keys().forEach((key: any) => {
|
||||
extensionsIndex(key);
|
||||
});
|
||||
|
||||
@@ -52,7 +53,7 @@ export class GrafanaApp {
|
||||
this.ngModuleDependencies = [];
|
||||
}
|
||||
|
||||
useModule(module) {
|
||||
useModule(module: angular.IModule) {
|
||||
if (this.preBootModules) {
|
||||
this.preBootModules.push(module);
|
||||
} else {
|
||||
@@ -67,40 +68,49 @@ export class GrafanaApp {
|
||||
|
||||
moment.locale(config.bootData.user.locale);
|
||||
|
||||
app.config(($locationProvider, $controllerProvider, $compileProvider, $filterProvider, $httpProvider, $provide) => {
|
||||
// pre assing bindings before constructor calls
|
||||
$compileProvider.preAssignBindingsEnabled(true);
|
||||
app.config(
|
||||
(
|
||||
$locationProvider: angular.ILocationProvider,
|
||||
$controllerProvider: angular.IControllerProvider,
|
||||
$compileProvider: angular.ICompileProvider,
|
||||
$filterProvider: angular.IFilterProvider,
|
||||
$httpProvider: angular.IHttpProvider,
|
||||
$provide: angular.auto.IProvideService
|
||||
) => {
|
||||
// pre assing bindings before constructor calls
|
||||
$compileProvider.preAssignBindingsEnabled(true);
|
||||
|
||||
if (config.buildInfo.env !== 'development') {
|
||||
$compileProvider.debugInfoEnabled(false);
|
||||
}
|
||||
if (config.buildInfo.env !== 'development') {
|
||||
$compileProvider.debugInfoEnabled(false);
|
||||
}
|
||||
|
||||
$httpProvider.useApplyAsync(true);
|
||||
$httpProvider.useApplyAsync(true);
|
||||
|
||||
this.registerFunctions.controller = $controllerProvider.register;
|
||||
this.registerFunctions.directive = $compileProvider.directive;
|
||||
this.registerFunctions.factory = $provide.factory;
|
||||
this.registerFunctions.service = $provide.service;
|
||||
this.registerFunctions.filter = $filterProvider.register;
|
||||
this.registerFunctions.controller = $controllerProvider.register;
|
||||
this.registerFunctions.directive = $compileProvider.directive;
|
||||
this.registerFunctions.factory = $provide.factory;
|
||||
this.registerFunctions.service = $provide.service;
|
||||
this.registerFunctions.filter = $filterProvider.register;
|
||||
|
||||
$provide.decorator('$http', [
|
||||
'$delegate',
|
||||
'$templateCache',
|
||||
($delegate, $templateCache) => {
|
||||
const get = $delegate.get;
|
||||
$delegate.get = (url, config) => {
|
||||
if (url.match(/\.html$/)) {
|
||||
// some template's already exist in the cache
|
||||
if (!$templateCache.get(url)) {
|
||||
url += '?v=' + new Date().getTime();
|
||||
$provide.decorator('$http', [
|
||||
'$delegate',
|
||||
'$templateCache',
|
||||
($delegate: any, $templateCache: any) => {
|
||||
const get = $delegate.get;
|
||||
$delegate.get = (url: string, config: any) => {
|
||||
if (url.match(/\.html$/)) {
|
||||
// some template's already exist in the cache
|
||||
if (!$templateCache.get(url)) {
|
||||
url += '?v=' + new Date().getTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
return get(url, config);
|
||||
};
|
||||
return $delegate;
|
||||
},
|
||||
]);
|
||||
});
|
||||
return get(url, config);
|
||||
};
|
||||
return $delegate;
|
||||
},
|
||||
]);
|
||||
}
|
||||
);
|
||||
|
||||
this.ngModuleDependencies = [
|
||||
'grafana.core',
|
||||
@@ -116,7 +126,7 @@ export class GrafanaApp {
|
||||
];
|
||||
|
||||
// makes it possible to add dynamic stuff
|
||||
_.each(angularModules, m => {
|
||||
_.each(angularModules, (m: angular.IModule) => {
|
||||
this.useModule(m);
|
||||
});
|
||||
|
||||
@@ -129,7 +139,7 @@ export class GrafanaApp {
|
||||
|
||||
// bootstrap the app
|
||||
angular.bootstrap(document, this.ngModuleDependencies).invoke(() => {
|
||||
_.each(this.preBootModules, module => {
|
||||
_.each(this.preBootModules, (module: angular.IModule) => {
|
||||
_.extend(module, this.registerFunctions);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user