Skip to content

Commit

Permalink
Merge pull request #8228 from ever-co/refactor/send-activities-process
Browse files Browse the repository at this point in the history
[Refactor] Send activities process
  • Loading branch information
evereq authored Sep 18, 2024
2 parents eeba5f9 + 10d64a8 commit 98b8452
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 170 deletions.
4 changes: 2 additions & 2 deletions apps/desktop-timer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"devDependencies": {
"@electron/rebuild": "^3.2.10",
"@types/moment-duration-format": "^2.2.3",
"electron": "28.1.0",
"electron-builder": "^24.6.4",
"electron": "^30.0.1",
"electron-builder": "^24.13.3",
"electron-installer-dmg": "^4.0.0",
"electron-packager": "^17.1.1",
"electron-reload": "~1.5.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"devDependencies": {
"@electron/rebuild": "^3.2.10",
"@types/moment-duration-format": "^2.2.3",
"electron": "28.1.0",
"electron-builder": "^24.6.4",
"electron": "^30.0.1",
"electron-builder": "^24.13.3",
"electron-installer-dmg": "^4.0.0",
"electron-packager": "^17.1.1",
"electron-reload": "~1.5.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/server-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"devDependencies": {
"@electron/rebuild": "^3.2.10",
"@types/moment-duration-format": "^2.2.3",
"electron": "28.1.0",
"electron-builder": "^24.6.4",
"electron": "^30.0.1",
"electron-builder": "^24.13.3",
"electron-installer-dmg": "^4.0.0",
"electron-packager": "^17.1.1",
"electron-reload": "~1.5.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"devDependencies": {
"@electron/rebuild": "^3.2.10",
"@types/moment-duration-format": "^2.2.3",
"electron": "28.1.0",
"electron-builder": "^24.6.4",
"electron": "^30.0.1",
"electron-builder": "^24.13.3",
"electron-installer-dmg": "^4.0.0",
"electron-packager": "^17.1.1",
"electron-reload": "~1.5.0",
Expand Down
80 changes: 40 additions & 40 deletions package.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/desktop-libs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
"devDependencies": {
"@types/node": "^20.14.9",
"@types/unzipper": "^0.10.9",
"electron": "28.1.0"
"electron": "^30.0.1"
}
}
12 changes: 6 additions & 6 deletions packages/desktop-libs/src/lib/desktop-ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ export function ipcMainHandler(store, startServer, knex, config, timeTrackerWind
}
});

ipcMain.handle('TAKE_SCREEN_CAPTURE', async (event, { quitApp }) => {
ipcMain.handle('COLLECT_ACTIVITIES', async (event, { quitApp }) => {
try {
log.info('Take Screen Capture');
return await timerHandler.makeScreenshot(knex, quitApp);
log.info('Collect Activities');
return await timerHandler.collectAllActivities(knex, quitApp);
} catch (error) {
log.error('Error on take screen capture', error);
throw new UIError('500', error, 'IPCTKSCAPTURE');
log.error('Error collecting activities', error);
throw new UIError('500', error, 'HANDLE ACTIVITIES');
}
});

Expand Down Expand Up @@ -1195,7 +1195,7 @@ export function removeAllHandlers() {
'UPDATE_SYNCED',
'DESKTOP_CAPTURER_GET_SOURCES',
'FINISH_SYNCED_TIMER',
'TAKE_SCREEN_CAPTURE',
'COLLECT_ACTIVITIES',
'START_SERVER'
];
channels.forEach((channel: string) => {
Expand Down
8 changes: 4 additions & 4 deletions packages/desktop-libs/src/lib/desktop-timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,19 +635,19 @@ export default class TimerHandler {
}

/*
* Make screenshots and activities after start and stop timer
* Collect All activities after start and stop timer
*/
async makeScreenshot(knex, quitApp) {
async collectAllActivities(knex, quitApp) {
console.log(`Time Slot Start/End At ${quitApp ? 'End' : 'Beginning'}`, this.timeSlotStart);

if (this.timeSlotStart) {
console.log('Make Screenshot Started for: ', this.timeSlotStart);
console.log('Collection Started At: ', this.timeSlotStart);
await this._activeWindow.updateActivities();
console.log('Updated Activities');

const activities = await this.getAllActivities(knex, this.timeSlotStart);

console.log('Make Screenshot Ended for: ', this.timeSlotStart);
console.log('Collection Ended At: ', this.timeSlotStart);

return activities;
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-ui-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@types/jest": "^29.4.4",
"@types/moment-duration-format": "^2.2.3",
"@types/node": "^20.14.9",
"electron": "28.1.0",
"electron": "^30.0.1",
"jest-preset-angular": "^13.1.4",
"tslint": "^6.1.3"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Injectable } from '@angular/core';
import { Store, StoreConfig } from '@datorama/akita';
import { ITimeLogFilters, TimeLogSourceEnum } from '@gauzy/contracts';
import { moment } from '../../shared/features/date-range-picker';

export type IRequestState = ITimeLogFilters;

export function createInitialState(): IRequestState {
return {
source: [TimeLogSourceEnum.DESKTOP],
logType: [],
timeZone: moment.tz.guess(),
activityLevel: {
start: 0,
end: 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { RequestQuery } from '../../+state/request/request.query';
import { Store, TimeTrackerDateManager, ToastrNotificationService } from '../../../services';
import { TimesheetService, TimesheetStatisticsService } from '../../services/timesheet';
import { moment } from '../../shared/features/date-range-picker';
import { IDateRangePicker } from '../../shared/features/date-range-picker/date-picker.interface';
import { MonthlyRecapQuery } from './monthly.query';
import { IMonthlyRecapState, MonthlyRecapStore } from './monthly.store';
Expand Down Expand Up @@ -51,7 +52,7 @@ export class MonthlyRecapService {
this.monthlyStore.setLoading(true);
const { organizationId, tenantId, user } = this.store;
const employeeIds = [user.employee.id];
const timeZone = user.timeZone;
const timeZone = user.timeZone || moment.tz.guess();
const timeFormat = user.timeFormat;
const request: IGetTimeLogInput = {
...this.requestQuery.request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { RequestQuery } from '../../+state/request/request.query';
import { Store, TimeTrackerDateManager, ToastrNotificationService } from '../../../services';
import { TimesheetService, TimesheetStatisticsService } from '../../services/timesheet';
import { moment } from '../../shared/features/date-range-picker';
import { IDateRangePicker } from '../../shared/features/date-range-picker/date-picker.interface';
import { WeeklyRecapQuery } from './weekly.query';
import { IWeeklyRecapState, WeeklyRecapStore } from './weekly.store';
Expand Down Expand Up @@ -51,7 +52,7 @@ export class WeeklyRecapService {
this.weeklyStore.setLoading(true);
const { organizationId, tenantId, user } = this.store;
const employeeIds = [user.employee.id];
const timeZone = user.timeZone;
const timeZone = user.timeZone || moment.tz.guess();
const timeFormat = user.timeFormat;
const request: IGetTimeLogInput = {
...this.requestQuery.request,
Expand Down
Loading

0 comments on commit 98b8452

Please sign in to comment.