Skip to content

Commit

Permalink
Merge pull request #8224 from ever-co/develop
Browse files Browse the repository at this point in the history
* [Fix] Remove nested event listeners (#8211)

* refactor: PowerManagerDetectInactivity, DesktopOsInactivityHandler, IntervalDAO, and TimeTrackerComponent classes; modify event listeners, method calls, and conditional statements; remove ipcMain and _clearIntervals references.

* fix: missing await

* fix: theme switch

* fix: add .titlebar-space class with margin-top: 15px

* refactor: rename `sort` to `isSortable` in Smart Table columns

* fix: email template utils query optimization

* fix: email templates rendering migrations

* fix(cspell): typo spelling :-)

* revert: fix: email templates rendering migrations

* fix: favorite entity missing column indexing

* fix: favorite entity missing column indexing (sqlite & mysql)

* MySQL syntax error on Time Tracking Dashboard reload

* [Fix] Offline sync and permission (#8222)

* feat: add hasAllPermissions and hasAnyPermissions utility function

* fix: toggleApiStop method adding source and refactor

* fix: added optional chaining operator to access `status.lastLog.id`

* [Fix] Activity Watch integration issue (#8223)

* feat: add timeout to upload Images method time tracker service

* fix: speed up timer start/stop

---------

Co-authored-by: Kifungo A <[email protected]>
Co-authored-by: Rahul R. <[email protected]>
Co-authored-by: samuelmbabhazi <[email protected]>
  • Loading branch information
4 people committed Sep 17, 2024
2 parents 24635e7 + eeba5f9 commit 1c18930
Show file tree
Hide file tree
Showing 31 changed files with 828 additions and 495 deletions.
2 changes: 1 addition & 1 deletion apps/gauzy/src/app/pages/employees/employees.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements
}
this.setFilter({ field: 'tags', search: tagIds });
},
sort: false
isSortable: false
},
workStatus: {
title: this.getTranslation('SM_TABLE.STATUS'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export class EventTypeComponent extends PaginationFilterBaseComponent implements
title: this.getTranslation('EVENT_TYPE_PAGE.EMPLOYEE'),
type: 'string',
isFilterable: false,
sort: false
isSortable: false
}
},
pager: {
Expand Down
8 changes: 4 additions & 4 deletions apps/gauzy/src/app/pages/expenses/expenses.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export class ExpensesComponent extends PaginationFilterBaseComponent implements
filterFunction: (value: IOrganizationVendor) => {
this.setFilter({ field: 'vendorId', search: value?.id || null });
},
sort: false
isSortable: false
},
categoryName: {
title: this.getTranslation('SM_TABLE.CATEGORY'),
Expand All @@ -279,13 +279,13 @@ export class ExpensesComponent extends PaginationFilterBaseComponent implements
filterFunction: (value: IExpenseCategory) => {
this.setFilter({ field: 'categoryId', search: value?.id || null });
},
sort: false
isSortable: false
},
employee: {
title: this.getTranslation('SM_TABLE.EMPLOYEE'),
isFilterable: false,
type: 'custom',
sort: false,
isSortable: false,
renderComponent: EmployeeLinksComponent,
componentInitFunction: (instance: EmployeeLinksComponent, cell: Cell) => {
instance.rowData = cell.getRow().getData();
Expand All @@ -296,7 +296,7 @@ export class ExpensesComponent extends PaginationFilterBaseComponent implements
title: this.getTranslation('SM_TABLE.PROJECT'),
type: 'string',
isFilterable: false,
sort: false
isSortable: false
},
amount: {
title: this.getTranslation('SM_TABLE.VALUE'),
Expand Down
4 changes: 2 additions & 2 deletions apps/gauzy/src/app/pages/income/income.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class IncomeComponent extends PaginationFilterBaseComponent implements Af
isFilterable: false,
width: '15%',
type: 'custom',
sort: false,
isSortable: false,
renderComponent: EmployeeLinksComponent,
componentInitFunction: (instance: EmployeeLinksComponent, cell: Cell) => {
instance.rowData = cell.getRow().getData();
Expand Down Expand Up @@ -302,7 +302,7 @@ export class IncomeComponent extends PaginationFilterBaseComponent implements Af
}
this.setFilter({ field: 'tags', search: tagIds });
},
sort: false
isSortable: false
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export class InvoicesReceivedComponent extends PaginationFilterBaseComponent imp
title: this.getTranslation('INVOICES_PAGE.SENDER'),
type: 'custom',
isFilterable: false,
sort: false,
isSortable: false,
renderComponent: ContactLinksComponent,
componentInitFunction: (instance: ContactLinksComponent, cell: Cell) => {
instance.rowData = cell.getRow().getData();
Expand Down Expand Up @@ -439,7 +439,7 @@ export class InvoicesReceivedComponent extends PaginationFilterBaseComponent imp
}
this.setFilter({ field: 'tags', search: tagIds });
},
sort: false,
isSortable: false,
componentInitFunction: (instance: TagsOnlyComponent, cell: Cell) => {
instance.rowData = cell.getRow().getData();
instance.value = cell.getValue();
Expand Down
2 changes: 1 addition & 1 deletion apps/gauzy/src/app/pages/invoices/invoices.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ export class InvoicesComponent extends PaginationFilterBaseComponent implements
type: 'custom',
width: '12%',
isFilterable: false,
sort: false,
isSortable: false,
renderComponent: ContactLinksComponent,
componentInitFunction: (instance: ContactLinksComponent, cell: Cell) => {
instance.rowData = cell.getRow().getData();
Expand Down
10 changes: 5 additions & 5 deletions apps/gauzy/src/app/pages/payments/payments.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ export class PaymentsComponent extends PaginationFilterBaseComponent implements
type: 'text',
isFilterable: false,
width: '8%',
sort: false
isSortable: false
},
paymentDate: {
title: this.getTranslation('PAYMENTS_PAGE.PAYMENT_DATE'),
Expand Down Expand Up @@ -541,7 +541,7 @@ export class PaymentsComponent extends PaginationFilterBaseComponent implements
type: 'text',
isFilterable: false,
width: '10%',
sort: false
isSortable: false
},
note: {
title: this.getTranslation('PAYMENTS_PAGE.NOTE'),
Expand Down Expand Up @@ -569,14 +569,14 @@ export class PaymentsComponent extends PaginationFilterBaseComponent implements
filterFunction: (value: IOrganizationContact | null) => {
this.setFilter({ field: 'organizationContactId', search: value?.id || null });
},
sort: false
isSortable: false
},
projectName: {
title: this.getTranslation('PAYMENTS_PAGE.PROJECT'),
type: 'text',
width: '12%',
isFilterable: false,
sort: false
isSortable: false
},
overdue: {
title: this.getTranslation('PAYMENTS_PAGE.STATUS'),
Expand Down Expand Up @@ -608,7 +608,7 @@ export class PaymentsComponent extends PaginationFilterBaseComponent implements
}
this.setFilter({ field: 'tags', search: tagIds });
},
sort: false
isSortable: false
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion apps/gauzy/src/app/pages/users/users.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ export class UsersComponent extends PaginationFilterBaseComponent implements OnI
}
this.setFilter({ field: 'tags', search: tagIds });
},
sort: false,
isSortable: false,
class: 'align-row',
width: '10%'
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,111 +1,117 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { MigrationInterface, QueryRunner } from 'typeorm';
import * as chalk from 'chalk';
import { EmailTemplateEnum } from "@gauzy/contracts";
import { EmailTemplateUtils } from "../../email-template/utils";
import { DatabaseTypeEnum } from "@gauzy/config";

