-
Notifications
You must be signed in to change notification settings - Fork 0
Upgrade Angular, Node.js, and related dependencies #1243
Conversation
Pre-upgrade steps from https://update.angular.io/#4.4:8.0.
http module moved into core.
See: angular/angular-cli#14553 (comment) Fixes build error "TS2554: Expected 2 arguments, but got 1."
Both are in compiler instead.
Still on 2.x
FIXME: remove when upgrade complete.
This allows the temperate Angular app to successfully compile. PlanItApiHttp was removed in favor of plain old HttpClient. PlanItApiHttp was causing cryptic errors when requests were made, such as: 'XMLHttpRequest failed to open with scheme: HTTP://LOCALHOST:8081/API/USER/' Why caps? And why is that a scheme? Now we just get normal 401 authorized failures because we need to implement an HTTP Interceptor to add the token to all API requests.
- Adds token to API requests - Redirects to home page in case of auth failure
So that we match the old Azavea ngx-bootstrap typeaheadMinLength=0 behavior.
…etc) The token interceptor was trying to add an authorization token even when there was no logged in user, causing requests to be rejected.
The newer version Angular we're upgrading to strips whitespace. In the few places where we were depending on whitespace to add padding to inline elements, I've explicitly added non-breaking spaces to accommodate.
Without also setting [typeaheadSelectFirstItem]="false", tabbing out of the input won't work with [typeaheadIsFirstItemActive]="false" set.
This library was failing in AoT mode, due to attempting to assign to the '.name' property of an anonymous function. It is unclear to me why this was not an issue before, but is now. Regardless, since the library was last updated 7 years ago and has several similarly old unmerged pull requests, it seemed like the best solution was to copy it into our project and fix it there rather than attempting to fork it and submit a fix. to fork it and submit a pull
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on the fence on if it's worth it to reformat the indentation in the copied-over components code - that mostly used 4-space indentation, while Temperate uses 2-space indentation.
If folks have strong opinions, please leave a 👍 or 👎
src/angular/planit/src/app/climate-api/api/models/historic-range.model.ts
Outdated
Show resolved
Hide resolved
src/angular/planit/src/app/core/services/account-create.service.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I successfully compiled the app and logged in, and I tested as much functionality as I could. I found one unrelated bug, and one thing that didn't seem to function as it should: on the indicator graphs, changing the Scenario, Dataset, and Model wasn't causing the graph to update for me. I also confirmed that live reload worked.
@@ -3,7 +3,7 @@ import { ActivatedRoute, Params, Router } from '@angular/router'; | |||
|
|||
import { AlertModule } from 'ngx-bootstrap'; | |||
|
|||
import { Observable } from 'rxjs/Rx'; | |||
import { Observable } from 'rxjs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎊
@@ -21,7 +21,9 @@ <h3 class="step-title">Details</h3> | |||
autocomplete="off" | |||
formControlName="action_type" | |||
[typeahead]="actionTypes" | |||
[typeaheadMinLength]="0"> | |||
[typeaheadMinLength]="0" | |||
[typeaheadIsFirstItemActive]="false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
|
||
import { environment } from '../../../environments/environment'; | ||
|
||
|
||
@Injectable() | ||
export class CityProfileService { | ||
|
||
constructor(private apiHttp: PlanItApiHttp) {} | ||
constructor(private http: HttpClient) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my own understanding, what changed to make the subclass unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We added these HTTP interceptors 3eb24a3 (a new feature introduced in Angular 5), which take the place of the custom code we had added to the subclass.
A new lint was added since Angular 4 that enforces this naming scheme These had already been renamed in the components repo before it was folded into this repository
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be good for someone else (probably @flibbertigibbet ) to take a second look at this before it goes in, given how large it is, but everything seems to be working pretty smoothly for me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
@Injectable() | ||
export class ActionTypeService { | ||
|
||
constructor(private apiHttp: PlanItApiHttp, | ||
constructor(private http: HttpClient, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎊
return new User(user); | ||
return this.http.get(url).pipe(map(response => { | ||
if (response) { | ||
return new User(response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
} | ||
|
||
listOptions(): Observable<{[key: string]: CityProfileOption[]}> { | ||
const url = `${environment.apiUrl}/api/city-profile-options/`; | ||
return this.apiHttp.get(url).map(response => response.json()); | ||
return this.http.get<{[key: string]: CityProfileOption[]}>(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// Parse string to array of arrays | ||
const csvData = papa.parse(resp['_body'], { newline: '\r\n' }); | ||
const csvData = papa.parse(resp, { newline: '\r\n' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎊
I think if you run |
Overview
The main effort in this PR is to upgrade Angular from version
4
to8
.As a consequence of that effort, the following other changes were also made:
6
to10
ngx-bootstrap
updated to the latest version, instead of using our forked version3
to4
climate-change-components
repository was copied into this repository, instead of remaining a separate dependency, due to difficulties in upgrading and integrating with the new Angular CLI support for library projectsdifflib
dependency (used by the password validation popup) was copied into this project with minor fixes, due to an error which was not fatal in our old CLI toolchain but became so in the newer toolchain.Demo
N/A
Everything should continue to work as it did before, with no changes in behavior or styling.
Testing Instructions
scripts/update
scripts/server
localhost:8000
by stoppingscripts/server
and runningdocker-compose up django nginx
Closes #1202
Closes #263
Closes #876