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

[Fix] #8454 Team Selector (Web Tracker) #8458

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 6 additions & 8 deletions packages/contracts/src/organization-team.model.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { IEmployeeEntityInput, IMemberEntityBased } from './employee.model';
import { IBasePerTenantAndOrganizationEntityModel, ID } from './base-entity.model';
import { IOrganizationTeamEmployee } from './organization-team-employee-model';
import { ITag } from './tag.model';
import { ITaggable } from './tag.model';
import { ITask } from './task.model';
import { ITimerStatusInput } from './timesheet.model';
import { IRelationalImageAsset } from './image-asset.model';
import { CrudActionEnum } from './organization.model';
import { IOrganizationProject } from './organization-projects.model';
import { IOrganizationProject, IOrganizationProjectCreateInput } from './organization-projects.model';
import { IOrganizationProjectModule } from './organization-project-module.model';
import { IComment } from './comment.model';

export interface IOrganizationTeam extends IBasePerTenantAndOrganizationEntityModel, IRelationalImageAsset {
export interface IOrganizationTeam extends IBasePerTenantAndOrganizationEntityModel, IRelationalImageAsset, ITaggable {
name: string;
color?: string;
emoji?: string;
Expand All @@ -26,7 +26,6 @@ export interface IOrganizationTeam extends IBasePerTenantAndOrganizationEntityMo
projects?: IOrganizationProject[];
modules?: IOrganizationProjectModule[];
assignedComments?: IComment[];
tags?: ITag[];
tasks?: ITask[];
}

Expand All @@ -41,7 +40,8 @@ export interface IOrganizationTeamFindInput extends IBasePerTenantAndOrganizatio
export interface IOrganizationTeamCreateInput
extends IBasePerTenantAndOrganizationEntityModel,
IRelationalImageAsset,
IMemberEntityBased {
IMemberEntityBased,
ITaggable {
name: string;
emoji?: string;
teamSize?: string;
Expand All @@ -52,12 +52,10 @@ export interface IOrganizationTeamCreateInput
requirePlanToTrack?: boolean;
public?: boolean;
profile_link?: string;
tags?: ITag[];
projects?: IOrganizationProject[];
projects?: IOrganizationProjectCreateInput[];
}

export interface IOrganizationTeamUpdateInput extends Partial<IOrganizationTeamCreateInput> {
id: string;
shareProfileView?: boolean;
requirePlanToTrack?: boolean;
public?: boolean;
Expand Down
21 changes: 13 additions & 8 deletions packages/core/src/organization-team/organization-team.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,28 @@ export class OrganizationTeamService extends TenantAwareCrudService<Organization
}

/**
* GET organization teams pagination by params
* GET organization teams pagination by params.
*
* @param filter
* @returns
* @param options - The pagination parameters including filters.
* @returns A promise that resolves to a paginated list of organization teams.
*/
public async pagination(options?: PaginationParams<OrganizationTeam>): Promise<IPagination<OrganizationTeam>> {
if ('where' in options) {
if (options?.where) {
const { where } = options;
if ('name' in where) {
options['where']['name'] = ILike(`%${where.name}%`);

// Update name filter using ILike
if (where.name) {
options.where.name = ILike(`%${where.name}%`);
}
if ('tags' in where) {
options['where']['tags'] = {

rahul-rocket marked this conversation as resolved.
Show resolved Hide resolved
// Update tags filter using In
if (where.tags) {
options.where.tags = {
id: In(where.tags as [])
};
rahul-rocket marked this conversation as resolved.
Show resolved Hide resolved
}
}

rahul-rocket marked this conversation as resolved.
Show resolved Hide resolved
return await this.findAll(options);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
import { catchError, firstValueFrom, of } from 'rxjs';
import {
IOrganizationTeam,
IOrganizationTeamFindInput,
IOrganizationTeamCreateInput,
IPagination,
IOrganizationTeamUpdateInput,
IBasePerTenantAndOrganizationEntityModel
IBasePerTenantAndOrganizationEntityModel,
ID
} from '@gauzy/contracts';
import { API_PREFIX, toParams } from '@gauzy/ui-core/common';

Expand All @@ -24,10 +25,23 @@ export class OrganizationTeamsService {
// 4) Delete a team
// 5) Display all teams: show team name and members - avatar + full name for each member;

create(body: IOrganizationTeamCreateInput): Promise<IOrganizationTeam> {
return firstValueFrom(this.http.post<IOrganizationTeam>(`${API_PREFIX}/organization-team`, body));
/**
* Creates a new organization team.
*
* @param input - The input data for creating the team.
* @returns A promise that resolves to the created organization team.
*/
create(input: IOrganizationTeamCreateInput): Promise<IOrganizationTeam> {
return firstValueFrom(this.http.post<IOrganizationTeam>(`${API_PREFIX}/organization-team`, input));
}

/**
* Retrieves all organization teams, optionally filtered and related.
*
* @param relations - An array of relations to include in the response.
* @param where - Optional filter criteria for retrieving teams.
* @returns A promise that resolves to a paginated list of organization teams.
*/
getAll(relations: string[] = [], where?: IOrganizationTeamFindInput): Promise<IPagination<IOrganizationTeam>> {
return firstValueFrom(
this.http.get<IPagination<IOrganizationTeam>>(`${API_PREFIX}/organization-team`, {
Expand All @@ -36,34 +50,65 @@ export class OrganizationTeamsService {
);
}

update(id: IOrganizationTeam['id'], body: IOrganizationTeamUpdateInput): Promise<any> {
return firstValueFrom(this.http.put(`${API_PREFIX}/organization-team/${id}`, body));
/**
* Updates an existing organization team.
*
* @param id - The ID of the team to update.
* @param input - The input data for updating the team.
* @returns A promise that resolves to the updated organization team or a response.
*/
update(id: ID, input: IOrganizationTeamUpdateInput): Promise<any> {
return firstValueFrom(this.http.put(`${API_PREFIX}/organization-team/${id}`, input));
rahul-rocket marked this conversation as resolved.
Show resolved Hide resolved
rahul-rocket marked this conversation as resolved.
Show resolved Hide resolved
}

delete(
id: IOrganizationTeam['id'],
params: IBasePerTenantAndOrganizationEntityModel
): Promise<IOrganizationTeam | HttpErrorResponse> {
/**
* Deletes an organization team by ID.
*
* @param id - The ID of the team to delete.
* @param params - Additional parameters for the delete request.
* @returns A promise that resolves to the deleted organization team or an error response.
*/
delete(id: ID, params: IBasePerTenantAndOrganizationEntityModel): Promise<IOrganizationTeam | HttpErrorResponse> {
return firstValueFrom(
this.http.delete<IOrganizationTeam>(`${API_PREFIX}/organization-team/${id}`, {
params: toParams(params)
})
);
}
rahul-rocket marked this conversation as resolved.
Show resolved Hide resolved

getCount(request: IOrganizationTeamFindInput): Promise<number> {
/**
* Gets the count of organization teams based on the provided filter.
*
* @param params - The filter criteria for counting teams.
* @returns A promise that resolves to the number of organization teams.
*/
getCount(params: IOrganizationTeamFindInput): Promise<number> {
return firstValueFrom(
this.http.get<number>(`${API_PREFIX}/organization-team/count`, {
params: toParams({ ...request })
params: toParams({ ...params })
})
);
}

/**
* Fetches the teams associated with the authenticated user.
*
* @param where - Optional filter criteria for fetching teams.
* @param relations - Optional list of relations to include in the response.
* @returns A promise that resolves to a paginated list of organization teams.
*/
getMyTeams(where?: IOrganizationTeamFindInput, relations: string[] = []): Promise<IPagination<IOrganizationTeam>> {
return firstValueFrom(
this.http.get<IPagination<IOrganizationTeam>>(`${API_PREFIX}/organization-team/me`, {
params: toParams({ where, relations })
})
this.http
.get<IPagination<IOrganizationTeam>>(`${API_PREFIX}/organization-team/me`, {
params: toParams({ where, relations })
})
.pipe(
catchError((error) => {
console.log('Error fetching teams:', error);
return of({ total: 0, items: [] });
})
)
rahul-rocket marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
IOrganization,
TimerState,
TimeLogSourceEnum,
ITimerStatusInput
ITimerStatusInput,
ITimerPosition
} from '@gauzy/contracts';
import { API_PREFIX, BACKGROUND_SYNC_INTERVAL, toLocal, toParams, toUTC } from '@gauzy/ui-core/common';
import { Store as AppStore } from '../store/store.service';
Expand All @@ -34,7 +35,8 @@ export function createInitialTimerState(): TimerState {
projectId: null,
taskId: null,
organizationContactId: null,
description: '',
organizationTeamId: null,
description: null,
logType: TimeLogType.TRACKED,
source: TimeLogSourceEnum.WEB_TIMER,
startedAt: null,
Expand Down Expand Up @@ -65,7 +67,6 @@ export function createInitialTimerState(): TimerState {
} as TimerState;
}


@Injectable({ providedIn: 'root' })
@StoreConfig({ name: 'timer' })
export class TimerStore extends Store<TimerState> {
Expand Down Expand Up @@ -147,64 +148,112 @@ export class TimeTrackerService implements OnDestroy {
.catch(() => {});
}

/**
* Gets the value indicating whether the timer window is shown.
*
* @returns A boolean indicating if the timer window is displayed.
*/
public get showTimerWindow(): boolean {
const { showTimerWindow } = this.timerQuery.getValue();
return showTimerWindow;
return this.timerQuery.getValue().showTimerWindow;
}

/**
* Sets the value indicating whether to show the timer window.
*
* @param value - A boolean value to set for displaying the timer window.
*/
public set showTimerWindow(value: boolean) {
this.timerStore.update({
showTimerWindow: value
});
this.timerStore.update({ showTimerWindow: value });
}

/**
* Gets the current duration of the timer.
*
* @returns The duration in seconds.
*/
public get duration(): number {
const { duration } = this.timerQuery.getValue();
return duration;
return this.timerQuery.getValue().duration;
}

/**
* Sets the duration of the timer.
*
* @param value - A number representing the duration to set.
*/
public set duration(value: number) {
this.timerStore.update({
duration: value
});
this.timerStore.update({ duration: value });
}

/**
* Gets the current session duration of the timer.
*
* @returns The current session duration in seconds.
*/
public get currentSessionDuration(): number {
const { currentSessionDuration } = this.timerQuery.getValue();
return currentSessionDuration;
return this.timerQuery.getValue().currentSessionDuration;
}

/**
* Sets the current session duration of the timer.
*
* @param value - A number representing the current session duration to set.
*/
public set currentSessionDuration(value: number) {
this.timerStore.update({
currentSessionDuration: value
});
this.timerStore.update({ currentSessionDuration: value });
}

/**
* Gets the configuration settings for the timer.
*
* @returns The timer configuration object.
*/
public get timerConfig(): ITimerToggleInput {
const { timerConfig } = this.timerQuery.getValue();
return timerConfig;
return this.timerQuery.getValue().timerConfig;
}

/**
* Sets the configuration settings for the timer.
*
* @param value - An object containing the timer configuration to set.
*/
public set timerConfig(value: ITimerToggleInput) {
this.timerStore.update({
timerConfig: value
});
this.timerStore.update({ timerConfig: value });
rahul-rocket marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Gets the running state of the timer.
*
* @returns A boolean indicating if the timer is currently running.
*/
public get running(): boolean {
const { running } = this.timerQuery.getValue();
return running;
return this.timerQuery.getValue().running;
}

/**
* Sets the running state of the timer.
*
* @param value - A boolean value to indicate whether the timer should be running.
*/
public set running(value: boolean) {
this.timerStore.update({
running: value
});
this.timerStore.update({ running: value });
}

public get position() {
const { position } = this.timerQuery.getValue();
return position;
/**
* Gets the current position of the timer.
*
* @returns The current position or offset of the timer.
*/
public get position(): ITimerPosition {
return this.timerQuery.getValue().position;
}
public set position(offSet: any) {
this.timerStore.update({
position: offSet
});

/**
* Sets the position of the timer.
*
* @param offset - The offset value to set for the timer's position.
*/
public set position(offset: ITimerPosition) {
this.timerStore.update({ position: offset });
rahul-rocket marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/ui-core/i18n/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3786,6 +3786,7 @@
"SELECT_PROJECT": "اختر المشروع",
"SELECT_TASK": "اختر المهمة",
"SELECT_CLIENT": "اختر العميل",
"SELECT_TEAM": "اختر الفريق",
"DATE": "التاريخ",
"START_TIME": "وقت البدء",
"END_TIME": "وقت الانتهاء",
Expand Down
1 change: 1 addition & 0 deletions packages/ui-core/i18n/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3820,6 +3820,7 @@
"SELECT_PROJECT": "Select Project",
"SELECT_TASK": "Select Task",
"SELECT_CLIENT": "Select Client",
"SELECT_TEAM": "Избери отбор",
"DATE": "Дата",
"START_TIME": "Start Time",
"END_TIME": "End Time",
Expand Down
Loading
Loading