import { EmailTemplateEnum } from '@gauzy/contracts';
import { DatabaseTypeEnum } from '@gauzy/config';
import { EmailTemplateUtils } from '../../email-template/utils';

export class MigrateEmailTemplatesData1643809486960 implements MigrationInterface {
name = 'MigrateEmailTemplatesData1643809486960';

/**
* Up Migration
*
* @param queryRunner
*/
public async up(queryRunner: QueryRunner): Promise<void> {
console.log(chalk.yellow(this.name + ' start running!'));

switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlUpQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}

name = 'MigrateEmailTemplatesData1643809486960';
/**
* Down Migration
*
* @param queryRunner
*/
public async down(queryRunner: QueryRunner): Promise<void> {
switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlDownQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}

/**
* Up Migration
*
* @param queryRunner
*/
public async up(queryRunner: QueryRunner): Promise<void> {
console.log(chalk.yellow(this.name + ' start running!'));
/**
* Up Migration
*
* @param queryRunner
*/
public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
console.log(chalk.yellow(this.name + ' start running!'));

switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlUpQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}
/**
* Down Migration
*
* @param queryRunner
*/
public async down(queryRunner: QueryRunner): Promise<void> {
switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlDownQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}
// Migrate email templates for all templates
const templates = Object.values(EmailTemplateEnum);

/**
* Up Migration
*
* @param queryRunner
*/
public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
console.log(chalk.yellow(this.name + ' start running!'));
// Iterate over each template and migrate the data
for await (const template of templates) {
try {
await EmailTemplateUtils.migrateEmailTemplates(queryRunner, template);
} catch (error) {
console.log(`Error while migrating missing email templates for ${template}`, error);
}
}
}

