Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize siteHeader not working #183

Open
Hellothi11 opened this issue Jul 21, 2020 · 1 comment
Open

Customize siteHeader not working #183

Hellothi11 opened this issue Jul 21, 2020 · 1 comment

Comments

@Hellothi11
Copy link

Hellothi11 commented Jul 21, 2020

I tried to setup the Admin site by nestjs-admin but I cannot customize the siteHeader, it's always NestJS Administrator
Here are my codes:

Custom Admin Site

import { Injectable } from '@nestjs/common';
import { DefaultAdminSite } from 'nestjs-admin';

@Injectable()
export class AdminSiteService extends DefaultAdminSite {
  siteHeader = 'Admin Dashboard';
}

Backoffice module:

const CoreModule = AdminCoreModuleFactory.createAdminCoreModule({
  adminController: AdminController,
  adminSite: AdminSiteService,
});
const AdminAuthModule = AdminAuthModuleFactory.createAdminAuthModule({
  adminCoreModule: CoreModule, // what admin module are you configuring authentication for
  credentialValidator: adminCredentialValidator, // how do you validate credentials
  imports: [AuthModule], // what modules export the dependencies of the credentialValidator available
  providers: [], // additional providers that will be instanciated and exported by the AdminAuthModuleFactory
});

@Module({
  imports: [CoreModule, AdminAuthModule],
})
export class BackofficeModule {}

I'm using nestjs-admin version 0.4.0
Someone can help me about this issue? Thank you

@Hellothi11
Copy link
Author

Hellothi11 commented Jul 21, 2020

I found out the problem by myself, because in my the feature modules, I tried to import the DefaultAdminModule and inject DefaultAdminSite instead of my custom modules and my custom service, so the DefaultAdminModule was still used.
So the codes in one of my feature modules should be changed to:

import { CoreModule } from 'modules/backoffice.module';
import { AdminSiteService } from 'services/admin-site.service';

@Module({
  imports: [
    TypeOrmModule.forFeature([Exam]),
    CoreModule,
  ],
  providers: [ExamService],
  controllers: [ExamController, ExamFrontendController],
})
export class ExamModule {
  constructor(private readonly adminSite: AdminSiteService) {
    adminSite.register('Exam', Exam);
  }
}

The CoreModule that I created should be exported to be imported in feature modules. Now every customization work well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant