Skip to content

Commit 22db249

Browse files
Merge pull request #22 from CentreForDigitalHumanities/feature/upgrade-ng-18
Upgrade to Angular 19
2 parents 15df653 + a4d1b74 commit 22db249

26 files changed

Lines changed: 2752 additions & 1953 deletions

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python Debugger: Current File",
9+
"type": "debugpy",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
},
14+
{
15+
"name": "Python Debugger: Pytest Functional Tests",
16+
"type": "debugpy",
17+
"request": "launch",
18+
"module": "pytest",
19+
"args": ["functional-tests"],
20+
"console": "integratedTerminal"
21+
}
22+
]
23+
}

backend/langpro_annotator/index.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ def index(request: HttpRequest):
1010
language = request.LANGUAGE_CODE
1111
page = request.path[1:].split("/", 1)[0]
1212
# pre-rendered version available?
13+
print('Location:', path.join(language, page, "index.html"))
14+
print('Language code:', language)
15+
1316
location = finders.find(path.join(language, page, "index.html"))
1417
if not location:
1518
location = finders.find(path.join(language, "index.html"))

frontend/angular.json

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
"outputPath": "dist",
2424
"index": "src/index.html",
2525
"browser": "src/main.ts",
26-
"polyfills": [
27-
"zone.js"
28-
],
26+
"polyfills": ["zone.js", "@angular/localize/init"],
2927
"tsConfig": "tsconfig.app.json",
3028
"inlineStyleLanguage": "scss",
3129
"assets": [
@@ -49,9 +47,7 @@
4947
"scripts": [],
5048
"server": "src/main.server.ts",
5149
"prerender": true,
52-
"ssr": {
53-
"entry": "server.ts"
54-
},
50+
"ssr": false,
5551
"baseHref": "/"
5652
},
5753
"configurations": {
@@ -77,9 +73,7 @@
7773
"sourceMap": true
7874
},
7975
"nl": {
80-
"localize": [
81-
"nl"
82-
]
76+
"localize": ["nl"]
8377
}
8478
},
8579
"defaultConfiguration": "production"
@@ -109,17 +103,16 @@
109103
"format": "xlf",
110104
"outputPath": "locale",
111105
"includeContext": true,
112-
"targetFiles": [
113-
"messages.nl.xlf"
114-
]
106+
"targetFiles": ["messages.nl.xlf"]
115107
}
116108
},
117109
"test": {
118110
"builder": "@angular-devkit/build-angular:karma",
119111
"options": {
120112
"polyfills": [
121113
"zone.js",
122-
"zone.js/testing"
114+
"zone.js/testing",
115+
"@angular/localize/init"
123116
],
124117
"tsConfig": "tsconfig.spec.json",
125118
"inlineStyleLanguage": "scss",
@@ -128,26 +121,22 @@
128121
"src/favicon.svg",
129122
"src/assets"
130123
],
131-
"styles": [
132-
"src/styles.scss"
133-
],
124+
"styles": ["src/styles.scss"],
134125
"scripts": [],
135126
"karmaConfig": "karma.conf.js"
136127
}
137128
}
138129
},
139130
"i18n": {
140131
"sourceLocale": {
141-
"code": "en",
142-
"baseHref": "/en/"
132+
"code": "en"
143133
},
144134
"locales": {
145135
"nl": {
146-
"translation": "locale/messages.nl.xlf",
147-
"baseHref": "/nl/"
136+
"translation": "locale/messages.nl.xlf"
148137
}
149138
}
150139
}
151140
}
152141
}
153-
}
142+
}

