Base solution for your next web application
Open Closed

Implementing Customizable Dashboards - V8.0 #7997


User avatar
1
dmux created

I am exploring the new Customizable Dashboards and I'm excited about implementing this feature.

I noticed that if my user does not have the AppPermissions.Pages_Administration_AuditLogs permission, the dashboard does not get populated and they have no widgets available. (I note the generalStats widget adds the AppPermissions.Pages_Administration_AuditLogs to its permissions but I can't see why that would cause a problem).

I managed to work around this in the short term by adding the AppPermissions.Pages_Tenant_Dashboard permission to the AuditLogAppService, but I couldn't see exactly where this dependency was introduced. Of course, my workaround is not ideal, so maybe someone can identify the root cause.

Also a question: I am looking at setting up a library of widgets as partial html files, which are inserted at runtime. But is this something you guys are planning to develop soon? If so I'll hold off and just keep using the pattern you have set up so that upgrades are simpler.


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @dmux

    I couldn't find AppPermissions.Pages_Administration_AuditLogs permission usage for any widget in our code base. Is it possible that someone on your team accidentally did that ?

  • User Avatar
    1
    dmux created

    Hi ismcagdas,

    Thank you for following up.

    I have had a chance to dig a bit deeper and I think I have found the issue.

    In Core/DashboardCustomization/Definitions/DashboardConfiguration.cs this is the pattern provided in the default project:

    var tenantWidgetsDefaultPermission = new List
    {
    AppPermissions\.Pages\_Tenant\_Dashboard
    };
    
    var dailySales = new WidgetDefinition(
        WebPortalDashboardCustomizationConsts.Widgets.Tenant.DailySales,
        "WidgetDailySales",
        side: MultiTenancySides.Tenant,
        usedWidgetFilters: new List<string> { dateRangeFilter.Id },
        permissions: tenantWidgetsDefaultPermission
    );
    
    var generalStats = new WidgetDefinition(
        WebPortalDashboardCustomizationConsts.Widgets.Tenant.GeneralStats,
        "WidgetGeneralStats",
        side: MultiTenancySides.Tenant,
        permissions: tenantWidgetsDefaultPermission
        );
    
    generalStats.Permissions.Add(AppPermissions.Pages_Administration_AuditLogs);
    

    ... and so forth. I haven't yet removed all thses default widgets from my project so they are all still there.

    What happens is that each new widget definition sets its "permissions" to be a pointer to the list called "tenantWidgetsDefaultPermission". The result is that all widgets end up with the same list, which includes any added permissions like the one listed on the last line here. This is why all my widget users required AuditLogs permission for every widget, when they should only require that permission for GeneralStats.

    What I did to stop this behaviour is I added ".ToList()" when setting the widget "permissions" property, so that the permissions list would be a new object. This resolved the issue, like this:

    var generalStats = new WidgetDefinition(
        WebPortalDashboardCustomizationConsts.Widgets.Tenant.GeneralStats,
        "WidgetGeneralStats",
        side: MultiTenancySides.Tenant,
        permissions: tenantWidgetsDefaultPermission.ToList()
        );
    

    There might be nicer ways to do it, but this works for me for the moment.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks @dmux

  • User Avatar
    0
    ISTeam created

    @ismcagdas this issue is still present in MVC Core & jQuery template. I followed exact steps to create my first dashboard widget mentioned in the documentation then I got an error :

    abpexception there is no permission with name "HelloWorld".

    And in fact in the documentation URL there is no mention of how to setup the permission for this particular Widget which they are describing.

    So, in addition to adding ".ToList()" change for generalStats, I had to completely remove the HelloWorld permission. Because all the permissions setup are for pages and there is no specific permission for particular Widget. (i.e. tenantWidgetsDefaultPermission is nothing but AppPermissions.Pages_Tenant_Dashboard)

    And yes even today, the tenant dashboard is empty because of the AuditLog permission mentioned above!

    Thanks @dmux for your explaination and sharing the solution as well!