• Stars
    star
    115
  • Rank 304,365 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 4 years ago
  • Updated 18 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An ABP module used to manage ABP settings.

中文

Abp.SettingUi

ABP version NuGet NuGet Download Discord online GitHub stars

An ABP module used to manage ABP settings

demo

If you are using ABP version <2.1.1, please see Abp.SettingManagement.Mvc.UI

Features

  • Manage ABP setting values via UI
  • Support localization
  • Group settings
  • Display settings with appropriate input controls
  • Control display of settings by permissions

Online Demo

We have launched an online demo for this module: https://settingui.samples.easyabp.io

Installation

Add ABP packages with AbpHelper (Recommended)

Run following command in your ABP project root folder:

abphelper module add EasyAbp.Abp.SettingUi -acshlw

Add ABP packages manually

  1. Install the following NuGet packages.

    • EasyAbp.Abp.SettingUi.Application
    • EasyAbp.Abp.SettingUi.Application.Contracts
    • EasyAbp.Abp.SettingUi.Domain.Shared
    • EasyAbp.Abp.SettingUi.HttpApi
    • EasyAbp.Abp.SettingUi.HttpApi.Client (Only Tiered structure is needed)
    • EasyAbp.Abp.SettingUi.Web
  2. Add DependsOn(typeof(AbpSettingUiXxxModule)) attribute to configure the module dependencies. (see how)

Configure localization resource

In order to let SettingUi module use localization resources from this application, we need to add them to SettingUiResource:

  • MyAbpApp.Domain.Shared project - MyAbpAppDomainSharedModule class

    Configure<AbpLocalizationOptions>(options =>
    {
        ...
        options.Resources
            .Get<SettingUiResource>()
            .AddVirtualJson("/Localization/MyAbpApp");
    });

Usage

  1. Grant permission ("Setting UI" - "Show Setting Page")

    permission

  2. Refresh the browser then you can use "Administration" - "Settings" menu to see all ABP built-in settings

Manage custom settings

Beside ABP built-in settings, you can also use this module to manage your own settings.

  1. Define a setting

    • MyAbpApp.Domain project - Settings/MyAbpAppSettingDefinitionProvider class

      public class MyAbpAppSettingDefinitionProvider : SettingDefinitionProvider
      {
          public override void Define(ISettingDefinitionContext context)
          {
              context.Add(
                  new SettingDefinition(
                      "Connection.Ip", // Setting name
                      "127.0.0.1", // Default value
                      L("DisplayName:Connection.Ip"), // Display name
                      L("Description:Connection.Ip") // Description
                  ));
          }
      
          private static LocalizableString L(string name)
          {
              return LocalizableString.Create<MyAbpAppResource>(name);
          }
      }
      • The setting name is "Connection.Ip"
      • Provide a default value: "127.0.0.1"
      • Set the DisplayName and Description to a localizable string by using a helper method L. The format "DisplayName:{SettingName}" is the convention recommended by ABP

      For ABP setting system, please see Settings document

  2. Define localization resources for the setting, for demonstration purpose, we defined English and Chinese localization resources

    • MyAbpApp.Domain.Shared project

      • Localization/MyAbpApp/en.json

        {
            "culture": "en",
            "texts": {
                ...
                "DisplayName:Connection.Ip": "IP",
                "Description:Connection.Ip": "The IP address of the server."
            }
        }
      • Localization/MyAbpApp/zh-Hans.json

        {
            "culture": "zh-Hans",
            "texts": {
                ...
                "DisplayName:Connection.Ip": "IP",
                "Description:Connection.Ip": "服务器的IP地址."
            }
        }
  3. Relaunch the application, we can see the setting displayed, and the localization also works

    custom-setting

Grouping

You may notice that our custom setting is displayed in "Others" tab, and "Others" card, these are the default group display names called "Group1" and "Group2" respectively:

group

