DURACOM-235 Lint fix

This commit is contained in:
Mattia Vianelli
2024-05-06 16:47:34 +02:00
parent 57563ddf96
commit a525b066ce
6 changed files with 58 additions and 42 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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<any>;
@@ -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: {},

View File

@@ -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<T extends Collection | Community> 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<T extends Collection | Community> 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<T extends Collection | Community> 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<NoContent>) => {
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<T extends Collection | Community> 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<T extends Collection | Community> 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<T extends Collection | Community> implements On
*/
private fetchUpdatedDso(): Observable<RemoteData<T>> {
return this.dsoService.findById(this.dso.id, false, true, followLink('logo')).pipe(
getFirstCompletedRemoteData()
getFirstCompletedRemoteData(),
) as Observable<RemoteData<T>>;
}

View File

@@ -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 */
},
};

View File

@@ -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<TDomain extends Community | Collection> imp
onSubmit(event) {
if (!isEmpty(event.operations)) {
this.dsoDataService.patch(event.dso, event.operations).pipe(getFirstCompletedRemoteData())
.subscribe(async (response: RemoteData<DSpaceObject>) => {
.subscribe( (response: RemoteData<DSpaceObject>) => {
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`));