From a525b066ceff128d97e3935f3464aebd129e6cee Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Mon, 6 May 2024 16:47:34 +0200 Subject: [PATCH] DURACOM-235 Lint fix --- .../collection-form.component.ts | 41 ++++++++++++++----- .../community-form.component.ts | 2 +- .../comcol-form/comcol-form.component.spec.ts | 11 ++--- .../comcol-form/comcol-form.component.ts | 29 ++++++++----- .../comcol-metadata.component.spec.ts | 4 +- .../comcol-metadata.component.ts | 13 ++---- 6 files changed, 58 insertions(+), 42 deletions(-) diff --git a/src/app/collection-page/collection-form/collection-form.component.ts b/src/app/collection-page/collection-form/collection-form.component.ts index 2c21d64cd3..0758435db8 100644 --- a/src/app/collection-page/collection-form/collection-form.component.ts +++ b/src/app/collection-page/collection-form/collection-form.component.ts @@ -1,33 +1,54 @@ -import { AsyncPipe, NgClass, NgIf, } from '@angular/common'; -import { ChangeDetectorRef, Component, Input, OnChanges, OnInit, SimpleChange, SimpleChanges, } from '@angular/core'; +import { + AsyncPipe, + NgClass, + NgIf, +} from '@angular/common'; +import { + ChangeDetectorRef, + Component, + Input, + OnChanges, + OnInit, + SimpleChange, + SimpleChanges, +} from '@angular/core'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { DynamicFormControlModel, DynamicFormOptionConfig, DynamicFormService, DynamicSelectModel, } from '@ng-dynamic-forms/core'; -import { TranslateModule, TranslateService, } from '@ngx-translate/core'; +import { + TranslateModule, + TranslateService, +} from '@ngx-translate/core'; import { Observable } from 'rxjs'; -import { hasNoValue, isNotNull, } from 'src/app/shared/empty.util'; +import { + hasNoValue, + isNotNull, +} from 'src/app/shared/empty.util'; -import { Collection } from '../../core/shared/collection.model'; -import { ComColFormComponent } from '../../shared/comcol/comcol-forms/comcol-form/comcol-form.component'; -import { NotificationsService } from '../../shared/notifications/notifications.service'; -import { CollectionDataService } from '../../core/data/collection-data.service'; import { AuthService } from '../../core/auth/auth.service'; import { ObjectCacheService } from '../../core/cache/object-cache.service'; +import { CollectionDataService } from '../../core/data/collection-data.service'; import { EntityTypeDataService } from '../../core/data/entity-type-data.service'; import { RequestService } from '../../core/data/request.service'; +import { Collection } from '../../core/shared/collection.model'; import { ItemType } from '../../core/shared/item-relationships/item-type.model'; import { NONE_ENTITY_TYPE } from '../../core/shared/item-relationships/item-type.resource-type'; import { MetadataValue } from '../../core/shared/metadata.models'; import { getFirstSucceededRemoteListPayload } from '../../core/shared/operators'; -import { collectionFormEntityTypeSelectionConfig, collectionFormModels, } from './collection-form.models'; -import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { ComColFormComponent } from '../../shared/comcol/comcol-forms/comcol-form/comcol-form.component'; import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component'; import { FormComponent } from '../../shared/form/form.component'; +import { NotificationsService } from '../../shared/notifications/notifications.service'; import { UploaderComponent } from '../../shared/upload/uploader/uploader.component'; import { VarDirective } from '../../shared/utils/var.directive'; +import { + collectionFormEntityTypeSelectionConfig, + collectionFormModels, +} from './collection-form.models'; /** * Form used for creating and editing collections diff --git a/src/app/community-page/community-form/community-form.component.ts b/src/app/community-page/community-form/community-form.component.ts index 2afba89d74..d32d9e408f 100644 --- a/src/app/community-page/community-form/community-form.component.ts +++ b/src/app/community-page/community-form/community-form.component.ts @@ -10,6 +10,7 @@ import { SimpleChange, SimpleChanges, } from '@angular/core'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { DynamicFormControlModel, DynamicFormService, @@ -33,7 +34,6 @@ import { FormComponent } from '../../shared/form/form.component'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { UploaderComponent } from '../../shared/upload/uploader/uploader.component'; import { VarDirective } from '../../shared/utils/var.directive'; -import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; /** * Form used for creating and editing communities diff --git a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.spec.ts b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.spec.ts index c0f3e3c376..2035c313fe 100644 --- a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.spec.ts +++ b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.spec.ts @@ -29,17 +29,12 @@ import { hasValue } from '../../../empty.util'; import { FormComponent } from '../../../form/form.component'; import { AuthServiceMock } from '../../../mocks/auth.service.mock'; import { NotificationsService } from '../../../notifications/notifications.service'; -import { - createFailedRemoteDataObject$, - createSuccessfulRemoteDataObject$, -} from '../../../remote-data.utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils'; import { NotificationsServiceStub } from '../../../testing/notifications-service.stub'; import { UploaderComponent } from '../../../upload/uploader/uploader.component'; import { VarDirective } from '../../../utils/var.directive'; import { ComcolPageLogoComponent } from '../../comcol-page-logo/comcol-page-logo.component'; import { ComColFormComponent } from './comcol-form.component'; -import { Operation } from 'fast-json-patch'; -import { createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils'; describe('ComColFormComponent', () => { let comp: ComColFormComponent; @@ -82,7 +77,7 @@ describe('ComColFormComponent', () => { const dsoService = Object.assign({ getLogoEndpoint: () => observableOf(logoEndpoint), deleteLogo: () => createSuccessfulRemoteDataObject$({}), - findById: () => createSuccessfulRemoteDataObject$({}) + findById: () => createSuccessfulRemoteDataObject$({}), }); const notificationsService = new NotificationsServiceStub(); @@ -92,7 +87,7 @@ describe('ComColFormComponent', () => { const requestServiceStub = jasmine.createSpyObj('requestService', { removeByHrefSubstring: {}, - setStaleByHrefSubstring: {} + setStaleByHrefSubstring: {}, }); const objectCacheStub = jasmine.createSpyObj('objectCache', { remove: {}, diff --git a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts index 77cd8c2c1f..0c80ce0d1d 100644 --- a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts +++ b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts @@ -13,6 +13,10 @@ import { ViewChild, } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; +import { + NgbModal, + NgbModalRef, +} from '@ng-bootstrap/ng-bootstrap'; import { DynamicFormControlModel, DynamicFormService, @@ -27,10 +31,15 @@ import { FileUploader } from 'ng2-file-upload'; import { BehaviorSubject, combineLatest as observableCombineLatest, + Observable, Subscription, + switchMap, } from 'rxjs'; +import { + filter, + take, +} from 'rxjs/operators'; -import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, Subscription, switchMap } from 'rxjs'; import { AuthService } from '../../../../core/auth/auth.service'; import { ObjectCacheService } from '../../../../core/cache/object-cache.service'; import { ComColDataService } from '../../../../core/data/comcol-data.service'; @@ -46,6 +55,7 @@ import { import { NoContent } from '../../../../core/shared/NoContent.model'; import { getFirstCompletedRemoteData } from '../../../../core/shared/operators'; import { ResourceType } from '../../../../core/shared/resource-type'; +import { ConfirmationModalComponent } from '../../../confirmation-modal/confirmation-modal.component'; import { hasValue, isNotEmpty, @@ -54,12 +64,9 @@ import { FormComponent } from '../../../form/form.component'; import { NotificationsService } from '../../../notifications/notifications.service'; import { UploaderComponent } from '../../../upload/uploader/uploader.component'; import { UploaderOptions } from '../../../upload/uploader/uploader-options.model'; +import { followLink } from '../../../utils/follow-link-config.model'; import { VarDirective } from '../../../utils/var.directive'; import { ComcolPageLogoComponent } from '../../comcol-page-logo/comcol-page-logo.component'; -import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; -import { followLink } from '../../../utils/follow-link-config.model'; -import { ConfirmationModalComponent } from '../../../confirmation-modal/confirmation-modal.component'; -import { filter, take } from 'rxjs/operators'; /** * A form for creating and editing Communities or Collections @@ -220,7 +227,7 @@ export class ComColFormComponent implements On this.refreshDSO$.pipe( switchMap(() => this.refreshDsoCache()), filter(rd => rd.hasSucceeded), - ).subscribe(({ payload }) => this.dso = payload) + ).subscribe(({ payload }) => this.dso = payload), ); } @@ -324,7 +331,7 @@ export class ComColFormComponent implements On */ subscribeToConfirmationResponse(modalRef: NgbModalRef): void { modalRef.componentInstance.response.pipe( - take(1) + take(1), ).subscribe((confirmed: boolean) => { if (confirmed) { this.handleLogoDeletion(); @@ -338,7 +345,7 @@ export class ComColFormComponent implements On handleLogoDeletion(): void { if (hasValue(this.dso.id) && hasValue(this.dso._links.logo)) { this.dsoService.deleteLogo(this.dso).pipe( - getFirstCompletedRemoteData() + getFirstCompletedRemoteData(), ).subscribe((response: RemoteData) => { const successMessageKey = `${this.type.value}.edit.logo.notifications.delete.success`; const errorMessageKey = `${this.type.value}.edit.logo.notifications.delete.error`; @@ -362,7 +369,7 @@ export class ComColFormComponent implements On this.refreshDSO$.next(); this.notificationsService.success( this.translate.get(`${successMessageKey}.title`), - this.translate.get(`${successMessageKey}.content`) + this.translate.get(`${successMessageKey}.content`), ); } @@ -374,7 +381,7 @@ export class ComColFormComponent implements On private handleFailedDeletion(errorMessageKey: string, errorMessage: string): void { this.notificationsService.error( this.translate.get(`${errorMessageKey}.title`), - errorMessage + errorMessage, ); } @@ -399,7 +406,7 @@ export class ComColFormComponent implements On */ private fetchUpdatedDso(): Observable> { return this.dsoService.findById(this.dso.id, false, true, followLink('logo')).pipe( - getFirstCompletedRemoteData() + getFirstCompletedRemoteData(), ) as Observable>; } diff --git a/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts b/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts index afa8e7d5f9..e2b71b3941 100644 --- a/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts +++ b/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts @@ -195,12 +195,12 @@ describe('ComColMetadataComponent', () => { dso: new Community(), uploader: { options: { - url: '' + url: '', }, queue: [], /* eslint-disable no-empty,@typescript-eslint/no-empty-function */ uploadAll: () => { - } + }, /* eslint-enable no-empty,@typescript-eslint/no-empty-function */ }, }; diff --git a/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts b/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts index 2f6b70f61f..b895f6c80d 100644 --- a/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts +++ b/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts @@ -15,10 +15,6 @@ import { import { ComColDataService } from '../../../../../core/data/comcol-data.service'; import { RemoteData } from '../../../../../core/data/remote-data'; -import { ActivatedRoute, Router } from '@angular/router'; -import { map, take } from 'rxjs/operators'; -import { getFirstCompletedRemoteData, getFirstSucceededRemoteData } from '../../../../../core/shared/operators'; -import { isEmpty } from '../../../../empty.util'; import { Collection } from '../../../../../core/shared/collection.model'; import { Community } from '../../../../../core/shared/community.model'; import { DSpaceObject } from '../../../../../core/shared/dspace-object.model'; @@ -27,10 +23,7 @@ import { getFirstSucceededRemoteData, } from '../../../../../core/shared/operators'; import { ResourceType } from '../../../../../core/shared/resource-type'; -import { - hasValue, - isEmpty, -} from '../../../../empty.util'; +import { isEmpty } from '../../../../empty.util'; import { NotificationsService } from '../../../../notifications/notifications.service'; @Component({ @@ -72,9 +65,9 @@ export class ComcolMetadataComponent imp onSubmit(event) { if (!isEmpty(event.operations)) { this.dsoDataService.patch(event.dso, event.operations).pipe(getFirstCompletedRemoteData()) - .subscribe(async (response: RemoteData) => { + .subscribe( (response: RemoteData) => { if (response.hasSucceeded) { - await this.router.navigate([this.frontendURL, event.dso.uuid]); // todo: ok not to await this? + this.router.navigate([this.frontendURL, event.dso.uuid]); // todo: ok not to await this? this.notificationsService.success(null, this.translate.get(`${this.type.value}.edit.notifications.success`)); } else if (response.statusCode === 403) { this.notificationsService.error(null, this.translate.get(`${this.type.value}.edit.notifications.unauthorized`));