initial import for Open Source 🎉

This commit is contained in:
Jimmy Zelinskie 2019-11-12 11:09:47 -05:00
parent 1898c361f3
commit 9c0dd3b722
2048 changed files with 218743 additions and 0 deletions

View file

@ -0,0 +1,22 @@
import { PageServiceImpl } from './page.service.impl';
describe("Service: PageServiceImpl", () => {
var pageServiceImpl: PageServiceImpl;
beforeEach(() => {
pageServiceImpl = new PageServiceImpl();
});
describe("create", () => {
// TODO
});
describe("get", () => {
// TODO
});
describe("$get", () => {
// TODO
});
});

View file

@ -0,0 +1,41 @@
import { Injectable } from 'ng-metadata/core';
import { PageService, QuayPage, QuayPageProfile } from './page.service';
@Injectable(PageService.name)
export class PageServiceImpl implements ng.IServiceProvider {
private pages: {[pageName: string]: QuayPage} = {};
public create(pageName: string,
templateName: string,
controller?: any,
flags: any = {},
profiles: string[] = ['old-layout', 'layout']): void {
for (var i = 0; i < profiles.length; ++i) {
this.pages[profiles[i] + ':' + pageName] = {
'name': pageName,
'controller': controller,
'templateName': templateName,
'flags': flags
};
}
}
public get(pageName: string, profiles: QuayPageProfile[]): [QuayPageProfile, QuayPage] | null {
for (let i = 0; i < profiles.length; ++i) {
var current = profiles[i];
var key = current.id + ':' + pageName;
var page = this.pages[key];
if (page) {
return [current, page];
}
}
return null;
}
public $get(): PageService {
return this;
}
}

View file

@ -0,0 +1,53 @@
/**
* Manages the creation and retrieval of pages (route + controller)
*/
export abstract class PageService implements ng.IServiceProvider {
/**
* Create a page.
* @param pageName The name of the page.
* @param templateName The file name of the template.
* @param controller Controller for the page.
* @param flags Additional flags passed to route provider.
* @param profiles Available profiles.
*/
public abstract create(pageName: string,
templateName: string,
controller?: any,
flags?: any,
profiles?: string[]): void;
/**
* Retrieve a registered page.
* @param pageName The name of the page.
* @param profiles Available profiles to search.
*/
public abstract get(pageName: string, profiles: QuayPageProfile[]): [QuayPageProfile, QuayPage] | null;
/**
* Provide the service instance.
* @return pageService The singleton service instance.
*/
public abstract $get(): PageService;
}
/**
* A type representing a registered application page.
*/
export type QuayPage = {
name: string;
controller: ng.IController;
templateName: string,
flags: {[key: string]: any};
};
/**
* Represents a page profile type.
*/
export type QuayPageProfile = {
id: string;
templatePath: string;
};