Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optmise injections and imports #3174

Merged
merged 7 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

import { Component, OnInit, ViewEncapsulation, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AppExtensionService, ContentApiService, PageComponent } from '@alfresco/aca-shared';
import { AppStore, NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { Store } from '@ngrx/store';
import { ContentManagementService } from '../../services/content-management.service';
import { ContentApiService, PageComponent } from '@alfresco/aca-shared';
import { NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { Subject } from 'rxjs';

@Component({
Expand All @@ -42,14 +40,8 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
onDestroy$ = new Subject<boolean>();
activeTab = 1;

constructor(
private route: ActivatedRoute,
private contentApi: ContentApiService,
store: Store<AppStore>,
content: ContentManagementService,
extensions: AppExtensionService
) {
super(store, extensions, content);
constructor(private route: ActivatedRoute, private contentApi: ContentApiService) {
super();
}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { Store } from '@ngrx/store';
import { SiteEntry, FavoritePaging, Pagination } from '@alfresco/js-api';
import { ContentManagementService } from '../../services/content-management.service';
import { AppExtensionService, AppHookService, ContentApiService, PageComponent } from '@alfresco/aca-shared';
import { AppHookService, ContentApiService, PageComponent } from '@alfresco/aca-shared';
import { NavigateLibraryAction } from '@alfresco/aca-shared/store';
import { UserPreferencesService } from '@alfresco/adf-core';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';
Expand All @@ -43,20 +40,15 @@ export class FavoriteLibrariesComponent extends PageComponent implements OnInit
});
isLoading = false;
list: FavoritePaging;
isSmallScreen = false;
columns: DocumentListPresetRef[] = [];

constructor(
content: ContentManagementService,
store: Store<any>,
extensions: AppExtensionService,
private appHookService: AppHookService,
private contentApiService: ContentApiService,
private breakpointObserver: BreakpointObserver,
private preferences: UserPreferencesService,
private changeDetectorRef: ChangeDetectorRef
) {
super(store, extensions, content);
super();
}

ngOnInit() {
Expand All @@ -69,11 +61,7 @@ export class FavoriteLibrariesComponent extends PageComponent implements OnInit
this.appHookService.libraryUpdated.subscribe(() => this.reloadList()),
this.appHookService.libraryJoined.subscribe(() => this.reloadList()),
this.appHookService.libraryLeft.subscribe(() => this.reloadList()),
this.appHookService.favoriteLibraryToggle.subscribe(() => this.reloadList()),

this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => {
this.isSmallScreen = result.matches;
})
this.appHookService.favoriteLibraryToggle.subscribe(() => this.reloadList())
]);
this.columns = this.extensions.documentListPresets.favoriteLibraries || [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,28 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { AcaFileAutoDownloadService, AppExtensionService, ContentApiService, PageComponent } from '@alfresco/aca-shared';
import { AppStore } from '@alfresco/aca-shared/store';
import { UploadService } from '@alfresco/adf-content-services';
import { ContentApiService, PageComponent } from '@alfresco/aca-shared';
import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, PathInfo } from '@alfresco/js-api';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { debounceTime, map } from 'rxjs/operators';
import { ContentManagementService } from '../../services/content-management.service';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';

@Component({
templateUrl: './favorites.component.html'
})
export class FavoritesComponent extends PageComponent implements OnInit {
isSmallScreen = false;

columns: DocumentListPresetRef[] = [];

constructor(
private router: Router,
store: Store<AppStore>,
extensions: AppExtensionService,
private contentApi: ContentApiService,
content: ContentManagementService,
private uploadService: UploadService,
private breakpointObserver: BreakpointObserver,
fileAutoDownloadService: AcaFileAutoDownloadService
) {
super(store, extensions, content, fileAutoDownloadService);
constructor(private contentApi: ContentApiService) {
super();
}

ngOnInit() {
super.ngOnInit();

this.subscriptions = this.subscriptions.concat([
this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe((_) => this.reload()),
this.uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe((_) => this.reload()),

this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => {
this.isSmallScreen = result.matches;
})
this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe(() => this.reload()),
this.uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe(() => this.reload())
]);

this.columns = this.extensions.documentListPresets.favorites;
Expand Down
48 changes: 13 additions & 35 deletions projects/aca-content/src/lib/components/files/files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,63 +24,45 @@

import { ShowHeaderMode } from '@alfresco/adf-core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { ActivatedRoute, Params } from '@angular/router';
import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElement, PathElementEntity } from '@alfresco/js-api';
import { ContentManagementService } from '../../services/content-management.service';
import { NodeActionsService } from '../../services/node-actions.service';
import { AcaFileAutoDownloadService, AppExtensionService, ContentApiService, PageComponent } from '@alfresco/aca-shared';
import { SetCurrentFolderAction, isAdmin, AppStore, UploadFileVersionAction, showLoaderSelector } from '@alfresco/aca-shared/store';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { ContentApiService, PageComponent } from '@alfresco/aca-shared';
import { SetCurrentFolderAction, isAdmin, UploadFileVersionAction, showLoaderSelector } from '@alfresco/aca-shared/store';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { FilterSearch, ShareDataRow, UploadService, FileUploadEvent } from '@alfresco/adf-content-services';
import { FilterSearch, ShareDataRow, FileUploadEvent } from '@alfresco/adf-content-services';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';
import { Observable } from 'rxjs';

@Component({
templateUrl: './files.component.html'
})
export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
isValidPath = true;
isSmallScreen = false;
isAdmin = false;
selectedNode: MinimalNodeEntity;
queryParams = null;

showLoader$: Observable<boolean>;
showLoader$ = this.store.select(showLoaderSelector);
private nodePath: PathElement[];

columns: DocumentListPresetRef[] = [];

constructor(
private router: Router,
private route: ActivatedRoute,
private contentApi: ContentApiService,
store: Store<AppStore>,
private nodeActionsService: NodeActionsService,
private uploadService: UploadService,
content: ContentManagementService,
extensions: AppExtensionService,
private breakpointObserver: BreakpointObserver,
fileAutoDownloadService: AcaFileAutoDownloadService
) {
super(store, extensions, content, fileAutoDownloadService);
constructor(private route: ActivatedRoute, private contentApi: ContentApiService, private nodeActionsService: NodeActionsService) {
super();
}

ngOnInit() {
super.ngOnInit();

const { route, nodeActionsService, uploadService } = this;
const { data } = route.snapshot;
const { data } = this.route.snapshot;

this.title = data.title;

this.showLoader$ = this.store.select(showLoaderSelector);
route.queryParamMap.subscribe((queryMap: Params) => {
this.route.queryParamMap.subscribe((queryMap: Params) => {
this.queryParams = queryMap.params;
});

route.params.subscribe(({ folderId }: Params) => {
this.route.params.subscribe(({ folderId }: Params) => {
const nodeId = folderId || data.defaultNodeId;

this.contentApi.getNode(nodeId).subscribe(
Expand All @@ -100,13 +82,9 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
});

this.subscriptions = this.subscriptions.concat([
nodeActionsService.contentCopied.subscribe((nodes) => this.onContentCopied(nodes)),
uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe((file) => this.onFileUploadedEvent(file)),
uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe((file) => this.onFileUploadedEvent(file)),

this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => {
this.isSmallScreen = result.matches;
})
this.nodeActionsService.contentCopied.subscribe((nodes) => this.onContentCopied(nodes)),
this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe((file) => this.onFileUploadedEvent(file)),
this.uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe((file) => this.onFileUploadedEvent(file))
]);

this.store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,20 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { AppStore, NavigateLibraryAction } from '@alfresco/aca-shared/store';
import { NavigateLibraryAction } from '@alfresco/aca-shared/store';
import { SiteEntry } from '@alfresco/js-api';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { Component, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';
import { ContentManagementService } from '../../services/content-management.service';
import { AppExtensionService, AppHookService, PageComponent } from '@alfresco/aca-shared';
import { AppHookService, PageComponent } from '@alfresco/aca-shared';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';

@Component({
templateUrl: './libraries.component.html'
})
export class LibrariesComponent extends PageComponent implements OnInit {
isSmallScreen = false;

columns: DocumentListPresetRef[] = [];

constructor(
content: ContentManagementService,
store: Store<AppStore>,
extensions: AppExtensionService,
private appHookService: AppHookService,
private breakpointObserver: BreakpointObserver
) {
super(store, extensions, content);
constructor(private appHookService: AppHookService) {
super();
}

ngOnInit() {
Expand All @@ -55,11 +44,7 @@ export class LibrariesComponent extends PageComponent implements OnInit {
this.subscriptions.push(
this.appHookService.libraryDeleted.subscribe(() => this.reload()),
this.appHookService.libraryUpdated.subscribe(() => this.reload()),
this.appHookService.libraryLeft.subscribe(() => this.reload()),

this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => {
this.isSmallScreen = result.matches;
})
this.appHookService.libraryLeft.subscribe(() => this.reload())
);

this.columns = this.extensions.documentListPresets.libraries || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,27 @@
*/

import { Component, OnInit } from '@angular/core';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { MinimalNodeEntity } from '@alfresco/js-api';
import { ContentManagementService } from '../../services/content-management.service';
import { Store } from '@ngrx/store';
import { AppStore } from '@alfresco/aca-shared/store';
import { UploadService } from '@alfresco/adf-content-services';
import { debounceTime } from 'rxjs/operators';
import { Router } from '@angular/router';
import { AcaFileAutoDownloadService, AppExtensionService, PageComponent } from '@alfresco/aca-shared';
import { PageComponent } from '@alfresco/aca-shared';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';

@Component({
templateUrl: './recent-files.component.html'
})
export class RecentFilesComponent extends PageComponent implements OnInit {
isSmallScreen = false;

columns: DocumentListPresetRef[] = [];

constructor(
store: Store<AppStore>,
extensions: AppExtensionService,
content: ContentManagementService,
private uploadService: UploadService,
private breakpointObserver: BreakpointObserver,
private router: Router,
fileAutoDownloadService: AcaFileAutoDownloadService
) {
super(store, extensions, content, fileAutoDownloadService);
constructor() {
super();
}

ngOnInit() {
super.ngOnInit();

this.subscriptions = this.subscriptions.concat([
this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe(() => this.onFileUploadedEvent()),
this.uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe(() => this.onFileUploadedEvent()),

this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => {
this.isSmallScreen = result.matches;
})
this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe(() => this.reload()),
this.uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe(() => this.reload())
]);

this.columns = this.extensions.documentListPresets.recent || [];
Expand All @@ -78,8 +58,4 @@ export class RecentFilesComponent extends PageComponent implements OnInit {
handleNodeClick(event: Event) {
this.onNodeDoubleClick((event as CustomEvent).detail?.node);
}

private onFileUploadedEvent() {
this.reload();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { NavigateLibraryAction, AppStore } from '@alfresco/aca-shared/store';
import { NavigateLibraryAction } from '@alfresco/aca-shared/store';
import { NodePaging, Pagination, SiteEntry } from '@alfresco/js-api';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { Store } from '@ngrx/store';
import { ContentManagementService } from '../../../services/content-management.service';
import { SearchLibrariesQueryBuilderService } from './search-libraries-query-builder.service';
import { AppExtensionService, AppHookService, AppService, PageComponent } from '@alfresco/aca-shared';
import { AppHookService, AppService, PageComponent } from '@alfresco/aca-shared';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';

@Component({
Expand All @@ -39,7 +36,6 @@ import { DocumentListPresetRef } from '@alfresco/adf-extensions';
styleUrls: ['./search-libraries-results.component.scss']
})
export class SearchLibrariesResultsComponent extends PageComponent implements OnInit {
isSmallScreen = false;
searchedWord: string;
queryParamName = 'q';
data: NodePaging;
Expand All @@ -48,16 +44,12 @@ export class SearchLibrariesResultsComponent extends PageComponent implements On
columns: DocumentListPresetRef[] = [];

constructor(
private breakpointObserver: BreakpointObserver,
private librariesQueryBuilder: SearchLibrariesQueryBuilderService,
private route: ActivatedRoute,
private appHookService: AppHookService,
private appService: AppService,
store: Store<AppStore>,
extensions: AppExtensionService,
content: ContentManagementService
private appService: AppService
) {
super(store, extensions, content);
super();

librariesQueryBuilder.paging = {
skipCount: 0,
Expand Down Expand Up @@ -96,10 +88,6 @@ export class SearchLibrariesResultsComponent extends PageComponent implements On
this.appHookService.library400Error.next();
}
} catch (e) {}
}),

this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => {
this.isSmallScreen = result.matches;
})
);

Expand Down
Loading