This file contains hidden or 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
import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; | |
@Entity() | |
export class User extends BaseEntity { | |
@PrimaryGeneratedColumn() | |
id: number; | |
@Column({ unique: true }) | |
email: string; |
This file contains hidden or 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
import { INestApplication } from '@nestjs/common'; | |
import { Database, Resource } from 'admin-bro-typeorm'; | |
import AdminBro from 'admin-bro'; | |
import * as AdminBroExpress from 'admin-bro-expressjs'; | |
export async function setupAdminPanel(app: INestApplication): Promise<void> { | |
/** |
This file contains hidden or 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
import { ResourceWithOptions } from 'admin-bro'; | |
import { User } from '../../users/entities/user.entity'; | |
const UserResource: ResourceWithOptions = { | |
resource: User, | |
options: {}, | |
}; | |
export default UserResource; |
This file contains hidden or 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
import { BaseEntity, Column, Entity, OneToMany, PrimaryColumn } from 'typeorm'; | |
import { UseAsTitle } from 'admin-bro-typeorm'; | |
import { Post } from '../../posts/entities/post.entity'; | |
@Entity('users') | |
export class User extends BaseEntity { | |
@PrimaryColumn({ | |
name: 'pk_user', | |
generated: 'increment', |
This file contains hidden or 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
@Entity('posts') | |
export class Post extends BaseEntity { | |
@PrimaryColumn({ | |
name: 'pk_post', | |
generated: 'increment', | |
}) | |
id: number; // <= Should always be `id` | |
... |
This file contains hidden or 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
import { ResourceWithOptions } from 'admin-bro'; | |
import { Post } from '../../models/posts/entities/post.entity'; | |
import AdminBro from 'admin-bro'; | |
const PostResource: ResourceWithOptions = { | |
resource: Post, | |
options: { | |
properties: { | |
userLink: { | |
components: { |
This file contains hidden or 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
import * as React from 'react'; | |
import { Box } from 'admin-bro' | |
const PropertyItem = (props) => { | |
return ( | |
<Box>{props.record.populated.userId.params.link}</Box> | |
) | |
} | |
export default PropertyItem; |
This file contains hidden or 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
import { ResourceWithOptions } from 'admin-bro'; | |
import { Post } from '../../models/posts/entities/post.entity'; | |
import AdminBro from 'admin-bro'; | |
const PostResource: ResourceWithOptions = { | |
resource: Post, | |
options: { | |
properties: { | |
userLink: { | |
custom: { |
This file contains hidden or 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
import * as React from 'react'; | |
import { Box } from 'admin-bro' | |
const PropertyItem = (props) => { | |
const { join, param } = props.property.custom; | |
return ( | |
<Box>{props.record.populated[join].params[param]}</Box> | |
) |
This file contains hidden or 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
// Main function | |
function convertToInterface(obj) { | |
const resObj = {}; | |
for (let key in obj) { | |
if (typeof obj[key] === 'string') { | |
resObj[key] = 'string'; | |
} else if (typeof obj[key] === 'number') { | |
resObj[key] = 'number'; | |
} else if (typeof obj[key] === 'boolean') { | |
resObj[key] = 'boolean'; |