So how can we custom the group of the setting? There are two ways:

  1. Use WithProperty method

    The WithProperty method is a method provided by ABP SettingDefinition class, we can directly use it in setting defining:

    • MyAbpApp.Domain project - Settings/MyAbpAppSettingDefinitionProvider class

      context.Add(
          new SettingDefinition(
                  "Connection.Ip", // Setting name
                  "127.0.0.1", // Default value
                  L("DisplayName:Connection.Ip"), // Display name
                  L("Description:Connection.Ip") // Description
              )
              .WithProperty(SettingUiConst.Group1, "Server")
              .WithProperty(SettingUiConst.Group2, "Connection")
      );
      • The constants Group1 and Group2 are defined in the SettingUiConst class
      • Set the "Server" to "Group1", and "Connection" to "Group2"

    Then we should provide the localization resource for these two group names:

    • MyAbpApp.Domain.Shared project

      • Localization/MyAbpApp/en.json

        {
            "culture": "en",
            "texts": {
                ...
                "Server": "Server",
                "Connection": "Connection"
            }
        }
      • Localization/MyAbpApp/zh-Hans.json

        {
            "culture": "zh-Hans",
            "texts": {
                ...
                "Server": "服务器",
                "Connection": "连接"
            }
        }

    Relaunch the application and see if the group names are correctly set

    group-name

  2. Use setting property file

    Another way of setting group is use the setting property file, which is provided by the SettingUi module. It's useful when you can not easily modify the setting definition, or you want to put the grouping information into one single place.

    For demonstration in this way, let's define a new setting:

    • MyAbpApp.Domain project - Settings/MyAbpAppSettingDefinitionProvider class

      new SettingDefinition(
          "Connection.Port",
          8080.ToString(),
          L("DisplayName:Connection.Port"),
          L("Description:Connection.Port")
      )

    The steps of adding localization for this setting are omitted.

    Then we need to create a new json file with arbitrary filename, however the path must be "/SettingProperties", because SettingUi module will look for the setting property files from this path.

    • MyAbpApp.Domain.Shared project - /SettingProperties/MySettingProperties.json file

      {
          "Connection.Port": {
              "Group1": "Server",
              "Group2": "Connection"
          }
      }
      • The setting name Connection.Port as the key of the JSON object
      • Use "Group1" and "Group2" to set the grouping names
    • Relaunch the application to see the new grouped setting

      group-by-setting-property-file

Setting types

By default a setting value is string type, which will be rendered as a text input control in UI. We can custom it simply by providing a setting property "Type":

  • MyAbpApp.Domain.Shared project - /SettingProperties/MySettingProperties.json file

    {
        "Connection.Port": {
            "Group1": "Server",
            "Group2": "Connection",
            "Type": "number"
        }
    }
    • Set the "Connection.Port" setting type to "number"

No need to relaunch the application, just press F5 to refresh the browser, you should be able to see the effect immediately:

type-number

Now the input type changed to "number", and the frontend validations also work.

The setting types can also be configured through WithProperty method, like WithProperty("Type", "number")

For now SettingUi supports following setting types:

  • text (default)
  • number
  • checkbox
  • select
    • Needs an additional property "Options" to provide select options, which is a string separated by a vertical bar (|)

      "Connection.Protocol": {
          "Group1": "Server",
          "Group2": "Connection",
          "Type": "select",
          "Options": "|HTTP|TCP|RDP|FTP|SFTP"
      }
      

      The render result:

      selection

This is the end of the tutorial. Through this tutorial, you should be able to easily manage your settings using SettingUi. The source of the tutorial can be found in the sample folder.

Localization

The SettingUi module uses ABP's localization system to display the localization information of the settings.The languages currently supported are:

  • en
  • zh-Hans
  • tr

The localization resource files are under /Localization/SettingUi of the EasyAbp.Abp.SettingUi.Domain.Shared project.

You can add more resource files to make this module support more languages. Welcome PRs 😊 .

For ABP's localization system, please see the document

Permissions

SettingUi controls whether to display SettingUi's page by checking the SettingUi.ShowSettingPage permission.

As long as the permission is granted, all settings in the system can be modified through SettingUi.

But sometimes, we don't want users to see certain settings in SettingUi, which can be achieved by defining specific permissions.

For example, if we need to hide the "system" group from users, then we need to add a child permission of SettingUi.ShowSettingPage, the name of the permission is SettingUi.System. The code is as follows:

public override void Define(IPermissionDefinitionContext context)
{
    var settingUiPage = context.GetPermissionOrNull(SettingUiPermissions.ShowSettingPage);  // Get ShowSettingPage permission
    var systemGroup = settingUiPage.AddChild("SettingUi.System", L("Permission:SettingUi.System")); // Add display permission of Group1: System
}

