diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 1a483476f4..1479f96156 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -18,6 +18,7 @@ "@angular/platform-browser": "~15.1.2", "@angular/platform-browser-dynamic": "~15.1.2", "@angular/router": "~15.1.2", + "@ngneat/until-destroy": "^9.2.3", "@types/semver": "^7.3.13", "buffer": "^6.0.3", "file-saver": "^2.0.5", @@ -3775,6 +3776,18 @@ "tslib": "^2.1.0" } }, + "node_modules/@ngneat/until-destroy": { + "version": "9.2.3", + "resolved": "https://registry.npmjs.org/@ngneat/until-destroy/-/until-destroy-9.2.3.tgz", + "integrity": "sha512-ryX0vqDOdmYo53f7v5Ivbj1jcqOEX+vM1iiV9NYepWDha4VJp9lWrDFK9tRt2evAMzF/9u67JLzs4Xjcoh+Taw==", + "dependencies": { + "tslib": "^2.3.0" + }, + "peerDependencies": { + "@angular/core": ">=13", + "rxjs": "^6.4.0 || ^7.0.0" + } + }, "node_modules/@ngtools/webpack": { "version": "15.1.3", "resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-15.1.3.tgz", @@ -5168,6 +5181,7 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, "dependencies": { "color-convert": "^1.9.0" }, @@ -5903,6 +5917,7 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -6080,6 +6095,7 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, "dependencies": { "color-name": "1.1.3" } @@ -6087,7 +6103,8 @@ "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true }, "node_modules/color-support": { "version": "1.1.3", @@ -7307,6 +7324,7 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, "engines": { "node": ">=0.8.0" } @@ -8831,6 +8849,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, "engines": { "node": ">=4" } @@ -10138,7 +10157,8 @@ "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true }, "node_modules/json-parse-helpfulerror": { "version": "1.0.3", @@ -11398,6 +11418,7 @@ "version": "0.5.6", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, "dependencies": { "minimist": "^1.2.6" }, @@ -16959,6 +16980,7 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, "dependencies": { "has-flag": "^3.0.0" }, @@ -17203,7 +17225,8 @@ "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==" + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true }, "node_modules/through": { "version": "2.3.8", diff --git a/frontend/package.json b/frontend/package.json index ba251f0ac8..bb179ceddb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -23,6 +23,7 @@ "@angular/platform-browser": "~15.1.2", "@angular/platform-browser-dynamic": "~15.1.2", "@angular/router": "~15.1.2", + "@ngneat/until-destroy": "^9.2.3", "@types/semver": "^7.3.13", "buffer": "^6.0.3", "file-saver": "^2.0.5", diff --git a/frontend/src/app/projects/create-project/create-project.component.html b/frontend/src/app/projects/create-project/create-project.component.html index 750dbfb29a..4b472ad4fe 100644 --- a/frontend/src/app/projects/create-project/create-project.component.html +++ b/frontend/src/app/projects/create-project/create-project.component.html @@ -66,11 +66,9 @@ -
+
- +
-
+

Team4Capella sources

diff --git a/frontend/src/app/settings/modelsources/git-settings/edit-git-settings/edit-git-settings.component.ts b/frontend/src/app/settings/modelsources/git-settings/edit-git-settings/edit-git-settings.component.ts index c05aa3be1d..9ba4e6c565 100644 --- a/frontend/src/app/settings/modelsources/git-settings/edit-git-settings/edit-git-settings.component.ts +++ b/frontend/src/app/settings/modelsources/git-settings/edit-git-settings/edit-git-settings.component.ts @@ -6,13 +6,15 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { filter, Subscription } from 'rxjs'; +import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { filter } from 'rxjs'; import { BreadcrumbsService } from 'src/app/general/breadcrumbs/breadcrumbs.service'; import { GitInstance, GitInstancesService, } from 'src/app/settings/modelsources/git-settings/service/git-instances.service'; +@UntilDestroy() @Component({ selector: 'app-edit-git-settings', templateUrl: './edit-git-settings.component.html', @@ -21,7 +23,7 @@ import { export class EditGitSettingsComponent implements OnInit, OnDestroy { id: number = -1; - gitSettingsForm = new FormGroup({ + gitInstanceForm = new FormGroup({ type: new FormControl('', Validators.required), name: new FormControl('', Validators.required), url: new FormControl('', Validators.required), @@ -31,39 +33,34 @@ export class EditGitSettingsComponent implements OnInit, OnDestroy { constructor( private router: Router, private route: ActivatedRoute, - private gitSettingsService: GitInstancesService, + private gitInstancesService: GitInstancesService, private breadcrumbsService: BreadcrumbsService ) {} - private gitSettingsSubscription?: Subscription; - private paramsSubscription?: Subscription; - ngOnInit(): void { - this.gitSettingsSubscription = this.gitSettingsService.gitInstance - .pipe(filter(Boolean)) + this.gitInstancesService.gitInstance + .pipe(filter(Boolean), untilDestroyed(this)) .subscribe((instance: GitInstance) => { - this.gitSettingsForm.patchValue(instance); + this.gitInstanceForm.patchValue(instance); this.breadcrumbsService.updatePlaceholder({ gitInstance: instance }); }); - this.paramsSubscription = this.route.params.subscribe((params) => { + this.route.params.pipe(untilDestroyed(this)).subscribe((params) => { this.id = params['id']; if (!!this.id) { - this.gitSettingsService.loadGitInstanceById(this.id); + this.gitInstancesService.loadGitInstanceById(this.id); } }); } ngOnDestroy(): void { - this.gitSettingsSubscription?.unsubscribe(); - this.paramsSubscription?.unsubscribe(); this.breadcrumbsService.updatePlaceholder({ gitInstance: undefined }); } - editGitSettings() { - this.gitSettingsService + editGitInstance() { + this.gitInstancesService .editGitInstance({ - ...this.gitSettingsForm.value, + ...this.gitInstanceForm.value, id: this.id, } as GitInstance) .subscribe((_) => this.goBack()); diff --git a/frontend/src/app/settings/modelsources/git-settings/git-settings.component.html b/frontend/src/app/settings/modelsources/git-settings/git-settings.component.html index 1a046af961..89577a0614 100644 --- a/frontend/src/app/settings/modelsources/git-settings/git-settings.component.html +++ b/frontend/src/app/settings/modelsources/git-settings/git-settings.component.html @@ -4,11 +4,11 @@ -->
-
+
Existing instances
-
- +
+
@@ -88,7 +88,7 @@ diff --git a/frontend/src/app/settings/modelsources/git-settings/git-settings.component.ts b/frontend/src/app/settings/modelsources/git-settings/git-settings.component.ts index 14b8ccf30c..5664887755 100644 --- a/frontend/src/app/settings/modelsources/git-settings/git-settings.component.ts +++ b/frontend/src/app/settings/modelsources/git-settings/git-settings.component.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { AbstractControl, FormControl, @@ -13,7 +13,8 @@ import { Validators, } from '@angular/forms'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { filter, Subscription } from 'rxjs'; +import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { filter } from 'rxjs'; import { absoluteUrlValidator } from 'src/app/helpers/validators/url-validator'; import { DeleteGitSettingsDialogComponent } from 'src/app/settings/modelsources/git-settings/delete-git-settings-dialog/delete-git-settings-dialog.component'; import { @@ -22,13 +23,14 @@ import { GitType, } from 'src/app/settings/modelsources/git-settings/service/git-instances.service'; +@UntilDestroy() @Component({ selector: 'app-git-settings', templateUrl: './git-settings.component.html', styleUrls: ['./git-settings.component.css'], }) -export class GitSettingsComponent implements OnInit, OnDestroy { - public availableGitSettings: GitInstance[] = []; +export class GitSettingsComponent implements OnInit { + public availableGitInstances: GitInstance[] = []; gitInstancesForm = new FormGroup({ type: new FormControl('', Validators.required), @@ -37,36 +39,30 @@ export class GitSettingsComponent implements OnInit, OnDestroy { apiURL: new FormControl('', absoluteUrlValidator()), }); - private gitSettingsSubscription?: Subscription; - constructor( - private gitSettingsService: GitInstancesService, public dialog: MatDialog, - public dialogRef: MatDialogRef + public dialogRef: MatDialogRef, + private gitInstancesService: GitInstancesService ) {} ngOnInit(): void { - this.gitSettingsService.gitInstances - .pipe(filter(Boolean)) + this.gitInstancesService.gitInstances + .pipe(filter(Boolean), untilDestroyed(this)) .subscribe((gitInstances) => { - this.availableGitSettings = gitInstances; + this.availableGitInstances = gitInstances; }); - this.gitSettingsService.loadGitInstances(); - } - - ngOnDestroy(): void { - this.gitSettingsSubscription?.unsubscribe(); + this.gitInstancesService.loadGitInstances(); } - createGitSettings(): void { + createGitInstance(): void { if (this.gitInstancesForm.valid) { let url = this.gitInstancesForm.value.url!; if (url.endsWith('/')) { url = url.slice(0, -1); } - this.gitSettingsService + this.gitInstancesService .createGitInstance({ name: this.gitInstancesForm.value.name!, url: url, @@ -77,30 +73,30 @@ export class GitSettingsComponent implements OnInit, OnDestroy { } } - deleteGitSettings(id: number): void { - const toDeleteGitSetting: GitInstance = this.availableGitSettings.find( - (gitSetting) => gitSetting.id == id + deleteGitInstance(id: number): void { + const toDeleteGitInstance: GitInstance = this.availableGitInstances.find( + (gitInstance) => gitInstance.id == id )!; this.dialog .open(DeleteGitSettingsDialogComponent, { - data: toDeleteGitSetting, + data: toDeleteGitInstance, }) .afterClosed() .subscribe((response) => { if (response) { - this.gitSettingsService.deleteGitInstance(id).subscribe(); + this.gitInstancesService.deleteGitInstance(id).subscribe(); } }); } nameValidator(): ValidatorFn { return (control: AbstractControl): ValidationErrors | null => { - const existingGitSetting = this.availableGitSettings.find( - (gitSetting) => gitSetting.name == control.value + const existingGitInstance = this.availableGitInstances.find( + (gitInstance) => gitInstance.name == control.value ); - if (existingGitSetting) { - return { uniqueName: { value: existingGitSetting.name } }; + if (existingGitInstance) { + return { uniqueName: { value: existingGitInstance.name } }; } return null; }; diff --git a/frontend/src/app/settings/modelsources/git-settings/service/git-instances.service.ts b/frontend/src/app/settings/modelsources/git-settings/service/git-instances.service.ts index 85babe6a3e..a2c3e5df70 100644 --- a/frontend/src/app/settings/modelsources/git-settings/service/git-instances.service.ts +++ b/frontend/src/app/settings/modelsources/git-settings/service/git-instances.service.ts @@ -37,7 +37,7 @@ export class GitInstancesService { ); }) ) - .subscribe((gitSettings) => this._gitInstances.next(gitSettings)); + .subscribe((gitInstance) => this._gitInstances.next(gitInstance)); } transformGitInstance( @@ -52,7 +52,7 @@ export class GitInstancesService { loadGitInstanceById(id: number): void { this.http .get(this.BACKEND_URL_PREFIX + '/' + id) - .subscribe((gitSetting) => this._gitInstance.next(gitSetting)); + .subscribe((gitInstance) => this._gitInstance.next(gitInstance)); } createGitInstance(gitInstance: BasicGitInstance): Observable { diff --git a/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.component.ts b/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.component.ts index 52ffeaf7e4..7eb35115a2 100644 --- a/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.component.ts +++ b/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.component.ts @@ -6,14 +6,8 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { - BehaviorSubject, - filter, - map, - Subscription, - switchMap, - tap, -} from 'rxjs'; +import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { BehaviorSubject, filter, map, switchMap, tap } from 'rxjs'; import { BreadcrumbsService } from 'src/app/general/breadcrumbs/breadcrumbs.service'; import { ToastService } from 'src/app/helpers/toast/toast.service'; import { @@ -28,6 +22,7 @@ import { ToolVersion, } from 'src/app/settings/core/tools-settings/tool.service'; +@UntilDestroy() @Component({ selector: 'app-edit-t4c-instance', templateUrl: './edit-t4c-instance.component.html', @@ -35,7 +30,6 @@ import { }) export class EditT4CInstanceComponent implements OnInit, OnDestroy { editing: boolean = false; - paramsSubscription?: Subscription; existing: boolean = false; @@ -89,7 +83,7 @@ export class EditT4CInstanceComponent implements OnInit, OnDestroy { ) {} ngOnInit(): void { - this.paramsSubscription = this.route.params + this.route.params .pipe( map((params) => params.instance), filter(Boolean), @@ -97,7 +91,8 @@ export class EditT4CInstanceComponent implements OnInit, OnDestroy { this.existing = true; this.form.disable(); }), - switchMap((instance) => this.t4cInstanceService.getInstance(instance)) + switchMap((instance) => this.t4cInstanceService.getInstance(instance)), + untilDestroyed(this) ) .subscribe(this._instance); @@ -172,7 +167,6 @@ export class EditT4CInstanceComponent implements OnInit, OnDestroy { } ngOnDestroy(): void { - this.paramsSubscription?.unsubscribe(); this._instance.next(undefined); this.breadcrumbsService.updatePlaceholder({ t4cInstance: undefined }); }