frontend/package.json

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,60 @@
11
{
2-
"name": "langpro-annotator",
3-
"scripts": {
4-
"start": "yarn serve",
5-
"build": "ng build --base-href=/static/ --localize",
6-
"watch": "ng build --watch",
7-
"test": "ng test --watch=true",
8-
"serve:ssr:langpro-annotator": "node dist/langpro-annotator/server/server.mjs",
9-
"prebuild": "node ./build/build-pre.js",
10-
"i18n": "ng extract-i18n --output-path locale",
11-
"preserve": "yarn prebuild",
12-
"serve": "ng serve",
13-
"serve:en": "ng serve --configuration=en",
14-
"serve:nl": "ng serve --configuration=nl",
15-
"stop": "lsof -t -i tcp:4200 | xargs kill -9 || echo \"not running\"",
16-
"pretest": "yarn prebuild",
17-
"test-once": "ng test --watch=false"
18-
},
19-
"private": true,
20-
"dependencies": {
21-
"@angular/animations": "^17.3.0",
22-
"@angular/common": "^17.3.0",
23-
"@angular/compiler": "^17.3.0",
24-
"@angular/core": "^17.3.0",
25-
"@angular/forms": "^17.3.0",
26-
"@angular/platform-browser": "^17.3.0",
27-
"@angular/platform-browser-dynamic": "^17.3.0",
28-
"@angular/platform-server": "^17.3.0",
29-
"@angular/router": "^17.3.0",
30-
"@angular/ssr": "^17.3.13",
31-
"@fortawesome/angular-fontawesome": "^0.14.1",
32-
"@fortawesome/fontawesome-svg-core": "^6.5.2",
33-
"@fortawesome/free-solid-svg-icons": "^6.5.2",
34-
"@ng-bootstrap/ng-bootstrap": "^16.0.0",
35-
"@ngrx/effects": "^17.2.0",
36-
"@ngrx/store": "^17.2.0",
37-
"@popperjs/core": "^2.11.8",
38-
"bootstrap": "^5.3.3",
39-
"colors": "^1.4.0",
40-
"express": "^4.18.2",
41-
"rxjs": "~7.8.0",
42-
"tslib": "^2.3.0",
43-
"zone.js": "~0.14.3"
44-
},
45-
"devDependencies": {
46-
"@angular-devkit/build-angular": "^17.3.13",
47-
"@angular/cli": "^17.3.13",
48-
"@angular/compiler-cli": "^17.3.0",
49-
"@angular/localize": "17.3.12",
50-
"@types/express": "^4.17.17",
51-
"@types/jasmine": "~5.1.0",
52-
"@types/node": "^18.18.0",
53-
"jasmine-core": "~5.1.0",
54-
"karma": "~6.4.0",
55-
"karma-chrome-launcher": "~3.2.0",
56-
"karma-coverage": "~2.2.0",
57-
"karma-jasmine": "~5.1.0",
58-
"karma-jasmine-html-reporter": "~2.1.0",
59-
"ng-extract-i18n-merge": "^2.12.0",
60-
"typescript": "~5.4.2"
61-
}
62-
}
2+
"name": "langpro-annotator",
3+
"scripts": {
4+
"start": "yarn serve",
5+
"build": "ng build --base-href=/static/ --localize",
6+
"watch": "ng build --watch",
7+
"test": "ng test --watch=true",
8+
"serve:ssr:langpro-annotator": "node dist/langpro-annotator/server/server.mjs",
9+
"prebuild": "node ./build/build-pre.js",
10+
"i18n": "ng extract-i18n --output-path locale",
11+
"preserve": "yarn prebuild",
12+
"serve": "ng serve",
13+
"serve:en": "ng serve --configuration=en",
14+
"serve:nl": "ng serve --configuration=nl",
15+
"stop": "lsof -t -i tcp:4200 | xargs kill -9 || echo \"not running\"",
16+
"pretest": "yarn prebuild",
17+
"test-once": "ng test --watch=false"
18+
},
19+
"private": true,
20+
"dependencies": {
21+
"@angular/animations": "^19.2.13",
22+
"@angular/common": "^19.2.13",
23+
"@angular/compiler": "^19.2.13",
24+
"@angular/core": "^19.2.13",
25+
"@angular/forms": "^19.2.13",
26+
"@angular/platform-browser": "^19.2.13",
27+
"@angular/platform-browser-dynamic": "^19.2.13",
28+
"@angular/platform-server": "^19.2.13",
29+
"@angular/router": "^19.2.13",
30+
"@angular/ssr": "^19.2.13",
31+
"@fortawesome/angular-fontawesome": "^1.0.0",
32+
"@fortawesome/fontawesome-svg-core": "^6.7.2",
33+
"@fortawesome/free-solid-svg-icons": "^6.7.2",
34+
"@ng-bootstrap/ng-bootstrap": "^18.0.0",
35+
"@popperjs/core": "^2.11.8",
36+
"bootstrap": "^5.3.3",
37+
"colors": "^1.4.0",
38+
"express": "^4.18.2",
39+
"rxjs": "~7.8.0",
40+
"tslib": "^2.3.0",
41+
"zone.js": "~0.15.1"
42+
},
43+
"devDependencies": {
44+
"@angular-devkit/build-angular": "^19.2.13",
45+
"@angular/cli": "^19.2.13",
46+
"@angular/compiler-cli": "^19.2.13",
47+
"@angular/localize": "19.2.13",
48+
"@types/express": "^4.17.17",
49+
"@types/jasmine": "~5.1.0",
50+
"@types/node": "^18.18.0",
51+
"jasmine-core": "~5.1.0",
52+
"karma": "~6.4.0",
53+
"karma-chrome-launcher": "~3.2.0",
54+
"karma-coverage": "~2.2.0",
55+
"karma-jasmine": "~5.1.0",
56+
"karma-jasmine-html-reporter": "~2.1.0",
57+
"ng-extract-i18n-merge": "^2.12.0",
58+
"typescript": "~5.8.3"
59+
}
60+
}

