Skip to content

Commit

Permalink
Replace injector instance by inject (#824)
Browse files Browse the repository at this point in the history
* Improve widget parameter encryption documentation

* Fix typos

* Fix typo in readme

* Replace injector with inject
  • Loading branch information
loicgreffier authored Dec 11, 2023
1 parent 33671df commit 64886eb
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -40,14 +40,12 @@ export class ConfigurationsComponent extends ListComponent<CategoryParameter> {
*
* @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();
Expand Down
8 changes: 3 additions & 5 deletions src/main/webapp/app/admin/dashboards/dashboards.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -49,15 +49,13 @@ export class DashboardsComponent extends ListComponent<Project | ProjectRequest>
* @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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -55,15 +55,13 @@ export class RepositoriesComponent extends ListComponent<Repository> {
* @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();
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/webapp/app/admin/users/users.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -45,14 +45,12 @@ export class UsersComponent extends ListComponent<User> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

import { Component, Injector } from '@angular/core';
import { Component } from '@angular/core';
import { InputComponent } from '../input/input.component';

/**
Expand All @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

import { Component, Injector } from '@angular/core';
import { Component } from '@angular/core';
import { InputComponent } from '../input/input.component';

/**
Expand All @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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
*/
Expand Down
19 changes: 9 additions & 10 deletions src/main/webapp/app/shared/components/list/list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -146,15 +146,14 @@ export class ListComponent<T> implements OnInit, OnDestroy {
* Constructor
*
* @param childService The child http service
* @param injector Manage services injection
*/
constructor(private readonly childService: AbstractHttpService<T>, 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<T>) {
this.dialogService = inject(DialogService);
this.sidenavService = inject(SidenavService);
this.translateService = inject(TranslateService);
this.toastService = inject(ToastService);
this.router = inject(Router);
this.formService = inject(FormService);
}

/**
Expand Down
22 changes: 12 additions & 10 deletions src/main/webapp/app/shared/components/wizard/wizard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/main/webapp/app/widget/catalog/catalog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -33,10 +33,9 @@ export class CatalogComponent extends ListComponent<Widget | WidgetRequest> {
* 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();
Expand Down

0 comments on commit 64886eb

Please sign in to comment.