Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 8 Migration #3950

Merged
merged 55 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
814d697
ng update wip
KlapTrap Oct 2, 2019
76a1259
More ng update wip
KlapTrap Oct 2, 2019
a0b326b
More ng update?
KlapTrap Oct 2, 2019
6c25e06
WIP angular 8 migration
KlapTrap Oct 3, 2019
d6b9433
Migrate autosclaer effects to use httpclient
KlapTrap Oct 3, 2019
5a358b3
WIP Migration
KlapTrap Oct 3, 2019
55725b0
Migrate httpclient
KlapTrap Oct 3, 2019
dbd280a
More http -> httpClient
KlapTrap Oct 3, 2019
9d1a837
Httpclient
KlapTrap Oct 3, 2019
71dff9e
Httpclient in cf effect
KlapTrap Oct 3, 2019
55ea22c
Remove http module
KlapTrap Oct 3, 2019
93c8b78
Setup httpClient fixes
KlapTrap Oct 3, 2019
0c191af
More httpclient
KlapTrap Oct 3, 2019
3b1339b
More http migration
KlapTrap Oct 3, 2019
b9ada20
ViewChild static migration
KlapTrap Oct 3, 2019
d25f043
Merge branch 'master' into angular-8
KlapTrap Oct 17, 2019
8f0ac85
WIP Angular 8 migration
KlapTrap Oct 17, 2019
75e0f29
Fix get action builders tying
KlapTrap Oct 17, 2019
0a9b962
Remove uneeded store freeze
KlapTrap Oct 18, 2019
411041c
Tidy up action dispatcher typing
KlapTrap Oct 18, 2019
b4a72bc
Added view child static field
KlapTrap Oct 18, 2019
a6da13e
WIP HTTP Client migration
KlapTrap Oct 18, 2019
f85e3f7
WIP Angular 8 migration
KlapTrap Oct 29, 2019
cd7317c
More angular 8 migrations
KlapTrap Oct 30, 2019
7a6cde8
Fixed some post angular update issues
KlapTrap Oct 31, 2019
dc695d6
Fixing ssh and log viewer
KlapTrap Oct 31, 2019
70850e4
Test fixes after angular 8 migration
KlapTrap Oct 31, 2019
5e86230
Fix `core` unit tests
richard-cox Nov 1, 2019
5965f57
Fix cf-autoscaler tests
richard-cox Nov 1, 2019
5f1a083
Fix immutablilty in unit tests
KlapTrap Nov 1, 2019
606d61f
Test bump of node version
richard-cox Nov 1, 2019
90ecdee
Fix istanbul see https://github.com/gotwarlost/istanbul/issues/868
KlapTrap Nov 1, 2019
10e7b20
Remove npm pegging
richard-cox Nov 1, 2019
5b113c8
Remove unused component
KlapTrap Nov 4, 2019
c820166
Remove delete scss file referance
KlapTrap Nov 4, 2019
1043eef
Another scss refernace delete
KlapTrap Nov 4, 2019
19d8fcd
Updated todos
KlapTrap Nov 4, 2019
0ac6b24
Added back in nav tab interface
KlapTrap Nov 4, 2019
8ae5e20
More tab typing
KlapTrap Nov 4, 2019
3c247ba
Remove protractor describe skipWhen usage
richard-cox Nov 4, 2019
27909e1
Change skipped tests from failure to a warning
KlapTrap Nov 4, 2019
d62c15b
WIP E2e fix
KlapTrap Nov 5, 2019
6bb359f
Fix e2e-dev & e2e-local. Print guthub url check success
richard-cox Nov 5, 2019
4f8f266
Get SSH Viewer component working again
nwmac Nov 5, 2019
b3b931f
Update log viewer connection status logic
KlapTrap Nov 11, 2019
f871195
Merge branch 'master' into angular-8
KlapTrap Nov 13, 2019
aa10d4b
Fix service instance update
KlapTrap Nov 13, 2019
d453d04
Fix application deploy
KlapTrap Nov 15, 2019
6c55044
Fix org delete
KlapTrap Nov 15, 2019
c70c701
Fix space delete
KlapTrap Nov 15, 2019
97a7131
Fix space creation after org creation
KlapTrap Nov 15, 2019
516aaca
Fix quota delete
KlapTrap Nov 18, 2019
9c31341
Fix route assign
KlapTrap Nov 18, 2019
05cc443
Fix space quota assign
KlapTrap Nov 18, 2019
2ddd7e8
Fix space update
KlapTrap Nov 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP Angular 8 migration
  • Loading branch information
KlapTrap committed Oct 17, 2019
commit 8f0ac85cc8ac0a1337fb0f662c806283d9492612
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@
"typescript": "<3.6.0",
"@nrwl/workspace": "8.5.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { NgModel } from '@angular/forms';
import { Store } from '@ngrx/store';
import * as moment from 'moment';
import { NEVER, Observable, Subject } from 'rxjs';
import websocketConnect from 'rxjs-websockets';
import { catchError, filter, share } from 'rxjs/operators';
import makeWebSocketObservable, { GetWebSocketResponses } from 'rxjs-websockets';
import { catchError, filter, share, switchMap, map } from 'rxjs/operators';

