-
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.
Merge pull request #8224 from ever-co/develop
* [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
Showing
31 changed files
with
828 additions
and
495 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
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
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
200 changes: 103 additions & 97 deletions
200
packages/core/src/database/migrations/1643809486960-MigrateEmailTemplatesData.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 |
---|---|---|
@@ -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> {} | ||
} |
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
Oops, something went wrong.