-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/some-permission-logic
- Loading branch information
Showing
21 changed files
with
2,331 additions
and
347 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
28 changes: 18 additions & 10 deletions
28
packages/core/src/lib/dashboard/commands/handlers/dashboard.create.handler.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,20 +1,28 @@ | ||
import { HttpException, HttpStatus, Logger } from '@nestjs/common'; | ||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; | ||
import { IDashboard } from '@gauzy/contracts'; | ||
import { DashboardService } from '../../dashboard.service'; | ||
import { DashboardCreateCommand } from '../dashboard.create.command'; | ||
|
||
@CommandHandler(DashboardCreateCommand) | ||
export class DashboardCreateHandler implements ICommandHandler<DashboardCreateCommand> { | ||
private readonly logger = new Logger(DashboardCreateHandler.name); | ||
|
||
constructor(private readonly dashboardService: DashboardService) {} | ||
|
||
/** | ||
* Handles the DashboardCreateCommand to create a new dashboard. | ||
* | ||
* @param command - The command containing the input data for dashboard creation. | ||
* @returns A promise that resolves to the created dashboard. | ||
*/ | ||
public async execute(command: DashboardCreateCommand): Promise<IDashboard> { | ||
const { input } = command; | ||
return this.dashboardService.create(input); | ||
} | ||
/** | ||
* Handles the DashboardCreateCommand to create a new dashboard. | ||
* | ||
* @param command - The command containing the input data for dashboard creation. | ||
* @returns A promise that resolves to the created dashboard. | ||
*/ | ||
public async execute(command: DashboardCreateCommand): Promise<IDashboard> { | ||
try { | ||
const { input } = command; | ||
return await this.dashboardService.create(input); | ||
} catch (error) { | ||
this.logger.error('Failed to create dashboard', error.stack); | ||
throw new HttpException(`Error while creating dashboard: ${error.message}`, HttpStatus.BAD_REQUEST); | ||
} | ||
} | ||
} |
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.