import { CFAppState } from '../../../../../../../../cloud-foundry/src/cf-app-state';
import { LoggerService } from '../../../../../../../../core/src/core/logger.service';
Expand Down Expand Up @@ -53,18 +53,27 @@ export class LogStreamTabComponent implements OnInit {
this.applicationService.cfGuid
}/apps/${this.applicationService.appGuid}/stream`;

const { messages, connectionStatus } = websocketConnect(streamUrl, new Subject<string>());
messages.pipe(catchError(e => {
const socket$ = makeWebSocketObservable(streamUrl);
socket$.pipe(catchError(e => {
this.logService.error(
'Error while connecting to socket: ' + JSON.stringify(e)
);
return [];
}),
share(),
filter(data => !!data && data.length));

this.messages = messages;
this.connectionStatus = connectionStatus;
filter(data => !!data && data.length)
);

this.messages = socket$.pipe(
// the observable produces a value once the websocket has been opened
switchMap((getResponses: GetWebSocketResponses) => {
console.log('websocket opened')
return getResponses(new Subject<string>());
}),
map((message: string) => message),
share()
);
// this.connectionStatus = connectionStatus;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class DeployApplicationDeployer {

this.inputStream = new Subject<string>();
this.messages = websocketConnect(streamUrl, this.inputStream)
.messages.pipe(
.pipe(
catchError(e => {
return [];
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { NEVER, Observable, Subject, Subscription } from 'rxjs';
import websocketConnect from 'rxjs-websockets';
import { catchError, first, map } from 'rxjs/operators';
import { catchError, first, map, switchMap } from 'rxjs/operators';

import { CFAppState } from '../../../../../cloud-foundry/src/cf-app-state';
import { IApp } from '../../../../../core/src/core/cf-api.types';
Expand Down Expand Up @@ -81,19 +81,20 @@ export class SshApplicationComponent implements OnInit {
);
this.sshInput = new Subject<string>();
const connection = websocketConnect(
streamUrl,
this.sshInput
streamUrl
);

this.messages = connection.messages.pipe(
this.messages = connection.pipe(
switchMap(getResponse => getResponse(this.sshInput)),
catchError(e => {
if (e.type === 'error') {
this.errorMessage = 'Error connecting to web socket';
}
return [];
}));

this.connectionStatus = connection.connectionStatus;
// TODO angular 8
// this.connectionStatus = connection.connectionStatus;

this.breadcrumbs$ = this.applicationService.waitForAppEntity$.pipe(
map(app => this.getBreadcrumbs(app.entity.entity)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import websocketConnect from 'rxjs-websockets';
import { catchError, filter, share } from 'rxjs/operators';
import { catchError, filter, share, map, switchMap } from 'rxjs/operators';

import { LoggerService } from '../../../../../../core/src/core/logger.service';
import { UtilsService } from '../../../../../../core/src/core/utils.service';
Expand Down Expand Up @@ -41,14 +41,15 @@ export class CloudFoundryFirehoseComponent implements OnInit {
}

private setupFirehoseStream(streamUrl: string) {
const { messages, connectionStatus } = websocketConnect(
streamUrl,
new Subject<string>()
this.messages = websocketConnect(
streamUrl
).pipe(
switchMap((get) => get(new Subject<string>())),
map((message: string) => message)
);

this.messages = messages;
this.connectionStatus = connectionStatus;
messages.pipe(
// TODO Angular 8
// this.connectionStatus = connectionStatus;
this.messages.pipe(
catchError(e => {
return [];
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class EntityActionDispatcherManager<T extends OrchestratedActionBuilders
return this.getActionDispatcher('create').dispatch(...args);
}

public dispatchGetAll(...args: Parameters<T['getAll']>) {
public dispatchGetAll(...args: Parameters<T['getMultiple']>) {
return this.getActionDispatcher('getMultiple').dispatch(...args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ export class ActionOrchestrator<T extends OrchestratedActionBuilders = Orchestra
return new EntityActionDispatcherManager<T>(actionDispatcher, this);
}

public getActionBuilder<Y extends keyof T>(actionType: Y): T[Y] {
public getActionBuilder<Y extends keyof T>(actionType: Y) {
const actionBuilderForType = this.actionBuilders[actionType];
if (!actionBuilderForType) {
return null;
}
const actionBuilder: T[Y] = (...args: Parameters<T[Y]>) => {
const actionBuilder = (...args: Parameters<T[Y]>) => {
const action = actionBuilderForType(...args) as ActionBuilderAction;
if (action) {
action.actionBuilderActionType = actionType as string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, Input } from '@angular/core';
import { OnInit } from '@angular/core/src/metadata/lifecycle_hooks';
import { Component, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class SimpleListComponent implements OnInit {
@Input()
public catalogueEntity: StratosCatalogueEntity;

@ViewChild(ListHostDirective)
@ViewChild(ListHostDirective, { static: true })
public listHost: ListHostDirective;

private listConfig: ListConfig<any>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ export class PageSubheaderComponent implements AfterViewInit, OnDestroy {
this.checkScrollBounds();
}
}

// TODO ANGULAR 8
private navIsOverflowing() {
if (this.navOuter) {
const avaliableWidth = this.navOuter.nativeElement.offsetWidth;
const navFullWidth = this.nav._elementRef.nativeElement.offsetWidth;
return avaliableWidth < navFullWidth;
}
// if (this.navOuter) {
// const avaliableWidth = this.navOuter.nativeElement.offsetWidth;
// const navFullWidth = this.nav._elementRef.nativeElement.offsetWidth;
// return avaliableWidth < navFullWidth;
// }
return false;
}

Expand Down Expand Up @@ -174,10 +174,11 @@ export class PageSubheaderComponent implements AfterViewInit, OnDestroy {
this.disableRight = false;
}
}

// TODO ANGULAR 8
private navScrolledFarRight() {
const { scrollLeft } = this.navScroller.nativeElement;
return this.nav._elementRef.nativeElement.offsetWidth === (this.navScroller.nativeElement.offsetWidth + scrollLeft);
// const { scrollLeft } = this.navScroller.nativeElement;
// return this.nav._elementRef.nativeElement.offsetWidth === (this.navScroller.nativeElement.offsetWidth + scrollLeft);
return false;
}

private navScrolledFarLeft() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
} from '@angular/core';

import { Terminal } from 'xterm';
import { fit } from 'xterm/lib/addons/fit/fit';
// TODO
// import { fit } from 'xterm/lib/addons/fit/fit';

import { Observable, Subject, Subscription } from 'rxjs';

Expand Down Expand Up @@ -71,23 +72,26 @@ export class SshViewerComponent implements OnInit, OnDestroy, AfterViewChecked {
});

this.xterm.open(this.container.nativeElement);
this.xterm.on('data', this.onTermSendData);
this.xterm.on('resize', this.onTermResize);
// TODO
// this.xterm.on('data', this.onTermSendData);
// this.xterm.on('resize', this.onTermResize);

this.reconnect();
}

ngAfterViewChecked() {
if (this.xterm) {
fit(this.xterm);
// TODO ANGULAR 8
// fit(this.xterm);
}
}

ngOnDestroy() {
this.isDestroying = true;
if (this.xterm) {
this.xterm.off('data', this.onTermSendData);
this.xterm.off('resize', this.onTermResize);
// TODO ANGULAR 8
// this.xterm.off('data', this.onTermSendData);
// this.xterm.off('resize', this.onTermResize);
}
this.disconnect();
if (this.connectSubscription && !this.connectSubscription.closed) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { HttpHeaders, HttpParams, HttpRequest } from '@angular/common/http';
import { RequestOptions } from '@angular/http';

import { ApiRequestTypes } from '../../reducers/api-request-reducer/request-helpers';

Expand All @@ -19,35 +18,36 @@ export function getRequestTypeFromRequestType(requestType: ApiRequestTypes) {

return 'GET';
}

function getHttpParams(options: RequestOptions) {
if (!options.params) {
return null;
}
return Array.from(options.params.paramsMap.entries()).reduce((obj, [key, value]) => {
obj[key] = value;
return obj;
}, {});
}
// TODO Remove - angular 8
// function getHttpParams(options: RequestOptions) {
// if (!options.params) {
// return null;
// }
// return Array.from(options.params.paramsMap.entries()).reduce((obj, [key, value]) => {
// obj[key] = value;
// return obj;
// }, {} as { [param: string]: string });
// }

// This will convert the old style RequestOptions into a new HttpRequest
function getRequestFromLegacyOptions(
options: RequestOptions,
requestType: ApiRequestTypes
) {
const method = getRequestTypeFromRequestType(requestType);
return new HttpRequest(
method,
options.url,
options.body,
{
headers: new HttpHeaders(options.headers ? options.headers.toJSON() : null),
params: new HttpParams({
fromObject: getHttpParams(options)
})
},
);
}
// TODO Remove - angular 8
// function getRequestFromLegacyOptions(
// options: RequestOptions,
// requestType: ApiRequestTypes
// ) {
// const method = getRequestTypeFromRequestType(requestType);
// return new HttpRequest(
// method,
// options.url,
// options.body,
// {
// headers: new HttpHeaders(options.headers ? options.headers.toJSON() : null),
// params: new HttpParams({
// fromObject: getHttpParams(options)
// })
// },
// );
// }


export const buildRequestEntityPipe = (
Expand Down
20 changes: 15 additions & 5 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"module": "es2015",
"types": ["hammerjs", "jasmine", "jasminewd2", "karma"],
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"],
"module": "commonjs",
"types": [
"hammerjs",
"jasmine",
"jasminewd2",
"karma"
],
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
"preserveSymlinks": true
}
}
}