In this way, when SettingUi enumerates the settings, if a permission in the form of SettingUi.Group1 is found, the Group1 will only be displayed after the permission is explicitly granted.

You can also use the SettingUiPermissions.GroupName variable. The effect is the same as the above code. The code is as follows:

public override void Define(IPermissionDefinitionContext context)
{
    var settingUiPage = context.GetPermissionOrNull(SettingUiPermissions.ShowSettingPage);  // Get ShowSettingPage permission
    var systemGroup = settingUiPage.AddChild(SettingUiPermissions.GroupName + ".System", L("Permission:SettingUi.System")); // Add display permission of Group1: System
}

We can continue to add permissions to control Group2, such as "System" -> "Password" group, we need to add a permission with the Group2 name as the suffix, the code is as follows:

public override void Define(IPermissionDefinitionContext context)
{
    ...
    var passwordGroup = systemGroup.AddChild("SettingUi.System.Password", L("Permission:SettingUi.System.Password"));   // Add display permission of Group2: Password
}

In this way, when SettingUi enumerates the settings, if a permission in the form of SettingUi.Group1.Group2 is found, the Group2 in Group1 will only be displayed after the permission is explicitly granted.

Of course, we can also continue to add a permission to precisely control a specified setting, such as "System" -> "Password" -> "Required Length", we need to add a permission with the setting name as the suffix, the code is as follows:

public override void Define(IPermissionDefinitionContext context)
{
    ...
    var requiredLength = passwordGroup.AddChild("SettingUi.System.Password.Abp.Identity.Password.RequiredLength", L("Permission:SettingUi.System.Password.RequiredLength"));    // Add display permission of Abp.Identity.Password.RequiredLength
}

In this way, when SettingUi enumerates the settings, if a permission in the form of SettingUi.Group1.Group2.SettingName is found, the setting in Group2 in Group1 will only be displayed after the permission is explicitly granted.

Through the above three-level permission definition way, we can arbitrarily control the display of settings in SettingUi.

The following figure is a screenshot of Setting Ui permissions, and the displayed result:

setting_permission

For ABP's permission system, please see the document

More Repositories

1

AbpHelper.GUI

Providing code generation and more features to help you develop applications and modules with the ABP framework.
C#
719
star
2

awesome-abp

Resources for abp.io - a modular application framework for .net core
445
star
3

EasyAbpGuide

Introduce EasyAbp organization, list our modules, provide the specification for the module development.
409
star
4

Abp.WeChat

Abp 微信 SDK 模块,包含对微信小程序、公众号、企业微信、开放平台、第三方平台等相关接口封装。
C#
314
star
5

AbpHelper.CLI

Providing code generation and more features to help you develop applications and modules with the ABP framework.
C#
285
star
6

EShop

An abp application module group that provides basic e-shop service.
C#
250
star
7

WeChatManagement

基于EasyAbp.Abp.WeChat模块实现微信登录、微信用户信息存储、微信服务器管理、微信第三方平台等高级功能的Abp应用模块组
C#
128
star
8

Abp.EventBus.CAP

This is a repository integrated CAP with ABP EventBus
C#
110
star
9

FileManagement

An abp.io application module that allows users to upload and maintain files.
C#
98
star
10

NotificationService

An integrated user notification service Abp module, supporting email, SMS, PM, and more other methods.
C#
71
star
11

PaymentService

An abp application module that provides payment service.
C#
68
star
12

UniappManagement

实现uni-app的应用版本管理、整包更新、热更新、差量热更新等功能的Abp应用模块
C#
64
star
13

Abp.DynamicEntity

An ABP module that can dynamically create entities at runtime and perform CRUD operations like normal entities
C#
49
star
14

Abp.Aliyun

专门为 ABP vNext 框架开发的阿里云 SDK 模块。
C#
45
star
15

Elsa

An Abp module integrates Elsa workflows and provides some preset Elsa activities for the ABP framework.
C#
43
star
16

EasyMall

Quickly build an e-commerce application based on EasyAbp.EShop.
C#
39
star
17

PrivateMessaging

An abp application module that allows users to send private messages to each other.
C#
38
star
18

Abp.DynamicQuery

An ABP module helps you quickly implement dynamic queries
C#
37
star
19

Abp.Trees

An abp module that provides standard tree structure entity implement.
C#
34
star
20

Abp.PhoneNumberLogin

