Optimise imports using inject function (#8557)

* optimise AuthGuard

* optimise UploadBase

* optimise BaseAuthenticationService

* optimise FormComponent

* optimise BaseCloudService

* optimise card view
This commit is contained in:
Denys Vuika 2023-06-05 17:31:44 +01:00 committed by GitHub
parent 991f11178d
commit f5abce8baa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 99 additions and 330 deletions

View File

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

View 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$))

View File

@ -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) => {

View File

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

View File

@ -24,16 +24,19 @@ import {
UrlTree
} from '@angular/router';
import { AuthenticationService } from '../services/authentication.service';
import {
AppConfigService,
AppConfigValues
} from '../../app-config/app-config.service';
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
import { OauthConfigModel } from '../models/oauth-config.model';
import { MatDialog } from '@angular/material/dialog';
import { StorageService } from '../../common/services/storage.service';
import { Observable } from 'rxjs';
import { inject } from '@angular/core';
export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
protected authenticationService = inject(AuthenticationService);
protected router = inject(Router);
protected appConfigService = inject(AppConfigService);
protected dialog = inject(MatDialog);
private storageService = inject(StorageService);
protected get withCredentials(): boolean {
return this.appConfigService.get<boolean>(
@ -42,15 +45,6 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
);
}
constructor(
protected authenticationService: AuthenticationService,
protected router: Router,
protected appConfigService: AppConfigService,
protected dialog: MatDialog,
private storageService: StorageService
) {
}
abstract checkLogin(
activeRoute: ActivatedRouteSnapshot,
redirectUrl: string

View File

@ -16,26 +16,13 @@
*/
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router';
import { AppConfigService } from '../../app-config/app-config.service';
import { AuthenticationService } from '../services/authentication.service';
import { ActivatedRouteSnapshot, UrlTree } from '@angular/router';
import { AuthGuardBase } from './auth-guard-base';
import { MatDialog } from '@angular/material/dialog';
import { StorageService } from '../../common/services/storage.service';
@Injectable({
providedIn: 'root'
})
export class AuthGuardBpm extends AuthGuardBase {
constructor(authenticationService: AuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog,
storageService: StorageService) {
super(authenticationService, router, appConfigService, dialog, storageService);
}
async checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Promise<boolean | UrlTree> {
if (this.authenticationService.isBpmLoggedIn() || this.withCredentials) {
return true;

View File

@ -16,28 +16,13 @@
*/
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot, Router, UrlTree
} from '@angular/router';
import { AuthenticationService } from '../services/authentication.service';
import { AppConfigService } from '../../app-config/app-config.service';
import { ActivatedRouteSnapshot, UrlTree } from '@angular/router';
import { AuthGuardBase } from './auth-guard-base';
import { MatDialog } from '@angular/material/dialog';
import { StorageService } from '../../common/services/storage.service';
@Injectable({
providedIn: 'root'
})
export class AuthGuardEcm extends AuthGuardBase {
constructor(authenticationService: AuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog,
storageService: StorageService) {
super(authenticationService, router, appConfigService, dialog, storageService);
}
async checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Promise<boolean | UrlTree> {
if (this.authenticationService.isEcmLoggedIn() || this.withCredentials) {
return true;

View File

@ -16,13 +16,9 @@
*/
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router';
import { AuthenticationService } from '../services/authentication.service';
import { AppConfigService } from '../../app-config/app-config.service';
import { ActivatedRouteSnapshot, UrlTree } from '@angular/router';
import { AuthGuardBase } from './auth-guard-base';
import { JwtHelperService } from '../services/jwt-helper.service';
import { MatDialog } from '@angular/material/dialog';
import { StorageService } from '../../common/services/storage.service';
@Injectable({
providedIn: 'root'
@ -31,13 +27,8 @@ export class AuthGuard extends AuthGuardBase {
ticketChangeBind: any;
constructor(private jwtHelperService: JwtHelperService,
authenticationService: AuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog,
storageService: StorageService) {
super(authenticationService, router, appConfigService, dialog, storageService);
constructor(private jwtHelperService: JwtHelperService) {
super();
this.ticketChangeBind = this.ticketChange.bind(this);
window.addEventListener('storage', this.ticketChangeBind);

View File

@ -18,26 +18,11 @@
import { Observable, of, throwError } from 'rxjs';
import { Injectable } from '@angular/core';
import { AuthenticationService } from '../services/authentication.service';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { CookieService } from '../../common/services/cookie.service';
import { LogService } from '../../common/services/log.service';
import { StorageService } from '../../common/services/storage.service';
import { AppConfigService } from '../../app-config/app-config.service';
@Injectable({
providedIn: 'root'
})
export class AuthenticationMock extends AuthenticationService {
constructor(
appConfig: AppConfigService,
storageService: StorageService,
alfrescoApi: AlfrescoApiService,
cookie: CookieService,
logService: LogService
) {
super(alfrescoApi, appConfig, cookie, logService, storageService);
}
login(username: string, password: string): Observable<{ type: string; ticket: any }> {
if (username === 'fake-username' && password === 'fake-password') {
return of({ type: 'type', ticket: 'ticket' });

View File

@ -15,16 +15,13 @@
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { OAuthService, OAuthStorage } from 'angular-oauth2-oidc';
import { EMPTY, Observable } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { AppConfigValues } from '../../app-config/app-config.service';
import { BaseAuthenticationService } from '../../services/base-authentication.service';
import { CookieService } from '../../common/services/cookie.service';
import { JwtHelperService } from '../services/jwt-helper.service';
import { LogService } from '../../common/services/log.service';
import { AuthConfigService } from '../oidc/auth-config.service';
import { AuthService } from './auth.service';
@ -32,19 +29,15 @@ import { AuthService } from './auth.service';
providedIn: 'root'
})
export class OIDCAuthenticationService extends BaseAuthenticationService {
private authStorage = inject(OAuthStorage);
private oauthService = inject(OAuthService);
private readonly authConfig = inject(AuthConfigService);
private readonly auth = inject(AuthService);
readonly supportCodeFlow = true;
constructor(
alfrescoApi: AlfrescoApiService,
appConfig: AppConfigService,
cookie: CookieService,
logService: LogService,
private authStorage: OAuthStorage,
private oauthService: OAuthService,
private readonly authConfig: AuthConfigService,
private readonly auth: AuthService
) {
super(alfrescoApi, appConfig, cookie, logService);
constructor() {
super();
this.alfrescoApi.alfrescoApiInitialized.subscribe(() => {
this.alfrescoApi.getInstance().reply('logged-in', () => {
this.onLogin.next();

View File

@ -15,12 +15,9 @@
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { Observable, from } from 'rxjs';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { CookieService } from '../../common/services/cookie.service';
import { LogService } from '../../common/services/log.service';
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
import { AppConfigValues } from '../../app-config/app-config.service';
import { map, catchError, tap } from 'rxjs/operators';
import { JwtHelperService } from './jwt-helper.service';
import { StorageService } from '../../common/services/storage.service';
@ -30,16 +27,11 @@ import { BaseAuthenticationService } from '../../services/base-authentication.se
providedIn: 'root'
})
export class AuthenticationService extends BaseAuthenticationService {
private storageService = inject(StorageService);
readonly supportCodeFlow = false;
constructor(
alfrescoApi: AlfrescoApiService,
appConfig: AppConfigService,
cookie: CookieService,
logService: LogService,
private storageService: StorageService
) {
super(alfrescoApi, appConfig, cookie, logService);
constructor() {
super();
this.alfrescoApi.alfrescoApiInitialized.subscribe(() => {
this.alfrescoApi.getInstance().reply('logged-in', () => {
this.onLogin.next();

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Input, OnDestroy, Directive } from '@angular/core';
import { Input, OnDestroy, Directive, inject } from '@angular/core';
import { CardViewUpdateService } from '../services/card-view-update.service';
import { CardViewItem } from '../interfaces/card-view.interfaces';
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
@ -25,13 +25,14 @@ import { takeUntil } from 'rxjs/operators';
@Directive()
// eslint-disable-next-line @angular-eslint/directive-class-suffix
export abstract class BaseCardView<T extends CardViewItem> implements OnDestroy {
protected cardViewUpdateService = inject(CardViewUpdateService);
@Input()
property: T;
protected destroy$ = new Subject<boolean>();
constructor(protected cardViewUpdateService: CardViewUpdateService) {
constructor() {
this.cardViewUpdateService.updateItem$
.pipe(takeUntil(this.destroy$))
.subscribe((itemModel: CardViewBaseItemModel) => {

View File

@ -17,7 +17,6 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { CardViewArrayItemModel } from '../../models/card-view-arrayitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { BaseCardView } from '../base-card-view';
@Component({
@ -27,11 +26,6 @@ import { BaseCardView } from '../base-card-view';
encapsulation: ViewEncapsulation.None
})
export class CardViewArrayItemComponent extends BaseCardView<CardViewArrayItemModel> {
constructor(cardViewUpdateService: CardViewUpdateService) {
super(cardViewUpdateService);
}
clicked(): void {
if (this.isClickable()) {
this.cardViewUpdateService.clicked(this.property);

View File

@ -18,7 +18,6 @@
import { Component, Input } from '@angular/core';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { CardViewBoolItemModel } from '../../models/card-view-boolitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { BaseCardView } from '../base-card-view';
@Component({
@ -27,14 +26,9 @@ import { BaseCardView } from '../base-card-view';
})
export class CardViewBoolItemComponent extends BaseCardView<CardViewBoolItemModel> {
@Input()
editable: boolean;
constructor(cardViewUpdateService: CardViewUpdateService) {
super(cardViewUpdateService);
}
isEditable() {
return this.editable && this.property.editable;
}

View File

@ -21,7 +21,6 @@ import { DatetimeAdapter, MAT_DATETIME_FORMATS, MatDatetimepickerComponent } fro
import { MAT_MOMENT_DATETIME_FORMATS, MomentDatetimeAdapter } from '@mat-datetimepicker/moment';
import moment, { Moment } from 'moment';
import { CardViewDateItemModel } from '../../models/card-view-dateitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { UserPreferencesService, UserPreferenceValues } from '../../../common/services/user-preferences.service';
import { MomentDateAdapter } from '../../../common/utils/moment-date-adapter';
import { MOMENT_DATE_FORMATS } from '../../../common/utils/moment-date-formats.model';
@ -66,13 +65,12 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
private onDestroy$ = new Subject<boolean>();
constructor(cardViewUpdateService: CardViewUpdateService,
private dateAdapter: DateAdapter<Moment>,
constructor(private dateAdapter: DateAdapter<Moment>,
private userPreferencesService: UserPreferencesService,
private appConfig: AppConfigService,
private clipboardService: ClipboardService,
private translateService: TranslationService) {
super(cardViewUpdateService);
super();
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
}

View File

@ -16,7 +16,6 @@
*/
import { Component, Input, OnChanges, ViewEncapsulation } from '@angular/core';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { CardViewKeyValuePairsItemModel } from '../../models/card-view.models';
import { CardViewKeyValuePairsItemType } from '../../interfaces/card-view.interfaces';
import { MatTableDataSource } from '@angular/material/table';
@ -37,10 +36,6 @@ export class CardViewKeyValuePairsItemComponent extends BaseCardView<CardViewKey
values: CardViewKeyValuePairsItemType[];
matTableValues: MatTableDataSource<CardViewKeyValuePairsItemType>;
constructor(cardViewUpdateService: CardViewUpdateService) {
super(cardViewUpdateService);
}
ngOnChanges() {
this.values = this.property.value || [];
this.matTableValues = new MatTableDataSource(this.values);

View File

@ -17,7 +17,6 @@
import { Component, Input } from '@angular/core';
import { CardViewMapItemModel } from '../../models/card-view-mapitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { BaseCardView } from '../base-card-view';
@Component({
@ -33,10 +32,6 @@ export class CardViewMapItemComponent extends BaseCardView<CardViewMapItemModel>
@Input()
displayEmpty: boolean = true;
constructor(cardViewUpdateService: CardViewUpdateService) {
super(cardViewUpdateService);
}
showProperty() {
return this.displayEmpty || !this.property.isEmpty();
}

View File

@ -15,9 +15,8 @@
* limitations under the License.
*/
import { Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
import { Component, Input, OnChanges, OnDestroy, OnInit, inject } from '@angular/core';
import { CardViewSelectItemModel } from '../../models/card-view-selectitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { BehaviorSubject, combineLatest, Observable, Subject } from 'rxjs';
import { CardViewSelectItemOption } from '../../interfaces/card-view.interfaces';
import { MatSelectChange } from '@angular/material/select';
@ -31,6 +30,7 @@ import { takeUntil, map } from 'rxjs/operators';
styleUrls: ['./card-view-selectitem.component.scss']
})
export class CardViewSelectItemComponent extends BaseCardView<CardViewSelectItemModel<string | number>> implements OnInit, OnChanges, OnDestroy {
private appConfig = inject(AppConfigService);
static HIDE_FILTER_LIMIT = 5;
@Input() editable: boolean = false;
@ -51,10 +51,6 @@ export class CardViewSelectItemComponent extends BaseCardView<CardViewSelectItem
list$: Observable<CardViewSelectItemOption<string | number>[]> = null;
constructor(cardViewUpdateService: CardViewUpdateService, private appConfig: AppConfigService) {
super(cardViewUpdateService);
}
ngOnChanges(): void {
this.value = this.property.value;
}

View File

@ -17,7 +17,6 @@
import { ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { CardViewTextItemModel } from '../../models/card-view-textitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { BaseCardView } from '../base-card-view';
import { MatChipInputEvent } from '@angular/material/chips';
import { ClipboardService } from '../../../clipboard/clipboard.service';
@ -67,11 +66,10 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
private onDestroy$ = new Subject<boolean>();
constructor(cardViewUpdateService: CardViewUpdateService,
private clipboardService: ClipboardService,
constructor(private clipboardService: ClipboardService,
private translateService: TranslationService,
private cd: ChangeDetectorRef) {
super(cardViewUpdateService);
super();
}
ngOnChanges(changes: SimpleChanges): void {

View File

@ -23,36 +23,35 @@ import { AppConfigService, AppConfigValues } from '../app-config/app-config.serv
import { AlfrescoApiService } from './alfresco-api.service';
import { CookieService } from '../common/services/cookie.service';
import { LogService } from '../common/services/log.service';
import { inject } from '@angular/core';
const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME';
const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30;
export abstract class BaseAuthenticationService {
protected alfrescoApi = inject(AlfrescoApiService);
protected appConfig = inject(AppConfigService);
protected cookie = inject(CookieService);
private logService = inject(LogService);
protected bearerExcludedUrls: readonly string[] = ['resources/', 'assets/', 'auth/realms', 'idp/'];
protected redirectUrl: RedirectionModel = null;
onLogin = new ReplaySubject<any>(1);
onLogout = new ReplaySubject<any>(1);
_peopleApi: PeopleApi;
private _peopleApi: PeopleApi;
get peopleApi(): PeopleApi {
this._peopleApi = this._peopleApi ?? new PeopleApi(this.alfrescoApi.getInstance());
return this._peopleApi;
}
_profileApi: UserProfileApi;
private _profileApi: UserProfileApi;
get profileApi(): UserProfileApi {
this._profileApi = this._profileApi ?? new UserProfileApi(this.alfrescoApi.getInstance());
return this._profileApi;
}
constructor(
protected alfrescoApi: AlfrescoApiService,
protected appConfig: AppConfigService,
protected cookie: CookieService,
private logService: LogService
) {}
abstract readonly supportCodeFlow: boolean;
abstract getToken(): string;
abstract isLoggedIn(): boolean;

View File

@ -16,13 +16,7 @@
*/
import { Injectable } from '@angular/core';
import {
AlfrescoApiService,
FormValues,
AppConfigService,
FormModel,
FormFieldOption
} from '@alfresco/adf-core';
import { FormValues, FormModel, FormFieldOption } from '@alfresco/adf-core';
import { Observable, from, EMPTY } from 'rxjs';
import { expand, map, reduce, switchMap } from 'rxjs/operators';
import { TaskDetailsCloudModel } from '../../task/start-task/models/task-details-cloud.model';
@ -43,11 +37,8 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
return this._uploadApi;
}
constructor(
apiService: AlfrescoApiService,
appConfigService: AppConfigService
) {
super(apiService, appConfigService);
constructor() {
super();
}
/**

View File

@ -16,7 +16,6 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
import { map } from 'rxjs/operators';
import { from, Observable } from 'rxjs';
import { BaseCloudService } from '../../services/base-cloud.service';
@ -27,12 +26,6 @@ import { FormDefinitionSelectorCloudServiceInterface } from './form-definition-s
providedIn: 'root'
})
export class FormDefinitionSelectorCloudService extends BaseCloudService implements FormDefinitionSelectorCloudServiceInterface {
constructor(apiService: AlfrescoApiService,
appConfigService: AppConfigService) {
super(apiService, appConfigService);
}
/**
* Get all forms of an app.
*

View File

@ -16,7 +16,6 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core';
import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model';
import { Observable, throwError } from 'rxjs';
import { ProcessListCloudSortingModel } from '../models/process-list-sorting.model';
@ -25,13 +24,6 @@ import { map } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class ProcessListCloudService extends BaseCloudService {
constructor(apiService: AlfrescoApiService,
appConfigService: AppConfigService,
private logService: LogService) {
super(apiService, appConfigService);
}
private getProcess(
callback: (queryUrl: string, queryParams: any) => Observable<any>,
defaultQueryUrl: string,

View File

@ -16,7 +16,6 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core';
import { Observable, throwError } from 'rxjs';
import { BaseCloudService } from '../../../services/base-cloud.service';
import { map } from 'rxjs/operators';
@ -27,13 +26,6 @@ import { TaskListCloudSortingModel } from '../../../models/task-list-sorting.mod
@Injectable({ providedIn: 'root' })
export class ProcessTaskListCloudService extends BaseCloudService implements TaskListCloudServiceInterface {
constructor(apiService: AlfrescoApiService,
appConfigService: AppConfigService,
protected logService: LogService) {
super(apiService, appConfigService);
}
/**
* Finds a task using an object with optional query properties.
*

View File

@ -15,7 +15,6 @@
* limitations under the License.
*/
import { AlfrescoApiService, LogService, AppConfigService } from '@alfresco/adf-core';
import { Injectable } from '@angular/core';
import { Observable, Subject, throwError } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
@ -29,15 +28,8 @@ import { ProcessCloudInterface } from './process-cloud.interface';
providedIn: 'root'
})
export class ProcessCloudService extends BaseCloudService implements ProcessCloudInterface {
dataChangesDetected = new Subject<ProcessInstanceCloud>();
constructor(apiService: AlfrescoApiService,
appConfigService: AppConfigService,
private logService: LogService) {
super(apiService, appConfigService);
}
/**
* Gets details of a process instance.
*

View File

@ -15,7 +15,6 @@
* limitations under the License.
*/
import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core';
import { Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';
import { map } from 'rxjs/operators';
@ -29,13 +28,6 @@ import { TaskVariableCloud } from '../../../form/models/task-variable-cloud.mode
providedIn: 'root'
})
export class StartProcessCloudService extends BaseCloudService {
constructor(apiService: AlfrescoApiService,
private logService: LogService,
appConfigService: AppConfigService) {
super(apiService, appConfigService);
}
/**
* Gets the process definitions associated with an app.
*

View File

@ -15,7 +15,8 @@
* limitations under the License.
*/
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core';
import { Injectable, inject } from '@angular/core';
import { from, Observable } from 'rxjs';
export interface CallApiParams {
@ -33,7 +34,11 @@ export interface CallApiParams {
responseType?: string;
}
@Injectable()
export class BaseCloudService {
protected apiService = inject(AlfrescoApiService);
protected appConfigService = inject(AppConfigService);
protected logService = inject(LogService);
protected defaultParams: CallApiParams = {
path: '',
@ -42,10 +47,6 @@ export class BaseCloudService {
accepts: ['application/json']
};
constructor(
protected apiService: AlfrescoApiService,
protected appConfigService: AppConfigService) {}
getBasePath(appName: string): string {
return appName
? `${this.contextRoot}/${appName}`

View File

@ -22,21 +22,16 @@ import { WebSocketLink } from '@apollo/client/link/ws';
import { onError } from '@apollo/client/link/error';
import { getMainDefinition } from '@apollo/client/utilities';
import { Injectable } from '@angular/core';
import { AppConfigService, AlfrescoApiService } from '@alfresco/adf-core';
import { BaseCloudService } from './base-cloud.service';
@Injectable({
providedIn: 'root'
})
export class NotificationCloudService extends BaseCloudService {
appsListening = [];
constructor(apiService: AlfrescoApiService,
appConfigService: AppConfigService,
public apollo: Apollo,
private http: HttpLink) {
super(apiService, appConfigService);
constructor(public apollo: Apollo, private http: HttpLink) {
super();
}
private get webSocketHost() {

View File

@ -17,20 +17,11 @@
import { Injectable } from '@angular/core';
import { PreferenceCloudServiceInterface } from './preference-cloud.interface';
import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core';
import { throwError, Observable } from 'rxjs';
import { BaseCloudService } from './base-cloud.service';
@Injectable({ providedIn: 'root' })
export class UserPreferenceCloudService extends BaseCloudService implements PreferenceCloudServiceInterface {
constructor(
apiService: AlfrescoApiService,
appConfigService: AppConfigService,
private logService: LogService) {
super(apiService, appConfigService);
}
/**
* Gets user preferences
*

View File

@ -16,7 +16,6 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { StartTaskCloudRequestModel } from '../start-task/models/start-task-cloud-request.model';
@ -25,13 +24,6 @@ import { BaseCloudService } from '../../services/base-cloud.service';
@Injectable({ providedIn: 'root' })
export class StartTaskCloudService extends BaseCloudService {
constructor(
apiService: AlfrescoApiService,
appConfigService: AppConfigService) {
super(apiService, appConfigService);
}
/**
* @deprecated in 3.5.0, use TaskCloudService instead.
* Creates a new standalone task.

View File

@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService, LogService, AppConfigService, CardViewArrayItem, TranslationService } from '@alfresco/adf-core';
import { CardViewArrayItem, TranslationService } from '@alfresco/adf-core';
import { throwError, Observable, of, Subject } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import {
@ -30,10 +30,7 @@ import {
import { BaseCloudService } from '../../services/base-cloud.service';
import { StartTaskCloudRequestModel } from '../start-task/models/start-task-cloud-request.model';
import { ProcessDefinitionCloud } from '../../models/process-definition-cloud.model';
import {
DEFAULT_TASK_PRIORITIES,
TaskPriorityOption
} from '../models/task.model';
import { DEFAULT_TASK_PRIORITIES, TaskPriorityOption } from '../models/task.model';
import { TaskCloudServiceInterface } from './task-cloud.service.interface';
import { IdentityUserService } from '../../people/services/identity-user.service';
@ -45,13 +42,10 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
dataChangesDetected$ = new Subject();
constructor(
apiService: AlfrescoApiService,
appConfigService: AppConfigService,
private logService: LogService,
private translateService: TranslationService,
private identityUserService: IdentityUserService
) {
super(apiService, appConfigService);
super();
}
/**

View File

@ -15,7 +15,6 @@
* limitations under the License.
*/
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
import { Injectable, Inject } from '@angular/core';
import { Observable, of, BehaviorSubject, throwError } from 'rxjs';
import { TaskFilterCloudModel } from '../models/filter-cloud.model';
@ -55,10 +54,8 @@ export class TaskFilterCloudService extends BaseCloudService {
private identityUserService: IdentityUserService,
@Inject(TASK_FILTERS_SERVICE_TOKEN)
public preferenceService: PreferenceCloudServiceInterface,
apiService: AlfrescoApiService,
appConfigService: AppConfigService,
private notificationCloudService: NotificationCloudService) {
super(apiService, appConfigService);
super();
this.filtersSubject = new BehaviorSubject([]);
this.filters$ = this.filtersSubject.asObservable();
}

View File

@ -16,7 +16,6 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core';
import { ServiceTaskQueryCloudRequestModel, ServiceTaskIntegrationContextCloudModel } from '../models/service-task-cloud.model';
import { Observable, throwError } from 'rxjs';
import { TaskListCloudSortingModel } from '../../../models/task-list-sorting.model';
@ -25,13 +24,6 @@ import { map } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class ServiceTaskListCloudService extends BaseCloudService {
constructor(apiService: AlfrescoApiService,
appConfigService: AppConfigService,
private logService: LogService) {
super(apiService, appConfigService);
}
/**
* Finds a task using an object with optional query properties.
*

View File

@ -16,7 +16,6 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core';
import { TaskQueryCloudRequestModel } from '../../../models/filter-cloud-model';
import { Observable, throwError } from 'rxjs';
import { TaskListCloudSortingModel } from '../../../models/task-list-sorting.model';
@ -27,13 +26,6 @@ import { TaskListCloudServiceInterface } from '../../../services/task-list-cloud
@Injectable({ providedIn: 'root' })
export class TaskListCloudService extends BaseCloudService implements TaskListCloudServiceInterface {
constructor(apiService: AlfrescoApiService,
appConfigService: AppConfigService,
protected logService: LogService) {
super(apiService, appConfigService);
}
/**
* Finds a task using an object with optional query properties.
*

View File

@ -24,7 +24,8 @@ import {
SimpleChanges,
OnInit,
OnDestroy,
OnChanges
OnChanges,
inject
} from '@angular/core';
import {
WidgetVisibilityService,
@ -57,6 +58,14 @@ import { FormDefinitionModel } from './model/form-definition.model';
encapsulation: ViewEncapsulation.None
})
export class FormComponent extends FormBaseComponent implements OnInit, OnDestroy, OnChanges {
protected formService = inject(FormService);
protected taskFormService = inject(TaskFormService);
protected taskService = inject(TaskService);
protected editorService = inject(EditorService);
protected modelService = inject(ModelService);
protected visibilityService = inject(WidgetVisibilityService);
protected ecmModelService = inject(EcmModelService);
protected nodeService = inject(NodesApiService);
/** Underlying form model instance. */
@Input()
@ -92,36 +101,29 @@ export class FormComponent extends FormBaseComponent implements OnInit, OnDestro
/** Emitted when the form is submitted with the `Save` or custom outcomes. */
@Output()
formSaved: EventEmitter<FormModel> = new EventEmitter<FormModel>();
formSaved = new EventEmitter<FormModel>();
/** Emitted when the form is submitted with the `Complete` outcome. */
@Output()
formCompleted: EventEmitter<FormModel> = new EventEmitter<FormModel>();
formCompleted = new EventEmitter<FormModel>();
/** Emitted when form content is clicked. */
@Output()
formContentClicked: EventEmitter<ContentLinkModel> = new EventEmitter<ContentLinkModel>();
formContentClicked = new EventEmitter<ContentLinkModel>();
/** Emitted when the form is loaded or reloaded. */
@Output()
formLoaded: EventEmitter<FormModel> = new EventEmitter<FormModel>();
formLoaded = new EventEmitter<FormModel>();
/** Emitted when form values are refreshed due to a data property change. */
@Output()
formDataRefreshed: EventEmitter<FormModel> = new EventEmitter<FormModel>();
formDataRefreshed = new EventEmitter<FormModel>();
debugMode: boolean = false;
protected onDestroy$ = new Subject<boolean>();
constructor(protected formService: FormService,
protected taskFormService: TaskFormService,
protected taskService: TaskService,
protected editorService: EditorService,
protected modelService: ModelService,
protected visibilityService: WidgetVisibilityService,
protected ecmModelService: EcmModelService,
protected nodeService: NodesApiService) {
constructor() {
super();
}

View File

@ -26,15 +26,12 @@ import {
SimpleChanges,
ViewChild,
ViewEncapsulation,
OnDestroy
OnDestroy,
inject
} from '@angular/core';
import { FormComponent } from './form.component';
import { ContentLinkModel, FormService, WidgetVisibilityService, FormOutcomeModel } from '@alfresco/adf-core';
import { ContentLinkModel, FormOutcomeModel } from '@alfresco/adf-core';
import { ProcessService } from '../process-list/services/process.service';
import { EditorService } from './services/editor.service';
import { ModelService } from './services/model.service';
import { TaskFormService } from './services/task-form.service';
import { TaskService } from './services/task.service';
@Component({
selector: 'adf-start-form',
@ -43,6 +40,7 @@ import { TaskService } from './services/task.service';
encapsulation: ViewEncapsulation.None
})
export class StartFormComponent extends FormComponent implements OnChanges, OnInit, OnDestroy {
public processService = inject(ProcessService);
/** Definition ID of the process to start, this parameter can not be use in combination with processId */
@Input()
@ -66,22 +64,17 @@ export class StartFormComponent extends FormComponent implements OnChanges, OnIn
/** Emitted when the user clicks one of the outcome buttons that completes the form. */
@Output()
outcomeClick: EventEmitter<any> = new EventEmitter<any>();
outcomeClick = new EventEmitter<any>();
/** Emitted when a field of the form is clicked. */
@Output()
formContentClicked: EventEmitter<ContentLinkModel> = new EventEmitter<ContentLinkModel>();
formContentClicked = new EventEmitter<ContentLinkModel>();
@ViewChild('outcomesContainer')
outcomesContainer: ElementRef = null;
constructor(public processService: ProcessService,
taskFormService: TaskFormService,
taskService: TaskService,
editorService: EditorService,
modelService: ModelService,
formService: FormService, visibilityService: WidgetVisibilityService) {
super(formService, taskFormService, taskService, editorService, modelService, visibilityService, null, null);
constructor() {
super();
this.showTitle = false;
}