Skip to content

Commit 806eeb0

Browse files
committed
feat: update
1 parent a1e20e2 commit 806eeb0

7 files changed

Lines changed: 54 additions & 56 deletions

File tree

frontend/src/angular/package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/angular/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@angular/material": "^22.0.1",
3131
"@angular/platform-browser": "^22.0.1",
3232
"@angular/platform-browser-dynamic": "^22.0.1",
33-
"@angular/router": "^22.0.1",
33+
"@angular/router": "^22.0.1",
3434
"bingmaps": "^2.0.3",
3535
"material-icons": "^1.11.11",
3636
"rxjs": "^7.4.0",
@@ -50,6 +50,7 @@
5050
"@types/jasmine": "~3.10.0",
5151
"@types/jasminewd2": "~2.0.3",
5252
"@types/node": "^18.0.0",
53+
"@types/bingmaps": "^7.0.20",
5354
"@typescript-eslint/eslint-plugin": "^8.60.0",
5455
"@typescript-eslint/parser": "^8.60.0",
5556
"cpy-cli": "^4.2.0",

frontend/src/angular/src/app/maps/company-site/company-site.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<input matSliderThumb formControlName="{{ SLIDER_YEAR }}" />
4141
</mat-slider>
4242
<span class="my-year" i18n="@@companysite.slideryear">
43-
Year: {{ componentForm.get("sliderYear").value }}</span
43+
Year: {{ componentForm.get("sliderYear")?.value }}</span
4444
>
4545
</div>
4646
</div>

frontend/src/angular/src/app/maps/company-site/company-site.component.ts

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference types="bingmaps" />
12
/**Copyright 2016 Sven Loesekann
23
34
Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +14,7 @@
1314
limitations under the License.
1415
*/
1516
/* eslint-disable @typescript-eslint/naming-convention */
17+
declare const Microsoft: any;
1618
import {
1719
Component,
1820
OnInit,
@@ -24,7 +26,6 @@ import {
2426
inject,
2527
} from "@angular/core";
2628
import { CompanySiteService } from "../../services/company-site.service";
27-
import "bingmaps";
2829
import { ConfigurationService } from "../../services/configuration.service";
2930
import { MainConfiguration } from "../model/main-configuration";
3031
import { Observable, of, iif, Subject, forkJoin } from "rxjs";
@@ -89,13 +90,13 @@ interface PolygonMetaData {
8990
})
9091
export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
9192
@ViewChild("bingMap")
92-
protected bingMapContainer: ElementRef;
93+
protected bingMapContainer!: ElementRef;
9394

9495
protected newLocations: NewLocation[] = [];
95-
protected map: Microsoft.Maps.Map = null;
96+
protected map: any = null;
9697
protected resetInProgress = false;
9798

