removed unnecessary factory classes, simplified existing services
This commit is contained in:
parent
2a59014f0b
commit
64a4b68216
15 changed files with 69 additions and 158 deletions
|
@ -13,7 +13,7 @@ angular.module('quay').directive('buildLogsView', function () {
|
||||||
'useTimestamps': '=useTimestamps',
|
'useTimestamps': '=useTimestamps',
|
||||||
'buildUpdated': '&buildUpdated'
|
'buildUpdated': '&buildUpdated'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, $interval, $sanitize, ansi2html, ViewArrayFactory,
|
controller: function($scope, $element, $interval, $sanitize, ansi2html, ViewArray,
|
||||||
AngularPollChannel, ApiService, Restangular, UtilService) {
|
AngularPollChannel, ApiService, Restangular, UtilService) {
|
||||||
|
|
||||||
var result = $element.find('#copyButton').clipboardCopy();
|
var result = $element.find('#copyButton').clipboardCopy();
|
||||||
|
@ -53,7 +53,7 @@ angular.module('quay').directive('buildLogsView', function () {
|
||||||
var entry = logs[i];
|
var entry = logs[i];
|
||||||
var type = entry['type'] || 'entry';
|
var type = entry['type'] || 'entry';
|
||||||
if (type == 'command' || type == 'phase' || type == 'error') {
|
if (type == 'command' || type == 'phase' || type == 'error') {
|
||||||
entry['logs'] = ViewArrayFactory.create();
|
entry['logs'] = ViewArray.create();
|
||||||
entry['index'] = $scope.logStartIndex + i;
|
entry['index'] = $scope.logStartIndex + i;
|
||||||
|
|
||||||
$scope.logEntries.push(entry);
|
$scope.logEntries.push(entry);
|
||||||
|
|
|
@ -13,7 +13,7 @@ angular.module('quay').directive('imageFeatureView', function () {
|
||||||
'image': '=image',
|
'image': '=image',
|
||||||
'isEnabled': '=isEnabled'
|
'isEnabled': '=isEnabled'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, Config, ApiService, VulnerabilityService, ViewArrayFactory, ImageMetadataService, TableService) {
|
controller: function($scope, $element, Config, ApiService, VulnerabilityService, ViewArray, ImageMetadataService, TableService) {
|
||||||
$scope.options = {
|
$scope.options = {
|
||||||
'filter': null,
|
'filter': null,
|
||||||
'predicate': 'fixableScore',
|
'predicate': 'fixableScore',
|
||||||
|
|
|
@ -13,7 +13,7 @@ angular.module('quay').directive('imageVulnerabilityView', function () {
|
||||||
'image': '=image',
|
'image': '=image',
|
||||||
'isEnabled': '=isEnabled'
|
'isEnabled': '=isEnabled'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, Config, ApiService, VulnerabilityService, ViewArrayFactory, ImageMetadataService, TableService) {
|
controller: function($scope, $element, Config, ApiService, VulnerabilityService, ViewArray, ImageMetadataService, TableService) {
|
||||||
$scope.options = {
|
$scope.options = {
|
||||||
'filter': null,
|
'filter': null,
|
||||||
'fixableVulns': false,
|
'fixableVulns': false,
|
||||||
|
|
|
@ -2,8 +2,7 @@ import * as angular from 'angular';
|
||||||
import { quayConfig } from './quay.config';
|
import { quayConfig } from './quay.config';
|
||||||
import quayPages from './quay-pages.module';
|
import quayPages from './quay-pages.module';
|
||||||
import quayRun from './quay.run';
|
import quayRun from './quay.run';
|
||||||
import { ViewArrayFactory } from './services/view-array/view-array.factory';
|
import { ViewArrayImpl } from './services/view-array/view-array.impl';
|
||||||
import RouteBuilderFactory from './services/route-builder/route-builder.factory';
|
|
||||||
import NAME_PATTERNS from './constants/name-patterns.constant';
|
import NAME_PATTERNS from './constants/name-patterns.constant';
|
||||||
import { routeConfig } from './quay.routes';
|
import { routeConfig } from './quay.routes';
|
||||||
import { CONFIG } from './constants/quay-config.constant';
|
import { CONFIG } from './constants/quay-config.constant';
|
||||||
|
@ -51,7 +50,6 @@ export default angular
|
||||||
.config(routeConfig)
|
.config(routeConfig)
|
||||||
.constant('NAME_PATTERNS', NAME_PATTERNS)
|
.constant('NAME_PATTERNS', NAME_PATTERNS)
|
||||||
.constant('CONFIG', CONFIG)
|
.constant('CONFIG', CONFIG)
|
||||||
.service('RouteBuilderFactory', RouteBuilderFactory)
|
.service('ViewArray', ViewArrayImpl)
|
||||||
.service('ViewArrayFactory', ViewArrayFactory)
|
|
||||||
.run(quayRun)
|
.run(quayRun)
|
||||||
.name;
|
.name;
|
|
@ -1,18 +1,16 @@
|
||||||
import RouteBuilderFactory from './services/route-builder/route-builder.factory';
|
import { RouteBuilderImpl } from './services/route-builder/route-builder.service.impl';
|
||||||
import { RouteBuilder } from './services/route-builder/route-builder.service';
|
import { RouteBuilder } from './services/route-builder/route-builder.service';
|
||||||
import pages from './constants/pages.constant';
|
import pages from './constants/pages.constant';
|
||||||
|
|
||||||
|
|
||||||
routeConfig.$inject = [
|
routeConfig.$inject = [
|
||||||
'pages',
|
'pages',
|
||||||
'RouteBuilderFactoryProvider',
|
|
||||||
'$routeProvider',
|
'$routeProvider',
|
||||||
'$locationProvider',
|
'$locationProvider',
|
||||||
];
|
];
|
||||||
|
|
||||||
export function routeConfig(
|
export function routeConfig(
|
||||||
pages: any,
|
pages: any,
|
||||||
RouteBuilderFactoryProvider: any,
|
|
||||||
$routeProvider: ng.route.IRouteProvider,
|
$routeProvider: ng.route.IRouteProvider,
|
||||||
$locationProvider: ng.ILocationProvider) {
|
$locationProvider: ng.ILocationProvider) {
|
||||||
$locationProvider.html5Mode(true);
|
$locationProvider.html5Mode(true);
|
||||||
|
@ -22,15 +20,7 @@ export function routeConfig(
|
||||||
// index rule to make sure that deep links directly deep into the app continue to work.
|
// index rule to make sure that deep links directly deep into the app continue to work.
|
||||||
// WARNING WARNING WARNING
|
// WARNING WARNING WARNING
|
||||||
|
|
||||||
var layoutProfile: string = 'layout';
|
var routeBuilder: RouteBuilder = new RouteBuilderImpl($routeProvider, pages);
|
||||||
|
|
||||||
var routeBuilder: RouteBuilder = RouteBuilderFactoryProvider.$get().create($routeProvider, pages, [
|
|
||||||
// Start with the old pages (if we asked for it).
|
|
||||||
{id: 'old-layout', templatePath: '/static/partials/'},
|
|
||||||
|
|
||||||
// Fallback back combined new/existing pages.
|
|
||||||
{id: 'layout', templatePath: '/static/partials/'}
|
|
||||||
], layoutProfile);
|
|
||||||
|
|
||||||
if ((<any>window).__features.SUPER_USERS) {
|
if ((<any>window).__features.SUPER_USERS) {
|
||||||
// QE Management
|
// QE Management
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
import RouteBuilderFactory from './route-builder.factory';
|
|
||||||
import { RouteBuilder } from "static/js/services/route-builder/route-builder.service";
|
|
||||||
|
|
||||||
|
|
||||||
describe("Factory: RouteBuilderFactory", () => {
|
|
||||||
var routeBuilderFactory: RouteBuilderFactory;
|
|
||||||
var routeProviderMock;
|
|
||||||
var pagesMock;
|
|
||||||
var profiles;
|
|
||||||
var currentProfile;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
profiles = [
|
|
||||||
{id: 'old-layout', templatePath: '/static/partials/'},
|
|
||||||
{id: 'layout', templatePath: '/static/partials/'}
|
|
||||||
];
|
|
||||||
currentProfile = 'layout';
|
|
||||||
routeProviderMock = jasmine.createSpyObj('routeProvider', ['otherwise', 'when']);
|
|
||||||
pagesMock = jasmine.createSpyObj('pagesMock', ['get', 'create']);
|
|
||||||
routeBuilderFactory = new RouteBuilderFactory();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("constructor", () => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("create", () => {
|
|
||||||
|
|
||||||
it("returns a RouteBuilder instance", () => {
|
|
||||||
var routeBuilder: RouteBuilder = routeBuilderFactory.create(routeProviderMock, pagesMock, profiles, currentProfile);
|
|
||||||
|
|
||||||
expect(routeBuilder).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { RouteBuilder } from './route-builder.service';
|
|
||||||
import { RouteBuilderImpl } from './route-builder.service.impl';
|
|
||||||
|
|
||||||
|
|
||||||
export default class RouteBuilderFactory {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public create(routeProvider, pages, profiles, currentProfile): RouteBuilder {
|
|
||||||
return new RouteBuilderImpl(routeProvider, pages, profiles, currentProfile);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +1,20 @@
|
||||||
import { RouteBuilder } from './route-builder.service';
|
import { RouteBuilder } from './route-builder.service';
|
||||||
|
|
||||||
|
|
||||||
export function routeBuilderFactory() {
|
|
||||||
return (routeProvider, pages, profiles, currentProfile): RouteBuilder => {
|
|
||||||
return new RouteBuilderImpl(routeProvider, pages, profiles, currentProfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export class RouteBuilderImpl implements RouteBuilder {
|
export class RouteBuilderImpl implements RouteBuilder {
|
||||||
|
|
||||||
constructor(private routeProvider, private pages, public profiles, currentProfile) {
|
public currentProfile: string = 'layout';
|
||||||
|
public profiles: any[] = [
|
||||||
|
// Start with the old pages (if we asked for it).
|
||||||
|
{id: 'old-layout', templatePath: '/static/partials/'},
|
||||||
|
// Fallback back combined new/existing pages.
|
||||||
|
{id: 'layout', templatePath: '/static/partials/'}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
constructor(private routeProvider: ng.route.IRouteProvider, private pages: any) {
|
||||||
for (let i = 0; i < this.profiles.length; ++i) {
|
for (let i = 0; i < this.profiles.length; ++i) {
|
||||||
if (this.profiles[i].id == currentProfile) {
|
if (this.profiles[i].id == this.currentProfile) {
|
||||||
this.profiles = this.profiles.slice(i);
|
this.profiles = this.profiles.slice(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,15 @@ import { RouteBuilderImpl } from './route-builder.service.impl';
|
||||||
|
|
||||||
|
|
||||||
describe("Service: RouteBuilderImpl", () => {
|
describe("Service: RouteBuilderImpl", () => {
|
||||||
var routeProviderMock;
|
var routeProviderMock: any;
|
||||||
var pagesMock;
|
var pagesMock: any;
|
||||||
var profiles;
|
var profiles: any[];
|
||||||
var currentProfile;
|
|
||||||
|
|
||||||
beforeEach((() => {
|
beforeEach((() => {
|
||||||
profiles = [
|
profiles = [
|
||||||
{id: 'old-layout', templatePath: '/static/partials/'},
|
{id: 'old-layout', templatePath: '/static/partials/'},
|
||||||
{id: 'layout', templatePath: '/static/partials/'}
|
{id: 'layout', templatePath: '/static/partials/'}
|
||||||
];
|
];
|
||||||
currentProfile = 'layout';
|
|
||||||
routeProviderMock = jasmine.createSpyObj('routeProvider', ['otherwise', 'when']);
|
routeProviderMock = jasmine.createSpyObj('routeProvider', ['otherwise', 'when']);
|
||||||
pagesMock = jasmine.createSpyObj('pagesMock', ['get', 'create']);
|
pagesMock = jasmine.createSpyObj('pagesMock', ['get', 'create']);
|
||||||
}));
|
}));
|
||||||
|
@ -20,29 +18,37 @@ describe("Service: RouteBuilderImpl", () => {
|
||||||
describe("constructor", () => {
|
describe("constructor", () => {
|
||||||
|
|
||||||
it("returns a RouteBuilder object", () => {
|
it("returns a RouteBuilder object", () => {
|
||||||
var routeBuilder = new RouteBuilderImpl(routeProviderMock, pagesMock, profiles, currentProfile);
|
var routeBuilder: RouteBuilderImpl = new RouteBuilderImpl(routeProviderMock, pagesMock);
|
||||||
|
|
||||||
expect(routeBuilder).toBeDefined();
|
expect(routeBuilder).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets 'profiles' to all given profiles if given current profile does not match any of the given profiles' id", () => {
|
it("initializes current profile to 'layout'", () => {
|
||||||
var routeBuilder = new RouteBuilderImpl(routeProviderMock, pagesMock, profiles, 'fake-profile');
|
var routeBuilder: RouteBuilderImpl = new RouteBuilderImpl(routeProviderMock, pagesMock);
|
||||||
|
|
||||||
expect(routeBuilder.profiles).toEqual(profiles);
|
expect(routeBuilder.currentProfile).toEqual('layout');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("initializes available profiles", () => {
|
||||||
|
var routeBuilder: RouteBuilderImpl = new RouteBuilderImpl(routeProviderMock, pagesMock);
|
||||||
|
var matchingRoutes: any[] = routeBuilder.profiles.filter((profile) => {
|
||||||
|
return profiles.indexOf(profile) == -1;
|
||||||
|
});
|
||||||
|
expect(matchingRoutes).toEqual(routeBuilder.profiles);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets 'profiles' to the first given profile with id matching given current profile", () => {
|
it("sets 'profiles' to the first given profile with id matching given current profile", () => {
|
||||||
var routeBuilder = new RouteBuilderImpl(routeProviderMock, pagesMock, profiles, currentProfile);
|
var routeBuilder: RouteBuilderImpl = new RouteBuilderImpl(routeProviderMock, pagesMock);
|
||||||
|
|
||||||
expect(routeBuilder.profiles).toEqual([profiles[1]]);
|
expect(routeBuilder.profiles).toEqual([profiles[1]]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("otherwise", () => {
|
describe("otherwise", () => {
|
||||||
var routeBuilder;
|
var routeBuilder: RouteBuilderImpl;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
routeBuilder = new RouteBuilderImpl(routeProviderMock, pagesMock, profiles, currentProfile);
|
routeBuilder = new RouteBuilderImpl(routeProviderMock, pagesMock);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calls routeProvider to set fallback route with given options", () => {
|
it("calls routeProvider to set fallback route with given options", () => {
|
||||||
|
@ -54,10 +60,10 @@ describe("Service: RouteBuilderImpl", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("route", () => {
|
describe("route", () => {
|
||||||
var routeBuilder;
|
var routeBuilder: RouteBuilderImpl;
|
||||||
var path;
|
var path: string;
|
||||||
var pagename;
|
var pagename: string;
|
||||||
var page;
|
var page: any;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
path = '/repository/:namespace/:name';
|
path = '/repository/:namespace/:name';
|
||||||
|
@ -68,7 +74,7 @@ describe("Service: RouteBuilderImpl", () => {
|
||||||
controller: jasmine.createSpy('pageController'),
|
controller: jasmine.createSpy('pageController'),
|
||||||
flags: {},
|
flags: {},
|
||||||
};
|
};
|
||||||
routeBuilder = new RouteBuilderImpl(routeProviderMock, pagesMock, profiles, currentProfile);
|
routeBuilder = new RouteBuilderImpl(routeProviderMock, pagesMock);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calls pages with given pagename and 'profiles' to get matching page and profile pair", () => {
|
it("calls pages with given pagename and 'profiles' to get matching page and profile pair", () => {
|
||||||
|
@ -91,7 +97,7 @@ describe("Service: RouteBuilderImpl", () => {
|
||||||
|
|
||||||
it("calls routeProvider to set route for given path and options", () => {
|
it("calls routeProvider to set route for given path and options", () => {
|
||||||
pagesMock.get.and.returnValue([profiles[1], page]);
|
pagesMock.get.and.returnValue([profiles[1], page]);
|
||||||
var expectedOptions = {
|
var expectedOptions: any = {
|
||||||
templateUrl: profiles[1].templatePath + page.templateName,
|
templateUrl: profiles[1].templatePath + page.templateName,
|
||||||
reloadOnSearch: false,
|
reloadOnSearch: false,
|
||||||
controller: page.controller,
|
controller: page.controller,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Service which provides helper methods for constructing and managing tabular data.
|
* Service which provides helper methods for constructing and managing tabular data.
|
||||||
*/
|
*/
|
||||||
angular.module('quay').factory('TableService', ['ViewArrayFactory', function(ViewArrayFactory) {
|
angular.module('quay').factory('TableService', ['ViewArray', function(ViewArray) {
|
||||||
var tableService = {};
|
var tableService = {};
|
||||||
|
|
||||||
tableService.tablePredicateClass = function(name, predicate, reverse) {
|
tableService.tablePredicateClass = function(name, predicate, reverse) {
|
||||||
|
@ -31,7 +31,7 @@ angular.module('quay').factory('TableService', ['ViewArrayFactory', function(Vie
|
||||||
};
|
};
|
||||||
|
|
||||||
tableService.buildOrderedItems = function(items, options, filterFields, numericFields, opt_extrafilter) {
|
tableService.buildOrderedItems = function(items, options, filterFields, numericFields, opt_extrafilter) {
|
||||||
var orderedItems = ViewArrayFactory.create();
|
var orderedItems = ViewArray.create();
|
||||||
|
|
||||||
items.forEach(function(item) {
|
items.forEach(function(item) {
|
||||||
var filter = options.filter;
|
var filter = options.filter;
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
import { ViewArrayFactory } from './view-array.factory';
|
|
||||||
import { ViewArray } from './view-array';
|
|
||||||
|
|
||||||
|
|
||||||
describe("Factory: ViewArrayFactory", () => {
|
|
||||||
var viewArrayFactory: ViewArrayFactory;
|
|
||||||
var $intervalMock: any;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
$intervalMock = jasmine.createSpy('$intervalSpy');
|
|
||||||
$intervalMock.cancel = jasmine.createSpy('cancelSpy');
|
|
||||||
viewArrayFactory = new ViewArrayFactory($intervalMock)
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("constructor", () => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("create", () => {
|
|
||||||
|
|
||||||
it("returns a ViewArray object", () => {
|
|
||||||
var viewArray: ViewArray = viewArrayFactory.create();
|
|
||||||
|
|
||||||
expect(viewArray).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,29 +0,0 @@
|
||||||
import { ViewArray } from './view-array';
|
|
||||||
import { ViewArrayImpl } from './view-array.impl';
|
|
||||||
import { Inject } from '../../decorators/inject/inject.decorator';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory for creating ViewArray instances.
|
|
||||||
*/
|
|
||||||
export class ViewArrayFactory {
|
|
||||||
|
|
||||||
private ADDITIONAL_ENTRIES: number = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $interval Angular $interval service.
|
|
||||||
* @return viewArrayFactory A factory for creating ViewArray objects.
|
|
||||||
*/
|
|
||||||
constructor(@Inject('$interval') private $interval: ng.IIntervalService) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new ViewArray object.
|
|
||||||
* @return viewArray New ViewArrayImpl instance.
|
|
||||||
*/
|
|
||||||
public create(): ViewArray {
|
|
||||||
return new ViewArrayImpl(this.$interval, this.ADDITIONAL_ENTRIES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,14 +4,12 @@ import { ViewArrayImpl } from './view-array.impl';
|
||||||
describe("ViewArrayImplImpl", () => {
|
describe("ViewArrayImplImpl", () => {
|
||||||
var viewArrayImpl: ViewArrayImpl;
|
var viewArrayImpl: ViewArrayImpl;
|
||||||
var $intervalMock: any;
|
var $intervalMock: any;
|
||||||
var additionalCount: number;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
$intervalMock = jasmine.createSpy('$intervalSpy');
|
$intervalMock = jasmine.createSpy('$intervalSpy');
|
||||||
$intervalMock.and.returnValue({});
|
$intervalMock.and.returnValue({});
|
||||||
$intervalMock.cancel = jasmine.createSpy('cancelSpy');
|
$intervalMock.cancel = jasmine.createSpy('cancelSpy');
|
||||||
additionalCount = 20;
|
viewArrayImpl = new ViewArrayImpl($intervalMock);
|
||||||
viewArrayImpl = new ViewArrayImpl($intervalMock, additionalCount);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,4 +135,13 @@ describe("ViewArrayImplImpl", () => {
|
||||||
expect($intervalMock.cancel).toHaveBeenCalled();
|
expect($intervalMock.cancel).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("create", () => {
|
||||||
|
|
||||||
|
it("returns a new ViewArrayImpl instance", () => {
|
||||||
|
var newViewArrayImpl: ViewArrayImpl = viewArrayImpl.create();
|
||||||
|
|
||||||
|
expect(newViewArrayImpl).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -1,4 +1,5 @@
|
||||||
import { ViewArray } from './view-array';
|
import { ViewArray } from './view-array';
|
||||||
|
import { Inject } from '../../decorators/inject/inject.decorator';
|
||||||
|
|
||||||
|
|
||||||
export class ViewArrayImpl implements ViewArray {
|
export class ViewArrayImpl implements ViewArray {
|
||||||
|
@ -10,8 +11,9 @@ export class ViewArrayImpl implements ViewArray {
|
||||||
public hasHiddenEntries: boolean;
|
public hasHiddenEntries: boolean;
|
||||||
private timerRef: any;
|
private timerRef: any;
|
||||||
private currentIndex: number;
|
private currentIndex: number;
|
||||||
|
private additionalCount: number = 20;
|
||||||
|
|
||||||
constructor(private interval: any, private additionalCount: number) {
|
constructor(@Inject('$interval') private interval: any) {
|
||||||
this.isVisible = false;
|
this.isVisible = false;
|
||||||
this.visibleEntries = null;
|
this.visibleEntries = null;
|
||||||
this.hasEntries = false;
|
this.hasEntries = false;
|
||||||
|
@ -57,6 +59,10 @@ export class ViewArrayImpl implements ViewArray {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public create(): ViewArrayImpl {
|
||||||
|
return new ViewArrayImpl(this.interval);
|
||||||
|
}
|
||||||
|
|
||||||
private showAdditionalEntries(): void {
|
private showAdditionalEntries(): void {
|
||||||
var i: number = 0;
|
var i: number = 0;
|
||||||
for (i = this.currentIndex; i < (this.currentIndex + this.additionalCount) && i < this.entries.length; ++i) {
|
for (i = this.currentIndex; i < (this.currentIndex + this.additionalCount) && i < this.entries.length; ++i) {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { ViewArrayImpl } from "static/js/services/view-array/view-array.impl";
|
||||||
/**
|
/**
|
||||||
* Specialized wrapper around array which provides a toggle() method for viewing the contents of the
|
* Specialized wrapper around array which provides a toggle() method for viewing the contents of the
|
||||||
* array in a manner that is asynchronously filled in over a short time period. This prevents long
|
* array in a manner that is asynchronously filled in over a short time period. This prevents long
|
||||||
|
@ -59,4 +60,10 @@ export abstract class ViewArray {
|
||||||
* @param newState True/False if the contents are visible.
|
* @param newState True/False if the contents are visible.
|
||||||
*/
|
*/
|
||||||
public abstract setVisible(newState: boolean): void;
|
public abstract setVisible(newState: boolean): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory function to create a new ViewArray.
|
||||||
|
* @return viewArray New ViewArray instance.
|
||||||
|
*/
|
||||||
|
public abstract create(): ViewArrayImpl;
|
||||||
}
|
}
|
Reference in a new issue