This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/quay-config.module.ts

128 lines
3.8 KiB
TypeScript
Raw Normal View History

import { NgModule } from 'ng-metadata/core';
2017-02-20 02:35:46 +00:00
import { INJECTED_CONFIG, INJECTED_FEATURES, INJECTED_ENDPOINTS } from "./constants/injected-values.constant";
import { NAME_PATTERNS } from "./constants/name-patterns.constant";
import * as Raven from "raven-js";
var quayDependencies: string[] = [
2017-02-20 02:35:46 +00:00
'chieffancypants.loadingBar',
'cfp.hotkeys',
'angular-tour',
'restangular',
'angularMoment',
'mgcrea.ngStrap',
'ngCookies',
'ngSanitize',
'angular-md5',
'pasvaz.bindonce',
'ansiToHtml',
'core-ui',
'infinite-scroll',
2017-03-10 00:10:44 +00:00
'ngTagsInput',
2017-02-20 02:35:46 +00:00
];
if (INJECTED_CONFIG && (INJECTED_CONFIG.MIXPANEL_KEY ||
INJECTED_CONFIG.MUNCHKIN_KEY ||
INJECTED_CONFIG.GOOGLE_ANALYTICS_KEY)) {
quayDependencies.push('angulartics');
}
if (INJECTED_CONFIG && INJECTED_CONFIG.MIXPANEL_KEY) {
quayDependencies.push('angulartics.mixpanel');
}
if (INJECTED_CONFIG && INJECTED_CONFIG.MUNCHKIN_KEY) {
quayDependencies.push('angulartics.marketo');
}
if (INJECTED_CONFIG && INJECTED_CONFIG.GOOGLE_ANALYTICS_KEY) {
quayDependencies.push('angulartics.google.analytics');
}
if (INJECTED_CONFIG && INJECTED_CONFIG.RECAPTCHA_SITE_KEY) {
quayDependencies.push('vcRecaptcha');
}
/**
* Module for application-wide configuration.
*/
@NgModule({
imports: quayDependencies,
declarations: [],
providers: [
provideConfig,
{provide: 'INJECTED_CONFIG', useValue: INJECTED_CONFIG},
{provide: 'INJECTED_FEATURES', useValue: INJECTED_FEATURES},
{provide: 'INJECTED_ENDPOINTS', useValue: INJECTED_ENDPOINTS},
{provide: 'NAME_PATTERNS', useValue: NAME_PATTERNS},
]
2017-02-20 02:35:46 +00:00
})
export class QuayConfigModule {
2017-02-20 02:35:46 +00:00
}
2017-02-20 02:35:46 +00:00
/**
* Provider function for the application configuration.
* See https://hotell.gitbooks.io/ng-metadata/content/docs/recipes/startup-logic.html
*/
provideConfig.$inject = [
'$provide',
'$injector',
'cfpLoadingBarProvider',
'$tooltipProvider',
'$compileProvider',
'RestangularProvider',
];
function provideConfig($provide: ng.auto.IProvideService,
$injector: ng.auto.IInjectorService,
cfpLoadingBarProvider: any,
$tooltipProvider: any,
$compileProvider: ng.ICompileProvider,
RestangularProvider: any): void {
cfpLoadingBarProvider.includeSpinner = false;
2017-02-20 02:35:46 +00:00
// decorate the tooltip getter
var tooltipFactory: any = $tooltipProvider.$get[$tooltipProvider.$get.length - 1];
$tooltipProvider.$get[$tooltipProvider.$get.length - 1] = function($window: ng.IWindowService) {
if ('ontouchstart' in $window) {
const existing: any = tooltipFactory.apply(this, arguments);
return function(element) {
// Note: We only disable bs-tooltip's themselves. $tooltip is used for other things
// (such as the datepicker), so we need to be specific when canceling it.
if (element !== undefined && element.attr('bs-tooltip') == null) {
return existing.apply(this, arguments);
}
};
2017-02-20 02:35:46 +00:00
}
return tooltipFactory.apply(this, arguments);
};
2017-02-20 02:35:46 +00:00
if (!INJECTED_CONFIG['DEBUG']) {
$compileProvider.debugInfoEnabled(false);
}
2017-02-20 02:35:46 +00:00
// Configure compile provider to add additional URL prefixes to the sanitization list. We use
// these on the Contact page.
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|irc):/);
2017-02-20 02:35:46 +00:00
// Configure the API provider.
RestangularProvider.setBaseUrl('/api/v1/');
2017-02-20 02:35:46 +00:00
// Configure analytics.
if (INJECTED_CONFIG && INJECTED_CONFIG.MIXPANEL_KEY) {
let $analyticsProvider: any = $injector.get('$analyticsProvider');
$analyticsProvider.virtualPageviews(true);
}
2017-02-20 02:35:46 +00:00
// Configure sentry.
if (INJECTED_CONFIG && INJECTED_CONFIG.SENTRY_PUBLIC_DSN) {
$provide.decorator("$exceptionHandler", function($delegate) {
return function(ex, cause) {
$delegate(ex, cause);
Raven.captureException(ex, {extra: {cause: cause}});
};
});
}
}