Open Closed

Efficient user of Settings and Features #263


User avatar
0
ian@order2invoice.com created
  • ABP Framework version: v2.9
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): no

Relating to Settings and Features.

  1. One of our most used API calls needs to receive up to 30 settings to create data for a View Model. We are concerned about the time this will take on each call. Is the settings System suitable for this style of usage? Will it be efficient?
  2. Thoughout our app we need to check both if a Feature is enabled and a Setting indicating is a particular user can use that feature (e.g. Invoice Feature is enabled for a tenant, but only some users have access). What would be the most efficient way to implement this?

11 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    1. Setting system to read the value from cache,You don't have to worry about performance. Or you can use the object as the setting value, like this:
    public class qaSettingDefinitionProvider : SettingDefinitionProvider
    {
        public override void Define(ISettingDefinitionContext context)
        {
            context.Add(new SettingDefinition(MySettingModel.SettingKey,
                JsonConvert.SerializeObject(new MySettingModel {Name = "name", Email = "email"})));
        }
    }
    
    public class MySettingModel
    {
        public const string SettingKey = "MySettingModel";
    
        public string Name { get; set; }
    
        public string Email { get; set; }
    }
    

    Then you can read all the required settings at once:

    1. You can add features for tenants, like (Invoice...) and check feature in invoice management. you can grant users invoice management permission. Feature management document is not yet complete, you can refer to https://github.com/abpframework/abp/issues/2163.

    !

    I saw that you posted a duplicate question: https://support.abp.io/QA/Questions/262/Efficient-user-of-Settings-and-Features

  • User Avatar
    0
    ian@order2invoice.com created

    Thanks.

    I can see the settings page in as admin. But I can't find where to make tenant settings available for the tenant.

    Also how does a tenant see only their users and change settings for those user?

    And how can users change setting their are allowed to change.

    Or do need to write all that.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Tenants should be able to see the settings page, you can check current user is granted settings management permissions. Like this :

    A setting value read from the following provider:

    • DefaultValueSettingValueProvider
    • ConfigurationSettingValueProvider
    • GlobalSettingValueProvider
    • TenantSettingValueProvider
    • UserSettingValueProvider

    Setting fallback system works from bottom (user) to top (default).

    You can set the value using the method of ISettingManager :

    //For tenant's setting
    await _settingManager.SetForCurrentUserAsync("App.UI.LayoutType", "LeftMenu");
    await _settingManager.SetForUserAsync(user1Id, "App.UI.LayoutType", "LeftMenu");
    
    //For user's setting
    await _settingManager.SetForCurrentTenantAsync("App.UI.LayoutType", "LeftMenu");
    await _settingManager.SetForTenantAsync(tenant1Id, "App.UI.LayoutType", "LeftMenu");
    

    Have a nice day : ).

  • User Avatar
    0
    ian@order2invoice.com created

    Thanks. So I am still having following issues to get setting working. Can you help.

    1. Can I call the setting page for a User as well as a tenant
    2. how can I specify a setting as admin only
    3. how do I add a select in the interface.
  • User Avatar
    0
    alper created
    Support Team Director

    as I understand from your questions, you are trying to achieve a permission problem with settings. why don't you try to use Roles for this. add a permission to your admin role. or create a new TenantRole and add permissions to TenantRole. Setting system is more application related values (there's no scope for admins or users).

    See the definition https://docs.abp.io/en/abp/latest/Settings#settingdefinition. There's no option for users

  • User Avatar
    0
    ian@order2invoice.com created

    Thanks Apler,

    I have looked at the permissions system and the multi-tenant modules are I have the following issues. These are things we use to manage tenants in our current system that we need to explore in abp.io before full implementation. Which of there can we acheive these?

    1. Can we log in as a "host" user to a tenant. If we do this by creating a new user called, say, HostAdmin can that be hidden from the tenant in the user list. We need this so we can log into a tenant and check their data live or do admin tasks for them.
    2. There are permissions that we want the HostAdmin to set for tenants without letting them see or know about them. Also we don't want to show permissions if they don't have access to the feature.
    3. We only want to show localisation and settings associated with allowed permissions and features.
    4. A way to "loop" through all tenants and update permissions, localosations or settings globally access all tenants..

    For 1, 2 and 3 I think I would need override services to introduce a filter to the result, But I am having trouble getting this to work. Perhaps you can provide an example.

    Finally we wnt to persist permissions in a database. The doumentation ways to look at permission management module documentation, but it is TBD. when will this be available.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi:

    1. You can create host user , but if you want hidden from the tenant in the user list, you need use object extend system add an identifier (like: IsHostUser) to IdentityUser entity and override IdentityUserAppService to filter IsHostUser.
    2. Add an identifier(like: IsHostPermisson) to the Properties property of PermissionDefinition.
    3. It takes a lot of work, you need to associate localization, settings with permissions and features, and then filter when displaying.
    4. You can log in to the application as the host or use ICurrentTenant.Change(null) to switch to the host , and then you can get all tenants.

    If I have an incorrect understanding, please let me know. I will try to create an simple example for 1,2,3.

    Have a nice day : ).

  • User Avatar
    0
    ian@order2invoice.com created

    HI,

    Yes you ubderstand correctly. The examples of thes 4 points would be greatly appreciated so we can get past the setup phase and start implementing our solution.. Are the examples overrides of the commercial modules or are you suggesting writing our own UIs.

    Ian :)

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Example : https://github.com/realLiangshiwei/AbpQa263Demo

    • hostUser will not be displayed in the user list
    • hostPermission will not be displayed in the permisson group
    • Can't see settings without permissions (language management module is a commercial module, but you can do it according to the first point)
    • In DemoAppService, users of all tenants can be update.

    Note: This is not a best practice and not complete, it just provides an idea

  • User Avatar
    0
    ian@order2invoice.com created

    Thank you. However even with you demo I am unable to migrate to create databases for the new tenants?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Instance failure

    Please check your database server.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38