Hi,
I have some custom settings in the appsettings.json file. I would like to use some of those settings in the client-side to enable/disable some things.
Is there a way to add custom values to the 'AbpUserConfiguration/GetAll' response?
Thanks
2 Answer(s)
-
1
Hi, you can use similar implementation as entity history.
Add Custom Config Provider https://github.com/aspnetzero/aspnet-zero-core/blob/e70c1dfad2f5f634a975948792239cc0bd1bfc10/aspnet-core/src/MyCompanyName.AbpZeroTemplate.EntityFrameworkCore/EntityFrameworkCore/AbpZeroTemplateEntityFrameworkCoreModule.cs#L43-L45
Define Custom Config Provider https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/EntityHistory/EntityHistoryConfigProvider.cs
Get Custom Config (Client Side)
Angular https://github.com/aspnetzero/aspnet-zero-core/blob/312aa8b77542dbcc360c914c400a566cd7a00f7b/angular/src/app/admin/roles/roles.component.ts#L38-L41
jQuery https://github.com/aspnetzero/aspnet-zero-core/blob/62bbacdf02bcdd605ed42c22dbe61724a715a28b/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/wwwroot/view-resources/Areas/AppAreaName/Views/Roles/Index.js#L23-L29
-
0
Nice! I didn't know how to define the Custom Config Provider. I defined it like this in the CoreModule.PreInitialize method:
Configuration.CustomConfigProviders.Add(new AppCustomConfigProvider(IocManager.IocContainer.Resolve<CustomSettings>()));
Then it gets merged into the abp object in AppPreBootstrap.ts, so the last step was to define my custom settings in typings.d.ts:
declare namespace abp { namespace ui { function setBusy(elm?: any, text?: any, optionsOrPromise?: any): void; } namespace custom { namespace customSettings { interface ISomeCustomInterface { customProperty: boolean; } let someCustomSettings: ISomeCustomInterface; } } }
Thanks for your guidance :)