Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Aot #2594

Merged
merged 14 commits into from Jul 19, 2018
5 changes: 3 additions & 2 deletions angular.json
Expand Up @@ -34,10 +34,10 @@
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"buildOptimizer": true,
"fileReplacements": [{
"replace": "src/frontend/environments/environment.ts",
"with": "src/frontend/environments/environment.prod.ts"
Expand All @@ -48,6 +48,7 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"aot": true,
"sslCert": "dev-ssl/server.crt",
"proxyConfig": "proxy.conf.js",
"ssl": true,
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -19,6 +19,7 @@
"build-dev": "ng build --dev --preserve-symlinks",
"ng": "ng",
"start": "npm run customize && ng serve",
"start-high-mem": "npm run customize && node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve",
"start-prod": "ng serve --prod --source-map=true",
"test": "ng test --code-coverage",
"test-debug": "ng test --watch=true --source-map=true",
Expand Down Expand Up @@ -56,7 +57,7 @@
"@ngrx/router-store": "^6.0.1",
"@ngrx/store": "^6.0.1",
"@ngrx/store-devtools": "^6.0.1",
"@swimlane/ngx-charts": "^7.4.0",
"@swimlane/ngx-charts": "^8.1.0",
"angular2-virtual-scroll": "^0.3.1",
"core-js": "^2.5.7",
"hammerjs": "^2.0.8",
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/app/core/entity-service.spec.ts
Expand Up @@ -9,6 +9,7 @@ import { generateTestEntityServiceProvider } from '../test-framework/entity-serv
import { createBasicStoreModule } from '../test-framework/store-test-helper';
import { EntityService } from './entity-service';
import { EntityServiceFactory } from './entity-service-factory.service';
import { ENTITY_SERVICE } from '../shared/entity.tokens';

const appId = '4e4858c4-24ab-4caf-87a8-7703d1da58a0';
const cfId = '01ccda9d-8f40-4dd0-bc39-08eea68e364f';
Expand Down Expand Up @@ -36,12 +37,12 @@ describe('EntityServiceService', () => {
});
});