An abp module to avoid duplicate user phone numbers being confirmed and providing phone number confirmation and phone number login features and more.
C#
32
star
21

Abp.DataDictionary

Abp data dictionary module.
C#
29
star
22

Abp.AspNetCoreRateLimit

An Abp module helps you control how often your service is used.
C#
28
star
23

Serilog.Sinks.TencentCloud

仿照Serilog.Sinks.Http写的Serilog扩展将日志推送到腾讯云cls
C#
27
star
24

Abp.EntityUi

An abp module that dynamically generates management UI for entities in runtime.
C#
26
star
25

Abp.GraphQL

An ABP module that allows using application services by GraphQL. It also accepted custom schemes and types you defined.
C#
25
star
26

Abp.AspNetCore.Mvc.UI.Theme.LYear

A simple ABP MVC UI theme.
C#
24
star
27

Abp.VerificationCode

An ABP module to generate and verify verification codes.
C#
24
star
28

Abp.TencentCloud

专门为 ABP vNext 封装的腾讯云 SDK 模块。
C#
23
star
29

GiftCardManagement

An abp application module where you can create gift cards and your app user can use them to exchange something.
C#
23
star
30

Abp.EventBus.Boxes.Dtm

The DTM implementation module of ABP distributed event boxes.
C#
22
star
31

Abp.EventBus.Dapr

This is a repository integrated Dapr Pubsub with ABP EventBus
C#
21
star
32

CacheManagement

An abp application module helps administrators to manage the app cache data.
C#
19
star
33

Abp.TagHelperPlus

An Abp MVC UI tag-helper enhancement module to enhance ABP built-in tag-helpers and provide new tag-helpers such as rich text editor, advanced selector, and more.
C#
19
star
34

Abp.RelatedDtoLoader

An Abp module that help you automatically load related DTO (like ProductDto in OrderDto) under DDD.
C#
18
star
35

Forum

An abp forum application module.
C#
18
star
36

SharedResources

An abp application module that allows users to share resources with each other.
C#
18
star
37

Cms

An abp CMS application module.
C#
17
star
38

Abp.Sms.TencentCloud

Abp TencentCloud SMS module.
C#
16
star
39

BookingService

An ABP application module that allows users to book time for people or assets.
C#
14
star
40

Abp.DynamicPermission

An ABP module that allows you to define and grant dynamic permissions in runtime.
C#
14
star
41

Abp.LoginUi

An ABP module that provides enhanced login pages.
C#
12
star
42

ReviewManagement

An abp application module that provides general user review service. For example, a user can review a product he has bought with text, pictures and star-rating.
C#
11
star
43

LoggingManagement

An abp application module to help you query and manage your application logs.
C#
10
star
44

DynamicForm

An ABP module helps users to define and use dynamic forms at runtime.
C#
10
star
45

Abp.DynamicMenu

An abp module that dynamically creates menu items for ABP UI projects in runtime.
C#
10
star
46

EasyComment

An ABP application module provides a flexible comment system.
C#
10
star
47

BigDataSolution

A persistence layer based on ElasticSearch and Cassandra.
C#
6
star
48

EzGet

An abp module to create a NuGet and Symbol service.
C#
5
star
49

Abp.BlobStoring.TencentCloud

TencentCloud implementation of Abp BLOB Storing.
C#
4
star
50

ProcessManagement

An ABP module that helps define and track business processes.
C#
3
star
51

easyabp.github.io

EasyAbp official site.
3
star
52

AbpModuleHub

Discover and get the ABP modules you need. It's a web app to show authorized modules where module developers can publish free modules or commercial modules.
C#
3
star
53

InstantMessaging

An abp application module that allows users to chat with each other instantly.
2
star
54

WarehouseManagement

An abp application module that provides basic features to build a warehouse management system (WMS).
2
star
55

GoalManagement

An abp application module that allows setting goals and rewards users who achieve the goals.
1
star
56

Oa.Workflow

An abp application module you can use to create OA workflows with customized rules and data.
1
star
57

ModuleLibrary

Register all certified modules so that AbpHelper can install them.
1
star
58

CalendarManagement

An abp application module that allows users to arrange times for people or things, it is also easy to help you build a reservation system.
1
star
59

Abp.Cqrs

An Abp module to implement CQRS.
1
star
60

SeedingTool

An abp application module to help host/tenants re seed the initial data with background job in launched applications.
1
star