-
Notifications
You must be signed in to change notification settings - Fork 562
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 #8611 from ever-co/feat/dashboard-feature
[Feat] Dashboard Feature
- Loading branch information
Showing
14 changed files
with
326 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { IBasePerTenantAndOrganizationEntityModel, JsonData } from './base-entity.model'; | ||
import { ExcludeCreatorFields, IHasCreator } from './user.model'; | ||
|
||
/** | ||
* Interface representing a Dashboard entity. | ||
*/ | ||
export interface IDashboard extends IBasePerTenantAndOrganizationEntityModel, IHasCreator { | ||
name: string; | ||
identifier: string; | ||
description?: string; | ||
contentHtml?: JsonData; | ||
isDefault?: boolean; | ||
} | ||
|
||
/** | ||
* Input interface for creating a Dashboard entity. | ||
*/ | ||
export interface IDashboardCreateInput extends ExcludeCreatorFields<IDashboard> {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import { EntityRepositoryType } from '@mikro-orm/core'; | ||
import { JoinColumn, RelationId } from 'typeorm'; | ||
import { IsArray, IsBoolean, IsNotEmpty, IsOptional, IsString } from 'class-validator'; | ||
import { isMySQL, isPostgres } from '@gauzy/config'; | ||
import { ID, IDashboard, IUser, JsonData } from '@gauzy/contracts'; | ||
import { TenantOrganizationBaseEntity, User } from '../core/entities/internal'; | ||
import { ColumnIndex, MultiORMColumn, MultiORMEntity, MultiORMManyToOne } from '../core/decorators/entity'; | ||
import { MikroOrmDashboardRepository } from './repository/mikro-orm-dashboard.repository'; | ||
|
||
@MultiORMEntity('dashboard', { mikroOrmRepository: () => MikroOrmDashboardRepository }) | ||
export class Dashboard extends TenantOrganizationBaseEntity implements IDashboard { | ||
[EntityRepositoryType]?: MikroOrmDashboardRepository; | ||
|
||
/** | ||
* Name of the dashboard | ||
*/ | ||
@ApiProperty({ type: () => String }) | ||
@IsNotEmpty() | ||
@IsString() | ||
@MultiORMColumn() | ||
name: string; | ||
|
||
/** | ||
* Identifier of the dashboard | ||
*/ | ||
@ApiProperty({ type: () => String }) | ||
@IsNotEmpty() | ||
@IsString() | ||
@MultiORMColumn() | ||
identifier: string; | ||
|
||
/** | ||
* Description of the dashboard | ||
*/ | ||
@ApiPropertyOptional({ type: () => String }) | ||
@IsOptional() | ||
@IsString() | ||
@MultiORMColumn({ type: 'text', nullable: true }) | ||
description?: string; | ||
|
||
/** | ||
* Content of the dashboard | ||
*/ | ||
@ApiPropertyOptional({ type: () => Object }) | ||
@IsOptional() | ||
@IsArray() | ||
@MultiORMColumn({ type: isPostgres() ? 'jsonb' : isMySQL() ? 'json' : 'text', nullable: true }) | ||
contentHtml?: JsonData; | ||
|
||
/** | ||
* Indicates if the dashboard is the default dashboard | ||
*/ | ||
@ApiPropertyOptional({ type: Boolean }) | ||
@IsOptional() | ||
@IsBoolean() | ||
@MultiORMColumn({ default: false }) | ||
isDefault: boolean; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| @ManyToOne | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* Who created the dashboard | ||
*/ | ||
@MultiORMManyToOne(() => User, { | ||
/** Database cascade action on delete. */ | ||
onDelete: 'CASCADE' | ||
}) | ||
@JoinColumn() | ||
creator?: IUser; | ||
|
||
@RelationId((it: Dashboard) => it.creator) | ||
@ColumnIndex() | ||
@MultiORMColumn({ relationId: true }) | ||
creatorId?: ID; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { MikroOrmModule } from '@mikro-orm/nestjs'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Module } from '@nestjs/common'; | ||
import { Dashboard } from './dashboard.entity'; | ||
|
||
@Module({ | ||
imports: [ | ||
TypeOrmModule.forFeature([Dashboard]), | ||
MikroOrmModule.forFeature([Dashboard]), | ||
], | ||
controllers: [], | ||
providers: [], | ||
exports: [] | ||
}) | ||
export class DashboardModule {} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './mikro-orm-dashboard.repository'; | ||
export * from './type-orm-dashboard.repository'; |
4 changes: 4 additions & 0 deletions
4
packages/core/src/lib/dashboard/repository/mikro-orm-dashboard.repository.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { MikroOrmBaseEntityRepository } from '../../core/repository/mikro-orm-base-entity.repository'; | ||
import { Dashboard } from '../dashboard.entity'; | ||
|
||
export class MikroOrmDashboardRepository extends MikroOrmBaseEntityRepository<Dashboard> {} |
11 changes: 11 additions & 0 deletions
11
packages/core/src/lib/dashboard/repository/type-orm-dashboard.repository.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { Dashboard } from '../dashboard.entity'; | ||
|
||
@Injectable() | ||
export class TypeOrmDashboardRepository extends Repository<Dashboard> { | ||
constructor(@InjectRepository(Dashboard) readonly repository: Repository<Dashboard>) { | ||
super(repository.target, repository.manager, repository.queryRunner); | ||
} | ||
} |
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.