it('should be created', inject([EntityService], (service: EntityService) => {
it('should be created', inject([ENTITY_SERVICE], (service: EntityService) => {
expect(service).toBeTruthy();
}));

it('should poll', (done) => {
inject([EntityService, XHRBackend], (service: EntityService, mockBackend: MockBackend) => {
inject([ENTITY_SERVICE, XHRBackend], (service: EntityService, mockBackend: MockBackend) => {
const sub = service.poll(1).subscribe(a => {
sub.unsubscribe();
expect(sub.closed).toBeTruthy();
Expand Down
7 changes: 2 additions & 5 deletions src/frontend/app/core/entity-service.ts
@@ -1,8 +1,6 @@
import { Injectable } from '@angular/core';
import { compose, Store } from '@ngrx/store';
import { combineLatest, interval, Observable } from 'rxjs';
import { combineLatest, Observable } from 'rxjs';
import { filter, first, map, publishReplay, refCount, switchMap, tap, withLatestFrom } from 'rxjs/operators';

import { EntityMonitor } from '../shared/monitors/entity-monitor';
import { ValidateEntitiesStart } from '../store/actions/request.actions';
import { AppState } from '../store/app-state';
Expand All @@ -11,7 +9,7 @@ import {
RequestInfoState,
RequestSectionKeys,
TRequestTypeKeys,
UpdatingSection,
UpdatingSection
} from '../store/reducers/api-request-reducer/types';
import { getEntityUpdateSections, getUpdateSectionById } from '../store/selectors/api.selectors';
import { APIResource, EntityInfo } from '../store/types/api.types';
Expand All @@ -33,7 +31,6 @@ export function isEntityBlocked(entityRequestInfo: RequestInfoState) {
/**
* Designed to be used in a service factory provider
*/
@Injectable()
export class EntityService<T = any> {

constructor(
Expand Down
33 changes: 13 additions & 20 deletions src/frontend/app/features/applications/application.service.ts
@@ -1,25 +1,15 @@

import { of as observableOf, Observable } from 'rxjs';

import { startWith, combineLatest, first, publishReplay, refCount, filter, map, switchMap } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { Injectable, InjectionToken, Inject } from '@angular/core';
import { Store } from '@ngrx/store';

import { Observable } from 'rxjs';
import { combineLatest, filter, first, map, publishReplay, refCount, startWith, switchMap } from 'rxjs/operators';
import { IApp, IOrganization, ISpace } from '../../core/cf-api.types';
import { EntityService } from '../../core/entity-service';
import { EntityServiceFactory } from '../../core/entity-service-factory.service';
import {
ApplicationStateData,
ApplicationStateService,
} from '../../shared/components/application-state/application-state.service';
import { ApplicationStateData, ApplicationStateService } from '../../shared/components/application-state/application-state.service';
import { PaginationMonitor } from '../../shared/monitors/pagination-monitor';
import { PaginationMonitorFactory } from '../../shared/monitors/pagination-monitor.factory';
import {
AppMetadataTypes,
GetAppEnvVarsAction,
GetAppStatsAction,
GetAppSummaryAction,
} from '../../store/actions/app-metadata.actions';
import { AppMetadataTypes, GetAppEnvVarsAction, GetAppStatsAction, GetAppSummaryAction } from '../../store/actions/app-metadata.actions';
import { GetApplication, UpdateApplication, UpdateExistingApplication } from '../../store/actions/application.actions';
import { AppState } from '../../store/app-state';
import {
Expand All @@ -33,7 +23,7 @@ import {
routeSchemaKey,
serviceBindingSchemaKey,
spaceSchemaKey,
stackSchemaKey,
stackSchemaKey
} from '../../store/helpers/entity-factory';
import { createEntityRelationKey } from '../../store/helpers/entity-relations.types';
import { ActionState, rootUpdatingKey } from '../../store/reducers/api-request-reducer/types';
Expand All @@ -45,13 +35,16 @@ import { PaginationEntityState } from '../../store/types/pagination.types';
import {
getCurrentPageRequestInfo,
getPaginationObservables,
PaginationObservables,
PaginationObservables
} from './../../store/reducers/pagination-reducer/pagination-reducer.helper';
import {
ApplicationEnvVarsService,
EnvVarStratosProject,
EnvVarStratosProject
} from './application/application-tabs-base/tabs/build-tab/application-env-vars.service';
import { getRoute, isTCPRoute } from './routes/routes.helper';
import { CF_GUID, APP_GUID } from '../../shared/entity.tokens';



export function createGetApplicationAction(guid: string, endpointGuid: string) {
return new GetApplication(
Expand Down Expand Up @@ -81,8 +74,8 @@ export class ApplicationService {
private appSummaryEntityService: EntityService;

constructor(
public cfGuid: string,
public appGuid: string,
@Inject(CF_GUID) public cfGuid,
@Inject(APP_GUID) public appGuid,
private store: Store<AppState>,
private entityServiceFactory: EntityServiceFactory,
private appStateService: ApplicationStateService,
Expand Down
@@ -1,26 +1,26 @@
import { Component, HostBinding } from '@angular/core';
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';

import { EntityService } from '../../../core/entity-service';
import { EntityServiceFactory } from '../../../core/entity-service-factory.service';
import { ApplicationStateService } from '../../../shared/components/application-state/application-state.service';
import { APP_GUID, CF_GUID, ENTITY_SERVICE } from '../../../shared/entity.tokens';
import { PaginationMonitorFactory } from '../../../shared/monitors/pagination-monitor.factory';
import { AppState } from '../../../store/app-state';
import { applicationSchemaKey, entityFactory } from '../../../store/helpers/entity-factory';
import { ApplicationService, createGetApplicationAction } from '../application.service';
import { ApplicationEnvVarsService } from './application-tabs-base/tabs/build-tab/application-env-vars.service';


function applicationServiceFactory(

export function applicationServiceFactory(
cfId: string,
id: string,
store: Store<AppState>,
activatedRoute: ActivatedRoute,
entityServiceFactory: EntityServiceFactory,
appStateService: ApplicationStateService,
appEnvVarsService: ApplicationEnvVarsService,
paginationMonitorFactory: PaginationMonitorFactory
) {
const { id, cfId } = activatedRoute.snapshot.params;
return new ApplicationService(
cfId,
id,
Expand All @@ -32,11 +32,11 @@ function applicationServiceFactory(
);
}

function entityServiceFactory(
export function entityServiceFactory(
cfId: string,
id: string,
_entityServiceFactory: EntityServiceFactory,
activatedRoute: ActivatedRoute
) {
const { id, cfId } = activatedRoute.snapshot.params;
return _entityServiceFactory.create(
applicationSchemaKey,
entityFactory(applicationSchemaKey),
Expand All @@ -46,21 +46,41 @@ function entityServiceFactory(
);
}

export function getGuids(type?: string) {
return (activatedRoute: ActivatedRoute) => {
const { id, cfId } = activatedRoute.snapshot.params;
if (type) {
return cfId;
}
return id;
};
}

@Component({
selector: 'app-application-base',
templateUrl: './application-base.component.html',
styleUrls: ['./application-base.component.scss'],
providers: [
ApplicationService,
{
provide: CF_GUID,
useFactory: getGuids('cf'),
deps: [ActivatedRoute]
},
{
provide: APP_GUID,
useFactory: getGuids(),
deps: [ActivatedRoute]
},
{
provide: ApplicationService,
useFactory: applicationServiceFactory,
deps: [Store, ActivatedRoute, EntityServiceFactory, ApplicationStateService, ApplicationEnvVarsService, PaginationMonitorFactory]
deps: [CF_GUID, APP_GUID, Store, EntityServiceFactory, ApplicationStateService, ApplicationEnvVarsService, PaginationMonitorFactory]
},
{
provide: EntityService,
provide: ENTITY_SERVICE,
useFactory: entityServiceFactory,
deps: [EntityServiceFactory, ActivatedRoute]
deps: [CF_GUID, APP_GUID, EntityServiceFactory]
},

]
Expand Down
Expand Up @@ -29,7 +29,7 @@ export class ApplicationInstanceChartComponent implements OnInit {
private seriesTranslation: string;

@Input('title')
private title: string;
public title: string;

public instanceChartConfig: MetricsLineChartConfig;

Expand Down
@@ -1,5 +1,5 @@

import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit, Inject } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { Observable, Subscription, combineLatest as observableCombineLatest, of as observableOf } from 'rxjs';
Expand All @@ -20,6 +20,7 @@ import { APIResource } from '../../../../store/types/api.types';
import { EndpointModel } from '../../../../store/types/endpoint.types';
import { ApplicationService } from '../../application.service';
import { EndpointsService } from './../../../../core/endpoints.service';
import { ENTITY_SERVICE } from '../../../../shared/entity.tokens';


// Confirmation dialogs
Expand Down Expand Up @@ -57,8 +58,8 @@ export class ApplicationTabsBaseComponent implements OnInit, OnDestroy {
constructor(
private route: ActivatedRoute,
private router: Router,
private applicationService: ApplicationService,
private entityService: EntityService<APIResource>,
public applicationService: ApplicationService,
@Inject(ENTITY_SERVICE) private entityService: EntityService<APIResource>,
private store: Store<AppState>,
private confirmDialog: ConfirmationDialogService,
private endpointsService: EndpointsService
Expand Down
Expand Up @@ -4,7 +4,7 @@
<app-card-app-status></app-card-app-status>
</app-tile>
<app-tile>
<app-card-app-instances [busy]="summaryDataChanging$" showActions="true"></app-card-app-instances>
<app-card-app-instances showActions="true"></app-card-app-instances>
</app-tile>
<app-tile>
<app-card-app-usage></app-card-app-usage>
Expand Down
Expand Up @@ -17,13 +17,13 @@ import { StepOnNextFunction } from '../../../../shared/components/stepper/step/s
})
export class DeployApplicationStepSourceUploadComponent implements OnDestroy {

private deployer: DeployApplicationDeployer;
public deployer: DeployApplicationDeployer;

public valid$: Observable<boolean>;

constructor(private store: Store<AppState>,
public cfOrgSpaceService: CfOrgSpaceDataService,
private http: HttpClient,
http: HttpClient,
) {
this.deployer = new DeployApplicationDeployer(store, cfOrgSpaceService, http);
this.valid$ = this.deployer.fileTransferStatus$.pipe(
Expand Down
@@ -1,5 +1,5 @@
<div class="deploy-app">
<div class="deploy-app__title">{{ deployer.streamTitle }}</div>
<mat-progress-spinner *ngIf="deploying" diameter="20" mode="indeterminate"></mat-progress-spinner>
<mat-progress-spinner *ngIf="deployer.deploying" diameter="20" mode="indeterminate"></mat-progress-spinner>
</div>
<app-log-viewer class="deploy-app__log" *ngIf="deployer.messages" [logStream]="deployer.messages"></app-log-viewer>
Expand Up @@ -46,7 +46,7 @@ export class DeployApplicationStep3Component implements OnDestroy {
// Observable for when the deploy modal can be closed
closeable$: Observable<boolean>;

private deployer: DeployApplicationDeployer;
public deployer: DeployApplicationDeployer;

private deploySub: Subscription;
private errorSub: Subscription;
Expand Down
Expand Up @@ -4,10 +4,10 @@

<app-steppers cancel="/applications">
<app-step *ngIf="!appGuid" [title]="'Cloud Foundry'" [valid]="step1.validate | async" [onNext]="onNext" [blocked]="cfOrgSpaceService.isLoading$ | async">
<app-create-application-step1 [isRedeploy]="!!appGuid" #step1></app-create-application-step1>
<app-create-application-step1 [isRedeploy]="isRedeploy" #step1></app-create-application-step1>
</app-step>
<app-step [title]="'Source'" [valid]="step2.validate | async" [onNext]="step2.onNext" [nextButtonText]="(appGuid || (skipConfig$ | async)) ? deployButtonText : 'Next'">
<app-deploy-application-step2 [isRedeploy]="!!appGuid" #step2></app-deploy-application-step2>
<app-deploy-application-step2 [isRedeploy]="isRedeploy" #step2></app-deploy-application-step2>
</app-step>
<app-step [hidden]="appGuid || !(step2.sourceTypeGithub$ | async)" [title]="'Source Config'" [valid]="step2_1.validate | async" [skip]="skipConfig$ | async" [onLeave]="step2_1.onLeave" [onEnter]="step2_1.onEnter" [onNext]="step2_1.onNext" [nextButtonText]="deployButtonText">
<app-deploy-application-step2-1 #step2_1></app-deploy-application-step2-1>
Expand Down
@@ -1,5 +1,5 @@

import {of as observableOf, Observable , Subscription } from 'rxjs';
import { of as observableOf, Observable, Subscription } from 'rxjs';
import { Component, OnInit } from '@angular/core';
import { OnDestroy } from '@angular/core/src/metadata/lifecycle_hooks';
import { ActivatedRoute } from '@angular/router';
Expand Down Expand Up @@ -29,13 +29,15 @@ export class DeployApplicationComponent implements OnInit, OnDestroy {
initCfOrgSpaceService: Subscription[] = [];
deployButtonText = 'Deploy';
skipConfig$: Observable<boolean> = observableOf(false);
isRedeploy: boolean;

constructor(
private store: Store<AppState>,
private cfOrgSpaceService: CfOrgSpaceDataService,
private activatedRoute: ActivatedRoute
) {
this.appGuid = this.activatedRoute.snapshot.queryParams['appGuid'];
this.isRedeploy = !!this.appGuid;

this.skipConfig$ = this.store.select<DeployApplicationSource>(selectApplicationSource).pipe(
map((appSource: DeployApplicationSource) => {
Expand Down