Create a FeatureDefinitionProvider class in Application.Contracts :
using MyApp.Localization;
using Volo.Abp.Features;
using Volo.Abp.Localization;
using Volo.Abp.Validation.StringValues;
namespace MyApp.Features
{
public class MyAppFeatureDefinitionProvider : FeatureDefinitionProvider
{
public override void Define(IFeatureDefinitionContext context)
{
var myGroup = context.AddGroup("MyApp");
myGroup.AddFeature(
"MyApp.MyFeature",
defaultValue: "false",
displayName: LocalizableString
.Create<MyAppResource>("SomeFeature"),
valueType: new ToggleStringValueType()
);
}
}
}
Enable the feature :
Refresh the page then get the feature. I expect it to be 'true' but it's always false.
First I tried in route.provider.ts
import { ConfigStateService, RoutesService, eLayoutType } from '@abp/ng.core';
import { APP_INITIALIZER } from '@angular/core';
export const APP_ROUTE_PROVIDER = [{ provide: APP_INITIALIZER, useFactory: configureRoutes, deps: [RoutesService, ConfigStateService], multi: true }];
function configureRoutes(routes: RoutesService, config: ConfigStateService) {
return () => {
routes.add([
//...
{
path: '/mymy',
name: '::Menu:MyFeature',
iconClass: 'fas fa-whatever',
order: 3,
parentName: '::Menu:MyParent',
layout: eLayoutType.application,
//requiredPolicy: 'MyApp.MyFeature', // ---> Doesn't work (I guess it only works with permissions)
//invisible: config.getFeature('MyApp.MyFeature') != 'false',// ---> Always 'false'
},
]);
};
}
Second in app.component.ts :
import { Component } from '@angular/core';
import { NavItemsService, UserMenuService } from '@abp/ng.theme.shared';
import { eThemeLeptonXComponents, eUserMenuItems } from '@volosoft/abp.ng.theme.lepton-x';
import { ConfigStateService, ReplaceableComponentsService, RoutesService } from '@abp/ng.core';
@Component({
selector: 'app-root',
template: `
<abp-loader-bar></abp-loader-bar>
<abp-dynamic-layout></abp-dynamic-layout>
<abp-gdpr-cookie-consent></abp-gdpr-cookie-consent>
`,
})
export class AppComponent {
constructor(
private replaceComponent: ReplaceableComponentsService,
private config: ConfigStateService,
private routes: RoutesService,
) {
let myFeature = this.config.getFeature('MyApp.MyFeature'); // ---> Always 'false'
if (myFeature === 'false') {
this.routes.remove(['::Menu:MyFeature']);
}
}
}
How can I easily hide the bottom-right menu items ? Can I hide them separately or should I hide them one by one ?
I'm trying to implement public user automatic authentication (for permission management). When users access the website, I want them to be automatically connected under a single "public" user.
I tried this in app.component :
ngOnInit(): void {
//...
const currentUser = this.config.getOne("currentUser");
if(currentUser == null || currentUser.id == null){
const loginParams: LoginParams = {
username: 'public',
password: '**********'
}
this.authService.login(loginParams).subscribe(
() => {
window.location.reload();
}
);
}
}
window.location.reload()
is currently necessary to refresh the top right menu. If I don't reload the page, upon clicking on the user menu I get an error :
app.component.ts:38 ERROR TypeError: Cannot read properties of undefined (reading 'toggle')
at ToolbarContainerComponent.toggleCtxMenu (volosoft-ngx-lepton-x-layouts.mjs:373:22)
at ToolbarContainerComponent_Template_lpx_toolbar_profileClick_0_listener (volosoft-ngx-lepton-x-layouts.mjs:377:362)
at executeListenerWithErrorHandling (core.mjs:16195:16)
at Object.wrapListenerIn_markDirtyAndPreventDefault [as next] (core.mjs:16228:22)
at ConsumerObserver.next (Subscriber.js:91:33)
at SafeSubscriber._next (Subscriber.js:60:26)
at SafeSubscriber.next (Subscriber.js:31:18)
at Subject.js:34:30
at errorContext (errorContext.js:19:9)
at EventEmitter_.next (Subject.js:27:21)
How can I avoid reloading the page ?
I also tried moving the authentication code to an APP_INITIALIZER in app.module, but then, the authService is not yet initialized
Hi,
I have the exact same issue as 5179 (same abp version, angular, same configuration, same reproduce steps)
I see that you closed it without providing a solution. Is there a solution ?