Use ng-metadata as a Backport of Angular 2+ API (#2486)
* starting UtilService refactor * pre find-replace angular.module('quay') => angular.module('QuayModule') * successfully switched to ng-metadata for backported Angular2 API * working with parent component reference in child * fixing @Output to use EventEmitter * fixed @Output events for custom git trigger * more fixes * refactored QuayPages module for backwards-compatibility * reinitialized test.db * use minified libraries * replaced references for angular-ts-decorators * fixed ng-show
This commit is contained in:
parent
6352b3cac5
commit
7a352ddfbc
43 changed files with 642 additions and 551 deletions
|
@ -1,11 +1,10 @@
|
|||
import { NgModule } from 'angular-ts-decorators';
|
||||
import { NgModule } from 'ng-metadata/core';
|
||||
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";
|
||||
import * as angular from 'angular';
|
||||
|
||||
|
||||
var quayDependencies: any[] = [
|
||||
var quayDependencies: string[] = [
|
||||
'chieffancypants.loadingBar',
|
||||
'cfp.hotkeys',
|
||||
'angular-tour',
|
||||
|
@ -49,70 +48,80 @@ if (INJECTED_CONFIG && INJECTED_CONFIG.RECAPTCHA_SITE_KEY) {
|
|||
@NgModule({
|
||||
imports: quayDependencies,
|
||||
declarations: [],
|
||||
providers: []
|
||||
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},
|
||||
]
|
||||
})
|
||||
export class QuayConfig {
|
||||
export class QuayConfigModule {
|
||||
|
||||
public config($provide: ng.auto.IProvideService,
|
||||
$injector: ng.auto.IInjectorService,
|
||||
INJECTED_CONFIG: any,
|
||||
cfpLoadingBarProvider: any,
|
||||
$tooltipProvider: any,
|
||||
$compileProvider: ng.ICompileProvider,
|
||||
RestangularProvider: any): void {
|
||||
cfpLoadingBarProvider.includeSpinner = false;
|
||||
|
||||
// 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) {
|
||||
var 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return tooltipFactory.apply(this, arguments);
|
||||
};
|
||||
|
||||
if (!INJECTED_CONFIG['DEBUG']) {
|
||||
$compileProvider.debugInfoEnabled(false);
|
||||
}
|
||||
|
||||
// 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):/);
|
||||
|
||||
// Configure the API provider.
|
||||
RestangularProvider.setBaseUrl('/api/v1/');
|
||||
|
||||
// Configure analytics.
|
||||
if (INJECTED_CONFIG && INJECTED_CONFIG.MIXPANEL_KEY) {
|
||||
let $analyticsProvider: any = $injector.get('$analyticsProvider');
|
||||
$analyticsProvider.virtualPageviews(true);
|
||||
}
|
||||
|
||||
// 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}});
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: Make injected values into services and move to NgModule.providers, as constants are not supported in Angular 2
|
||||
angular
|
||||
.module(QuayConfig.name)
|
||||
.constant('NAME_PATTERNS', NAME_PATTERNS)
|
||||
.constant('INJECTED_CONFIG', INJECTED_CONFIG)
|
||||
.constant('INJECTED_FEATURES', INJECTED_FEATURES)
|
||||
.constant('INJECTED_ENDPOINTS', INJECTED_ENDPOINTS);
|
||||
/**
|
||||
* 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;
|
||||
|
||||
// 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) {
|
||||
var 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return tooltipFactory.apply(this, arguments);
|
||||
};
|
||||
|
||||
if (!INJECTED_CONFIG['DEBUG']) {
|
||||
$compileProvider.debugInfoEnabled(false);
|
||||
}
|
||||
|
||||
// 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):/);
|
||||
|
||||
// Configure the API provider.
|
||||
RestangularProvider.setBaseUrl('/api/v1/');
|
||||
|
||||
// Configure analytics.
|
||||
if (INJECTED_CONFIG && INJECTED_CONFIG.MIXPANEL_KEY) {
|
||||
let $analyticsProvider: any = $injector.get('$analyticsProvider');
|
||||
$analyticsProvider.virtualPageviews(true);
|
||||
}
|
||||
|
||||
// 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}});
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue