Skip to content

Commit

Permalink
Merge pull request #2086 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Jan 13, 2024
2 parents 24e36ec + 2ba676e commit 46e0355
Show file tree
Hide file tree
Showing 37 changed files with 311 additions and 763 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ Thumbs.db

# Local Netlify folder
.netlify

/.nx
33 changes: 0 additions & 33 deletions .nx/cache/nx-console-project-graph/project-graph.html

This file was deleted.

665 changes: 0 additions & 665 deletions .nx/cache/nx-console-project-graph/static/3rdpartylicenses.txt

This file was deleted.

21 changes: 0 additions & 21 deletions .nx/cache/nx-console-project-graph/static/environment.js

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion .nx/cache/nx-console-project-graph/static/main.js

This file was deleted.

1 change: 0 additions & 1 deletion .nx/cache/nx-console-project-graph/static/polyfills.js

This file was deleted.

1 change: 0 additions & 1 deletion .nx/cache/nx-console-project-graph/static/runtime.js

This file was deleted.

3 changes: 0 additions & 3 deletions .nx/cache/nx-console-project-graph/static/styles.css

This file was deleted.

1 change: 0 additions & 1 deletion .nx/cache/nx-console-project-graph/static/styles.js

This file was deleted.

3 changes: 2 additions & 1 deletion apps/web/app/api/timer/daily/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export async function GET(req: Request) {
todayEnd: endDate,
todayStart: startDate,
type,
bearer_token: access_token
bearer_token: access_token,
activityLevel: { start: 0, end: 100 }
});

return $res(data);
Expand Down
10 changes: 6 additions & 4 deletions apps/web/app/hooks/features/useTimeDailyActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import { useCallback, useEffect } from 'react';
import { useQuery } from '../useQuery';
import { useRecoilState } from 'recoil';
import { timeAppsState } from '@app/stores/time-slot';
import { timeAppsState, timeVisitedSitesState } from '@app/stores/time-slot';
import moment from 'moment';
import { useAuthenticateUser } from './useAuthenticateUser';
import { getTimerDailyRequestAPI } from '@app/services/client/api';

export function useTimeDailyActivity(type: string) {
const { user } = useAuthenticateUser();
const [visitedApps, setVisitedApps] = useRecoilState(timeAppsState);
const [visitedSites, setVisitedSites] = useRecoilState(timeVisitedSitesState);

const { loading, queryCall } = useQuery(getTimerDailyRequestAPI);

Expand All @@ -28,19 +29,20 @@ export function useTimeDailyActivity(type: string) {
})
.then((response) => {
if (response.data) {
console.log(response.data);
setVisitedApps(response.data);
if (type == 'APP') setVisitedApps(response.data);
else setVisitedSites(response.data);
}
})
.catch((err) => console.log(err));
}, [queryCall, setVisitedApps, user, type]);
}, [queryCall, setVisitedApps, setVisitedSites, user, type]);

useEffect(() => {
getVisitedApps();
}, [user, getVisitedApps]);

return {
visitedApps,
visitedSites,
getVisitedApps,
loading
};
Expand Down
14 changes: 8 additions & 6 deletions apps/web/app/hooks/features/useTimeSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import moment from 'moment';
import { useAuthenticateUser } from './useAuthenticateUser';
import { deleteTimerLogsRequestAPI, getTimerLogsRequestAPI } from '@app/services/client/api';

export function useTimeSlots(ids?: string[]) {
export function useTimeSlots() {
const { user } = useAuthenticateUser();
const [timeSlots, setTimeSlots] = useRecoilState(timeSlotsState);

Expand All @@ -26,13 +26,14 @@ export function useTimeSlots(ids?: string[]) {
todayStart
}).then((response) => {
if (response.data) {
setTimeSlots(response.data.timeSlots);
// @ts-expect-error
setTimeSlots(response.data[0].timeSlots);
}
});
}, [queryCall, setTimeSlots, user]);

const deleteTimeSlots = useCallback(() => {
if (ids?.length) {
const deleteTimeSlots = useCallback(
(ids: string[]) => {
queryDeleteCall({
tenantId: user?.tenantId ?? '',
organizationId: user?.employee.organizationId ?? '',
Expand All @@ -41,8 +42,9 @@ export function useTimeSlots(ids?: string[]) {
const updatedSlots = timeSlots.filter((el) => (!ids?.includes(el.id) ? el : null));
setTimeSlots(updatedSlots);
});
}
}, [queryDeleteCall, setTimeSlots, ids, timeSlots, user]);
},
[queryDeleteCall, setTimeSlots, timeSlots, user]
);

useEffect(() => {
getTimeSlots();
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/interfaces/IScreenshoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface IScreenshootPerHour {
}

export interface IScreenShootItem {
idSlot: string;
startTime: Date | string;
endTime: Date | string;
imageUrl: string;
Expand Down
27 changes: 27 additions & 0 deletions apps/web/app/interfaces/timer/ITimerApp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { IEmployee } from '../IEmployee';

export interface ITimerApps {
sessions: string;
duration: string;
Expand All @@ -6,3 +8,28 @@ export interface ITimerApps {
time: string;
title: string;
}

export interface IDetailTimerSite {
id: string;
createdAt: Date | string;
updatedAt: Date | string;
deletedAt: string;
isActive: boolean;
isArchived: boolean;
tenantId: string;
organizationId: string;
title: string;
description: string;
metaData: object;
date: string;
time: string;
duration: string;
type: string;
source: string;
recordedAt: Date | null;
employeeId: string;
projectId: string;
timeSlotId: string;
taskId: string;
employee: IEmployee;
}
2 changes: 1 addition & 1 deletion apps/web/app/services/client/api/activity/time-slots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function getTimerLogsRequestAPI({
? `/timesheet/statistics/time-slots?${query.toString()}`
: `/timer/slots?${query.toString()}`;

return get<ITimerSlotDataRequest>(endpoint);
return get<ITimerSlotDataRequest | ITimerSlotDataRequest[]>(endpoint);
}

export async function deleteTimerLogsRequestAPI({
Expand Down
9 changes: 7 additions & 2 deletions apps/web/app/services/server/requests/timer/daily.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export function getEmployeeDailyRequest({
todayEnd,
todayStart,
employeeId,
type
type,
activityLevel
}: {
bearer_token: string;
tenantId: string;
Expand All @@ -17,15 +18,19 @@ export function getEmployeeDailyRequest({
todayStart: Date;
employeeId: string;
type: string;
activityLevel: { start: number; end: number };
}) {
const params = {
tenantId: tenantId,
organizationId: organizationId,
'employeeIds[0]': employeeId,
startDate: todayStart.toISOString(),
endDate: todayEnd.toISOString(),
'types[0]': type
'types[0]': type,
'activityLevel[start]': activityLevel.start.toString(),
'activityLevel[end]': activityLevel.end.toString()
};

const query = new URLSearchParams(params);
return serverFetch<ITimerSlotDataRequest>({
path: `/timesheet/activity/daily?${query.toString()}`,
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/services/server/requests/timer/timer-slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export function getEmployeeTimeSlotsRequest({
tenantId: tenantId,
organizationId: organizationId,
employeeId,
todayEnd: todayEnd.toISOString(),
todayStart: todayStart.toISOString()
startDate: todayEnd.toISOString(),
endDate: todayStart.toISOString()
};
const query = new URLSearchParams(params);
return serverFetch<ITimerSlotDataRequest>({
Expand Down
5 changes: 5 additions & 0 deletions apps/web/app/stores/time-slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ export const timeAppsState = atom<ITimerApps[]>({
key: 'timeAppsState',
default: []
});

export const timeVisitedSitesState = atom<ITimerApps[]>({
key: 'timeVisitedSiteState',
default: []
});
2 changes: 1 addition & 1 deletion apps/web/lib/features/activity/apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function AppsTab() {
<div>
{app.apps?.map((item, i) => (
<div key={i} className="w-full">
<AppVisitedItem app={item} totalMilliseconds={app.totalMilliseconds} />
<AppVisitedItem app={item} totalMilliseconds={app.totalMilliseconds} type="APP"/>
</div>
))}
</div>
Expand Down
15 changes: 13 additions & 2 deletions apps/web/lib/features/activity/components/app-visited-Item.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import { formatDateString, secondsToTime } from '@app/helpers';
import { ITimerApps } from '@app/interfaces/timer/ITimerApp';
import { ProgressBar } from 'lib/components';
import Link from 'next/link';
import React from 'react';

const AppVisitedItem = ({ app, totalMilliseconds }: { app: ITimerApps; totalMilliseconds: number }) => {
const AppVisitedItem = ({
app,
totalMilliseconds,
type
}: {
app: ITimerApps;
totalMilliseconds: number;
type: string;
}) => {
const { h, m, s } = secondsToTime(+app.duration);
const percent = ((+app.duration * 100) / totalMilliseconds).toFixed(2);
return (
<div className="hover:dark:bg-[#26272C] border dark:border-[#26272C] bg-gray-200 dark:bg-[#191a20] p-4 rounded-md flex justify-between apps-center my-2">
<p className="text-lg flex-1">{app.title}</p>
<p className="text-lg flex-1">
{type == 'SITE' ? <Link href={app.title}>{app.title}</Link> : <span>{app.title}</span>}
</p>
<p className="text-lg text-center 2xl:w-56 3xl:w-64">
{formatDateString(new Date(app.date).toISOString())} - {app.time}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const ScreenshootPerHour = ({
percent={el.percentage}
imageUrl={el.screenshots[0]?.thumbUrl}
onShow={() => openModal()}
idSlot={el.id}
/>
<ScreenshotDetailsModal open={isOpen} closeModal={closeModal} slot={el} />
</div>
Expand Down
36 changes: 34 additions & 2 deletions apps/web/lib/features/activity/components/screenshot-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ const ScreenshotDetailsModal = ({
<p className="font-semibold py-1">
{slot.percentage} {t('timer.PERCENT_OF_MINUTES')}
</p>
<div className="my-2 flex overflow-x-auto">
<div className="my-2 flex w-full overflow-x-auto">
{slot.screenshots.map((screenshot, i) => (
<div key={i} className="w-1/3 p-2">
<div key={i} className="w-1/3 min-w-[20rem] p-2">
<Tooltip
label={screenshot.description}
placement="left-start"
type="VERTICAL"
labelContainerClassName="w-full"
>
<ScreenshotItem
idSlot={slot.id}
endTime={slot.stoppedAt}
startTime={screenshot.recordedAt}
imageUrl={screenshot.thumbUrl}
Expand All @@ -62,6 +63,37 @@ const ScreenshotDetailsModal = ({
</div>
))}
</div>
<div>
<h4 className="text-lg font-semibold">{t('timer.OTHER_DETAILS')}</h4>
<div className="flex gap-2">
<p>
<span className="font-semibold mx-2">{t('timer.KEYBOARD')}</span>
<span>
{t('timer.TIMES')} : {slot.keyboard} {slot.keyboardPercentage}%
</span>
</p>
<p>
<span className="font-semibold mx-2">{t('timer.MOUSE')}</span>
<span>
{t('timer.TIMES')} : {slot.mouse} {slot.mousePercentage}%
</span>
</p>
<p className="rounded-lg px-1 mb-1 text-white ">
{slot.isActive ? (
<span className=" bg-green-600 rounded-lg px-2 m-1">{t('timer.ACTIVE')}</span>
) : (
<span className=" bg-red-600 rounded-lg px-2 m-1">{t('timer.INACTIVE')}</span>
)}
</p>
<p>
{slot.isArchived ? (
<span className=" bg-gray-600 rounded-lg px-2 m-1">{t('timer.ARCHIVED')}</span>
) : (
<span className=" bg-blue-600 rounded-lg px-2 m-1">{t('timer.NOT_ARCHIVED')}</span>
)}
</p>
</div>
</div>
</div>
</Modal>
);
Expand Down
Loading

0 comments on commit 46e0355

Please sign in to comment.