-
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.
* feat: create selector interface * feat: create generate store and query abstract * feat: create reusable components * feat: create client selector feature * feat: create note selector feature * feat: project selector feature * feat: create task selector feature * feat: create team selector feature * feat: create time tracker form * refactored: Time Tracker component to use GauzyTimeTrackerForm, removed client, project, team, and task selection fields, and added TimeTrackerModule to imports in TimeTrackerModule. * updated various files in desktop-ui-lib, including selector stores, components, and modules, with changes to imports, exports, and method implementations. * fix: null safety in selector queries, and add canAddTag and addTagText properties to gauzy-select components" * feat: add isLoading input to SelectComponent and updated ClientSelector, ProjectSelector, TaskSelector, and TeamSelector components to use it. * update: styles and templates for ng-select component in desktop-ui-lib and desktop-timer apps. * feat: integrate selectors to time tracker * refactor SelectorStore: update data concatenation and remove redundant line * feat: add time tracker query, store, and implement dialog for task updates * remove: NbButtonModule, NbIconModule, and PipeModule imports from TimeTrackerFormModule. * update project selector, task selector, and team selector components; modify time tracker form and query; add ignition method to time tracker store; update time tracker component * update: time tracker component to calculate and send idle time on restart * fix: TimeTracker component to send startedAt as ISO string, and modify TimerTrackerChangeDialog component to add large class and expanded$ observable * feat: add isLoading$, disabled$, and hasError$ bindings to client-selector, project-selector, task-selector, and team-selector components * refactor: desktop timer app update imports, rename variables, and modify component templates and logic * refactor: adjust logic in time tracker form and dialog components. * chore: add new command to make mac build fast in package.json * fix: intervalDAO and IntervalService remove idle queries * refactor: PowerManagerDetectInactivity and DesktopOsInactivityHandler classes, updating event handling, inactivity detection, and idle time removal logic. * fix: remove idle event listener conditional statements, added checks, and modified IPC renderer events * feat: prevent duplicated API Requests method for start/stop API calls * feat: add `isOnBattery` property to `BasePowerManagerDecorator` and `DesktopPowerManager`, and updated `DesktopOsInactivityHandler` to use it. * feat: add new IPC handlers * refactor: TimeTrackerComponent and TimeTrackerService: removed ITimerStatus, added ITimeLog, modified method signatures and implementations * feat: add `hasPermission` property to selectors and update components to use new property, and removed old permission BehaviorSubjects. * feat: add UntilDestroy decorator to several components, modified time-tracker-form.component.ts, and updated time-tracker.query.ts and time-tracker.component.ts * fix: use complete value * feat: handle UPDATE_SELECTOR IPC event * feat: update desktop-ipc, desktop-timer, and time-tracker component with changes to timer handling and dependencies. * fix: deepscan
- Loading branch information
Showing
75 changed files
with
2,706 additions
and
608 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
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
34 changes: 34 additions & 0 deletions
34
packages/desktop-ui-lib/src/lib/shared/+state/selector.query.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,34 @@ | ||
import { Query } from '@datorama/akita'; | ||
import { Observable } from 'rxjs'; | ||
import { ISelector } from '../interfaces/selector.interface'; | ||
import { SelectorStore } from './selector.store'; | ||
|
||
export abstract class SelectorQuery<T> extends Query<ISelector<T>> { | ||
/** | ||
* Creates an instance of SelectorQuery. | ||
* @param store The store of type {@link SelectorStore<T>} | ||
*/ | ||
protected constructor(store: SelectorStore<T>) { | ||
super(store); | ||
} | ||
|
||
public get data$(): Observable<T[]> { | ||
return this.select((state) => state.data); | ||
} | ||
|
||
public get data(): T[] { | ||
return this.getValue().data; | ||
} | ||
|
||
public get selected$(): Observable<T> { | ||
return this.select((state) => state.selected); | ||
} | ||
|
||
public get selected(): T { | ||
return this.getValue().selected; | ||
} | ||
|
||
public get hasPermission$(): Observable<boolean> { | ||
return this.select((state) => state.hasPermission); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/desktop-ui-lib/src/lib/shared/+state/selector.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,44 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { SelectorQuery } from './selector.query'; | ||
import { SelectorStore } from './selector.store'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export abstract class SelectorService<T> { | ||
protected constructor( | ||
public readonly selectorStore: SelectorStore<T>, | ||
public readonly selectorQuery: SelectorQuery<T> | ||
) {} | ||
|
||
public abstract load(): Promise<void>; | ||
|
||
public getAll$(): Observable<T[]> { | ||
return this.selectorQuery.data$; | ||
} | ||
|
||
public getAll(): T[] { | ||
return this.selectorQuery.data; | ||
} | ||
|
||
public get selected(): T { | ||
return this.selectorQuery.selected; | ||
} | ||
|
||
public set selected(selected: T | string) { | ||
this.selectorStore.updateSelected(selected); | ||
} | ||
|
||
public set hasPermission(hasPermission: boolean) { | ||
this.selectorStore.update({ hasPermission: hasPermission }); | ||
} | ||
|
||
public get hasPermission(): boolean { | ||
return this.selectorStore.getValue().hasPermission; | ||
} | ||
|
||
public get hasPermission$(): Observable<boolean> { | ||
return this.selectorQuery.hasPermission$; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
packages/desktop-ui-lib/src/lib/shared/+state/selector.store.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,38 @@ | ||
import { Store } from '@datorama/akita'; | ||
import { ISelector } from '../interfaces/selector.interface'; | ||
|
||
export abstract class SelectorStore<T> extends Store<ISelector<T>> { | ||
protected constructor(private readonly initialState: ISelector<T>) { | ||
super(initialState); | ||
} | ||
|
||
public updateData(data: T[]): void { | ||
this.update({ data }); | ||
} | ||
|
||
public updateSelected(selected: T | string): void { | ||
if (!selected) { | ||
this.update({ selected: null }); | ||
return; | ||
} | ||
|
||
if (typeof selected === 'string') { | ||
selected = this.getValue().data.find((value: any) => selected === value.id); | ||
} | ||
|
||
this.update({ selected }); | ||
} | ||
|
||
public appendData(selected: T): void { | ||
if (!selected) { | ||
return; | ||
} | ||
const data = this.getValue().data; | ||
this.updateSelected(selected); | ||
this.updateData(data.concat([selected])); | ||
} | ||
|
||
public resetToInitialState(): void { | ||
this.update(this.initialState); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
packages/desktop-ui-lib/src/lib/shared/components/ui/select/select.component.html
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,62 @@ | ||
<div class="gauzy-select-container"> | ||
<label *ngIf="label">{{ label | translate }}</label> | ||
<ng-select | ||
(clear)="onClear()" | ||
[loading]="isLoading" | ||
(ngModelChange)="onModelChange($event)" | ||
[ngModel]="selectedItem" | ||
[addTagText]="addTagText | translate" | ||
[addTag]="canAddTag ? addTag : null" | ||
[class.error-border]="hasError" | ||
[clearable]="clearable" | ||
[disabled]="disabled" | ||
[items]="items" | ||
[nbTooltipDisabled]="!disabled" | ||
[nbTooltip]="tooltipText | translate" | ||
[placeholder]="placeholder | translate" | ||
[bindLabel]="bindLabel" | ||
[bindValue]="bindValue" | ||
nbTooltipStatus="warning" | ||
> | ||
<!-- Option Template --> | ||
<ng-template ng-option-tmp let-item="item"> | ||
<ng-container | ||
[ngTemplateOutlet]="bindLabel === 'title' ? titleTemplate : defaultTemplate" | ||
[ngTemplateOutletContext]="{ item: item }" | ||
></ng-container> | ||
</ng-template> | ||
|
||
<!-- Label Template --> | ||
<ng-template ng-label-tmp let-item="item"> | ||
<div class="selector-template"> | ||
<ng-container | ||
[ngTemplateOutlet]="bindLabel === 'title' ? titleTemplate : defaultTemplate" | ||
[ngTemplateOutletContext]="{ item: item }" | ||
></ng-container> | ||
</div> | ||
</ng-template> | ||
</ng-select> | ||
</div> | ||
|
||
<!-- Default Template --> | ||
<ng-template #defaultTemplate let-item="item"> | ||
<ng-container *ngTemplateOutlet="commonTemplate; context: { item: item, label: item[bindLabel] }"></ng-container> | ||
</ng-template> | ||
|
||
<!-- Title Template --> | ||
<ng-template #titleTemplate let-item="item"> | ||
<span class="text-container"> | ||
<span *ngIf="item?.number" class="gray-bold-text"> | ||
#{{ item?.prefix ? (item?.prefix + '-' + item?.number | uppercase) : item?.number }} | ||
</span> | ||
<span class="black-bold-text">{{ item?.title }}</span> | ||
</span> | ||
</ng-template> | ||
|
||
<!-- Common Template (for both option and label) --> | ||
<ng-template #commonTemplate let-item="item" let-label="label"> | ||
<div class="common-template"> | ||
<img *ngIf="item?.imageUrl" [src]="item?.imageUrl" height="20px" width="20px" /> | ||
<span class="black-bold-text">{{ label }}</span> | ||
</div> | ||
</ng-template> |
Oops, something went wrong.