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,5 +1,5 @@
|
|||
import { AvatarService } from './avatar.service';
|
||||
import { Injectable } from 'angular-ts-decorators';
|
||||
import { Injectable, Inject } from 'ng-metadata/core';
|
||||
|
||||
|
||||
@Injectable(AvatarService.name)
|
||||
|
@ -7,7 +7,8 @@ export class AvatarServiceImpl implements AvatarService {
|
|||
|
||||
private cache: {[cacheKey: string]: string} = {};
|
||||
|
||||
constructor(private Config: any, private md5: any) {
|
||||
constructor(@Inject('Config') private Config: any,
|
||||
@Inject('md5') private md5: any) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { BuildService } from './build.service';
|
||||
import { Injectable } from 'angular-ts-decorators';
|
||||
import { Injectable } from 'ng-metadata/core';
|
||||
|
||||
|
||||
@Injectable(BuildService.name)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { DataFileService } from './datafile.service';
|
||||
import { Injectable } from 'angular-ts-decorators';
|
||||
import { Injectable, Inject } from 'ng-metadata/core';
|
||||
declare const JSZip: (buf: any) => void;
|
||||
declare const Zlib: any;
|
||||
declare const Untar: (uint8Array: Uint8Array) => void;
|
||||
|
@ -8,7 +8,7 @@ declare const Untar: (uint8Array: Uint8Array) => void;
|
|||
@Injectable(DataFileService.name)
|
||||
export class DataFileServiceImpl implements DataFileService {
|
||||
|
||||
constructor(private fileReaderFactory: () => FileReader) {
|
||||
constructor(@Inject('fileReaderFactory') private fileReaderFactory: () => FileReader) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { DockerfileService, DockerfileInfo } from './dockerfile.service';
|
||||
import { Injectable } from 'angular-ts-decorators';
|
||||
import { Injectable, Inject } from 'ng-metadata/core';
|
||||
import { DataFileService } from '../datafile/datafile.service';
|
||||
|
||||
|
||||
@Injectable(DockerfileService.name)
|
||||
export class DockerfileServiceImpl implements DockerfileService {
|
||||
|
||||
constructor(private DataFileService: DataFileService,
|
||||
private Config: any,
|
||||
private fileReaderFactory: () => FileReader) {
|
||||
constructor(@Inject(DataFileService.name) private DataFileService: DataFileService,
|
||||
@Inject('Config') private Config: any,
|
||||
@Inject('fileReaderFactory') private fileReaderFactory: () => FileReader) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Injectable } from 'angular-ts-decorators';
|
||||
import { Injectable } from 'ng-metadata/core';
|
||||
import { PageService } from './page.service';
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { RouteBuilder } from './route-builder.service';
|
||||
import { Injectable, Inject } from 'ng-metadata/core';
|
||||
import { PageService } from '../page/page.service';
|
||||
|
||||
|
||||
@Injectable(RouteBuilder.name)
|
||||
export class RouteBuilderImpl implements RouteBuilder {
|
||||
|
||||
public currentProfile: string = 'layout';
|
||||
|
@ -12,7 +15,8 @@ export class RouteBuilderImpl implements RouteBuilder {
|
|||
];
|
||||
|
||||
|
||||
constructor(private routeProvider: ng.route.IRouteProvider, private pages: any) {
|
||||
constructor(@Inject('routeProvider') private routeProvider: ng.route.IRouteProvider,
|
||||
@Inject('pages') private pages: PageService) {
|
||||
for (let i = 0; i < this.profiles.length; ++i) {
|
||||
if (this.profiles[i].id == this.currentProfile) {
|
||||
this.profiles = this.profiles.slice(i);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { RouteBuilderImpl } from './route-builder.service.impl';
|
||||
import { PageService } from '../page/page.service';
|
||||
|
||||
|
||||
describe("Service: RouteBuilderImpl", () => {
|
||||
|
|
40
static/js/services/util/util.service.impl.spec.ts
Normal file
40
static/js/services/util/util.service.impl.spec.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { UtilServiceImpl } from './util.service.impl';
|
||||
|
||||
|
||||
describe("UtilServiceImpl", () => {
|
||||
var utilServiceImpl: UtilServiceImpl;
|
||||
var $sanitizeMock: ng.sanitize.ISanitizeService;
|
||||
|
||||
beforeEach(() => {
|
||||
$sanitizeMock = jasmine.createSpy('$sanitizeSpy').and.returnValue("");
|
||||
utilServiceImpl = new UtilServiceImpl($sanitizeMock);
|
||||
});
|
||||
|
||||
describe("isAdBlockEnabled", () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
describe("isEmailAddress", () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
describe("getMarkedDown", () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
describe("getFirstMarkdownLineAsText", () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
describe("escapeHtmlString", () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
describe("getRestUrl", () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
describe("textToSafeHtml", () => {
|
||||
// TODO
|
||||
});
|
||||
});
|
39
static/js/services/util/util.service.impl.ts
Normal file
39
static/js/services/util/util.service.impl.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { Injectable, Inject } from 'ng-metadata/core';
|
||||
import { UtilService } from './util.service';
|
||||
|
||||
|
||||
@Injectable(UtilService.name)
|
||||
export class UtilServiceImpl implements UtilService {
|
||||
|
||||
constructor(@Inject('$sanitize') private $sanitize: ng.sanitize.ISanitizeService) {
|
||||
|
||||
}
|
||||
|
||||
public isAdBlockEnabled(callback: (isEnabled: boolean) => void): void {
|
||||
|
||||
}
|
||||
|
||||
public isEmailAddress(str: string): boolean {
|
||||
return null;
|
||||
}
|
||||
|
||||
public getMarkedDown(str: string): string {
|
||||
return null;
|
||||
}
|
||||
|
||||
public getFirstMarkdownLineAsText(commentString: string, placeholderNeeded: boolean): string {
|
||||
return null;
|
||||
}
|
||||
|
||||
public escapeHtmlString(text: string): string {
|
||||
return null;
|
||||
}
|
||||
|
||||
public getRestUrl(args: any[]): string {
|
||||
return null;
|
||||
}
|
||||
|
||||
public textToSafeHtml(text: string): string {
|
||||
return null;
|
||||
}
|
||||
}
|
19
static/js/services/util/util.service.ts
Normal file
19
static/js/services/util/util.service.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Service which exposes various utility methods.
|
||||
*/
|
||||
export abstract class UtilService {
|
||||
|
||||
public abstract isAdBlockEnabled(callback: (isEnabled: boolean) => void): void;
|
||||
|
||||
public abstract isEmailAddress(str: string): boolean;
|
||||
|
||||
public abstract getMarkedDown(str: string): string;
|
||||
|
||||
public abstract getFirstMarkdownLineAsText(commentString: string, placeholderNeeded: boolean): string;
|
||||
|
||||
public abstract escapeHtmlString(text: string): string;
|
||||
|
||||
public abstract getRestUrl(args: any[]): string;
|
||||
|
||||
public abstract textToSafeHtml(text: string): string;
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
import { ViewArray } from './view-array';
|
||||
import { Inject } from '../../decorators/inject/inject.decorator';
|
||||
import { Injectable } from 'angular-ts-decorators';
|
||||
import { Injectable, Inject } from 'ng-metadata/core';
|
||||
|
||||
|
||||
@Injectable(ViewArray.name)
|
||||
|
@ -15,7 +14,7 @@ export class ViewArrayImpl implements ViewArray {
|
|||
private currentIndex: number;
|
||||
private additionalCount: number = 20;
|
||||
|
||||
constructor(@Inject('$interval') private interval: any) {
|
||||
constructor(@Inject('$interval') private $interval: ng.IIntervalService) {
|
||||
this.isVisible = false;
|
||||
this.visibleEntries = null;
|
||||
this.hasEntries = false;
|
||||
|
@ -62,7 +61,7 @@ export class ViewArrayImpl implements ViewArray {
|
|||
}
|
||||
|
||||
public create(): ViewArrayImpl {
|
||||
return new ViewArrayImpl(this.interval);
|
||||
return new ViewArrayImpl(this.$interval);
|
||||
}
|
||||
|
||||
private showAdditionalEntries(): void {
|
||||
|
@ -83,14 +82,14 @@ export class ViewArrayImpl implements ViewArray {
|
|||
return;
|
||||
}
|
||||
|
||||
this.timerRef = this.interval(() => {
|
||||
this.timerRef = this.$interval(() => {
|
||||
this.showAdditionalEntries();
|
||||
}, 10);
|
||||
}
|
||||
|
||||
private stopTimer(): void {
|
||||
if (this.timerRef) {
|
||||
this.interval.cancel(this.timerRef);
|
||||
this.$interval.cancel(this.timerRef);
|
||||
this.timerRef = null;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue