Skip to content

Commit

Permalink
Improve TSConfig (#829)
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

* Improve tsconfig

* Fix index

* Fix crash when saving widget edit

* Fix some typing issue

* Fix last typing issue

* fix lint

* Fix abstract http type

* Remove unused Karma conf
  • Loading branch information
loicgreffier authored Jan 5, 2024
1 parent 54e204b commit 88c0a53
Show file tree
Hide file tree
Showing 59 changed files with 268 additions and 382 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@angular-eslint/directive-selector": [
"error",
{
"prefix": "suricate",
"style": "camelCase",
"type": "attribute"
}
Expand Down
42 changes: 0 additions & 42 deletions karma.conf.js

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -75,4 +77,4 @@
"ts-node": "~10.9.1",
"typescript": "~5.2.2"
}
}
}
42 changes: 0 additions & 42 deletions src/main/webapp/.eslintrc.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ 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';
import { UntypedFormGroup } from '@angular/forms';

/**
* Component used to display the list of widgets
Expand All @@ -34,7 +38,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<CategoryParameter> {
export class ConfigurationsComponent extends ListComponent<CategoryParameter, WidgetConfigurationRequest> {
/**
* Constructor
*
Expand All @@ -55,14 +59,14 @@ export class ConfigurationsComponent extends ListComponent<CategoryParameter> {
/**
* {@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;
Expand All @@ -71,7 +75,7 @@ export class ConfigurationsComponent extends ListComponent<CategoryParameter> {
/**
* {@inheritDoc}
*/
protected getThirdLabel(configuration: CategoryParameter): string {
protected override getThirdLabel(configuration: CategoryParameter): string {
return configuration.category.name;
}

Expand Down Expand Up @@ -141,11 +145,11 @@ export class ConfigurationsComponent extends ListComponent<CategoryParameter> {
* @param configuration The repository clicked on the list
* @param saveCallback The function to call when save button is clicked
*/
private openFormSidenav(event: Event, configuration: CategoryParameter, saveCallback: (configuration: CategoryParameter) => 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)
});
}

Expand All @@ -171,10 +175,10 @@ export class ConfigurationsComponent extends ListComponent<CategoryParameter> {
/**
* Update a configuration
*
* @param configuration The configuration to update
* @param formGroup The form group
*/
private updateConfiguration(configuration: CategoryParameter): void {
this.httpCategoryParametersService.update(configuration.key, configuration).subscribe(() => {
private updateConfiguration(formGroup: UntypedFormGroup): void {
this.httpCategoryParametersService.update(formGroup.value.key, formGroup.value).subscribe(() => {
this.refreshList();
this.toastService.sendMessage('configuration.update.success', ToastTypeEnum.SUCCESS);
});
Expand Down
16 changes: 9 additions & 7 deletions src/main/webapp/app/admin/dashboards/dashboards.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ 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',
styleUrls: ['../../shared/components/list/list.component.scss']
})
export class DashboardsComponent extends ListComponent<Project | ProjectRequest> {
export class DashboardsComponent extends ListComponent<Project, ProjectRequest> {
/**
* Project selected in the list for modifications
*/
Expand Down Expand Up @@ -75,21 +76,21 @@ export class DashboardsComponent extends ListComponent<Project | ProjectRequest>
/**
* {@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]);
}

Expand Down Expand Up @@ -152,16 +153,17 @@ export class DashboardsComponent extends ListComponent<Project | ProjectRequest>
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(() => {
Expand Down
25 changes: 14 additions & 11 deletions src/main/webapp/app/admin/repositories/repositories.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,7 +39,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<Repository> {
export class RepositoriesComponent extends ListComponent<Repository, RepositoryRequest> {
/**
* The repository being built
*/
Expand Down Expand Up @@ -69,21 +70,21 @@ export class RepositoriesComponent extends ListComponent<Repository> {
/**
* {@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,
Expand Down Expand Up @@ -148,7 +149,7 @@ export class RepositoriesComponent extends ListComponent<Repository> {
/**
* {@inheritDoc}
*/
protected onItemsLoaded() {
protected override onItemsLoaded() {
this.initHeaderConfiguration();
this.dragAndDropDisabled = !this.objectsPaged.content || this.objectsPaged.content.length <= 1;
}
Expand All @@ -160,13 +161,13 @@ export class RepositoriesComponent extends ListComponent<Repository> {
* @param repository The repository clicked on the list
* @param saveCallback The function to call when save button is clicked
*/
private openFormSidenav(event: Event, repository: Repository, saveCallback: (repositoryRequest: RepositoryRequest) => 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)
});
}
Expand Down Expand Up @@ -211,9 +212,10 @@ export class RepositoriesComponent extends ListComponent<Repository> {
/**
* Update a repository
* If the repository is enabled, all the repositories will be resynchronized in priority order
* @param repositoryRequest The new repository with the modification made on the form
* @param formGroup The form group
*/
private updateRepository(repositoryRequest: RepositoryRequest): void {
private updateRepository(formGroup: UntypedFormGroup): void {
const repositoryRequest: RepositoryRequest = formGroup.value;
if (repositoryRequest.login.trim().length === 0) {
repositoryRequest.login = null;
}
Expand All @@ -239,7 +241,8 @@ export class RepositoriesComponent extends ListComponent<Repository> {
* Function used to add a repository
* @param repositoryRequest The new repository to add with the modification made on the form
*/
private addRepository(repositoryRequest: RepositoryRequest): void {
private addRepository(fromGroup: UntypedFormGroup): void {
const repositoryRequest: RepositoryRequest = fromGroup.value;
this.disableAllReposSync.next(true);
this.dragAndDropDisabled = true;
if (repositoryRequest.enabled) {
Expand Down Expand Up @@ -287,7 +290,7 @@ export class RepositoriesComponent extends ListComponent<Repository> {
/**
* 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;
});
Expand Down
Loading

0 comments on commit 88c0a53

Please sign in to comment.