From 38fe109cf49631167b7d4f3ec349ddf6c2b43c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Greffier?= Date: Sat, 9 Dec 2023 21:11:33 +0100 Subject: [PATCH 01/12] Improve widget parameter encryption documentation --- README.md | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7ba04147a..f9be94afb 100644 --- a/README.md +++ b/README.md @@ -23,14 +23,16 @@ This repository contains the source code of the Suricate application. * [Default Configuration](#default-configuration) * [Database](#database) * [Authentication](#authentication) - * [LDAP vs Database](#ldap-vs-database) - * [Social Login](#social-login) - * [GitHub](#github) - * [GitLab](#gitlab) - * [Redirection to Front-End](#redirection-to-front-end) - * [Name Parsing Strategy](#name-parsing-strategy) - * [Personal Access Token](#personal-access-token) - * [Repositories](#repositories) + * [LDAP vs Database](#ldap-vs-database) + * [Social Login](#social-login) + * [GitHub](#github) + * [GitLab](#gitlab) + * [Redirection to Front-End](#redirection-to-front-end) + * [Name Parsing Strategy](#name-parsing-strategy) + * [Personal Access Token](#personal-access-token) + * [Widgets](#widgets) + * [Encryption](#encryption) + * [Repositories](#repositories) * [Swagger UI](#swagger-ui) * [Contribution](#contribution) @@ -118,7 +120,7 @@ application.authentication.jwt.signingKey: 'changeitchangeitchangeitchangeit' application.authentication.jwt.tokenValidityMs: 86400000 ``` -The signing key should be at least 256 bits long and should be changed for each environment. +The signing key should be at least 256 bits long (since Suricate v2.8.0) and should be changed for each environment. #### Database @@ -130,12 +132,6 @@ You can choose this authentication mode using the following YAML property: application.authentication.provider: 'database' ``` -If you choose the database authentication mode, you must change the encryption password: - -```yaml -jasypt.encryptor.password: 'changeitchangeitchangeitchangeit' -``` - #### LDAP You can log in to Suricate an LDAP. @@ -256,7 +252,20 @@ It is recommended to update the _checksumSecret_ with a different secret for eac The _prefix_ is used by the application to identify the token type and parse it. -### Repositories +### Widgets + +Here is given the guidelines to configure the widgets. + +#### Encryption + +Sensitive widget parameters such as passwords or tokens are encrypted in the database. +You must change the encryption key for each environment using the following property: + +```yaml +jasypt.encryptor.password: changeitchangeitchangeitchangeit +``` + +#### Repositories The first time you start the application, you'll need to configure a repository of widgets. To do this, navigate to the repositories tab and add a new repository. You can choose to add either a local or remote repository (such as GitLab or From b883d82cd4b376f7c08164b8edc7495f095e07ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Greffier?= Date: Sun, 10 Dec 2023 18:06:41 +0100 Subject: [PATCH 02/12] Fix typos --- .../suricate/model/dto/api/error/ApiErrorDto.java | 8 +++++++- .../michelin/suricate/services/js/script/JsEndpoints.java | 4 +++- .../michelin/suricate/utils/exceptions/ApiException.java | 2 +- .../michelin/suricate/utils/http/OkHttpClientUtils.java | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/michelin/suricate/model/dto/api/error/ApiErrorDto.java b/src/main/java/com/michelin/suricate/model/dto/api/error/ApiErrorDto.java index 6b1647b5e..288a00d8c 100644 --- a/src/main/java/com/michelin/suricate/model/dto/api/error/ApiErrorDto.java +++ b/src/main/java/com/michelin/suricate/model/dto/api/error/ApiErrorDto.java @@ -27,7 +27,7 @@ import org.apache.commons.lang3.StringUtils; /** - * Api error dto. + * Api error DTO. */ @Data @NoArgsConstructor @@ -59,6 +59,12 @@ public ApiErrorDto(ApiErrorEnum apiErrorEnum) { this.status = apiErrorEnum.getStatus().value(); } + /** + * Constructor. + * + * @param message The error message + * @param apiError The API error enum + */ public ApiErrorDto(String message, ApiErrorEnum apiError) { this(apiError); this.message = StringUtils.isBlank(message) ? apiError.getMessage() : message; diff --git a/src/main/java/com/michelin/suricate/services/js/script/JsEndpoints.java b/src/main/java/com/michelin/suricate/services/js/script/JsEndpoints.java index b0ea696af..068149269 100644 --- a/src/main/java/com/michelin/suricate/services/js/script/JsEndpoints.java +++ b/src/main/java/com/michelin/suricate/services/js/script/JsEndpoints.java @@ -16,6 +16,8 @@ package com.michelin.suricate.services.js.script; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + import com.michelin.suricate.utils.exceptions.js.FatalException; import com.michelin.suricate.utils.exceptions.js.RemoteException; import com.michelin.suricate.utils.exceptions.js.RequestException; @@ -63,7 +65,7 @@ private static String executeRequest(String url, String headerName, String heade if (StringUtils.isNotBlank(body)) { builder.post( - RequestBody.create(body, MediaType.parse(org.springframework.http.MediaType.APPLICATION_JSON_VALUE))); + RequestBody.create(body, MediaType.parse(APPLICATION_JSON_VALUE))); } Request request = builder.build(); diff --git a/src/main/java/com/michelin/suricate/utils/exceptions/ApiException.java b/src/main/java/com/michelin/suricate/utils/exceptions/ApiException.java index e72531c1b..a76c56162 100644 --- a/src/main/java/com/michelin/suricate/utils/exceptions/ApiException.java +++ b/src/main/java/com/michelin/suricate/utils/exceptions/ApiException.java @@ -52,7 +52,7 @@ public ApiException(String message, ApiErrorEnum error) { /** * Method used to retrieve the error. * - * @return the APi error + * @return the API error */ public ApiErrorDto getError() { return error.toResponse(getMessage()); diff --git a/src/main/java/com/michelin/suricate/utils/http/OkHttpClientUtils.java b/src/main/java/com/michelin/suricate/utils/http/OkHttpClientUtils.java index cefc9575f..1584be6b5 100644 --- a/src/main/java/com/michelin/suricate/utils/http/OkHttpClientUtils.java +++ b/src/main/java/com/michelin/suricate/utils/http/OkHttpClientUtils.java @@ -82,7 +82,7 @@ public static OkHttpClient getUnsafeOkHttpClient() { } catch (NoSuchAlgorithmException e) { log.error("An error occurred during the OKHttpClient configuration: TLS algorithm not found", e); } catch (KeyManagementException e) { - log.error("An error occurred during the OKHttpClient configuration: Cannot init the SSL context", e); + log.error("An error occurred during the OKHttpClient configuration: Cannot init the TLS context", e); } return null; From 6b2d5923ced38df85e1b665802e114547a63d9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Greffier?= Date: Sun, 10 Dec 2023 18:23:56 +0100 Subject: [PATCH 03/12] Fix typo in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9be94afb..e9a45a804 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![Docker Pulls](https://img.shields.io/docker/pulls/michelin/suricate?label=Pulls&logo=docker&style=for-the-badge)](https://hub.docker.com/r/michelin/suricate/tags) [![Docker Stars](https://img.shields.io/docker/stars/michelin/suricate?label=Stars&logo=docker&style=for-the-badge)](https://hub.docker.com/r/michelin/suricate) [![SonarCloud Coverage](https://img.shields.io/sonar/coverage/michelin_suricate?logo=sonarcloud&server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge)](https://sonarcloud.io/component_measures?id=michelin_suricate&metric=coverage&view=list) -[![SonarCloud Tests](https://img.shields.io/sonar/tests/michelin_suricate/master?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarcloud)](https://sonarcloud.io/component_measures?metric=tests&view=list&id=michelin_kstreamplify) +[![SonarCloud Tests](https://img.shields.io/sonar/tests/michelin_suricate/master?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarcloud)](https://sonarcloud.io/component_measures?metric=tests&view=list&id=michelin_suricate) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=apache&style=for-the-badge)](https://opensource.org/licenses/Apache-2.0) This repository contains the source code of the Suricate application. @@ -70,7 +70,7 @@ default properties: docker-compose up -d ``` -Both Front-End and Back-End will be served on port 8080 by default. +After running the command, the application will be accessible on http://localhost:8080/. ## Configuration From 1586c70fc309565aca5e8a8777943780f79de684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Greffier?= Date: Sun, 10 Dec 2023 20:47:39 +0100 Subject: [PATCH 04/12] Replace injector with inject --- .../configurations.component.ts | 8 +++---- .../admin/dashboards/dashboards.component.ts | 8 +++---- .../repositories/repositories.component.ts | 8 +++---- .../webapp/app/admin/users/users.component.ts | 6 ++--- .../add-widget-to-project-wizard.component.ts | 20 ++++++++++------- .../inputs/checkbox/checkbox.component.ts | 8 +++---- .../color-picker/color-picker.component.ts | 8 +++---- .../inputs/fields/fields.component.ts | 8 +++---- .../inputs/file-input/file-input.component.ts | 8 +++---- .../inputs/input/input.component.ts | 10 ++++----- .../inputs/mosaic/mosaic.component.ts | 9 ++++---- .../shared/components/list/list.component.ts | 19 ++++++++-------- .../components/wizard/wizard.component.ts | 22 ++++++++++--------- .../app/widget/catalog/catalog.component.ts | 7 +++--- 14 files changed, 67 insertions(+), 82 deletions(-) diff --git a/src/main/webapp/app/admin/configurations/configurations.component.ts b/src/main/webapp/app/admin/configurations/configurations.component.ts index 687936372..34913f234 100644 --- a/src/main/webapp/app/admin/configurations/configurations.component.ts +++ b/src/main/webapp/app/admin/configurations/configurations.component.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Component, Injector } from '@angular/core'; +import { Component } from '@angular/core'; import { ListComponent } from '../../shared/components/list/list.component'; import { IconEnum } from '../../shared/enums/icon.enum'; import { ToastTypeEnum } from '../../shared/enums/toast-type.enum'; @@ -40,14 +40,12 @@ export class ConfigurationsComponent extends ListComponent { * * @param httpCategoryParametersService Suricate service used to manage http calls for category parameters * @param widgetConfigurationFormFieldsService Frontend service used to build form fields for project configuration - * @param injector Angular Service used to manage the injection of services */ constructor( private readonly httpCategoryParametersService: HttpCategoryParametersService, - private readonly widgetConfigurationFormFieldsService: WidgetConfigurationFormFieldsService, - protected injector: Injector + private readonly widgetConfigurationFormFieldsService: WidgetConfigurationFormFieldsService ) { - super(httpCategoryParametersService, injector); + super(httpCategoryParametersService); this.initHeaderConfiguration(); this.initListConfiguration(); diff --git a/src/main/webapp/app/admin/dashboards/dashboards.component.ts b/src/main/webapp/app/admin/dashboards/dashboards.component.ts index 14fcc90e6..e042c26a7 100644 --- a/src/main/webapp/app/admin/dashboards/dashboards.component.ts +++ b/src/main/webapp/app/admin/dashboards/dashboards.component.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Component, Injector } from '@angular/core'; +import { Component } from '@angular/core'; import { ListComponent } from '../../shared/components/list/list.component'; import { IconEnum } from '../../shared/enums/icon.enum'; import { Project } from '../../shared/models/backend/project/project'; @@ -49,15 +49,13 @@ export class DashboardsComponent extends ListComponent * @param httpProjectService Manage the http calls for a project * @param projectFormFieldsService Build form fields for a project * @param projectUsersFormFieldsService Build form fields for projects users - * @param injector Manage the injection of services */ constructor( private readonly httpProjectService: HttpProjectService, private readonly projectFormFieldsService: ProjectFormFieldsService, - private readonly projectUsersFormFieldsService: ProjectUsersFormFieldsService, - protected injector: Injector + private readonly projectUsersFormFieldsService: ProjectUsersFormFieldsService ) { - super(httpProjectService, injector); + super(httpProjectService); this.initHeaderConfiguration(); this.initListConfiguration(); diff --git a/src/main/webapp/app/admin/repositories/repositories.component.ts b/src/main/webapp/app/admin/repositories/repositories.component.ts index eea2e4d56..7921c4394 100644 --- a/src/main/webapp/app/admin/repositories/repositories.component.ts +++ b/src/main/webapp/app/admin/repositories/repositories.component.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Component, Injector } from '@angular/core'; +import { Component } from '@angular/core'; import { ListComponent } from '../../shared/components/list/list.component'; import { IconEnum } from '../../shared/enums/icon.enum'; import { Repository } from '../../shared/models/backend/repository/repository'; @@ -55,15 +55,13 @@ export class RepositoriesComponent extends ListComponent { * @param httpRepositoryService The HTTP repository service * @param repositoryFormFieldsService The repository form fields service * @param datePipe The date pipe - * @param injector The injector */ constructor( private readonly httpRepositoryService: HttpRepositoryService, private readonly repositoryFormFieldsService: RepositoryFormFieldsService, - private readonly datePipe: DatePipe, - protected injector: Injector + private readonly datePipe: DatePipe ) { - super(httpRepositoryService, injector); + super(httpRepositoryService); this.initListConfiguration(); this.initFilter(); } diff --git a/src/main/webapp/app/admin/users/users.component.ts b/src/main/webapp/app/admin/users/users.component.ts index 8ccd85b48..f215ba585 100644 --- a/src/main/webapp/app/admin/users/users.component.ts +++ b/src/main/webapp/app/admin/users/users.component.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Component, Injector, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ListComponent } from '../../shared/components/list/list.component'; import { User } from '../../shared/models/backend/user/user'; import { Role } from '../../shared/models/backend/role/role'; @@ -45,14 +45,12 @@ export class UsersComponent extends ListComponent implements OnInit { * * @param httpAdminUserService Manage the http calls for users as admin * @param userFormFieldsService Build the form fields for a user - * @param injector Manage the injection of services */ constructor( private readonly httpAdminUserService: HttpAdminUserService, private readonly userFormFieldsService: UserFormFieldsService, - protected injector: Injector ) { - super(httpAdminUserService, injector); + super(httpAdminUserService); this.initHeaderConfiguration(); this.initListConfiguration(); diff --git a/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts b/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts index 161f0dc2e..37946797f 100644 --- a/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts +++ b/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts @@ -14,14 +14,18 @@ * limitations under the License. */ -import { Component, Injector, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { WizardComponent } from '../../../../shared/components/wizard/wizard.component'; -import { ProjectWidgetFormStepsService } from '../../../../shared/services/frontend/form-steps/project-widget-form-steps/project-widget-form-steps.service'; +import { + ProjectWidgetFormStepsService +} from '../../../../shared/services/frontend/form-steps/project-widget-form-steps/project-widget-form-steps.service'; import { FormStep } from '../../../../shared/models/frontend/form/form-step'; import { ProjectWidgetRequest } from '../../../../shared/models/backend/project-widget/project-widget-request'; import { ToastService } from '../../../../shared/services/frontend/toast/toast.service'; import { ToastTypeEnum } from '../../../../shared/enums/toast-type.enum'; -import { HttpProjectWidgetService } from '../../../../shared/services/backend/http-project-widget/http-project-widget.service'; +import { + HttpProjectWidgetService +} from '../../../../shared/services/backend/http-project-widget/http-project-widget.service'; import { ProjectWidget } from '../../../../shared/models/backend/project-widget/project-widget'; import { HttpProjectService } from '../../../../shared/services/backend/http-project/http-project.service'; import { Project } from '../../../../shared/models/backend/project/project'; @@ -33,18 +37,18 @@ import { Project } from '../../../../shared/models/backend/project/project'; export class AddWidgetToProjectWizardComponent extends WizardComponent implements OnInit { /** * Constructor - * @param injector Angular Service used to manage the injection of services - * @param projectWidgetFormStepsService Frontend service used to build steps for project widget object - * @param toastService Frontend service used to display message + * @param projectWidgetFormStepsService The project widget form steps service + * @param httpProjectWidgetsService The http project widget service + * @param httpProjectService The http project service + * @param toastService The toast service */ constructor( - protected injector: Injector, private readonly projectWidgetFormStepsService: ProjectWidgetFormStepsService, private readonly httpProjectWidgetsService: HttpProjectWidgetService, private readonly httpProjectService: HttpProjectService, private readonly toastService: ToastService ) { - super(injector); + super(); this.initHeaderConfiguration(); } diff --git a/src/main/webapp/app/shared/components/inputs/checkbox/checkbox.component.ts b/src/main/webapp/app/shared/components/inputs/checkbox/checkbox.component.ts index aecfa2012..6b217621a 100644 --- a/src/main/webapp/app/shared/components/inputs/checkbox/checkbox.component.ts +++ b/src/main/webapp/app/shared/components/inputs/checkbox/checkbox.component.ts @@ -16,7 +16,7 @@ * */ -import { Component, Injector } from '@angular/core'; +import { Component } from '@angular/core'; import { InputComponent } from '../input/input.component'; /** @@ -30,11 +30,9 @@ import { InputComponent } from '../input/input.component'; export class CheckboxComponent extends InputComponent { /** * Constructor - * - * @param injector Manage services injection */ - constructor(protected injector: Injector) { - super(injector); + constructor() { + super(); } /** diff --git a/src/main/webapp/app/shared/components/inputs/color-picker/color-picker.component.ts b/src/main/webapp/app/shared/components/inputs/color-picker/color-picker.component.ts index 4136d6891..6a8abbdcc 100644 --- a/src/main/webapp/app/shared/components/inputs/color-picker/color-picker.component.ts +++ b/src/main/webapp/app/shared/components/inputs/color-picker/color-picker.component.ts @@ -16,7 +16,7 @@ * */ -import { Component, Injector } from '@angular/core'; +import { Component } from '@angular/core'; import { InputComponent } from '../input/input.component'; /** @@ -30,11 +30,9 @@ import { InputComponent } from '../input/input.component'; export class ColorPickerComponent extends InputComponent { /** * Constructor - * - * @param injector Manage services injection */ - constructor(protected injector: Injector) { - super(injector); + constructor() { + super(); } /** diff --git a/src/main/webapp/app/shared/components/inputs/fields/fields.component.ts b/src/main/webapp/app/shared/components/inputs/fields/fields.component.ts index 26f21205e..16bcf2e10 100644 --- a/src/main/webapp/app/shared/components/inputs/fields/fields.component.ts +++ b/src/main/webapp/app/shared/components/inputs/fields/fields.component.ts @@ -16,7 +16,7 @@ * */ -import { Component, Injector, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { InputComponent } from '../input/input.component'; import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; import { DataTypeEnum } from '../../../enums/data-type.enum'; @@ -39,11 +39,9 @@ export class FieldsComponent extends InputComponent implements OnInit{ /** * Constructor - * - * @param injector Manage services injection */ - constructor(protected injector: Injector) { - super(injector); + constructor() { + super(); } /** diff --git a/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.ts b/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.ts index 2cd9595ca..8efd4cd36 100644 --- a/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.ts +++ b/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.ts @@ -16,7 +16,7 @@ * */ -import { Component, Injector, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { InputComponent } from '../input/input.component'; import { animate, style, transition, trigger } from '@angular/animations'; import { FileUtils } from '../../../utils/file.utils'; @@ -51,11 +51,9 @@ export class FileInputComponent extends InputComponent implements OnInit { /** * Constructor - * - * @param injector Manage services injection */ - constructor(protected injector: Injector) { - super(injector); + constructor() { + super(); } /** diff --git a/src/main/webapp/app/shared/components/inputs/input/input.component.ts b/src/main/webapp/app/shared/components/inputs/input/input.component.ts index 589f6328b..9be24a82d 100644 --- a/src/main/webapp/app/shared/components/inputs/input/input.component.ts +++ b/src/main/webapp/app/shared/components/inputs/input/input.component.ts @@ -16,8 +16,8 @@ * */ -import { Component, EventEmitter, Injector, Input, OnInit, Output, ViewEncapsulation } from '@angular/core'; -import { AbstractControl, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms'; +import { Component, EventEmitter, inject, Input, OnInit, Output, ViewEncapsulation } from '@angular/core'; +import { AbstractControl, UntypedFormGroup, Validators } from '@angular/forms'; import { animate, style, transition, trigger } from '@angular/animations'; import { DataTypeEnum } from '../../../enums/data-type.enum'; @@ -103,11 +103,9 @@ export class InputComponent implements OnInit { /** * Constructor - * - * @param injector Manage services injection */ - constructor(protected injector: Injector) { - this.translateService = injector.get(TranslateService); + constructor() { + this.translateService = inject(TranslateService); } /** diff --git a/src/main/webapp/app/shared/components/inputs/mosaic/mosaic.component.ts b/src/main/webapp/app/shared/components/inputs/mosaic/mosaic.component.ts index 5ef0c1270..eaaa52653 100644 --- a/src/main/webapp/app/shared/components/inputs/mosaic/mosaic.component.ts +++ b/src/main/webapp/app/shared/components/inputs/mosaic/mosaic.component.ts @@ -16,7 +16,7 @@ * */ -import { Component, Injector, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { InputComponent } from '../input/input.component'; import { MosaicFormOption } from '../../../models/frontend/form/mosaic-form-option'; @@ -41,12 +41,11 @@ export class MosaicComponent extends InputComponent implements OnInit { /** * Constructor - * - * @param injector Manage services injection */ - constructor(protected injector: Injector) { - super(injector); + constructor() { + super(); } + /** * Called when the component is init */ diff --git a/src/main/webapp/app/shared/components/list/list.component.ts b/src/main/webapp/app/shared/components/list/list.component.ts index d71af0902..3f84a0882 100644 --- a/src/main/webapp/app/shared/components/list/list.component.ts +++ b/src/main/webapp/app/shared/components/list/list.component.ts @@ -16,7 +16,7 @@ * */ -import { Component, Injector, OnDestroy, OnInit } from '@angular/core'; +import { Component, inject, OnDestroy, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { ListConfiguration } from '../../models/frontend/list/list-configuration'; @@ -146,15 +146,14 @@ export class ListComponent implements OnInit, OnDestroy { * Constructor * * @param childService The child http service - * @param injector Manage services injection - */ - constructor(private readonly childService: AbstractHttpService, protected injector: Injector) { - this.dialogService = injector.get(DialogService); - this.sidenavService = injector.get(SidenavService); - this.translateService = injector.get(TranslateService); - this.toastService = injector.get(ToastService); - this.router = injector.get(Router); - this.formService = injector.get(FormService); + */ + constructor(private readonly childService: AbstractHttpService) { + this.dialogService = inject(DialogService); + this.sidenavService = inject(SidenavService); + this.translateService = inject(TranslateService); + this.toastService = inject(ToastService); + this.router = inject(Router); + this.formService = inject(FormService); } /** diff --git a/src/main/webapp/app/shared/components/wizard/wizard.component.ts b/src/main/webapp/app/shared/components/wizard/wizard.component.ts index 39d5de51e..537da3743 100644 --- a/src/main/webapp/app/shared/components/wizard/wizard.component.ts +++ b/src/main/webapp/app/shared/components/wizard/wizard.component.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Component, Injector, OnInit, ViewChild } from '@angular/core'; +import { Component, inject, OnInit, ViewChild } from '@angular/core'; import { HeaderConfiguration } from '../../models/frontend/header/header-configuration'; import { UntypedFormGroup } from '@angular/forms'; import { WizardConfiguration } from '../../models/frontend/wizard/wizard-configuration'; @@ -27,9 +27,13 @@ import { ActivatedRoute, Router } from '@angular/router'; import { StepperSelectionEvent } from '@angular/cdk/stepper'; import { ValueChangedEvent } from '../../models/frontend/form/value-changed-event'; import { FormField } from '../../models/frontend/form/form-field'; -import { WidgetConfigurationFormFieldsService } from '../../services/frontend/form-fields/widget-configuration-form-fields/widget-configuration-form-fields.service'; +import { + WidgetConfigurationFormFieldsService +} from '../../services/frontend/form-fields/widget-configuration-form-fields/widget-configuration-form-fields.service'; import { MatSlideToggleChange } from '@angular/material/slide-toggle'; -import { ProjectWidgetFormStepsService } from '../../services/frontend/form-steps/project-widget-form-steps/project-widget-form-steps.service'; +import { + ProjectWidgetFormStepsService +} from '../../services/frontend/form-steps/project-widget-form-steps/project-widget-form-steps.service'; /** * Generic component used to display wizards @@ -107,14 +111,12 @@ export class WizardComponent implements OnInit { /** * Constructor - * - * @param injector Angular service used to manage injection of service */ - constructor(protected readonly injector: Injector) { - this.formService = injector.get(FormService); - this.widgetConfigurationFormFieldsService = injector.get(WidgetConfigurationFormFieldsService); - this.activatedRoute = injector.get(ActivatedRoute); - this.router = injector.get(Router); + constructor() { + this.formService = inject(FormService); + this.widgetConfigurationFormFieldsService = inject(WidgetConfigurationFormFieldsService); + this.activatedRoute = inject(ActivatedRoute); + this.router = inject(Router); } /** diff --git a/src/main/webapp/app/widget/catalog/catalog.component.ts b/src/main/webapp/app/widget/catalog/catalog.component.ts index dbc3dbcac..f392f4bc2 100644 --- a/src/main/webapp/app/widget/catalog/catalog.component.ts +++ b/src/main/webapp/app/widget/catalog/catalog.component.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Component, Injector } from '@angular/core'; +import { Component } from '@angular/core'; import { ListComponent } from '../../shared/components/list/list.component'; import { Widget } from '../../shared/models/backend/widget/widget'; import { WidgetRequest } from '../../shared/models/backend/widget/widget-request'; @@ -33,10 +33,9 @@ export class CatalogComponent extends ListComponent { * Constructor * * @param httpWidgetService Suricate service used to manage the http calls for widgets - * @param injector Angular Service used to manage the injection of services */ - constructor(private readonly httpWidgetService: HttpWidgetService, protected injector: Injector) { - super(httpWidgetService, injector); + constructor(private readonly httpWidgetService: HttpWidgetService) { + super(httpWidgetService); this.initHeaderConfiguration(); this.initFilter(); From 130f5b855eec9886e11f813c565de05634a3473d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Greffier?= Date: Sun, 17 Dec 2023 03:16:20 +0100 Subject: [PATCH 05/12] Improve tsconfig --- package.json | 4 +- .../configurations.component.ts | 11 +++-- .../admin/dashboards/dashboards.component.ts | 8 ++-- .../repositories/repositories.component.ts | 12 ++--- .../webapp/app/admin/users/users.component.ts | 10 ++-- .../security-settings.component.ts | 2 +- .../dashboard-screen.component.ts | 16 +++---- .../add-widget-to-project-wizard.component.ts | 6 +-- .../communication-dialog.component.scss | 18 +++---- .../inputs/fields/fields.component.ts | 2 +- .../inputs/file-input/file-input.component.ts | 2 +- .../inputs/input/input.component.ts | 18 +++---- .../inputs/mosaic/mosaic.component.ts | 2 +- .../slide-toggle/slide-toggle.component.ts | 2 +- .../shared/components/list/list.component.ts | 20 ++++---- .../hide-after-init.directive.ts | 2 +- .../widget-html/widget-html.directive.ts | 2 +- .../app/shared/models/backend/http-filter.ts | 2 + .../project-grid/project-grid-request.ts | 1 + .../models/backend/repository/repository.ts | 47 +------------------ .../shared/models/frontend/form/form-field.ts | 4 +- .../sidenav/form-sidenav-configuration.ts | 2 +- .../abstract-http/abstract-http.service.ts | 13 +++-- .../http-admin-user.service.ts | 2 +- .../http-category-parameters.service.ts | 4 +- .../http-filter/http-filter.service.ts | 2 +- .../http-project/http-project.service.ts | 2 +- .../http-repository.service.ts | 3 +- .../backend/http-user/http-user.service.ts | 12 +++-- .../http-widget/http-widget.service.ts | 5 +- .../services/frontend/css/css.service.ts | 28 ++++------- ...idget-configuration-form-fields.service.ts | 2 +- .../project-widget-form-steps.service.ts | 2 +- .../services/frontend/form/form.service.ts | 13 +++-- .../frontend/websocket/websocket.service.ts | 2 +- .../app/shared/validators/custom-validator.ts | 7 ++- .../app/widget/catalog/catalog.component.ts | 10 ++-- src/main/webapp/assets/i18n/en.json | 2 +- src/main/webapp/assets/i18n/fr.json | 2 +- src/main/webapp/sass/_global-styles.scss | 2 +- .../_mat-communication-dialog-theme.scss | 26 ++++++++++ .../webapp/sass/themes/_suricate-theme.scss | 4 +- src/main/webapp/tsconfig.app.json | 2 +- src/main/webapp/tsconfig.json | 31 ------------ tsconfig.json | 27 ++++++++--- 45 files changed, 180 insertions(+), 216 deletions(-) create mode 100644 src/main/webapp/sass/components/_mat-communication-dialog-theme.scss delete mode 100644 src/main/webapp/tsconfig.json diff --git a/package.json b/package.json index 0827bd7ac..f1d8081c3 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,9 @@ "@angular/language-service": "^17.0.5", "@types/jasmine": "~5.1.4", "@types/jasminewd2": "~2.0.13", + "@types/jotform-css.js": "^1.0.4", "@types/node": "^20.10.2", + "@types/sockjs-client": "^1.5.4", "@typescript-eslint/eslint-plugin": "^6.13.1", "@typescript-eslint/parser": "^6.13.1", "eslint": "^8.55.0", @@ -75,4 +77,4 @@ "ts-node": "~10.9.1", "typescript": "~5.2.2" } -} \ No newline at end of file +} diff --git a/src/main/webapp/app/admin/configurations/configurations.component.ts b/src/main/webapp/app/admin/configurations/configurations.component.ts index 34913f234..39fad130b 100644 --- a/src/main/webapp/app/admin/configurations/configurations.component.ts +++ b/src/main/webapp/app/admin/configurations/configurations.component.ts @@ -26,6 +26,9 @@ import { } from '../../shared/services/backend/http-category-parameters/http-category-parameters.service'; import { CategoryParameter } from '../../shared/models/backend/category-parameters/category-parameter'; import { DataTypeEnum } from '../../shared/enums/data-type.enum'; +import { + WidgetConfigurationRequest +} from '../../shared/models/backend/widget-configuration/widget-configuration-request'; /** * Component used to display the list of widgets @@ -34,7 +37,7 @@ import { DataTypeEnum } from '../../shared/enums/data-type.enum'; templateUrl: '../../shared/components/list/list.component.html', styleUrls: ['../../shared/components/list/list.component.scss'] }) -export class ConfigurationsComponent extends ListComponent { +export class ConfigurationsComponent extends ListComponent { /** * Constructor * @@ -55,14 +58,14 @@ export class ConfigurationsComponent extends ListComponent { /** * {@inheritDoc} */ - protected getFirstLabel(configuration: CategoryParameter): string { + protected override getFirstLabel(configuration: CategoryParameter): string { return configuration.description; } /** * {@inheritDoc} */ - protected getSecondLabel(configuration: CategoryParameter): string { + protected override getSecondLabel(configuration: CategoryParameter): string { return configuration.value && configuration.dataType === DataTypeEnum.PASSWORD && !configuration.showValue ? '•'.repeat(configuration.value.length) : configuration.value; @@ -71,7 +74,7 @@ export class ConfigurationsComponent extends ListComponent { /** * {@inheritDoc} */ - protected getThirdLabel(configuration: CategoryParameter): string { + protected override getThirdLabel(configuration: CategoryParameter): string { return configuration.category.name; } diff --git a/src/main/webapp/app/admin/dashboards/dashboards.component.ts b/src/main/webapp/app/admin/dashboards/dashboards.component.ts index e042c26a7..d2054c10d 100644 --- a/src/main/webapp/app/admin/dashboards/dashboards.component.ts +++ b/src/main/webapp/app/admin/dashboards/dashboards.component.ts @@ -37,7 +37,7 @@ import { CssService } from '../../shared/services/frontend/css/css.service'; templateUrl: '../../shared/components/list/list.component.html', styleUrls: ['../../shared/components/list/list.component.scss'] }) -export class DashboardsComponent extends ListComponent { +export class DashboardsComponent extends ListComponent { /** * Project selected in the list for modifications */ @@ -75,21 +75,21 @@ export class DashboardsComponent extends ListComponent /** * {@inheritDoc} */ - protected getFirstLabel(project: Project): string { + protected override getFirstLabel(project: Project): string { return project.name; } /** * {@inheritDoc} */ - protected getSecondLabel(project: Project): string { + protected override getSecondLabel(project: Project): string { return project.token; } /** * {@inheritDoc} */ - public redirectToBean(project: Project): void { + public override redirectToBean(project: Project): void { this.router.navigate(['/dashboards', project.token, project.grids[0].id]); } diff --git a/src/main/webapp/app/admin/repositories/repositories.component.ts b/src/main/webapp/app/admin/repositories/repositories.component.ts index 7921c4394..443c68b08 100644 --- a/src/main/webapp/app/admin/repositories/repositories.component.ts +++ b/src/main/webapp/app/admin/repositories/repositories.component.ts @@ -38,7 +38,7 @@ import { DatePipe } from '@angular/common'; templateUrl: '../../shared/components/list/list.component.html', styleUrls: ['../../shared/components/list/list.component.scss'] }) -export class RepositoriesComponent extends ListComponent { +export class RepositoriesComponent extends ListComponent { /** * The repository being built */ @@ -69,21 +69,21 @@ export class RepositoriesComponent extends ListComponent { /** * {@inheritDoc} */ - protected getFirstLabel(repository: Repository): string { + protected override getFirstLabel(repository: Repository): string { return repository.name; } /** * {@inheritDoc} */ - protected getSecondLabel(repository: Repository): string { + protected override getSecondLabel(repository: Repository): string { return repository.type === RepositoryTypeEnum.REMOTE ? repository.url : repository.localPath; } /** * {@inheritDoc} */ - protected getThirdLabel(repository: Repository): string { + protected override getThirdLabel(repository: Repository): string { return this.translateService.instant('repository.third.label', { type: repository.type, priority: repository.priority, @@ -148,7 +148,7 @@ export class RepositoriesComponent extends ListComponent { /** * {@inheritDoc} */ - protected onItemsLoaded() { + protected override onItemsLoaded() { this.initHeaderConfiguration(); this.dragAndDropDisabled = !this.objectsPaged.content || this.objectsPaged.content.length <= 1; } @@ -287,7 +287,7 @@ export class RepositoriesComponent extends ListComponent { /** * Update repositories priority when dropped and save them */ - public drop(): void { + public override drop(): void { this.objectsPaged.content.forEach(repository => { repository.priority = this.objectsPaged.content.indexOf(repository) + 1; }); diff --git a/src/main/webapp/app/admin/users/users.component.ts b/src/main/webapp/app/admin/users/users.component.ts index f215ba585..c4e3af28e 100644 --- a/src/main/webapp/app/admin/users/users.component.ts +++ b/src/main/webapp/app/admin/users/users.component.ts @@ -34,7 +34,7 @@ import { HttpAdminUserService } from '../../shared/services/backend/http-admin-u templateUrl: '../../shared/components/list/list.component.html', styleUrls: ['../../shared/components/list/list.component.scss'] }) -export class UsersComponent extends ListComponent implements OnInit { +export class UsersComponent extends ListComponent implements OnInit { /** * User selected in the list for modification */ @@ -60,7 +60,7 @@ export class UsersComponent extends ListComponent implements OnInit { /** * Called when the component is init */ - public ngOnInit(): void { + public override ngOnInit(): void { super.ngOnInit(); } @@ -105,21 +105,21 @@ export class UsersComponent extends ListComponent implements OnInit { /** * {@inheritDoc} */ - protected getFirstLabel(user: User): string { + protected override getFirstLabel(user: User): string { return `${user.firstname} ${user.lastname} (${user.username})`; } /** * {@inheritDoc} */ - protected getSecondLabel(user: User): string { + protected override getSecondLabel(user: User): string { return user.email; } /** * {@inheritDoc} */ - protected getThirdLabel(user: User): string { + protected override getThirdLabel(user: User): string { return user.roles.map((role: Role) => role.name).join(', '); } diff --git a/src/main/webapp/app/core/components/settings/security-settings/security-settings.component.ts b/src/main/webapp/app/core/components/settings/security-settings/security-settings.component.ts index e1d234318..b8ef2d5b4 100644 --- a/src/main/webapp/app/core/components/settings/security-settings/security-settings.component.ts +++ b/src/main/webapp/app/core/components/settings/security-settings/security-settings.component.ts @@ -57,7 +57,7 @@ export class SecuritySettingsComponent implements OnInit { /** * The revoke button */ - public revokeButton: ButtonConfiguration; + public revokeButton: ButtonConfiguration; /** * The created token diff --git a/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen.component.ts b/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen.component.ts index 062dc7b4b..49fcddf62 100644 --- a/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen.component.ts +++ b/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen.component.ts @@ -155,36 +155,36 @@ export class DashboardScreenComponent implements AfterViewInit, OnChanges, OnDes * @param changes The change event */ public ngOnChanges(changes: SimpleChanges): void { - if (changes.project) { - if (!changes.project.previousValue) { + if (changes['project']) { + if (!changes['project'].previousValue) { // Inject this variable in the window scope because some widgets use it to init the js (window as any).page_loaded = true; } - if (changes.project.currentValue) { + if (changes['project'].currentValue) { this.initGridStackOptions(); // Do not add libs in the DOM at first view init // Let the after view init method handle the first initialization - if (!changes.project.firstChange) { + if (!changes['project'].firstChange) { this.addExternalJSLibrariesToTheDOM(); } - if (!changes.project.previousValue) { + if (!changes['project'].previousValue) { this.initProjectWebsockets(); } else { - if (changes.project.previousValue.token !== changes.project.currentValue.token) { + if (changes['project'].previousValue.token !== changes['project'].currentValue.token) { this.resetProjectWebsockets(); } } } } - if (changes.readOnly) { + if (changes['readOnly']) { this.initGridStackOptions(); } - if (changes.projectWidgets) { + if (changes['projectWidgets']) { this.initGrid(); } } diff --git a/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts b/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts index 37946797f..d06dda8f0 100644 --- a/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts +++ b/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts @@ -55,7 +55,7 @@ export class AddWidgetToProjectWizardComponent extends WizardComponent implement /** * Called when the component is init */ - public ngOnInit(): void { + public override ngOnInit(): void { this.projectWidgetFormStepsService.generateGlobalSteps().subscribe((formSteps: FormStep[]) => { this.wizardConfiguration = { steps: formSteps }; @@ -75,14 +75,14 @@ export class AddWidgetToProjectWizardComponent extends WizardComponent implement /** * {@inheritDoc} */ - protected closeWizard(): void { + protected override closeWizard(): void { this.redirectToDashboard(); } /** * {@inheritDoc} */ - protected saveWizard(formData: FormData): void { + protected override saveWizard(formData: FormData): void { this.httpProjectService.getById(this.dashboardToken).subscribe((project: Project) => { this.httpProjectWidgetsService.getAllByProjectToken(this.dashboardToken).subscribe((widgets: ProjectWidget[]) => { let row = 1; diff --git a/src/main/webapp/app/shared/components/communication-dialog/communication-dialog.component.scss b/src/main/webapp/app/shared/components/communication-dialog/communication-dialog.component.scss index 562d8b8db..2ec91047b 100644 --- a/src/main/webapp/app/shared/components/communication-dialog/communication-dialog.component.scss +++ b/src/main/webapp/app/shared/components/communication-dialog/communication-dialog.component.scss @@ -15,31 +15,25 @@ * * limitations under the License. * */ -@use '@angular/material' as mat; .communication-dialog-wrapper { height: 100%; display: flex; flex-direction: column; - .mat-dialog-content { + .mat-mdc-dialog-content { & { - width: 94%; background-color: #cfd2da42; - margin: auto; - padding: 19px 20px; + margin: auto 24px; + padding: 20px; } &.spacer { flex-grow: 1; } } -} -@mixin communication-dialog-component-theme($theme) { - $warn: map-get($theme, warn); - - .communication-dialog-wrapper .mat-dialog-content.communication-dialog-error { - color: mat.get-color-from-palette($warn, 500); + .mat-mdc-dialog-actions { + padding: 14px 24px; } -} +} \ No newline at end of file diff --git a/src/main/webapp/app/shared/components/inputs/fields/fields.component.ts b/src/main/webapp/app/shared/components/inputs/fields/fields.component.ts index 16bcf2e10..6ff1780eb 100644 --- a/src/main/webapp/app/shared/components/inputs/fields/fields.component.ts +++ b/src/main/webapp/app/shared/components/inputs/fields/fields.component.ts @@ -47,7 +47,7 @@ export class FieldsComponent extends InputComponent implements OnInit{ /** * Called when the component is init */ - public ngOnInit(): void { + public override ngOnInit(): void { super.ngOnInit() if (this.field.deleteRow) { diff --git a/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.ts b/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.ts index 8efd4cd36..223ff7dd0 100644 --- a/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.ts +++ b/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.ts @@ -59,7 +59,7 @@ export class FileInputComponent extends InputComponent implements OnInit { /** * When the component is init */ - public ngOnInit(): void { + public override ngOnInit(): void { this.setBase64File(this.field.value); } diff --git a/src/main/webapp/app/shared/components/inputs/input/input.component.ts b/src/main/webapp/app/shared/components/inputs/input/input.component.ts index 9be24a82d..db453c39a 100644 --- a/src/main/webapp/app/shared/components/inputs/input/input.component.ts +++ b/src/main/webapp/app/shared/components/inputs/input/input.component.ts @@ -140,37 +140,39 @@ export class InputComponent implements OnInit { * Return the string code of the error to display it. */ public getInputErrors(): string { - if (this.getFormControl()['errors']?.required) { + if (this.getFormControl()['errors']?.['required']) { return 'field.error.required'; } - if (this.getFormControl()['errors']?.minlength) { + if (this.getFormControl()['errors']?.['minlength']) { return 'field.error.length'; } - if (this.getFormControl()['errors']?.email) { + if (this.getFormControl()['errors']?.['email']) { return 'field.error.email.format'; } - if (this.getFormControl()['errors']?.passwordMismatch) { + if (this.getFormControl()['errors']?.['passwordMismatch']) { return 'field.error.password.mismatch'; } - if (this.getFormControl()['errors']?.pattern) { + if (this.getFormControl()['errors']?.['pattern']) { return 'field.error.pattern'; } - if (this.getFormControl()['errors']?.digits) { + if (this.getFormControl()['errors']?.['digits']) { return 'field.error.digits'; } - if (this.getFormControl()['errors']?.gt0) { + if (this.getFormControl()['errors']?.['gt0']) { return 'field.error.gt0'; } - if (this.getFormControl()['errors']?.uniquePriority) { + if (this.getFormControl()['errors']?.['uniquePriority']) { return 'field.error.repository.unique.priority'; } + + return undefined; } /** diff --git a/src/main/webapp/app/shared/components/inputs/mosaic/mosaic.component.ts b/src/main/webapp/app/shared/components/inputs/mosaic/mosaic.component.ts index eaaa52653..6a7bed7a7 100644 --- a/src/main/webapp/app/shared/components/inputs/mosaic/mosaic.component.ts +++ b/src/main/webapp/app/shared/components/inputs/mosaic/mosaic.component.ts @@ -49,7 +49,7 @@ export class MosaicComponent extends InputComponent implements OnInit { /** * Called when the component is init */ - public ngOnInit(): void { + public override ngOnInit(): void { if (this.field.mosaicOptions) { this.field.mosaicOptions(this.formGroup).subscribe((mosaicOptions: MosaicFormOption[]) => { this.mosaicOptions = mosaicOptions; diff --git a/src/main/webapp/app/shared/components/inputs/slide-toggle/slide-toggle.component.ts b/src/main/webapp/app/shared/components/inputs/slide-toggle/slide-toggle.component.ts index a5b1b7ac4..24e628969 100644 --- a/src/main/webapp/app/shared/components/inputs/slide-toggle/slide-toggle.component.ts +++ b/src/main/webapp/app/shared/components/inputs/slide-toggle/slide-toggle.component.ts @@ -29,7 +29,7 @@ export class SlideToggleComponent { * The label of the slide toggle */ @Input() - public label: String; + public label: string; /** * Is the toggle button checked or not diff --git a/src/main/webapp/app/shared/components/list/list.component.ts b/src/main/webapp/app/shared/components/list/list.component.ts index 3f84a0882..66c65ce91 100644 --- a/src/main/webapp/app/shared/components/list/list.component.ts +++ b/src/main/webapp/app/shared/components/list/list.component.ts @@ -46,7 +46,7 @@ import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; template: '', styleUrls: ['./list.component.scss'] }) -export class ListComponent implements OnInit, OnDestroy { +export class ListComponent implements OnInit, OnDestroy { /** * Key for the research field */ @@ -100,7 +100,7 @@ export class ListComponent implements OnInit, OnDestroy { /** * The configuration of the list component */ - public listConfiguration = new ListConfiguration(); + public listConfiguration = new ListConfiguration(); /** * Is drag & drop disabled @@ -110,7 +110,7 @@ export class ListComponent implements OnInit, OnDestroy { /** * The object list to display */ - public objectsPaged: Page; + public objectsPaged: Page; /** * Display the loader when it's true, end hide when it's false @@ -147,7 +147,7 @@ export class ListComponent implements OnInit, OnDestroy { * * @param childService The child http service */ - constructor(private readonly childService: AbstractHttpService) { + constructor(private readonly childService: AbstractHttpService) { this.dialogService = inject(DialogService); this.sidenavService = inject(SidenavService); this.translateService = inject(TranslateService); @@ -193,7 +193,7 @@ export class ListComponent implements OnInit, OnDestroy { protected refreshList(): void { this.displayLoader(); - this.childService.getAll(this.httpFilter).subscribe((objectsPaged: Page) => { + this.childService.getAll(this.httpFilter).subscribe((objectsPaged: Page) => { this.objectsPaged = objectsPaged; this.hideLoader(); this.onItemsLoaded(); @@ -231,7 +231,7 @@ export class ListComponent implements OnInit, OnDestroy { * * @param object The object of the list */ - protected getFirstLabel(object: T): string { + protected getFirstLabel(object: TRet): string { return ''; } @@ -241,7 +241,7 @@ export class ListComponent implements OnInit, OnDestroy { * * @param object The object of the list */ - protected getSecondLabel(object: T): string { + protected getSecondLabel(object: TRet): string { return ''; } @@ -251,7 +251,7 @@ export class ListComponent implements OnInit, OnDestroy { * * @param object The object of the list */ - protected getThirdLabel(object: T): string { + protected getThirdLabel(object: TRet): string { return ''; } @@ -261,7 +261,7 @@ export class ListComponent implements OnInit, OnDestroy { * * @param object The object of the list */ - public getObjectImageURL(object: T): string { + public getObjectImageURL(object: TRet): string { return null; } @@ -271,7 +271,7 @@ export class ListComponent implements OnInit, OnDestroy { * * @param object The object used for the redirection */ - public redirectToBean(object: T): void {} + public redirectToBean(object: TRet): void {} /** * Perform actions after items have been loaded diff --git a/src/main/webapp/app/shared/directives/hide-after-init/hide-after-init.directive.ts b/src/main/webapp/app/shared/directives/hide-after-init/hide-after-init.directive.ts index c868eb83e..45efabfaf 100644 --- a/src/main/webapp/app/shared/directives/hide-after-init/hide-after-init.directive.ts +++ b/src/main/webapp/app/shared/directives/hide-after-init/hide-after-init.directive.ts @@ -28,7 +28,7 @@ export class HideAfterInitDirective implements OnChanges, AfterViewInit { * @param changes */ ngOnChanges(changes: SimpleChanges): void { - if (changes.hide.previousValue != undefined && changes.hide) { + if (changes['hide'].previousValue != undefined && changes['hide']) { this.elementRef.nativeElement.style.display = this.hide ? 'none' : 'block'; } } diff --git a/src/main/webapp/app/shared/directives/widget-html/widget-html.directive.ts b/src/main/webapp/app/shared/directives/widget-html/widget-html.directive.ts index 6f372b55e..a857a2331 100644 --- a/src/main/webapp/app/shared/directives/widget-html/widget-html.directive.ts +++ b/src/main/webapp/app/shared/directives/widget-html/widget-html.directive.ts @@ -26,7 +26,7 @@ export class WidgetHtmlDirective implements OnChanges { */ ngOnChanges(changes: SimpleChanges): void { // When the widget changes, reapply the JS scripts - if (changes.projectWidget) { + if (changes['projectWidget']) { this.reapplyJSScripts(); } } diff --git a/src/main/webapp/app/shared/models/backend/http-filter.ts b/src/main/webapp/app/shared/models/backend/http-filter.ts index 1829e5071..a7dbeaa97 100644 --- a/src/main/webapp/app/shared/models/backend/http-filter.ts +++ b/src/main/webapp/app/shared/models/backend/http-filter.ts @@ -20,6 +20,8 @@ * Class that represent a filter request */ export class HttpFilter { + [key: string]: any; + /** * Search value */ diff --git a/src/main/webapp/app/shared/models/backend/project-grid/project-grid-request.ts b/src/main/webapp/app/shared/models/backend/project-grid/project-grid-request.ts index 9aec3e160..2028c3dda 100644 --- a/src/main/webapp/app/shared/models/backend/project-grid/project-grid-request.ts +++ b/src/main/webapp/app/shared/models/backend/project-grid/project-grid-request.ts @@ -1,6 +1,7 @@ import { GridRequest } from './grid-request'; export class ProjectGridRequest { + [key: string]: any; displayProgressBar: boolean; grids: GridRequest[]; } diff --git a/src/main/webapp/app/shared/models/backend/repository/repository.ts b/src/main/webapp/app/shared/models/backend/repository/repository.ts index 761f525eb..5c311f490 100644 --- a/src/main/webapp/app/shared/models/backend/repository/repository.ts +++ b/src/main/webapp/app/shared/models/backend/repository/repository.ts @@ -22,63 +22,18 @@ import { RepositoryTypeEnum } from '../../../enums/repository-type.enum'; * Repository class */ export class Repository { - /** - * The repository id - */ + [key: string]: any; id: number; - - /** - * The repository name - */ name: string; - - /** - * The repository url - */ url: string; - - /** - * The repository branch to clone - */ branch: string; - - /** - * The login to use for the connection to the remote repository - */ login: string; - - /** - * The password to use for the connection to the remote repository - */ password: string; - - /** - * The path of the repository in case of a local folder - */ localPath: string; - - /** - * The type of repository - */ type: RepositoryTypeEnum; - - /** - * If the repository is enabled or not - */ enabled: boolean; - - /** - * The priority order - */ priority: number; - - /** - * The repository created date - */ createdDate: Date; - /** - * Constructor - */ constructor() {} } diff --git a/src/main/webapp/app/shared/models/frontend/form/form-field.ts b/src/main/webapp/app/shared/models/frontend/form/form-field.ts index 269eaa633..0ec0d61ce 100644 --- a/src/main/webapp/app/shared/models/frontend/form/form-field.ts +++ b/src/main/webapp/app/shared/models/frontend/form/form-field.ts @@ -114,12 +114,12 @@ export class FormField { /** * The list of values to used in the array */ - values?: Observable; + values?: Observable; /** * Function used to delete a row */ - deleteRow?: { attribute: string; callback: (object: unknown) => Observable }; + deleteRow?: { attribute: string; callback: (object: any) => Observable }; /* ***************************************************************************************************************** */ /* Mosaic Field */ diff --git a/src/main/webapp/app/shared/models/frontend/sidenav/form-sidenav-configuration.ts b/src/main/webapp/app/shared/models/frontend/sidenav/form-sidenav-configuration.ts index 71082c150..acc68cc7b 100644 --- a/src/main/webapp/app/shared/models/frontend/sidenav/form-sidenav-configuration.ts +++ b/src/main/webapp/app/shared/models/frontend/sidenav/form-sidenav-configuration.ts @@ -44,7 +44,7 @@ export interface FormSidenavConfiguration { /** * The function to call when the form should be sent */ - save?: (object: unknown) => void; + save?: (object: any) => void; /** * Function to call when a value of a field has changed diff --git a/src/main/webapp/app/shared/services/backend/abstract-http/abstract-http.service.ts b/src/main/webapp/app/shared/services/backend/abstract-http/abstract-http.service.ts index 09a23e0c0..625ffd0ee 100644 --- a/src/main/webapp/app/shared/services/backend/abstract-http/abstract-http.service.ts +++ b/src/main/webapp/app/shared/services/backend/abstract-http/abstract-http.service.ts @@ -21,34 +21,33 @@ import { Page } from '../../../models/backend/page'; import { HttpFilter } from '../../../models/backend/http-filter'; /** - * Service used to define the minimum requirement for an http service + * Service used to define the minimum requirement for a http service */ @Injectable({ providedIn: 'root' }) -export abstract class AbstractHttpService { +export abstract class AbstractHttpService { /** * The base API url - * @type {string} */ public static readonly baseApiEndpoint = `${EnvironmentService.backendUrl}/api`; /** * Function used to retrieve the list of Objects */ - abstract getAll(filter?: HttpFilter): Observable>; + abstract getAll(filter?: HttpFilter): Observable>; /** * Function used to retrieve an Object of type T * * @param id The object id to retrieve */ - abstract getById(id: number | string): Observable; + abstract getById(id: number | string): Observable; /** * Function used to create an object of type T * * @param entity The object that we want to create */ - abstract create(entity: T): Observable; + abstract create(entity: TReq): Observable; /** * Function used to update an object of type T @@ -56,7 +55,7 @@ export abstract class AbstractHttpService { * @param id The object id if to update * @param entity The new object for this id */ - abstract update(id: number | string, entity: T): Observable; + abstract update(id: number | string, entity: TReq): Observable; /** * Function used to delete an object diff --git a/src/main/webapp/app/shared/services/backend/http-admin-user/http-admin-user.service.ts b/src/main/webapp/app/shared/services/backend/http-admin-user/http-admin-user.service.ts index 809c47c7f..336ef9960 100644 --- a/src/main/webapp/app/shared/services/backend/http-admin-user/http-admin-user.service.ts +++ b/src/main/webapp/app/shared/services/backend/http-admin-user/http-admin-user.service.ts @@ -27,7 +27,7 @@ import { UserRequest } from '../../../models/backend/user/user-request'; import { HttpUserService } from '../http-user/http-user.service'; @Injectable({ providedIn: 'root' }) -export class HttpAdminUserService implements AbstractHttpService { +export class HttpAdminUserService implements AbstractHttpService { public static readonly adminUsersApiEndpoint = `${AbstractHttpService.baseApiEndpoint}/v1/admin/users`; /** diff --git a/src/main/webapp/app/shared/services/backend/http-category-parameters/http-category-parameters.service.ts b/src/main/webapp/app/shared/services/backend/http-category-parameters/http-category-parameters.service.ts index 5d9b38774..6b9593e25 100644 --- a/src/main/webapp/app/shared/services/backend/http-category-parameters/http-category-parameters.service.ts +++ b/src/main/webapp/app/shared/services/backend/http-category-parameters/http-category-parameters.service.ts @@ -30,7 +30,7 @@ import { CategoryParameter } from '../../../models/backend/category-parameters/c * Configuration services manage http calls */ @Injectable({ providedIn: 'root' }) -export class HttpCategoryParametersService extends AbstractHttpService { +export class HttpCategoryParametersService extends AbstractHttpService { /** * Global configurations endpoint */ @@ -72,7 +72,7 @@ export class HttpCategoryParametersService extends AbstractHttpService { + public create(configuration: WidgetConfigurationRequest): Observable { return EMPTY; } diff --git a/src/main/webapp/app/shared/services/backend/http-filter/http-filter.service.ts b/src/main/webapp/app/shared/services/backend/http-filter/http-filter.service.ts index 869bde6a3..f2bdecb6f 100644 --- a/src/main/webapp/app/shared/services/backend/http-filter/http-filter.service.ts +++ b/src/main/webapp/app/shared/services/backend/http-filter/http-filter.service.ts @@ -83,7 +83,7 @@ export class HttpFilterService { Object.keys(httpFilter).forEach(filterKey => { if (httpFilter[filterKey]) { if (httpFilter[filterKey] instanceof Array) { - httpFilter[filterKey].forEach(filterKeyValue => { + httpFilter[filterKey].forEach((filterKeyValue: string) => { url += `&${filterKey}=${encodeURIComponent(filterKeyValue)}`; }); } else { diff --git a/src/main/webapp/app/shared/services/backend/http-project/http-project.service.ts b/src/main/webapp/app/shared/services/backend/http-project/http-project.service.ts index 40d24a1b2..306ac7b15 100644 --- a/src/main/webapp/app/shared/services/backend/http-project/http-project.service.ts +++ b/src/main/webapp/app/shared/services/backend/http-project/http-project.service.ts @@ -31,7 +31,7 @@ import { HttpFilterService } from '../http-filter/http-filter.service'; import { Page } from '../../../models/backend/page'; @Injectable({ providedIn: 'root' }) -export class HttpProjectService implements AbstractHttpService { +export class HttpProjectService implements AbstractHttpService { /** * Global endpoint for projects */ diff --git a/src/main/webapp/app/shared/services/backend/http-repository/http-repository.service.ts b/src/main/webapp/app/shared/services/backend/http-repository/http-repository.service.ts index 8e9657890..047cc1bee 100644 --- a/src/main/webapp/app/shared/services/backend/http-repository/http-repository.service.ts +++ b/src/main/webapp/app/shared/services/backend/http-repository/http-repository.service.ts @@ -32,10 +32,9 @@ import { Page } from '../../../models/backend/page'; * Service that manage HTTP repository calls */ @Injectable({ providedIn: 'root' }) -export class HttpRepositoryService implements AbstractHttpService { +export class HttpRepositoryService implements AbstractHttpService { /** * Global repositories endpoint - * @type {string} */ private static readonly repositoriesApiEndpoint = `${AbstractHttpService.baseApiEndpoint}/v1/repositories`; diff --git a/src/main/webapp/app/shared/services/backend/http-user/http-user.service.ts b/src/main/webapp/app/shared/services/backend/http-user/http-user.service.ts index 1a4c912e7..c8d89a6d2 100644 --- a/src/main/webapp/app/shared/services/backend/http-user/http-user.service.ts +++ b/src/main/webapp/app/shared/services/backend/http-user/http-user.service.ts @@ -26,14 +26,16 @@ import { AbstractHttpService } from '../abstract-http/abstract-http.service'; import { Page } from '../../../models/backend/page'; import { HttpFilter } from '../../../models/backend/http-filter'; import { HttpFilterService } from '../http-filter/http-filter.service'; -import { PersonalAccessTokenRequest } from '../../../models/backend/personal-access-token/personal-access-token-request'; +import { + PersonalAccessTokenRequest +} from '../../../models/backend/personal-access-token/personal-access-token-request'; import { PersonalAccessToken } from '../../../models/backend/personal-access-token/personal-access-token'; /** * Manage the http user calls */ @Injectable({ providedIn: 'root' }) -export class HttpUserService implements AbstractHttpService { +export class HttpUserService implements AbstractHttpService { public static readonly usersApiEndpoint = `${AbstractHttpService.baseApiEndpoint}/v1/users`; /** @@ -66,16 +68,16 @@ export class HttpUserService implements AbstractHttpService * Function used to create a new user * @param entity The user to create */ - public create(entity: User | UserRequest): Observable { + public create(entity: UserRequest): Observable { return EMPTY; } /** * Update a user - * @param {number} id The userId to update + * @param id The userId to update * @param entity The user request */ - public update(id: number, entity: User | UserRequest): Observable { + public update(id: number, entity: UserRequest): Observable { const url = `${HttpUserService.usersApiEndpoint}/${id}`; return this.httpClient.put(url, entity); diff --git a/src/main/webapp/app/shared/services/backend/http-widget/http-widget.service.ts b/src/main/webapp/app/shared/services/backend/http-widget/http-widget.service.ts index fb1e9a138..403880711 100644 --- a/src/main/webapp/app/shared/services/backend/http-widget/http-widget.service.ts +++ b/src/main/webapp/app/shared/services/backend/http-widget/http-widget.service.ts @@ -29,10 +29,9 @@ import { Page } from '../../../models/backend/page'; * Manage the Http widget calls */ @Injectable({ providedIn: 'root' }) -export class HttpWidgetService extends AbstractHttpService { +export class HttpWidgetService extends AbstractHttpService { /** * Global endpoint for Widgets - * @type {string} */ private static readonly widgetsApiEndpoint = `${AbstractHttpService.baseApiEndpoint}/v1/widgets`; @@ -72,7 +71,7 @@ export class HttpWidgetService extends AbstractHttpService { * * @param widget The object that we want to create */ - public create(widget: Widget): Observable { + public create(widget: WidgetRequest): Observable { return EMPTY; } diff --git a/src/main/webapp/app/shared/services/frontend/css/css.service.ts b/src/main/webapp/app/shared/services/frontend/css/css.service.ts index ea9193bc4..23f039269 100644 --- a/src/main/webapp/app/shared/services/frontend/css/css.service.ts +++ b/src/main/webapp/app/shared/services/frontend/css/css.service.ts @@ -18,7 +18,7 @@ import { Injectable } from '@angular/core'; import { CssSelector } from '../../../models/frontend/css-parser/css-selector'; import { CssRule } from '../../../models/frontend/css-parser/css-rule'; -import * as CSSParser from 'jotform-css.js/css.js'; +import * as CSSParser from 'jotform-css.js'; /** * The dashboard service @@ -30,18 +30,6 @@ export class CssService { */ constructor() {} - /** - * Used to parse the css from a string file - * - * @param cssContent The css file - */ - public static getParsedCss(cssContent: string): CssSelector[] { - if (cssContent) { - const parser = new CSSParser.cssjs(); - return parser.parseCSS(cssContent); - } - } - /** * Extract the value of a property from the css file * @@ -50,21 +38,21 @@ export class CssService { * @param propertyName The property that we should use to retrieve the value */ public static extractCssValue(cssContent: string, cssSelector: string, propertyName: string): string { - let propertyValue = null; - if (cssContent && cssSelector && propertyName) { - const cssParsed: CssSelector[] = CssService.getParsedCss(cssContent); + const parser = new CSSParser.cssjs(); + const parsedCss = parser.parseCSS(cssContent) as unknown as Array; - if (cssParsed) { - const cssSelectorFound: CssSelector = cssParsed.find((currCssSelector: CssSelector) => currCssSelector.selector === cssSelector); + if (parsedCss) { + const cssSelectorFound: CssSelector = parsedCss.find((currCssSelector: CssSelector) => currCssSelector.selector === cssSelector); if (cssSelectorFound) { const cssRule: CssRule = cssSelectorFound.rules.find((currCssRule: CssRule) => currCssRule.directive === propertyName); - propertyValue = cssRule ? cssRule.value : null; + return cssRule ? cssRule.value : null; } } } - return propertyValue; + + return null; } /** diff --git a/src/main/webapp/app/shared/services/frontend/form-fields/widget-configuration-form-fields/widget-configuration-form-fields.service.ts b/src/main/webapp/app/shared/services/frontend/form-fields/widget-configuration-form-fields/widget-configuration-form-fields.service.ts index 5b579553b..ec0b063fa 100644 --- a/src/main/webapp/app/shared/services/frontend/form-fields/widget-configuration-form-fields/widget-configuration-form-fields.service.ts +++ b/src/main/webapp/app/shared/services/frontend/form-fields/widget-configuration-form-fields/widget-configuration-form-fields.service.ts @@ -131,7 +131,7 @@ export class WidgetConfigurationFormFieldsService { const categorySettingsFormFields = this.generateCategoryParametersFormFields(categorySettings, widgetBackendConfig); if (checked) { - fields.push(...categorySettingsFormFields); + fields.unshift(...categorySettingsFormFields); this.formService.addControlsToFormGroupForFields(formGroup, categorySettingsFormFields); } else { for (const categoryField of categorySettingsFormFields) { diff --git a/src/main/webapp/app/shared/services/frontend/form-steps/project-widget-form-steps/project-widget-form-steps.service.ts b/src/main/webapp/app/shared/services/frontend/form-steps/project-widget-form-steps/project-widget-form-steps.service.ts index f090c06ea..3ebd9a0f5 100644 --- a/src/main/webapp/app/shared/services/frontend/form-steps/project-widget-form-steps/project-widget-form-steps.service.ts +++ b/src/main/webapp/app/shared/services/frontend/form-steps/project-widget-form-steps/project-widget-form-steps.service.ts @@ -143,7 +143,7 @@ export class ProjectWidgetFormStepsService { * @param widgetConfig The configuration already set */ public generateWidgetParametersFormFields(widgetParams: WidgetParam[], widgetConfig?: string): FormField[] { - const formFields = []; + const formFields: FormField[] = []; widgetParams.forEach((widgetParam: WidgetParam) => { let configValue = null; diff --git a/src/main/webapp/app/shared/services/frontend/form/form.service.ts b/src/main/webapp/app/shared/services/frontend/form/form.service.ts index c8d2a57ba..3b11ea9b2 100644 --- a/src/main/webapp/app/shared/services/frontend/form/form.service.ts +++ b/src/main/webapp/app/shared/services/frontend/form/form.service.ts @@ -17,7 +17,14 @@ */ import { Injectable } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, ValidatorFn } from '@angular/forms'; +import { + AbstractControl, + UntypedFormArray, + UntypedFormBuilder, + UntypedFormControl, + UntypedFormGroup, + ValidatorFn +} from '@angular/forms'; import { FormField } from '../../../models/frontend/form/form-field'; import { FormStep } from '../../../models/frontend/form/form-step'; @@ -131,8 +138,8 @@ export class FormService { const formArray = this.formBuilder.array([]); if (field && field.fields && field.values) { - field.values.subscribe((values: unknown[]) => { - values.forEach((value: unknown) => { + field.values.subscribe((values: any[]) => { + values.forEach((value: any) => { const formGroup = this.formBuilder.group({}); field.fields.forEach((innerField: FormField) => { formGroup.addControl(innerField.key, this.generateFormControl(innerField, value[innerField.key] ? value[innerField.key] : '')); diff --git a/src/main/webapp/app/shared/services/frontend/websocket/websocket.service.ts b/src/main/webapp/app/shared/services/frontend/websocket/websocket.service.ts index 51fa00e2e..435ee7dee 100644 --- a/src/main/webapp/app/shared/services/frontend/websocket/websocket.service.ts +++ b/src/main/webapp/app/shared/services/frontend/websocket/websocket.service.ts @@ -17,7 +17,7 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { EnvironmentService } from '../environment/environment.service'; -import * as SockJS from 'sockjs-client'; +import SockJS from 'sockjs-client'; import { IMessage, RxStompConfig } from '@stomp/rx-stomp'; import { RxStompService } from '../rx-stomp/rx-stomp.service'; diff --git a/src/main/webapp/app/shared/validators/custom-validator.ts b/src/main/webapp/app/shared/validators/custom-validator.ts index 029ad1308..68cae958b 100644 --- a/src/main/webapp/app/shared/validators/custom-validator.ts +++ b/src/main/webapp/app/shared/validators/custom-validator.ts @@ -32,6 +32,7 @@ export class CustomValidator { if ((passwordControl.dirty || passwordControl.touched) && (confirmPasswordControl.dirty || confirmPasswordControl.touched)) { return passwordControl.value !== confirmPasswordControl.value ? { passwordMismatch: true } : null; } + return null; }; } @@ -41,9 +42,11 @@ export class CustomValidator { * @param control The field control */ public static isDigits(control: AbstractControl) { - if (control.value) { - return String(control.value).match(new RegExp('^-?[0-9]\\d*(\\.\\d+)?$')) ? null : { digits: true }; + if (!control.value) { + return null; } + + return String(control.value).match(new RegExp('^-?[0-9]\\d*(\\.\\d+)?$')) ? null : { digits: true }; } /** diff --git a/src/main/webapp/app/widget/catalog/catalog.component.ts b/src/main/webapp/app/widget/catalog/catalog.component.ts index f392f4bc2..52add6233 100644 --- a/src/main/webapp/app/widget/catalog/catalog.component.ts +++ b/src/main/webapp/app/widget/catalog/catalog.component.ts @@ -28,7 +28,7 @@ import { HttpAssetService } from '../../shared/services/backend/http-asset/http- templateUrl: '../../shared/components/list/list.component.html', styleUrls: ['../../shared/components/list/list.component.scss'] }) -export class CatalogComponent extends ListComponent { +export class CatalogComponent extends ListComponent { /** * Constructor * @@ -44,28 +44,28 @@ export class CatalogComponent extends ListComponent { /** * {@inheritDoc} */ - public getFirstLabel(widget: Widget): string { + public override getFirstLabel(widget: Widget): string { return widget.name; } /** * {@inheritDoc} */ - public getSecondLabel(widget: Widget): string { + public override getSecondLabel(widget: Widget): string { return widget.description; } /** * {@inheritDoc} */ - public getThirdLabel(widget: Widget): string { + public override getThirdLabel(widget: Widget): string { return widget.category.name; } /** * {@inheritDoc} */ - public getObjectImageURL(widget: Widget): string { + public override getObjectImageURL(widget: Widget): string { return HttpAssetService.getContentUrl(widget.imageToken); } diff --git a/src/main/webapp/assets/i18n/en.json b/src/main/webapp/assets/i18n/en.json index a6f319fbc..935b45a33 100644 --- a/src/main/webapp/assets/i18n/en.json +++ b/src/main/webapp/assets/i18n/en.json @@ -51,7 +51,7 @@ "field.error.email.format": "Invalid email format", "field.error.gt0": "This field requires a number greater than 0", "field.error.length": "This field has an invalid length", - "field.error.password.mismatch": "The confirmation password and the password should match", + "field.error.password.mismatch": "Passwords do not match", "field.error.pattern": "The field do not respect the required format", "field.error.required": "This field is required", "field.error.repository.unique.priority": "Another repository already has this priority", diff --git a/src/main/webapp/assets/i18n/fr.json b/src/main/webapp/assets/i18n/fr.json index a02ee73cf..6ee0cb300 100644 --- a/src/main/webapp/assets/i18n/fr.json +++ b/src/main/webapp/assets/i18n/fr.json @@ -51,7 +51,7 @@ "field.error.email.format": "Format d'email non valide", "field.error.gt0": "Ce champ requiert un nombre supérieur à 0", "field.error.length": "La longueur du champ est incorrect", - "field.error.password.mismatch": "Le mot de passe et sa confirmation doivent correspondre", + "field.error.password.mismatch": "Les mots de passes ne correspondent pas", "field.error.pattern": "Le champ ne correspond pas au bon format", "field.error.required": "Ce champ est obligatoire", "field.error.repository.unique.priority": "Un autre dépôt possède déjà cette priorité", diff --git a/src/main/webapp/sass/_global-styles.scss b/src/main/webapp/sass/_global-styles.scss index d10e8f26d..aa3a36f1d 100644 --- a/src/main/webapp/sass/_global-styles.scss +++ b/src/main/webapp/sass/_global-styles.scss @@ -72,7 +72,7 @@ body { font-size: 11px; } - .mat-form-field-suffix .show-pwd-icon { + .mat-mdc-form-field-icon-suffix { cursor: pointer; } } diff --git a/src/main/webapp/sass/components/_mat-communication-dialog-theme.scss b/src/main/webapp/sass/components/_mat-communication-dialog-theme.scss new file mode 100644 index 000000000..4a45be71b --- /dev/null +++ b/src/main/webapp/sass/components/_mat-communication-dialog-theme.scss @@ -0,0 +1,26 @@ +/*! + * /* + * * Copyright 2012-2021 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ +@use '../../../../../node_modules/@angular/material/index' as mat; + +@mixin custom-communication-dialog-component-theme($theme) { + $warn: map-get($theme, warn); + + .communication-dialog-wrapper .mat-mdc-dialog-content.communication-dialog-error { + color: mat.get-color-from-palette($warn, 500); + } +} diff --git a/src/main/webapp/sass/themes/_suricate-theme.scss b/src/main/webapp/sass/themes/_suricate-theme.scss index c76e85565..185941c67 100644 --- a/src/main/webapp/sass/themes/_suricate-theme.scss +++ b/src/main/webapp/sass/themes/_suricate-theme.scss @@ -26,7 +26,7 @@ @import 'sass/components/mat-list-theme'; @import 'sass/components/mat-input-theme'; @import 'sass/components/mat-file-input-theme'; -@import 'app/shared/components/communication-dialog/communication-dialog.component'; +@import 'sass/components/mat-communication-dialog-theme'; @import 'app/dashboard/components/dashboard-detail/dashboard-detail.component'; /** @@ -44,6 +44,6 @@ @include custom-list-component-theme($theme); @include custom-input-component-theme($theme); @include custom-file-input-component-theme($theme); - @include communication-dialog-component-theme($theme); + @include custom-communication-dialog-component-theme($theme); @include dashboard-detail-component-theme($theme); } diff --git a/src/main/webapp/tsconfig.app.json b/src/main/webapp/tsconfig.app.json index 264c8c5a0..927875ee5 100644 --- a/src/main/webapp/tsconfig.app.json +++ b/src/main/webapp/tsconfig.app.json @@ -8,6 +8,6 @@ "files": ["main.ts", "polyfills.ts"], "include": [ "src/main/webapp/**/*.d.ts", - "./environments/*.ts" + "src/main/webapp/environments/environment.prod.ts" ] } diff --git a/src/main/webapp/tsconfig.json b/src/main/webapp/tsconfig.json deleted file mode 100644 index aeed08fbc..000000000 --- a/src/main/webapp/tsconfig.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "outDir": "./dist/out-tsc", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "esModuleInterop": true, - "sourceMap": true, - "declaration": false, - "experimentalDecorators": true, - "moduleResolution": "node", - "importHelpers": true, - "target": "ES2022", - "module": "ES2022", - "useDefineForClassFields": false, - "lib": [ - "ES2022", - "dom" - ] - }, - "angularCompilerOptions": { - "enableI18nLegacyMessageIdFormat": false, - "strictInjectionParameters": true, - "strictInputAccessModifiers": true, - "strictTemplates": true - } -} diff --git a/tsconfig.json b/tsconfig.json index 5ee94e983..d3a968f8a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,22 +2,35 @@ "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", + "forceConsistentCasingInFileNames": true, + //"strict": true, + "strictNullChecks": false, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "esModuleInterop": true, "sourceMap": true, "declaration": false, - "downlevelIteration": true, "experimentalDecorators": true, "moduleResolution": "node", "importHelpers": true, + "useDefineForClassFields": false, + "downlevelIteration": true, "target": "ES2022", - "module": "es2020", + "module": "ES2022", "lib": [ - "es2018", + "ES2022", "dom" ], - "allowSyntheticDefaultImports": true, "typeRoots": [ "node_modules/@types" - ], - "useDefineForClassFields": false + ] + }, + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true } -} +} \ No newline at end of file From 08e0d624eaf3dd52d90a977755d7795d1e745e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Greffier?= Date: Sat, 23 Dec 2023 16:46:57 +0100 Subject: [PATCH 06/12] Fix index --- .../configurations/configurations.component.ts | 11 ++++++----- .../admin/dashboards/dashboards.component.ts | 8 +++++--- .../repositories/repositories.component.ts | 13 ++++++++----- .../webapp/app/admin/users/users.component.ts | 10 ++++++---- .../app/core/components/home/home.component.ts | 12 ++++++++---- .../ux-settings/ux-settings.component.ts | 10 ++++------ .../dashboard-detail.component.ts | 18 +++++++++++------- .../dashboard-screen-widget.component.ts | 12 ++++++------ .../add-widget-to-project-wizard.component.ts | 13 +++++++------ .../form-sidenav/form-sidenav.component.ts | 2 +- .../components/wizard/wizard.component.ts | 6 +++--- .../sidenav/form-sidenav-configuration.ts | 3 ++- 12 files changed, 67 insertions(+), 51 deletions(-) diff --git a/src/main/webapp/app/admin/configurations/configurations.component.ts b/src/main/webapp/app/admin/configurations/configurations.component.ts index 39fad130b..a05539c7d 100644 --- a/src/main/webapp/app/admin/configurations/configurations.component.ts +++ b/src/main/webapp/app/admin/configurations/configurations.component.ts @@ -29,6 +29,7 @@ import { DataTypeEnum } from '../../shared/enums/data-type.enum'; import { WidgetConfigurationRequest } from '../../shared/models/backend/widget-configuration/widget-configuration-request'; +import { UntypedFormGroup } from '@angular/forms'; /** * Component used to display the list of widgets @@ -144,11 +145,11 @@ export class ConfigurationsComponent extends ListComponent void): void { + private openFormSidenav(event: Event, configuration: CategoryParameter, saveCallback: (formGroup: UntypedFormGroup) => void): void { this.sidenavService.openFormSidenav({ title: 'configuration.edit', formFields: this.widgetConfigurationFormFieldsService.generateFormFields(configuration), - save: (configurationRequest: CategoryParameter) => saveCallback(configurationRequest) + save: (formGroup: UntypedFormGroup) => saveCallback(formGroup) }); } @@ -174,10 +175,10 @@ export class ConfigurationsComponent extends ListComponent { + private updateConfiguration(formGroup: UntypedFormGroup): void { + this.httpCategoryParametersService.update(formGroup.value.key, formGroup.value).subscribe(() => { this.refreshList(); this.toastService.sendMessage('configuration.update.success', ToastTypeEnum.SUCCESS); }); diff --git a/src/main/webapp/app/admin/dashboards/dashboards.component.ts b/src/main/webapp/app/admin/dashboards/dashboards.component.ts index d2054c10d..50f2d71e4 100644 --- a/src/main/webapp/app/admin/dashboards/dashboards.component.ts +++ b/src/main/webapp/app/admin/dashboards/dashboards.component.ts @@ -32,6 +32,7 @@ import { ValueChangedEvent } from '../../shared/models/frontend/form/value-chang import { EMPTY, Observable, of } from 'rxjs'; import { switchMap } from 'rxjs/operators'; import { CssService } from '../../shared/services/frontend/css/css.service'; +import { UntypedFormGroup } from '@angular/forms'; @Component({ templateUrl: '../../shared/components/list/list.component.html', @@ -152,16 +153,17 @@ export class DashboardsComponent extends ListComponent this.sidenavService.openFormSidenav({ title: project ? 'dashboard.edit' : 'dashboard.create', formFields: this.projectFormFieldsService.generateProjectFormFields(project), - save: (projectRequest: ProjectRequest) => this.editProject(projectRequest) + save: (formGroup: UntypedFormGroup) => this.editProject(formGroup) }); } /** * Redirect on the edit page * - * @param projectRequest The project clicked on the list + * @param formGroup The form group */ - private editProject(projectRequest: ProjectRequest): void { + private editProject(formGroup: UntypedFormGroup): void { + const projectRequest: ProjectRequest = formGroup.value; projectRequest.cssStyle = CssService.buildCssFile([CssService.buildCssGridBackgroundColor(projectRequest.gridBackgroundColor)]); this.httpProjectService.update(this.projectSelected.token, projectRequest).subscribe(() => { diff --git a/src/main/webapp/app/admin/repositories/repositories.component.ts b/src/main/webapp/app/admin/repositories/repositories.component.ts index 443c68b08..4f044e3fb 100644 --- a/src/main/webapp/app/admin/repositories/repositories.component.ts +++ b/src/main/webapp/app/admin/repositories/repositories.component.ts @@ -30,6 +30,7 @@ import { ToastTypeEnum } from '../../shared/enums/toast-type.enum'; import { Observable } from 'rxjs/internal/Observable'; import { BehaviorSubject, EMPTY, forkJoin, of } from 'rxjs'; import { DatePipe } from '@angular/common'; +import { UntypedFormGroup } from '@angular/forms'; /** * Component used to display the list of git repositories @@ -160,13 +161,13 @@ export class RepositoriesComponent extends ListComponent void): void { + private openFormSidenav(event: Event, repository: Repository, saveCallback: (formGroup: UntypedFormGroup) => void): void { this.repository = repository ? Object.assign({}, repository) : new Repository(); this.sidenavService.openFormSidenav({ title: repository ? 'repository.edit' : 'repository.add', formFields: this.repositoryFormFieldsService.generateFormFields(repository), - save: (repositoryRequest: RepositoryRequest) => saveCallback(repositoryRequest), + save: (formGroup: UntypedFormGroup) => saveCallback(formGroup), onValueChanged: (valueChangedEvent: ValueChangedEvent) => this.onValueChanged(valueChangedEvent) }); } @@ -211,9 +212,10 @@ export class RepositoriesComponent extends ListComponent implements * @param user The user clicked on the list * @param saveCallback The function to call when save button is clicked */ - private openFormSidenav(event: Event, user: User, saveCallback: (userRequest: UserRequest) => void): void { + private openFormSidenav(event: Event, user: User, saveCallback: (formGroup: UntypedFormGroup) => void): void { this.userSelected = user; this.sidenavService.openFormSidenav({ title: user ? 'user.edit' : 'user.add', formFields: this.userFormFieldsService.generateFormFields(user), - save: (userRequest: UserRequest) => saveCallback(userRequest) + save: (formGroup: UntypedFormGroup) => saveCallback(formGroup) }); } /** * Edit a user - * @param userRequest The user request to make + * @param formGroup The form group */ - private editUser(userRequest: UserRequest): void { + private editUser(formGroup: UntypedFormGroup): void { + const userRequest: UserRequest = formGroup.value; this.httpAdminUserService.update(this.userSelected.id, userRequest).subscribe(() => { super.refreshList(); }); diff --git a/src/main/webapp/app/core/components/home/home.component.ts b/src/main/webapp/app/core/components/home/home.component.ts index 22a838030..ab648833e 100644 --- a/src/main/webapp/app/core/components/home/home.component.ts +++ b/src/main/webapp/app/core/components/home/home.component.ts @@ -1,5 +1,7 @@ import { Component, OnInit } from '@angular/core'; -import { ProjectFormFieldsService } from '../../../shared/services/frontend/form-fields/project-form-fields/project-form-fields.service'; +import { + ProjectFormFieldsService +} from '../../../shared/services/frontend/form-fields/project-form-fields/project-form-fields.service'; import { ProjectRequest } from '../../../shared/models/backend/project/project-request'; import { CssService } from '../../../shared/services/frontend/css/css.service'; import { Project } from '../../../shared/models/backend/project/project'; @@ -15,6 +17,7 @@ import { MaterialIconRecords } from '../../../shared/records/material-icon.recor import { IconEnum } from '../../../shared/enums/icon.enum'; import { HeaderConfiguration } from '../../../shared/models/frontend/header/header-configuration'; import { ButtonTypeEnum } from '../../../shared/enums/button-type.enum'; +import { UntypedFormGroup } from '@angular/forms'; @Component({ selector: 'suricate-my-dashboards', @@ -102,16 +105,17 @@ export class HomeComponent implements OnInit { this.sidenavService.openFormSidenav({ title: 'dashboard.create', formFields: this.projectFormFieldsService.generateProjectFormFields(), - save: (formData: ProjectRequest) => this.saveDashboard(formData) + save: (formGroup: UntypedFormGroup) => this.saveDashboard(formGroup) }); } /** * Create a new dashboard * - * @param formData The data retrieved from the form + * @param formGroup The form group */ - private saveDashboard(formData: ProjectRequest): void { + private saveDashboard(formGroup: UntypedFormGroup): void { + const formData: ProjectRequest = formGroup.value; formData.cssStyle = CssService.buildCssFile([CssService.buildCssGridBackgroundColor(formData.gridBackgroundColor)]); this.httpProjectService.create(formData).subscribe((project: Project) => { diff --git a/src/main/webapp/app/core/components/settings/ux-settings/ux-settings.component.ts b/src/main/webapp/app/core/components/settings/ux-settings/ux-settings.component.ts index fc791c3a4..9a2e07264 100644 --- a/src/main/webapp/app/core/components/settings/ux-settings/ux-settings.component.ts +++ b/src/main/webapp/app/core/components/settings/ux-settings/ux-settings.component.ts @@ -91,28 +91,26 @@ export class UxSettingsComponent implements OnInit { this.formService.validate(this.formGroup); if (this.formGroup.valid) { - this.saveSettings(this.formGroup.value); + this.saveSettings(); } } /** * Save the selected settings - * - * @param formData The selected settings from the form */ - private saveSettings(formData: FormData): void { + private saveSettings(): void { from(this.userSettings.map(userSetting => userSetting.setting)) .pipe( mergeMap((setting: Setting) => { const userSettingRequest = new UserSettingRequest(); if (setting.constrained && setting.allowedSettingValues) { const selectedAllowedSetting = setting.allowedSettingValues.find((allowedSettingValue: AllowedSettingValue) => { - return allowedSettingValue.value === formData[setting.type]; + return allowedSettingValue.value === this.formGroup.get(setting.type).value; }); userSettingRequest.allowedSettingValueId = selectedAllowedSetting.id; } else { - userSettingRequest.unconstrainedValue = formData[setting.type]; + userSettingRequest.unconstrainedValue = this.formGroup.get(setting.type).value; } return this.httpUserService.updateUserSetting(AuthenticationService.getConnectedUser().username, setting.id, userSettingRequest); diff --git a/src/main/webapp/app/dashboard/components/dashboard-detail/dashboard-detail.component.ts b/src/main/webapp/app/dashboard/components/dashboard-detail/dashboard-detail.component.ts index b350d115b..ae5efa99e 100644 --- a/src/main/webapp/app/dashboard/components/dashboard-detail/dashboard-detail.component.ts +++ b/src/main/webapp/app/dashboard/components/dashboard-detail/dashboard-detail.component.ts @@ -54,6 +54,7 @@ import { import { ProjectGridRequest } from '../../../shared/models/backend/project-grid/project-grid-request'; import { ProjectGrid } from '../../../shared/models/backend/project-grid/project-grid'; import { GridRequest } from '../../../shared/models/backend/project-grid/grid-request'; +import { UntypedFormGroup } from '@angular/forms'; /** * Component used to display a specific dashboard @@ -378,7 +379,7 @@ export class DashboardDetailComponent implements OnInit, OnDestroy { title: 'dashboard.edit', formFields: this.projectFormFieldsService.generateProjectFormFields(this.project), belongingComponent: this.dashboardScreen, - save: (formData: ProjectRequest) => this.editDashboard(formData) + save: (formGroup: UntypedFormGroup) => this.editDashboard(formGroup) }); } @@ -389,7 +390,7 @@ export class DashboardDetailComponent implements OnInit, OnDestroy { this.sidenavService.openFormSidenav({ title: 'grid.add', formFields: this.projectFormFieldsService.generateAddGridFormField(), - save: (formData: GridRequest) => this.addNewGrid(formData) + save: (formGroup: UntypedFormGroup) => this.addNewGrid(formGroup) }); } @@ -400,16 +401,17 @@ export class DashboardDetailComponent implements OnInit, OnDestroy { this.sidenavService.openFormSidenav({ title: 'dashboard.grid.management', formFields: this.projectFormFieldsService.generateGridsManagementFormFields(this.project), - save: (formData: ProjectGridRequest) => this.editGrids(formData) + save: (formGroup: UntypedFormGroup) => this.editGrids(formGroup) }); } /** * Execute the action edit the dashboard when the sidenav has been saved * - * @param formData The data retrieve from the form sidenav + * @param formGroup The form group */ - private editDashboard(formData: ProjectRequest): void { + private editDashboard(formGroup: UntypedFormGroup): void { + const formData: ProjectRequest = formGroup.value; formData.cssStyle = `.grid { background-color: ${formData.gridBackgroundColor}; }`; this.httpProjectService.update(this.project.token, formData).subscribe(() => { @@ -438,7 +440,8 @@ export class DashboardDetailComponent implements OnInit, OnDestroy { * * @param formData The data retrieved from the side nav */ - private addNewGrid(formData: GridRequest): void { + private addNewGrid(formGroup: UntypedFormGroup): void { + const formData: GridRequest = formGroup.value; this.httpProjectGridsService.create(this.project.token, formData).subscribe((createdProjectGrid: ProjectGrid) => { this.router.navigate(['/dashboards', this.dashboardToken, createdProjectGrid.id]); }); @@ -449,7 +452,8 @@ export class DashboardDetailComponent implements OnInit, OnDestroy { * * @param formData The data retrieve from the form sidenav */ - private editGrids(formData: ProjectGridRequest): void { + private editGrids(formGroup: UntypedFormGroup): void { + const formData: ProjectGridRequest = formGroup.value; const newTimes = Object.keys(formData) .filter(key => key.includes(ProjectFormFieldsService.timeFormFieldKey)) .map(key => formData[key]); diff --git a/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen-widget/dashboard-screen-widget.component.ts b/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen-widget/dashboard-screen-widget.component.ts index a98ccb192..7a22491c6 100644 --- a/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen-widget/dashboard-screen-widget.component.ts +++ b/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen-widget/dashboard-screen-widget.component.ts @@ -214,7 +214,7 @@ export class DashboardScreenWidgetComponent implements OnInit, OnDestroy { this.widget.params, this.projectWidget.backendConfig ), - save: (formData: FormData) => this.saveWidget(formData), + save: (formGroup: UntypedFormGroup) => this.saveWidget(formGroup), slideToggleButtonConfiguration: this.buildSlideToggleButtonConfiguration(this.widget.category.categoryParameters) }); } @@ -222,17 +222,17 @@ export class DashboardScreenWidgetComponent implements OnInit, OnDestroy { /** * Save the widget modifications * - * @param formData The form data + * @param formGroup The form group */ - public saveWidget(formData: FormData) { + public saveWidget(formGroup: UntypedFormGroup) { this.loading = true; const projectWidgetRequest: ProjectWidgetRequest = { widgetId: this.projectWidget.widgetId, customStyle: this.projectWidget.customStyle, - backendConfig: Object.keys(formData) - .filter((key: string) => formData[key] != null && String(formData[key]).trim() !== '') - .map((key: string) => `${key}=${String(formData[key]).replace(/\n/g, '\\n')}`) + backendConfig: Object.keys(formGroup) + .filter((key: string) => formGroup.get(key).value != null && String(formGroup.get(key).value).trim() !== '') + .map((key: string) => `${key}=${String(formGroup.get(key).value).replace(/\n/g, '\\n')}`) .join('\n') }; diff --git a/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts b/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts index d06dda8f0..9ff66e538 100644 --- a/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts +++ b/src/main/webapp/app/dashboard/components/wizard/add-widget-to-project-wizard/add-widget-to-project-wizard.component.ts @@ -29,6 +29,7 @@ import { import { ProjectWidget } from '../../../../shared/models/backend/project-widget/project-widget'; import { HttpProjectService } from '../../../../shared/services/backend/http-project/http-project.service'; import { Project } from '../../../../shared/models/backend/project/project'; +import { UntypedFormGroup } from '@angular/forms'; @Component({ templateUrl: '../../../../shared/components/wizard/wizard.component.html', @@ -82,7 +83,7 @@ export class AddWidgetToProjectWizardComponent extends WizardComponent implement /** * {@inheritDoc} */ - protected override saveWizard(formData: FormData): void { + protected override saveWizard(formGroup: UntypedFormGroup): void { this.httpProjectService.getById(this.dashboardToken).subscribe((project: Project) => { this.httpProjectWidgetsService.getAllByProjectToken(this.dashboardToken).subscribe((widgets: ProjectWidget[]) => { let row = 1; @@ -103,15 +104,15 @@ export class AddWidgetToProjectWizardComponent extends WizardComponent implement } const projectWidgetRequest: ProjectWidgetRequest = { - widgetId: formData[ProjectWidgetFormStepsService.selectWidgetStepKey][ProjectWidgetFormStepsService.widgetIdFieldKey], - backendConfig: Object.keys(formData[ProjectWidgetFormStepsService.configureWidgetStepKey]) + widgetId: formGroup.get(ProjectWidgetFormStepsService.selectWidgetStepKey).value[ProjectWidgetFormStepsService.widgetIdFieldKey], + backendConfig: Object.keys(formGroup.get(ProjectWidgetFormStepsService.configureWidgetStepKey).value) .filter( (key: string) => - formData[ProjectWidgetFormStepsService.configureWidgetStepKey][key] != null && - String(formData[ProjectWidgetFormStepsService.configureWidgetStepKey][key]).trim() !== '' + formGroup.get(ProjectWidgetFormStepsService.configureWidgetStepKey).value[key] != null && + String(formGroup.get(ProjectWidgetFormStepsService.configureWidgetStepKey).value[key]).trim() !== '' ) .map( - (key: string) => `${key}=${String(formData[ProjectWidgetFormStepsService.configureWidgetStepKey][key]).replace(/\n/g, '\\n')}` + (key: string) => `${key}=${String(formGroup.get(ProjectWidgetFormStepsService.configureWidgetStepKey).value[key]).replace(/\n/g, '\\n')}` ) .join('\n'), gridColumn: column, diff --git a/src/main/webapp/app/shared/components/form-sidenav/form-sidenav.component.ts b/src/main/webapp/app/shared/components/form-sidenav/form-sidenav.component.ts index b599abaea..758c689ca 100644 --- a/src/main/webapp/app/shared/components/form-sidenav/form-sidenav.component.ts +++ b/src/main/webapp/app/shared/components/form-sidenav/form-sidenav.component.ts @@ -151,7 +151,7 @@ export class FormSidenavComponent implements OnInit, OnDestroy { this.formService.validate(this.formGroup); if (this.formGroup.valid) { - this.configuration.save(this.formGroup.value); + this.configuration.save(this.formGroup); this.closeSidenav(); } } diff --git a/src/main/webapp/app/shared/components/wizard/wizard.component.ts b/src/main/webapp/app/shared/components/wizard/wizard.component.ts index 537da3743..67b9c08ff 100644 --- a/src/main/webapp/app/shared/components/wizard/wizard.component.ts +++ b/src/main/webapp/app/shared/components/wizard/wizard.component.ts @@ -274,9 +274,9 @@ export class WizardComponent implements OnInit { * Hook used to save the wizard * Implemented by child component * - * @param formData The value of the form + * @param formGroup The form group */ - protected saveWizard(formData: FormData): void {} + protected saveWizard(formGroup: UntypedFormGroup): void {} /** * Check if the stepper form is valid before saving the data @@ -285,7 +285,7 @@ export class WizardComponent implements OnInit { this.formService.validate(this.stepperFormGroup); if (this.stepperFormGroup.valid) { - this.saveWizard(this.stepperFormGroup.value); + this.saveWizard(this.stepperFormGroup); } } } diff --git a/src/main/webapp/app/shared/models/frontend/sidenav/form-sidenav-configuration.ts b/src/main/webapp/app/shared/models/frontend/sidenav/form-sidenav-configuration.ts index acc68cc7b..60643c995 100644 --- a/src/main/webapp/app/shared/models/frontend/sidenav/form-sidenav-configuration.ts +++ b/src/main/webapp/app/shared/models/frontend/sidenav/form-sidenav-configuration.ts @@ -21,6 +21,7 @@ import { ValueChangedEvent } from '../form/value-changed-event'; import { Observable } from 'rxjs'; import { SlideToggleButtonConfiguration } from '../button/slide-toggle/slide-toggle-button-configuration'; import { DashboardScreenComponent } from '../../../../dashboard/components/dashboard-screen/dashboard-screen.component'; +import { UntypedFormGroup } from '@angular/forms'; /** * Configuration used by the form sidenav @@ -44,7 +45,7 @@ export interface FormSidenavConfiguration { /** * The function to call when the form should be sent */ - save?: (object: any) => void; + save?: (formGroup: UntypedFormGroup) => void; /** * Function to call when a value of a field has changed From 9fdf839535dfd92fc3284528309ef48cfd98baee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Greffier?= Date: Sat, 23 Dec 2023 17:25:41 +0100 Subject: [PATCH 07/12] Fix crash when saving widget edit --- .../dashboard-screen-widget.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen-widget/dashboard-screen-widget.component.ts b/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen-widget/dashboard-screen-widget.component.ts index 7a22491c6..cd985bab0 100644 --- a/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen-widget/dashboard-screen-widget.component.ts +++ b/src/main/webapp/app/dashboard/components/dashboard-screen/dashboard-screen-widget/dashboard-screen-widget.component.ts @@ -230,7 +230,7 @@ export class DashboardScreenWidgetComponent implements OnInit, OnDestroy { const projectWidgetRequest: ProjectWidgetRequest = { widgetId: this.projectWidget.widgetId, customStyle: this.projectWidget.customStyle, - backendConfig: Object.keys(formGroup) + backendConfig: Object.keys(formGroup.value) .filter((key: string) => formGroup.get(key).value != null && String(formGroup.get(key).value).trim() !== '') .map((key: string) => `${key}=${String(formGroup.get(key).value).replace(/\n/g, '\\n')}`) .join('\n') From 1c829e22a87ecd3624ec8fc86c089a266d940cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Greffier?= Date: Tue, 26 Dec 2023 03:10:12 +0100 Subject: [PATCH 08/12] Fix some typing issue --- .../dashboard-detail.component.ts | 23 +++++-------------- .../form-sidenav/form-sidenav.component.html | 2 +- .../file-input/file-input.component.html | 2 +- .../inputs/file-input/file-input.component.ts | 4 ++-- .../inputs/input/input.component.html | 2 +- .../inputs/input/input.component.ts | 7 +++--- .../sidenav/form-sidenav-configuration.ts | 6 ++--- .../shared/records/material-icon.record.ts | 6 ++++- 8 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/main/webapp/app/dashboard/components/dashboard-detail/dashboard-detail.component.ts b/src/main/webapp/app/dashboard/components/dashboard-detail/dashboard-detail.component.ts index ae5efa99e..800641231 100644 --- a/src/main/webapp/app/dashboard/components/dashboard-detail/dashboard-detail.component.ts +++ b/src/main/webapp/app/dashboard/components/dashboard-detail/dashboard-detail.component.ts @@ -36,7 +36,6 @@ import { } from '../../../shared/services/frontend/form-fields/project-form-fields/project-form-fields.service'; import { mergeMap, switchMap, takeUntil, tap } from 'rxjs/operators'; import { EMPTY, Observable, of, Subject } from 'rxjs'; -import { DashboardScreenComponent } from '../dashboard-screen/dashboard-screen.component'; import { MatDialog } from '@angular/material/dialog'; import { MaterialIconRecords } from '../../../shared/records/material-icon.record'; import { ValueChangedEvent } from '../../../shared/models/frontend/form/value-changed-event'; @@ -66,14 +65,15 @@ import { UntypedFormGroup } from '@angular/forms'; }) export class DashboardDetailComponent implements OnInit, OnDestroy { /** - * Subject used to unsubscribe all the subscriptions when the component is destroyed + * The dashboard screen */ - private unsubscribe: Subject = new Subject(); + @ViewChild('dashboardScreen', { read: ElementRef }) + public dashboardScreen: ElementRef; /** - * The dashboard html (as HTML Element) + * Subject used to unsubscribe all the subscriptions when the component is destroyed */ - public dashboardScreen: DashboardScreenComponent; + private unsubscribe: Subject = new Subject(); /** * Hold the configuration of the header component @@ -378,7 +378,7 @@ export class DashboardDetailComponent implements OnInit, OnDestroy { this.sidenavService.openFormSidenav({ title: 'dashboard.edit', formFields: this.projectFormFieldsService.generateProjectFormFields(this.project), - belongingComponent: this.dashboardScreen, + componentRef: this.dashboardScreen, save: (formGroup: UntypedFormGroup) => this.editDashboard(formGroup) }); } @@ -558,15 +558,4 @@ export class DashboardDetailComponent implements OnInit, OnDestroy { public handlingDashboardDisconnect(): void { this.router.navigate(['/home']); } - - /** - * Set the dashboard screen component - * @param content The dashboard screen component - */ - @ViewChild('dashboardScreen', { read: ElementRef }) - public set content(content: DashboardScreenComponent) { - if (content) { - this.dashboardScreen = content; - } - } } diff --git a/src/main/webapp/app/shared/components/form-sidenav/form-sidenav.component.html b/src/main/webapp/app/shared/components/form-sidenav/form-sidenav.component.html index 88ecaaec7..fc7a695bb 100644 --- a/src/main/webapp/app/shared/components/form-sidenav/form-sidenav.component.html +++ b/src/main/webapp/app/shared/components/form-sidenav/form-sidenav.component.html @@ -16,7 +16,7 @@

{{ configuration.title | translate | uppercase }}

diff --git a/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.html b/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.html index 43f15314a..a63e1b4a0 100644 --- a/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.html +++ b/src/main/webapp/app/shared/components/inputs/file-input/file-input.component.html @@ -15,7 +15,7 @@