ABP uses
abp.message.error
to show errors andsweetalert2
is used in its infrastructure. So I think you can do this with Sweatalert2's configurations. For example:$(function () { abp.libs.sweetAlert.config.error.footer = "<button type='button' id='Copy Log' class='swal2-cancel swal2-styled'>Download Log</button>" abp.libs.sweetAlert.config.error.didOpen = () => { var errorDetails = Swal.getHtmlContainer(); console.log(errorDetails); } });
Note: As far as I know,
sweetalert2
allows you to change the entire error(or other default templates) template as well.Result:
Note: If you want to see the
detail
andstack trace
of the error in modal like me, you can do this as in the code below:Configure< AbpExceptionHandlingOptions >(options => { options.SendExceptionsDetailsToClients = true; options.SendStackTraceToClients = true; });
For more information:
- https://docs.abp.io/en/abp/latest/UI/AspNetCore/JavaScript-API/Message#sweetalert-configuration
- https://sweetalert2.github.io/
How to trigger Copy Log button click for this solution, can you give an example? Because, it can not be triggered.
$(function () { abp.libs.sweetAlert.config.error.footer = "<button type='button' id='Copy Log' class='swal2-cancel swal2-styled'>Download Log</button>" abp.libs.sweetAlert.config.error.didOpen = () => { var errorDetails = Swal.getHtmlContainer(); console.log(errorDetails); } });
Hi,
I used ABP ModalManager and I want to catch which is thrown exception from backend in openModal method in js. If I achieve this, then I can manage modal html code. Actually, I want to open modal, even if it throws exception from backend. I need to have a onError method in modalManager. Because using try catch block doesn't work in onOpen or Open methods to handle exception. Is there any way to catch example when openning abp modal or open modal even if it throws exception from backend ?
When throws exception from backend,
I want to change modal html code. But if there is a exception, then modal can not be opened.
So, I tried to catch exception in modal.open like this, but it doesn't work. So I think that I need to modal.onError or something like this.
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.
If you're creating a bug/problem report, please include followings:
Hi,
I want to change html code to add download button in 403 business exception modal. Like bellow, 1- Is it possible?
2- And also, I want to interrupt before onResult function if it has business exception. Because, if there is an error, I can not break in onResult function.
Thanks
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.
If you're creating a bug/problem report, please include followings:
ABP Framework version: v5.3.3
UI type: MVC
DB provider: EF Core
Tiered (MVC): yes
Exception message and stack trace:
Steps to reproduce the issue:"
hi
It is not recommended that you inject services inside the
ConfigureServices
method. The dependency injection container has not been created yet.I need to check tenant db connectionSetting before configuring menu contributor.
You can inject the services in
menu contributor
.public class AbpAccountUserMenuContributor : IMenuContributor { public virtual Task ConfigureMenuAsync(MenuConfigurationContext context) { var tenantRepository = context.ServiceProvider.GetRequiredService<ITenantRepository>(); return Task.CompletedTask; } }
I tried this solution first, but I get an error like this. What would be the reason?
And the above example is taken from our own module, but I want to use this logic also in Volo.CmsKit MenuContributor. How should I override it in CmsKit MenuContributor.
hi
You can remove the
CmsKit MenuContributor
from theAbpNavigationOptions
and copy the code to yourMenuContributor
Configure<AbpNavigationOptions>(options => { options.MenuContributors.Remove... });
Thanks for your advice but I don't want to manage with options. I need to override CmsKitAdminMenuContributor.cs on some special case. Is there any way to do this?
Hello,
I need to inject tenantRepository or tenantApppService in ConfigureServices method in DocsWebModule.cs. I need to check tenant db connectionSetting before configuring menu contributor. But I can not register in ConfigureServices.
Can you give an example?
Thanks
ABP Framework version: v5.3.2
UI type: / MVC /
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): yes / no
Exception message and stack trace:
Steps to reproduce the issue:"
Hello,
We have two questions about MenuContributor. Firstly, we always want to use MultiTenancySides.Both in permission side. But sometimes, we want to use just show our own module in host, not a tenant. We can create options class and then check it when if CurrentTenant.Id is null to achieve this. But we think that, it is not a best way for this. Can you give an advice about that?
And the above example is taken from our own module, but I want to use this logic also in Volo.CmsKit MenuContributor. How should I override it in CmsKit MenuContributor.
Thanks
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.
If you're creating a bug/problem report, please include followings:
ABP Framework version: v5.3.2
UI type: / MVC /
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): yes / no
Exception message and stack trace:
Steps to reproduce the issue:"
If you don't want to set
multiple
andmaximumSelectionLength
You can try this:
customModal.onOpen(function() { var modalId = customModal.getModalId() + 'Container'; $("#customSelect").select2({ tags: true, dropdownParent: $("#" + modalId +" .modal.fade"), insertTag: function(data, tag) { data.push(tag); } }); });
Actually, we were using it as in the first example and we were getting an error. It fixed when I Adding ".modal.fade" as you showed. Thank you so much.
Hi,
In the CmsKit example, you are using the select component with abp-dynamic-form in a normal html page. We want to use it in abp-modal. Still, I went through your example and tried it as in the CmsKit. Select component it has been enabled. However, we are using different features of select component. We could also add a new item to the select list dynamically as below. But this is working in normal pages but not in abp-modal. But, it is broken after we upgraded ABP version to 5.1.1.
The component class in your example does not have a new option insert feature. Can you show an example like this? We can also achieve this when we use bootstrap modal instead of abp-modal, but we want to achieve it with abp-modal.
We actually handled this using multiple ListBoxFor. We can also limit upper as 1. But we still hope to be able to use it as select component as before.
Thanks
Hello,
Select2 error was not fixed, even after upgrading the version to 5.3.0. Can you review our previous question from this link? https://support.abp.io/QA/Questions/2577/use-of-select2-on-abp-modal-is-broken-after-version-upgraded--to-v511
Thanks,
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.
If you're creating a bug/problem report, please include followings:
ABP Framework version: v5.3.0
UI type: / MVC /
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): yes / no
Exception message and stack trace:
Steps to reproduce the issue:"