98-
protected companySiteOptions: Observable<CompanySite[]>;
99+
protected companySiteOptions!: Observable<CompanySite[]>;
99100
protected componentForm = this.formBuilder.group({
100101
companySite: ["Finkenwerder" as string | CompanySite, Validators.required],
101102
sliderYear: [2020],
@@ -105,7 +106,7 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
105106
protected readonly COMPANY_SITE = "companySite";
106107
protected readonly SLIDER_YEAR = "sliderYear";
107108
protected readonly PROPERTY = "property";
108-
private mainConfiguration: MainConfiguration = null;
109+
private mainConfiguration!: MainConfiguration;
109110
private readonly containerInitSubject = new Subject<Container>();
110111
private readonly destroy: DestroyRef = inject(DestroyRef);
111112

@@ -125,11 +126,11 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
125126
() =>
126127
!this.getCompanySiteTitle() ||
127128
this.getCompanySiteTitle().length < 3 ||
128-
!this.componentForm.get(this.SLIDER_YEAR).value,
129+
!this.componentForm.get(this.SLIDER_YEAR)?.value,
129130
of<CompanySite[]>([]),
130131
this.companySiteService.findByTitleAndYear(
131132
this.getCompanySiteTitle(),
132-
this.componentForm.get(this.SLIDER_YEAR).value
133+
this.componentForm.get(this.SLIDER_YEAR)?.value ?? 0
133134
)
134135
)
135136
),
@@ -143,7 +144,7 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
143144
filter(
144145
(year) =>
145146
!(
146-
typeof this.componentForm.get(this.COMPANY_SITE).value ===
147+
typeof this.componentForm.get(this.COMPANY_SITE)?.value ===
147148
"string"
148149
)
149150
),
@@ -155,7 +156,7 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
155156
),
156157
filter(
157158
(companySite) =>
158-
companySite?.length &&
159+
companySite != null &&
159160
companySite.length > 0 &&
160161
companySite[0].polygons.length > 0
161162
),
@@ -166,7 +167,7 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
166167
this.configurationService.importConfiguration(),
167168
this.companySiteService.findByTitleAndYearWithChildren(
168169
this.getCompanySiteTitle(),
169-
this.componentForm.controls[this.SLIDER_YEAR].value
170+
this.componentForm.controls[this.SLIDER_YEAR]?.value ?? 0
170171
),
171172
]).pipe(takeUntilDestroyed(this.destroy)).subscribe((values) => {
172173
this.mainConfiguration = values[0];
@@ -197,13 +198,13 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
197198
.subscribe((container) => {
198199
const mapOptions =
199200
container.companySite.polygons.length < 1
200-
? ({} as Microsoft.Maps.IMapLoadOptions)
201-
: ({
201+
? {}
202+
: {
202203
center: new Microsoft.Maps.Location(
203204
container.companySite.polygons[0].latitude,
204205
container.companySite.polygons[0].longitude
205206
),
206-
} as Microsoft.Maps.IMapLoadOptions);
207+
};
207208
this.map = new Microsoft.Maps.Map(
208209
this.bingMapContainer.nativeElement as HTMLElement,
209210
mapOptions
@@ -214,7 +215,7 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
214215
container.companySite.polygons.forEach((polygon) =>
215216
this.addPolygon(polygon)
216217
);
217-
Microsoft.Maps.Events.addHandler(this.map, "click", (e) =>
218+
Microsoft.Maps.Events.addHandler(this.map, "click", (e: any) =>
218219
this.onMapClick(e)
219220
);
220221
});
@@ -237,10 +238,10 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
237238
}
238239

239240
upsertCompanySite(): void {
240-
if (typeof this.componentForm.get(this.COMPANY_SITE).value === "string") {
241+
if (typeof this.componentForm.get(this.COMPANY_SITE)?.value === "string") {
241242
console.log(
242243
"should create new company site: " +
243-
this.componentForm.get(this.COMPANY_SITE).value
244+
this.componentForm.get(this.COMPANY_SITE)?.value
244245
);
245246
} else {
246247
const myCompanySite = this.componentForm.controls[this.COMPANY_SITE]
@@ -298,7 +299,7 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
298299
this.companySiteService.findByTitleAndYear("Finkenwerder", 2020)
299300
),
300301
filter(
301-
(myCompanySite) => myCompanySite?.length && myCompanySite?.length > 0
302+
(myCompanySite) => myCompanySite != null && myCompanySite.length > 0
302303
),
303304
takeUntilDestroyed(this.destroy)
304305
)
@@ -333,49 +334,41 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
333334
new Microsoft.Maps.Location(myLocation.latitude, myLocation.longitude)
334335
)
335336
);
336-
const mapPolygon = new Microsoft.Maps.Polygon(polygonRings);
337-
mapPolygon.metadata = {
337+
const mapPolygon = new Microsoft.Maps.Polygon(polygonRings.flat());
338+
(mapPolygon as any).metadata = {
338339
companySiteId: (
339340
this.componentForm.controls[this.COMPANY_SITE].value as CompanySite
340341
).id,
341342
polygonId: polygon.id,
342343
} as PolygonMetaData;
343-
Microsoft.Maps.Events.addHandler(mapPolygon, "click", (e) =>
344+
Microsoft.Maps.Events.addHandler(mapPolygon, "click", (e: any) =>
344345
this.onPolygonDblClick(e)
345346
);
346347
this.map.entities.push(mapPolygon);
347348
}
348349

349-
private onPolygonDblClick(
350-
e:
351-
| Microsoft.Maps.IMouseEventArgs
352-
| Microsoft.Maps.IPrimitiveChangedEventArgs
353-
): void {
350+
private onPolygonDblClick(e: any): void {
354351
console.log(e);
355352
if (
356-
(e as Microsoft.Maps.IMouseEventArgs).targetType === "polygon" &&
357-
(e as Microsoft.Maps.IMouseEventArgs).eventName === "click"
353+
(e as any).targetType === "polygon" &&
354+
(e as any).eventName === "click"
358355
) {
359-
//console.log((e as Microsoft.Maps.IMouseEventArgs).target);
360-
const myPolygon = (e as Microsoft.Maps.IMouseEventArgs)
361-
.target as Microsoft.Maps.Polygon;
356+
//console.log((e as MicrosoftMapsIMouseEventArgs).target);
357+
const myPolygon = (e as any).target as any;
362358
this.openDeleteDialog(myPolygon.metadata as PolygonMetaData);
363359
}
364360
}
365361

366-
private onMapClick(
367-
e: Microsoft.Maps.IMouseEventArgs | Microsoft.Maps.IMapTypeChangeEventArgs
368-
): void {
369-
if ((e as Microsoft.Maps.IMouseEventArgs).location) {
362+
private onMapClick(e: any): void {
363+
if ((e as any).location) {
370364
const myLocation = {
371365
id: this.newLocations.length + 1,
372-
location: (e as Microsoft.Maps.IMouseEventArgs).location,
366+
location: (e as any).location,
373367
selected: true,
374368
};
375369
this.newLocations.push(myLocation);
376370
this.map.entities.push(
377371
new Microsoft.Maps.Pushpin(myLocation.location, {
378-
title: "" + myLocation.id,
379372
icon: "assets/map-pin.png",
380373
anchor: new Microsoft.Maps.Point(12, 39),
381374
})
@@ -400,7 +393,7 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
400393
companySite.polygons[0].latitude,
401394
companySite.polygons[0].longitude
402395
),
403-
} as Microsoft.Maps.IMapLoadOptions);
396+
});
404397
this.map.entities.clear();
405398
companySite.polygons.forEach((polygon) => this.addPolygon(polygon));
406399
this.map.setView({
@@ -414,23 +407,21 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
414407
}
415408

416409
private getCompanySiteTitle(): string {
417-
return typeof this.componentForm.get(this.COMPANY_SITE).value === "string"
418-
? (this.componentForm.get(this.COMPANY_SITE).value as string)
419-
: (this.componentForm.get(this.COMPANY_SITE).value as CompanySite).title;
410+
return typeof this.componentForm.get(this.COMPANY_SITE)?.value === "string"
411+
? (this.componentForm.get(this.COMPANY_SITE)?.value as string)
412+
: (this.componentForm.get(this.COMPANY_SITE)?.value as CompanySite).title;
420413
}
421414

422415
private updateMapPushPins(): void {
423-
const mapPinsToAdd: Microsoft.Maps.Pushpin[] = [];
424-
const mapPinsToRemove: Microsoft.Maps.Pushpin[] = [];
425-
const mapPins: Microsoft.Maps.Pushpin[] = [];
416+
const mapPinsToAdd: any[] = [];
417+
const mapPinsToRemove: any[] = [];
418+
const mapPins: any[] = [];
426419
for (let i = 0; i < this.map.entities.getLength(); i++) {
427420
if (
428-
typeof (this.map.entities.get(i) as Microsoft.Maps.Pushpin).getIcon ===
429-
"function" &&
430-
typeof (this.map.entities.get(i) as Microsoft.Maps.Pushpin).getTitle ===
421+
typeof (this.map.entities.get(i) as any).getIcon ===
431422
"function"
432423
) {
433-
mapPins.push(this.map.entities.get(i) as Microsoft.Maps.Pushpin);
424+
mapPins.push(this.map.entities.get(i) as any);
434425
}
435426
}
436427
if (this.newLocations.length === 0) {
@@ -448,7 +439,6 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
448439
if (!myMapPin || (myMapPin.length === 0 && newLocation.selected)) {
449440
mapPinsToAdd.push(
450441
new Microsoft.Maps.Pushpin(newLocation.location, {
451-
title: "" + newLocation.id,
452442
icon: "assets/map-pin.png",
453443
anchor: new Microsoft.Maps.Point(12, 39),
454444
})
@@ -457,7 +447,7 @@ export class CompanySiteComponent implements OnInit, AfterViewInit, OnDestroy {
457447
});
458448
}
459449
mapPinsToRemove.forEach((myPin) => this.map.entities.remove(myPin));
460-
mapPinsToAdd.forEach((myPin) => this.map.entities.add(myPin));
450+
mapPinsToAdd.forEach((myPin) => this.map.entities.push(myPin));
461451
}
462452

463453
private openDeleteDialog(polygonMetaData: PolygonMetaData): void {

frontend/src/angular/src/app/services/bing-maps.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export class BingMapsService {
3232
script.charset = "utf-8";
3333
document.head.appendChild(script);
3434
const scriptPromise = new Promise<boolean>((resolve, reject) => {
35-
window[callBackName] = () => {
35+
(window as any)[callBackName] = () => {
3636
this.initialized = true;
3737
resolve(true);
3838
};
39-
script.onerror = (error: Event) => {
39+
script.onerror = (error: Event | string) => {
4040
console.log(error);
4141
reject(false);
4242
};

frontend/src/angular/src/app/services/configuration.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { GraphqlService } from "./graphql.service";
2020

2121
@Injectable({ providedIn: "root" })
2222
export class ConfigurationService {
23-
private mainConfiguration: MainConfiguration = null;
23+
private mainConfiguration!: MainConfiguration;
2424

2525
constructor(private graphqlService: GraphqlService) {}
2626

frontend/src/angular/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"compileOnSave": false,
3-
"compilerOptions": {
4-
"baseUrl": "./",
3+
"compilerOptions": {
54
"outDir": "./dist/out-tsc",
65
"forceConsistentCasingInFileNames": true,
76
"esModuleInterop": true,

0 commit comments

Comments
 (0)