mirror of https://github.com/abpframework/abp.git
committed by
GitHub
8 changed files with 2 additions and 222 deletions
@ -1,26 +0,0 @@ |
|||||
@page |
|
||||
@using Microsoft.Extensions.Localization |
|
||||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|
||||
@using Volo.Abp.TenantManagement.Localization |
|
||||
@using Volo.Abp.TenantManagement.Web.Pages.TenantManagement.Tenants |
|
||||
@model ConnectionStringsModal |
|
||||
@inject IStringLocalizer<AbpTenantManagementResource> L |
|
||||
@{ |
|
||||
Layout = null; |
|
||||
} |
|
||||
<form method="post" asp-page="/TenantManagement/Tenants/ConnectionStringsModal"> |
|
||||
<abp-modal> |
|
||||
<abp-modal-header title="@L["ConnectionStrings"]"></abp-modal-header> |
|
||||
<abp-modal-body> |
|
||||
<abp-input asp-for="Tenant.Id"></abp-input> |
|
||||
|
|
||||
<abp-input asp-for="Tenant.UseSharedDatabase"></abp-input> |
|
||||
|
|
||||
<div id="Tenant_DefaultConnectionString_Wrap" class="@(Model.Tenant.UseSharedDatabase ? "d-none" : "")" > |
|
||||
<abp-input asp-for="Tenant.DefaultConnectionString"></abp-input> |
|
||||
</div> |
|
||||
|
|
||||
</abp-modal-body> |
|
||||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
|
||||
</abp-modal> |
|
||||
</form> |
|
||||
@ -1,61 +0,0 @@ |
|||||
using System; |
|
||||
using System.ComponentModel.DataAnnotations; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Volo.Abp.Validation; |
|
||||
|
|
||||
namespace Volo.Abp.TenantManagement.Web.Pages.TenantManagement.Tenants |
|
||||
{ |
|
||||
public class ConnectionStringsModal : TenantManagementPageModel |
|
||||
{ |
|
||||
[BindProperty] |
|
||||
public TenantInfoModel Tenant { get; set; } |
|
||||
|
|
||||
protected ITenantAppService TenantAppService { get; } |
|
||||
|
|
||||
public ConnectionStringsModal(ITenantAppService tenantAppService) |
|
||||
{ |
|
||||
TenantAppService = tenantAppService; |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<IActionResult> OnGetAsync(Guid id) |
|
||||
{ |
|
||||
var defaultConnectionString = await TenantAppService.GetDefaultConnectionStringAsync(id); |
|
||||
Tenant = new TenantInfoModel |
|
||||
{ |
|
||||
Id = id, |
|
||||
DefaultConnectionString = defaultConnectionString, |
|
||||
UseSharedDatabase = defaultConnectionString.IsNullOrWhiteSpace() |
|
||||
}; |
|
||||
|
|
||||
return Page(); |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<IActionResult> OnPostAsync() |
|
||||
{ |
|
||||
ValidateModel(); |
|
||||
|
|
||||
if (Tenant.UseSharedDatabase || Tenant.DefaultConnectionString.IsNullOrWhiteSpace()) |
|
||||
{ |
|
||||
await TenantAppService.DeleteDefaultConnectionStringAsync(Tenant.Id); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
await TenantAppService.UpdateDefaultConnectionStringAsync(Tenant.Id, Tenant.DefaultConnectionString); |
|
||||
} |
|
||||
|
|
||||
return NoContent(); |
|
||||
} |
|
||||
|
|
||||
public class TenantInfoModel |
|
||||
{ |
|
||||
[HiddenInput] |
|
||||
public Guid Id { get; set; } |
|
||||
|
|
||||
public bool UseSharedDatabase { get; set; } |
|
||||
|
|
||||
[DynamicStringLength(typeof(TenantConnectionStringConsts), nameof(TenantConnectionStringConsts.MaxValueLength))] |
|
||||
public string DefaultConnectionString { get; set; } |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
(function ($) { |
|
||||
abp.modals.TenantConnectionStringManagement = function () { |
|
||||
var initModal = function (publicApi, args) { |
|
||||
publicApi |
|
||||
.getModal() |
|
||||
.find('input[name="Tenant.UseSharedDatabase"]') |
|
||||
.change(function () { |
|
||||
var $this = $(this); |
|
||||
$('#Tenant_DefaultConnectionString_Wrap').toggleClass( |
|
||||
'd-none' |
|
||||
); |
|
||||
$this.val($this.prop('checked')); |
|
||||
}); |
|
||||
}; |
|
||||
|
|
||||
return { |
|
||||
initModal: initModal, |
|
||||
}; |
|
||||
}; |
|
||||
})(jQuery); |
|
||||
Loading…
Reference in new issue