-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Perf] Introduce server side pagination for selectors (#8274)
* feat: create routing for tabs * feat: improve lanaguage service * feat: create cached server data server * feat: caching task for 24 hours * feat: add new observable to `selectorService` * feat: change modidier private to public * feat: improve create task dialog * feat: create task table features * feat: replace table with router tabset * fix: deepscan * feat: add pagination type to task cache * feat: improve selector with pagination params * feat: add new input to generic ng selector * feat: update ISelector interface * feat: introduce server side pagination for task selectors * feat: infinite scroll on client selector * feat: removed 'tags' from relations in client selector request and updated method call to getClientWithPagination * refactor: code in various components and services to improve pagination and caching functionality * feat: add reset page functionality to client, project, and team selectors; updated task table component to use selected project and team IDs; refactored time tracker service to use toParams function * fix: remove "prefix" property from search term object in task table component. * feat: updated TimeTrackerService to use TaskStatisticsCacheService * fix: 'tags' from relations and modified join and where clauses in TimeTrackerService * feat: add search component with debounce and loading indicator, updated task table component to display loading spinner, and refactored cached server data source to handle loading state * fix: removed spinner from search component, updated search component to use distinctUntilChange and filter, and removed loading state handling from task table component * feat: update SelectComponent to use Subject<string> for typeahead instead of any" * fix: add search functionality to TaskSelectorService and TaskSelectorComponent, updated TimeTrackerService to include search term in API request * fix: add search functionality to client selector, project selector, and team selector components and services * feat: add typeToSearchText input property to SelectComponent and updated template to use it * refactor: moved nbSpinner to separate div, added absolute positioning and dimensions to .smart-table class * fix: relations and join from TimeTrackerService query parameters, update employeeId condition * refactored: tasks component, replaced ng-select with gauzy-select, updated imports and modules, and made minor template changes. * fix: Task Table component HTML and SCSS: wrapped spinner in ng-container, changed smart-table styles to use absolute positioning and added padding. * fix: remove resetPage calls from client-selector, project-selector, and team-selector components. * refactor: selector components to extend AbstractSelectorComponent, update search logic, and add NG_VALUE_ACCESSOR provider * feat: use selectors as `formControl` for reactive forms * refactor: selectors and make it reusable for reactive form and template binding form * refactor: selector store and components, update time tracker component and dialog * fix: max-width property * fix: cspell * Update project-cache.service.ts * Update client-cache.service.ts * Update teams-cache.service.ts --------- Co-authored-by: Ruslan Konviser <[email protected]>
- Loading branch information
Showing
49 changed files
with
970 additions
and
561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
packages/desktop-ui-lib/src/lib/services/client-cache.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { AbstractCacheService } from './abstract-cache.service'; | ||
import { IOrganizationContact } from '@gauzy/contracts'; | ||
import { IOrganizationContact, IPagination } from '@gauzy/contracts'; | ||
import { StorageService } from './storage.service'; | ||
import { Store } from '../services'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class ClientCacheService extends AbstractCacheService< | ||
IOrganizationContact[] | ||
IOrganizationContact[] | IPagination<IOrganizationContact> | ||
> { | ||
constructor( | ||
protected _storageService: StorageService<IOrganizationContact[]>, | ||
protected _storageService: StorageService<IOrganizationContact[] | IPagination<IOrganizationContact>>, | ||
protected _store: Store | ||
) { | ||
super(_storageService, _store); | ||
this.prefix = ClientCacheService.name.toString(); | ||
this.duration = 1 * 3600 * 1000; // 1 hour | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
export * from './abstract-cache.service'; | ||
export * from './client-cache.service'; | ||
export * from './employee-cache.service'; | ||
export * from './error-client.service'; | ||
export * from './error-handler.service'; | ||
export * from './error-server.service'; | ||
export * from './image-cache.service'; | ||
export * from './language-cache.service'; | ||
export * from './native-notification.service'; | ||
export * from './notification.service'; | ||
export * from './organizations-cache.service'; | ||
export * from './project-cache.service'; | ||
export * from './server-connection.service'; | ||
export * from './status-icon-service/status-icon-cache.service'; | ||
export * from './status-icon-service/status-icon.service'; | ||
export * from './storage.service'; | ||
export * from './store.service'; | ||
export * from './tag-cache.service'; | ||
export * from './tag.service'; | ||
export * from './task-cache.service'; | ||
export * from './task-priority-cache.service'; | ||
export * from './task-size-cache.service'; | ||
export * from './task-statistics-cache.service'; | ||
export * from './task-status-cache.service'; | ||
export * from './teams-cache.service'; | ||
export * from './time-log-cache.service'; | ||
export * from './time-slot-cache.service'; | ||
export * from './user-organization-cache.service'; | ||
export * from './error-client.service'; | ||
export * from './error-handler.service'; | ||
export * from './error-server.service'; | ||
export * from './native-notification.service'; | ||
export * from './notification.service'; | ||
export * from './toastr-notification.service'; | ||
export * from './store.service'; | ||
export * from './server-connection.service'; | ||
export * from './image-cache.service'; | ||
export * from './language-cache.service'; | ||
export * from './time-tracker-date.manager'; | ||
export * from './time-zone-manager'; | ||
export * from './task-status-cache.service'; | ||
export * from './teams-cache.service'; | ||
export * from './status-icon-service'; | ||
export * from './task-priority-cache.service'; | ||
export * from './task-size-cache.service'; | ||
export * from './tag.service'; | ||
export * from './toastr-notification.service'; | ||
export * from './user-organization-cache.service'; |
11 changes: 6 additions & 5 deletions
11
packages/desktop-ui-lib/src/lib/services/project-cache.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { IOrganizationProject, IPagination } from '@gauzy/contracts'; | ||
import { Store } from '../services'; | ||
import { AbstractCacheService } from './abstract-cache.service'; | ||
import { IOrganizationProject } from '@gauzy/contracts'; | ||
import { StorageService } from './storage.service'; | ||
import { Store } from '../services'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
providedIn: 'root' | ||
}) | ||
export class ProjectCacheService extends AbstractCacheService< | ||
IOrganizationProject[] | ||
IOrganizationProject[] | IPagination<IOrganizationProject> | ||
> { | ||
constructor( | ||
protected _storageService: StorageService<IOrganizationProject[]>, | ||
protected _storageService: StorageService<IOrganizationProject[] | IPagination<IOrganizationProject>>, | ||
protected _store: Store | ||
) { | ||
super(_storageService, _store); | ||
this.prefix = ProjectCacheService.name.toString(); | ||
this.duration = 1 * 3600 * 1000; // 1 hour | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
packages/desktop-ui-lib/src/lib/services/task-cache.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/desktop-ui-lib/src/lib/services/task-statistics-cache.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ITasksStatistics } from '@gauzy/contracts'; | ||
import { Store } from '.'; | ||
import { AbstractCacheService } from './abstract-cache.service'; | ||
import { StorageService } from './storage.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class TaskStatisticsCacheService extends AbstractCacheService<ITasksStatistics[]> { | ||
constructor(protected _storageService: StorageService<ITasksStatistics[]>, protected _store: Store) { | ||
super(_storageService, _store); | ||
this.prefix = TaskStatisticsCacheService.name.toString(); | ||
this.duration = 600 * 1000; // 1O minutes | ||
} | ||
} |
11 changes: 5 additions & 6 deletions
11
packages/desktop-ui-lib/src/lib/services/teams-cache.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { IOrganizationTeam, IPagination } from '@gauzy/contracts'; | ||
import { StorageService, Store } from '../services'; | ||
import { IOrganizationTeam } from '@gauzy/contracts'; | ||
import { AbstractCacheService } from './abstract-cache.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
providedIn: 'root' | ||
}) | ||
export class TeamsCacheService extends AbstractCacheService< | ||
IOrganizationTeam[] | ||
> { | ||
export class TeamsCacheService extends AbstractCacheService<IOrganizationTeam[] | IPagination<IOrganizationTeam>> { | ||
constructor( | ||
protected _storageService: StorageService<IOrganizationTeam[]>, | ||
protected _storageService: StorageService<IOrganizationTeam[] | IPagination<IOrganizationTeam>>, | ||
protected _store: Store | ||
) { | ||
super(_storageService, _store); | ||
this.prefix = TeamsCacheService.name.toString(); | ||
this.duration = 1 * 3600 * 1000; // 1 hour | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/desktop-ui-lib/src/lib/shared/components/abstract/selector.abstract.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Component } from '@angular/core'; | ||
import { ControlValueAccessor } from '@angular/forms'; | ||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; | ||
import { BehaviorSubject, Observable, Subject } from 'rxjs'; | ||
import { debounceTime, distinctUntilChanged, switchMap, tap } from 'rxjs/operators'; | ||
import { SelectorService } from '../../+state/selector.service'; | ||
|
||
@UntilDestroy({ checkProperties: true }) | ||
@Component({ | ||
template: '' | ||
}) | ||
export abstract class AbstractSelectorComponent<T> implements ControlValueAccessor { | ||
public search$ = new Subject<string>(); | ||
private onChange: (value: any) => void; | ||
private onTouched: () => void; | ||
protected isDisabled$ = new BehaviorSubject<boolean>(false); | ||
|
||
// Flag to control whether to update the store | ||
protected useStore: boolean = true; | ||
|
||
// Abstract members to be implemented in derived classes | ||
public abstract data$: Observable<T[]>; | ||
public abstract selected$: Observable<T>; | ||
public abstract isLoading$: Observable<boolean>; | ||
public abstract disabled$: Observable<boolean>; | ||
public abstract hasPermission$: Observable<boolean>; | ||
|
||
constructor() {} | ||
|
||
// Handle value change | ||
public change(value: string): void { | ||
this.onChange?.(value); // Notify the form control | ||
this.onTouched?.(); | ||
this.updateSelected(value); // Update the store only if useStore is true | ||
} | ||
|
||
// Implement ControlValueAccessor methods | ||
public writeValue(value: string): void { | ||
this.useStore = false; // Disable store updates when used in a form | ||
if (value) { | ||
this.updateSelected(value); | ||
} | ||
} | ||
|
||
public registerOnChange(fn: any): void { | ||
this.onChange = fn; | ||
} | ||
|
||
public registerOnTouched(fn: any): void { | ||
this.onTouched = fn; | ||
} | ||
|
||
public setDisabledState(isDisabled: boolean): void { | ||
this.isDisabled$.next(isDisabled); | ||
} | ||
|
||
// Abstract method to update selected item | ||
protected abstract updateSelected(value: string): void; | ||
|
||
// Common search handling logic | ||
protected handleSearch(service: SelectorService<T>) { | ||
this.search$ | ||
.pipe( | ||
debounceTime(300), | ||
distinctUntilChanged(), | ||
tap(() => service.resetPage()), | ||
switchMap((searchTerm) => service.load({ searchTerm })), | ||
untilDestroyed(this) | ||
) | ||
.subscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.