Thanks you liangshiwei. Your suggestion solved the issue. Your proposal for the 4.3 version looks good.
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
public class RemoveJqueryScriptContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.RemoveAll(x => x.StartsWith("/libs/jquery/jquery.js", StringComparison.InvariantCultureIgnoreCase));
}
}
Use this contributor in the webmodule like this :
Configure<AbpBundlingOptions>(options =>
{
options
.ScriptBundles
.Configure("Lepton.Global", bundle =>
{
bundle.AddContributors(typeof(Support.RemoveJqueryScriptContributor));
});
});
Start the application and go to the Identity/Users screen and view the source. There you will find that the jquery.js is still there. However, if you go to the Identity/Roles you will find jquery.js is not there. We have noticed that both screens ( Users and Organization Units) also include jstree.js. I To me it seems the reported problem is somehow related to the use of jstree.js.
source of Organization Units (incorrect):
Because we added jquery at the top of the page (wich works) the second added jquery.js by ABP itself will give a problem.
Hi liangshiwei,
Your first suggestion does not give the desired result. The SeedAsync is already called in the MigrateTenantDatabaseAsync. I think I need to take the second step and create a custom seeder.
But is there a way to use the KantanPermissionDefinitionProvider defined in the Application.Contracts ?
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
Could you explain to me hwo I should add the permissons we have defined in the PermissionDefinitionProvider in the Application.Contracts ? The code we use now to create the tenant database looks like this :
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(ITenantAppService), typeof(KantanTenantAppService))]
public class KantanTenantAppService : TenantAppService
{
private readonly ITenantRepository _tenantRepository;
private readonly IEditionRepository _editionRepository;
private readonly ITenantManager _tenantManager;
private readonly IDataSeeder _dataSeeder;
private readonly ICurrentTenant _currentTenant;
private readonly IConfiguration _config;
public KantanTenantAppService(ITenantRepository tenantRepository,
IEditionRepository editionRepository,
ITenantManager tenantManager,
IDataSeeder dataSeeder,
ICurrentTenant currentTenant,
IConfiguration config) : base(
tenantRepository,
editionRepository,
tenantManager,
dataSeeder)
{
_tenantRepository = tenantRepository;
_editionRepository = editionRepository;
_tenantManager = tenantManager;
_dataSeeder = dataSeeder;
_currentTenant = currentTenant;
_config = config;
}
[Authorize("Saas.Tenants.Create")]
public override async Task<SaasTenantDto> CreateAsync(SaasTenantCreateDto input)
{
SaasTenantDto result;
string configConnectionString = _config.GetConnectionString("NewTenantConnectionString");
string newConnectionString = string.Empty;
Tenant tenant;
string dbPrefix = _config.GetSection(KantanConsts.TenantConfigSection)["Default"];
result = await base.CreateAsync(input);
tenant = _tenantRepository.FindByName(input.Name);
if (tenant != null)
{
newConnectionString =
string.Format(configConnectionString
,dbPrefix
,tenant.Id.ToString().Replace("-","")
);
//Create default connection string for this new tenant
await base.UpdateDefaultConnectionStringAsync(tenant.Id, newConnectionString);
using (_currentTenant.Change(tenant.Id))
{
await ServiceProvider.
GetRequiredService<KantanDbMigrationService>()
.MigrateTenantDatabasesAsync(tenant);
// Add the additional Permissions
//addpermissions
//Add other data
//DoSomething
}
}
return result;
}
}
The definition provider for the permissions looks like this (in the application.contracts)
public class KantanPermissionDefinitionProvider : PermissionDefinitionProvider { public override void Define(IPermissionDefinitionContext context) { PermissionGroupDefinition KantanGroup = context.AddGroup(KantanPermissions.GroupName); PermissionDefinition pd;
KantanGroup.AddPermission(KantanPermissions.Dashboard.Host, L("Permission:Dashboard"), MultiTenancySides.Host);
KantanGroup.AddPermission(KantanPermissions.Dashboard.Tenant, L("Permission:Dashboard"), MultiTenancySides.Tenant);
pd = KantanGroup.AddPermission(KantanPermissions.FinancialStatement.FinancialStatementGroup, L("Permission:FinancialStatementGroupName"), MultiTenancySides.Host);
pd.AddChild(KantanPermissions.FinancialStatement.FinancialStatement_Add, L("Permission:Add"), MultiTenancySides.Host);
pd.AddChild(KantanPermissions.FinancialStatement.FinancialStatement_Delete, L("Permission:Delete"), MultiTenancySides.Host);
pd.AddChild(KantanPermissions.FinancialStatement.FinancialStatement_Edit, L("Permission:Edit"), MultiTenancySides.Host);
pd.AddChild(KantanPermissions.FinancialStatement.FinancialStatement_Read, L("Permission:Read"), MultiTenancySides.Host);
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<KantanResource>(name);
}
}
Basically we have two questions : 1 : How to add the permissions ? 2 : How to add other data to the tenant database ?
Do we need to use a seeder ? Thanks for your help.
Thanks liangshiwei. Got it working !
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
namespace Kantan
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(ITenantAppService), typeof(KantanTenantAppService))]
public class KantanTenantAppService : TenantAppService
{
private readonly ITenantRepository _tenantRepository;
private readonly IEditionRepository _editionRepository;
private readonly ITenantManager _tenantManager;
private readonly IDataSeeder _dataSeeder;
public KantanTenantAppService(ITenantRepository tenantRepository,
IEditionRepository editionRepository,
ITenantManager tenantManager,
IDataSeeder dataSeeder ) : base(
tenantRepository,
editionRepository,
tenantManager,
dataSeeder)
{
_tenantRepository = tenantRepository;
_editionRepository = editionRepository;
_tenantManager = tenantManager;
_dataSeeder = dataSeeder;
}
[Authorize("Saas.Tenants.Create")]
public override async Task<SaasTenantDto> CreateAsync(SaasTenantCreateDto input)
{
SaasTenantDto result;
string newConnectionString = "";
Tenant tenant;
result = await base.CreateAsync(input);
tenant = _tenantRepository.FindByName(input.Name);
if (tenant!=null)
{
newConnectionString = $"Server=(LocalDb)\\MSSQLLocalDB;Database=Kantan{input.Name};Trusted_Connection=True;MultipleActiveResultSets=true";
await base.UpdateDefaultConnectionStringAsync(tenant.Id, newConnectionString);
//await ServiceProvider.
// GetRequiredService<KantanDbMigrationService>()
// .MigrateHostDatabaseAsync();
await ServiceProvider.
GetRequiredService<KantanDbMigrationService>()
.MigrateTenantDatabasesAsync(tenant);
}
return result;
}
}
}
@alper Concerning my problem with removing jquery. You can close that issue because we needed to change the removal of jquery to the below code :
options
.ScriptBundles
.Configure(LeptonThemeBundles.Scripts.Global, bundle => {
bundle.AddContributors(typeof(Support.RemoveJqueryScriptContributor));
});
instead of
options
.ScriptBundles
.Configure(StandardBundles.Scripts.Global, bundle => {
bundle.AddContributors(typeof(Support.RemoveJqueryScriptContributor));
});
@liangshiwei ... Many thanks !!!! That solved the issue.
The documentation should be modified on this ;-)
@liangshiwei Thanks .. I removed the download link; did not think about the license. If needed I can provide you with the demo project.
@alper I have tried it using your suggestions but still nu luck.
But then I remembered I added the nuget telerik.com within VS2019 Package Manager Settings. Because dotnet does not run within the VS2019 context, it is missing the login for Telerik. Removing the Telerik nuget from VS solved the issue. Thanks for your support !