frontend/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { APP_BASE_HREF } from "@angular/common";
2-
import { CommonEngine } from "@angular/ssr";
2+
import { CommonEngine } from "@angular/ssr/node";
33
import express from "express";
44
import { fileURLToPath } from "node:url";
55
import { dirname, join, resolve } from "node:path";

frontend/src/app/annotate/annotation-input/knowledge-base-form/knowledge-base-form.component.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ <h3 class="h5" i18n>Knowledge Base</h3>
55
<div class="card-body">
66
<form [formGroup]="form" (ngSubmit)="onSubmit()">
77
<ul formArrayName="kbItems" class="ps-0 list-unstyled">
8-
<li
9-
*ngFor="
10-
let kbItem of form.controls.kbItems.controls;
11-
let i = index
12-
"
13-
class="mb-3"
14-
>
8+
@for (kbItem of form.controls.kbItems.controls; let i = $index;
9+
track $index) {
10+
<li class="mb-3">
1511
<div [formGroupName]="i" class="input-group">
1612
<input
1713
type="text"
@@ -27,9 +23,12 @@ <h3 class="h5" i18n>Knowledge Base</h3>
2723
<option value="" disabled selected i18n>
2824
Select Relationship
2925
</option>
30-
<option *ngFor="let relationship of relationshipTypes" [value]="relationship">
26+
@for (relationship of relationshipTypes; track
27+
$index) {
28+
<option [value]="relationship">
3129
{{ getRelationshipTypeName(relationship) }}
3230
</option>
31+
}
3332
</select>
3433
<input
3534
type="text"
@@ -53,6 +52,7 @@ <h3 class="h5" i18n>Knowledge Base</h3>
5352
</button>
5453
</div>
5554
</li>
55+
}
5656
</ul>
5757
<div class="btn-group" role="group">
5858
<button

frontend/src/app/annotate/annotation-input/premises-form/premises-form.component.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ <h3 class="h5" i18n>Premises and Conclusion</h3>
55
<div class="card-body">
66
<form [formGroup]="form" (ngSubmit)="onSubmit()">
77
<ul formArrayName="premises" class="ps-0 list-unstyled">
8-
<li
9-
*ngFor="let premise of premises.controls; let i = index"
10-
class="mb-3"
11-
>
8+
@for (premise of premises.controls; let i = $index; track
9+
$index) {
10+
11+
<li class="mb-3">
1212
<label
1313
[attr.for]="'premise-' + i"
1414
class="form-label fw-bold"
@@ -38,6 +38,7 @@ <h3 class="h5" i18n>Premises and Conclusion</h3>
3838
</button>
3939
</div>
4040
</li>
41+
}
4142
</ul>
4243
<button
4344
type="button"
Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1-
import { TestBed, waitForAsync } from '@angular/core/testing';
2-
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
3-
import { RouterTestingModule } from '@angular/router/testing';
4-
import { HttpClientTestingModule } from '@angular/common/http/testing';
1+
import { TestBed, waitForAsync } from "@angular/core/testing";
2+
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
3+
import { provideHttpClientTesting } from "@angular/common/http/testing";
54

6-
import { AppComponent } from './app.component';
5+
import { AppComponent } from "./app.component";
6+
import {
7+
provideHttpClient,
8+
withInterceptorsFromDi,
9+
} from "@angular/common/http";
10+
import { ActivatedRoute } from "@angular/router";
711

8-
describe('AppComponent', () => {
12+
describe("AppComponent", () => {
913
beforeEach(waitForAsync(() => {
1014
TestBed.configureTestingModule({
11-
imports: [
12-
AppComponent, NoopAnimationsModule, RouterTestingModule, HttpClientTestingModule]
15+
imports: [AppComponent, NoopAnimationsModule],
16+
providers: [
17+
provideHttpClient(withInterceptorsFromDi()),
18+
provideHttpClientTesting(),
19+
{
20+
provide: ActivatedRoute,
21+
useValue: {},
22+
},
23+
],
1324
}).compileComponents();
1425
}));
1526

16-
17-
it('should create the app', () => {
27+
it("should create the app", () => {
1828
const fixture = TestBed.createComponent(AppComponent);
1929
const app = fixture.debugElement.componentInstance;
2030
expect(app).toBeTruthy();
@@ -26,10 +36,12 @@ describe('AppComponent', () => {
2636
expect(app.title).toEqual(`LangPro Annotator`);
2737
});
2838

29-
it('should render title', () => {
39+
it("should render title", () => {
3040
const fixture = TestBed.createComponent(AppComponent);
3141
fixture.detectChanges();
3242
const compiled = fixture.debugElement.nativeElement;
33-
expect(compiled.querySelector('.navbar-brand').textContent).toContain('LangPro Annotator');
43+
expect(compiled.querySelector(".navbar-brand").textContent).toContain(
44+
"LangPro Annotator"
45+
);
3446
});
3547
});

0 commit comments

Comments
 (0)