mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Optimise imports using inject function (#8557)
* optimise AuthGuard * optimise UploadBase * optimise BaseAuthenticationService * optimise FormComponent * optimise BaseCloudService * optimise card view
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, NgZone } from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { TranslationService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { UploadBase } from './upload-base';
|
||||
import { UploadFilesEvent } from '../upload-files.event';
|
||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||
@@ -32,12 +32,6 @@ import { FileUploadErrorEvent } from '../../../common/events/file.event';
|
||||
template: 'test component'
|
||||
})
|
||||
export class UploadTestComponent extends UploadBase {
|
||||
|
||||
constructor(protected uploadService: UploadService,
|
||||
protected translationService: TranslationService,
|
||||
protected ngZone: NgZone) {
|
||||
super(uploadService, translationService, ngZone);
|
||||
}
|
||||
}
|
||||
|
||||
const file = { name: 'bigFile.png', size: 1000 } as File;
|
||||
|
@@ -19,7 +19,7 @@ import { FileInfo, TranslationService } from '@alfresco/adf-core';
|
||||
import { FileUploadErrorEvent } from '../../../common/events/file.event';
|
||||
import { FileModel } from '../../../common/models/file.model';
|
||||
import { UploadService } from '../../../common/services/upload.service';
|
||||
import { EventEmitter, Input, Output, OnInit, OnDestroy, NgZone, Directive } from '@angular/core';
|
||||
import { EventEmitter, Input, Output, OnInit, OnDestroy, NgZone, Directive, inject } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { UploadFilesEvent } from '../upload-files.event';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
@@ -27,6 +27,9 @@ import { takeUntil } from 'rxjs/operators';
|
||||
@Directive()
|
||||
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
||||
export abstract class UploadBase implements OnInit, OnDestroy {
|
||||
protected uploadService = inject(UploadService);
|
||||
protected translationService = inject(TranslationService);
|
||||
protected ngZone = inject(NgZone);
|
||||
|
||||
/** Sets a limit on the maximum size (in bytes) of a file to be uploaded.
|
||||
* Has no effect if undefined.
|
||||
@@ -82,11 +85,6 @@ export abstract class UploadBase implements OnInit, OnDestroy {
|
||||
|
||||
protected onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(protected uploadService: UploadService,
|
||||
protected translationService: TranslationService,
|
||||
protected ngZone: NgZone) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.uploadService.fileUploadError
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
|
@@ -15,15 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
EXTENDIBLE_COMPONENT, FileUtils,
|
||||
LogService, TranslationService
|
||||
} from '@alfresco/adf-core';
|
||||
import { EXTENDIBLE_COMPONENT, FileUtils, LogService } from '@alfresco/adf-core';
|
||||
import {
|
||||
Component, EventEmitter, forwardRef, Input,
|
||||
OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation, NgZone
|
||||
OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation, inject
|
||||
} from '@angular/core';
|
||||
import { UploadService } from '../../common/services/upload.service';
|
||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||
import { ContentService } from '../../common/services/content.service';
|
||||
import { AllowableOperationsEnum } from '../../common/models/allowable-operations.enum';
|
||||
@@ -43,6 +39,9 @@ import { NodeAllowableOperationSubject } from '../../interfaces/node-allowable-o
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class UploadButtonComponent extends UploadBase implements OnInit, OnChanges, NodeAllowableOperationSubject {
|
||||
private contentService = inject(ContentService);
|
||||
private nodesApiService = inject(NodesApiService);
|
||||
protected logService = inject(LogService);
|
||||
|
||||
/** Allows/disallows upload folders (only for Chrome). */
|
||||
@Input()
|
||||
@@ -66,20 +65,10 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
|
||||
|
||||
/** Emitted when create permission is missing. */
|
||||
@Output()
|
||||
permissionEvent: EventEmitter<PermissionModel> = new EventEmitter<PermissionModel>();
|
||||
permissionEvent = new EventEmitter<PermissionModel>();
|
||||
|
||||
private hasAllowableOperations: boolean = false;
|
||||
|
||||
protected permissionValue: Subject<boolean> = new Subject<boolean>();
|
||||
|
||||
constructor(protected uploadService: UploadService,
|
||||
private contentService: ContentService,
|
||||
private nodesApiService: NodesApiService,
|
||||
protected translationService: TranslationService,
|
||||
protected logService: LogService,
|
||||
protected ngZone: NgZone) {
|
||||
super(uploadService, translationService, ngZone);
|
||||
}
|
||||
protected permissionValue = new Subject<boolean>();
|
||||
|
||||
ngOnInit() {
|
||||
this.permissionValue.subscribe((permission: boolean) => {
|
||||
|
@@ -15,15 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
EXTENDIBLE_COMPONENT, FileInfo, FileUtils,
|
||||
NotificationService, TranslationService
|
||||
} from '@alfresco/adf-core';
|
||||
import { Component, forwardRef, ViewEncapsulation, NgZone } from '@angular/core';
|
||||
import { EXTENDIBLE_COMPONENT, FileInfo, FileUtils, NotificationService } from '@alfresco/adf-core';
|
||||
import { Component, forwardRef, ViewEncapsulation, inject } from '@angular/core';
|
||||
import { NodeAllowableOperationSubject } from '../../interfaces/node-allowable-operation-subject.interface';
|
||||
import { UploadBase } from './base-upload/upload-base';
|
||||
import { AllowableOperationsEnum } from '../../common/models/allowable-operations.enum';
|
||||
import { UploadService } from '../../common/services/upload.service';
|
||||
import { ContentService } from '../../common/services/content.service';
|
||||
import { FileModel } from '../../common/models/file.model';
|
||||
|
||||
@@ -38,14 +34,8 @@ import { FileModel } from '../../common/models/file.model';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class UploadDragAreaComponent extends UploadBase implements NodeAllowableOperationSubject {
|
||||
|
||||
constructor(protected uploadService: UploadService,
|
||||
protected translationService: TranslationService,
|
||||
private notificationService: NotificationService,
|
||||
private contentService: ContentService,
|
||||
protected ngZone: NgZone) {
|
||||
super(uploadService, translationService, ngZone);
|
||||
}
|
||||
private notificationService = inject(NotificationService);
|
||||
private contentService = inject(ContentService);
|
||||
|
||||
/**
|
||||
* Method called when files are dropped in the drag area.
|
||||
|
Reference in New Issue
Block a user