const templates = Object.values(EmailTemplateEnum);
for await (const template of templates) {
try {
await EmailTemplateUtils.migrateEmailTemplates(queryRunner, template);
} catch (error) {
console.log(`Error while migrating missing email templates for ${template}`, error);
}
}
}
/**
* Up Migration
*
* @param queryRunner
*/
public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
console.log(chalk.yellow(this.name + ' start running!'));
public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise<any> {}

const templates = Object.values(EmailTemplateEnum);
for await (const template of templates) {
try {
await EmailTemplateUtils.migrateEmailTemplates(queryRunner, template);
} catch (error) {
console.log(`Error while migrating missing email templates for ${template}`, error);
}
}
}
/**
* Up Migration
*
* @param queryRunner
*/
public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
console.log(chalk.yellow(this.name + ' start running!'));

public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise<any> { }
const templates = Object.values(EmailTemplateEnum);
for await (const template of templates) {
try {
await EmailTemplateUtils.migrateEmailTemplates(queryRunner, template);
} catch (error) {
console.log(`Error while migrating missing email templates for ${template}`, error);
}
}
}

public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise<any> { }
/**
* SqliteDB Down Migration
*
* @param queryRunner
*/
public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise<any> {}

/**
* MySQL Up Migration
*
* @param queryRunner
*/
public async mysqlUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
}
/**
* MySQL Up Migration
*
* @param queryRunner
*/
public async mysqlUpQueryRunner(queryRunner: QueryRunner): Promise<any> {}

/**
* MySQL Down Migration
*
* @param queryRunner
*/
public async mysqlDownQueryRunner(queryRunner: QueryRunner): Promise<any> {
}
/**
* MySQL Down Migration
*
* @param queryRunner
*/
public async mysqlDownQueryRunner(queryRunner: QueryRunner): Promise<any> {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ export class RolePermissionsReload1644312012849 implements MigrationInterface {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
case DatabaseTypeEnum.postgres:
case DatabaseTypeEnum.mysql:
try {
await RolePermissionUtils.migrateRolePermissions(queryRunner);
} catch (error) {
console.log(chalk.red(`Error while migrating missing role permisions: ${error}`));
}
break;
case DatabaseTypeEnum.mysql:
console.log('role permission migration is not supported for mysql yet');
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
Expand Down
Loading

0 comments on commit 1c18930

Please sign in to comment.