diff --git a/Volo.Abp.sln b/Volo.Abp.sln index b4bf0d2be1..259de7b7cf 100644 --- a/Volo.Abp.sln +++ b/Volo.Abp.sln @@ -242,7 +242,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Abp.MultiTenancy", "Abp.Mul EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.MultiTenancy.Application.Tests", "test\Volo.Abp.MultiTenancy.Application.Tests\Volo.Abp.MultiTenancy.Application.Tests.csproj", "{B65973F1-9EE0-4914-B6F2-D88F753E1D21}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.MultiTenancy.Web", "src\Volo.Abp.MultiTenancy.Web\Volo.Abp.MultiTenancy.Web.csproj", "{0808036D-065B-4525-BF30-CBCEA062F8E9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.MultiTenancy.Web", "src\Volo.Abp.MultiTenancy.Web\Volo.Abp.MultiTenancy.Web.csproj", "{0808036D-065B-4525-BF30-CBCEA062F8E9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.MultiTenancy.HttpApi", "src\Volo.Abp.MultiTenancy.HttpApi\Volo.Abp.MultiTenancy.HttpApi.csproj", "{06423FAC-67E2-4B7C-B29F-39578F460C4F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -634,6 +636,10 @@ Global {0808036D-065B-4525-BF30-CBCEA062F8E9}.Debug|Any CPU.Build.0 = Debug|Any CPU {0808036D-065B-4525-BF30-CBCEA062F8E9}.Release|Any CPU.ActiveCfg = Release|Any CPU {0808036D-065B-4525-BF30-CBCEA062F8E9}.Release|Any CPU.Build.0 = Release|Any CPU + {06423FAC-67E2-4B7C-B29F-39578F460C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06423FAC-67E2-4B7C-B29F-39578F460C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06423FAC-67E2-4B7C-B29F-39578F460C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06423FAC-67E2-4B7C-B29F-39578F460C4F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -752,6 +758,7 @@ Global {3CE22CAC-4B27-4EEC-A35E-C01219ED6E99} = {447C8A77-E5F0-4538-8687-7383196D04EA} {B65973F1-9EE0-4914-B6F2-D88F753E1D21} = {3CE22CAC-4B27-4EEC-A35E-C01219ED6E99} {0808036D-065B-4525-BF30-CBCEA062F8E9} = {CA154803-3589-47B3-B7CB-B18F94FE1EB6} + {06423FAC-67E2-4B7C-B29F-39578F460C4F} = {CA154803-3589-47B3-B7CB-B18F94FE1EB6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDesk.Web.Mvc.csproj b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDesk.Web.Mvc.csproj index 50e70c137d..f84002dfd1 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDesk.Web.Mvc.csproj +++ b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDesk.Web.Mvc.csproj @@ -27,7 +27,7 @@ - + diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs index 961e80f919..888efc6fb2 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs @@ -46,7 +46,7 @@ namespace AbpDesk.Web.Mvc typeof(AbpIdentityServerEntityFrameworkCoreModule), typeof(AbpAspNetCoreMultiTenancyModule), typeof(AbpMultiTenancyWebModule), - typeof(AbpMultiTenancyApplicationModule) + typeof(AbpMultiTenancyHttpApiModule) )] public class AbpDeskWebMvcModule : AbpModule //TODO: Rename to AbpDeskWebModule, change default namespace to AbpDesk.Web { diff --git a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs index 7c3f5f6288..4430047ed9 100644 --- a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs +++ b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs @@ -14,11 +14,14 @@ namespace Volo.Abp.Identity services.Configure(options => { - options.ConventionalControllers.Create(typeof(AbpIdentityApplicationModule).Assembly, opts => - { - opts.RootPath = "identity"; - opts.UrlControllerNameNormalizer = context => context.ControllerName.RemovePreFix("Identity"); - }); + options.ConventionalControllers.Create( + typeof(AbpIdentityApplicationModule).Assembly, + opts => + { + opts.RootPath = "identity"; + opts.UrlControllerNameNormalizer = context => context.ControllerName.RemovePreFix("Identity"); + } + ); }); } } diff --git a/src/Volo.Abp.Identity.Web/ObjectMappings/AbpIdentityWebAutoMapperProfile.cs b/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs similarity index 97% rename from src/Volo.Abp.Identity.Web/ObjectMappings/AbpIdentityWebAutoMapperProfile.cs rename to src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs index ada2fa3235..c8651d8e88 100644 --- a/src/Volo.Abp.Identity.Web/ObjectMappings/AbpIdentityWebAutoMapperProfile.cs +++ b/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs @@ -3,7 +3,7 @@ using Volo.Abp.Identity.Web.Pages.Identity.Roles; using CreateUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.CreateModalModel; using EditUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.EditModalModel; -namespace Volo.Abp.Identity.Web.ObjectMappings +namespace Volo.Abp.Identity.Web { public class AbpIdentityWebAutoMapperProfile : Profile { diff --git a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs index a0bb65dbef..5620fd0824 100644 --- a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs +++ b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs @@ -4,7 +4,6 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AutoMapper; using Volo.Abp.Identity.Web.Localization.Resources.AbpIdentity; using Volo.Abp.Identity.Web.Navigation; -using Volo.Abp.Identity.Web.ObjectMappings; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Ui.Navigation; @@ -46,7 +45,7 @@ namespace Volo.Abp.Identity.Web services.Configure(options => { - options.AddProfile(true); + options.AddProfile(validate: true); }); } } diff --git a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.less b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.less index 7534888421..21adf56097 100644 --- a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.less +++ b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.less @@ -1,4 +1,5 @@ -.dataTable { +//TODO: This code is duplicated for other pages too. Unify them. +.dataTable { width: 100% !important; border-spacing: 0 !important; } diff --git a/src/Volo.Abp.MultiTenancy.HttpApi/Volo.Abp.MultiTenancy.HttpApi.csproj b/src/Volo.Abp.MultiTenancy.HttpApi/Volo.Abp.MultiTenancy.HttpApi.csproj new file mode 100644 index 0000000000..d1bd8d796f --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.HttpApi/Volo.Abp.MultiTenancy.HttpApi.csproj @@ -0,0 +1,25 @@ + + + + + + netstandard2.0 + Volo.Abp.MultiTenancy.HttpApi + Volo.Abp.MultiTenancy.HttpApi + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; + false + false + false + + + + + + + + + + + + + diff --git a/src/Volo.Abp.MultiTenancy.HttpApi/Volo/Abp/MultiTenancy/AbpIdentityHttpApiModule.cs b/src/Volo.Abp.MultiTenancy.HttpApi/Volo/Abp/MultiTenancy/AbpIdentityHttpApiModule.cs new file mode 100644 index 0000000000..7c07258181 --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.HttpApi/Volo/Abp/MultiTenancy/AbpIdentityHttpApiModule.cs @@ -0,0 +1,26 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Modularity; + +namespace Volo.Abp.MultiTenancy +{ + [DependsOn(typeof(AbpMultiTenancyApplicationModule), typeof(AbpAspNetCoreMvcModule))] + public class AbpMultiTenancyHttpApiModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + + services.Configure(options => + { + options.ConventionalControllers.Create( + typeof(AbpMultiTenancyApplicationModule).Assembly, + opts => + { + opts.RootPath = "multi-tenancy"; + } + ); + }); + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/AbpMultiTenancyWebAutoMapperProfile.cs b/src/Volo.Abp.MultiTenancy.Web/AbpMultiTenancyWebAutoMapperProfile.cs new file mode 100644 index 0000000000..52c47012bb --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/AbpMultiTenancyWebAutoMapperProfile.cs @@ -0,0 +1,25 @@ +using AutoMapper; +using Volo.Abp.MultiTenancy.Web.Pages.MultiTenancy.Tenants; + +namespace Volo.Abp.MultiTenancy.Web +{ + public class AbpMultiTenancyWebAutoMapperProfile : Profile + { + public AbpMultiTenancyWebAutoMapperProfile() + { + CreateRoleMappings(); + } + + private void CreateRoleMappings() + { + //List + CreateMap(); + + //CreateModal + CreateMap(); + + //EditModal + CreateMap(); + } + } +} diff --git a/src/Volo.Abp.MultiTenancy.Web/AbpMultiTenancyWebModule.cs b/src/Volo.Abp.MultiTenancy.Web/AbpMultiTenancyWebModule.cs index c7ba169938..65a2b093d0 100644 --- a/src/Volo.Abp.MultiTenancy.Web/AbpMultiTenancyWebModule.cs +++ b/src/Volo.Abp.MultiTenancy.Web/AbpMultiTenancyWebModule.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AutoMapper; using Volo.Abp.Localization; @@ -15,6 +16,14 @@ namespace Volo.Abp.MultiTenancy.Web [DependsOn(typeof(AbpAutoMapperModule))] public class AbpMultiTenancyWebModule : AbpModule { + public override void PreConfigureServices(IServiceCollection services) + { + services.PreConfigure(options => + { + options.AddAssemblyResource(typeof(AbpMultiTenancyResource)); + }); + } + public override void ConfigureServices(IServiceCollection services) { services.AddAssemblyOf(); @@ -33,6 +42,11 @@ namespace Volo.Abp.MultiTenancy.Web { options.Resources.AddVirtualJson("en", "/Localization/Resources/AbpMultiTenancy"); }); + + services.Configure(options => + { + options.AddProfile(validate: true); + }); } } } \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/Localization/Resources/AbpMultiTenancy/IdentityResource.cs b/src/Volo.Abp.MultiTenancy.Web/Localization/Resources/AbpMultiTenancy/AbpMultiTenancyResource.cs similarity index 100% rename from src/Volo.Abp.MultiTenancy.Web/Localization/Resources/AbpMultiTenancy/IdentityResource.cs rename to src/Volo.Abp.MultiTenancy.Web/Localization/Resources/AbpMultiTenancy/AbpMultiTenancyResource.cs diff --git a/src/Volo.Abp.MultiTenancy.Web/Localization/Resources/AbpMultiTenancy/en.json b/src/Volo.Abp.MultiTenancy.Web/Localization/Resources/AbpMultiTenancy/en.json index 92e4e9582b..30b5f914bf 100644 --- a/src/Volo.Abp.MultiTenancy.Web/Localization/Resources/AbpMultiTenancy/en.json +++ b/src/Volo.Abp.MultiTenancy.Web/Localization/Resources/AbpMultiTenancy/en.json @@ -1,6 +1,7 @@ { "culture": "en", "texts": { - + "NewTenant": "New tenant", + "TenantName": "Tenant name" } } \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/CreateModal.cshtml b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/CreateModal.cshtml new file mode 100644 index 0000000000..ef28fb606e --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/CreateModal.cshtml @@ -0,0 +1,33 @@ +@page +@using Microsoft.Extensions.Localization +@using Volo.Abp.MultiTenancy.Web.Localization.Resources.AbpMultiTenancy +@using Volo.Abp.MultiTenancy.Web.Pages.MultiTenancy.Tenants +@model CreateModalModel +@inject IStringLocalizer L +@{ + Layout = null; +} + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/CreateModal.cshtml.cs b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/CreateModal.cshtml.cs new file mode 100644 index 0000000000..d64f3641ed --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/CreateModal.cshtml.cs @@ -0,0 +1,38 @@ +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.RazorPages; + +namespace Volo.Abp.MultiTenancy.Web.Pages.MultiTenancy.Tenants +{ + public class CreateModalModel : AbpPageModel + { + [BindProperty] + public TenantInfoModel TenantModel { get; set; } + + private readonly ITenantAppService _tenantAppService; + + public CreateModalModel(ITenantAppService tenantAppService) + { + _tenantAppService = tenantAppService; + } + + public async Task OnPostAsync() + { + ValidateModel(); + + var input = ObjectMapper.Map(TenantModel); + await _tenantAppService.CreateAsync(input); + + return NoContent(); + } + + public class TenantInfoModel + { + [Required] + [StringLength(TenantConsts.MaxNameLength)] + [Display(Name = "TenantName")] + public string Name { get; set; } + } + } +} diff --git a/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/EditModal.cshtml b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/EditModal.cshtml new file mode 100644 index 0000000000..97d9c9d4eb --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/EditModal.cshtml @@ -0,0 +1,35 @@ +@page +@using Microsoft.Extensions.Localization +@using Volo.Abp.MultiTenancy.Web.Localization.Resources.AbpMultiTenancy +@using Volo.Abp.MultiTenancy.Web.Pages.MultiTenancy.Tenants +@model EditModalModel +@inject IStringLocalizer L +@{ + Layout = null; +} + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/EditModal.cshtml.cs b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/EditModal.cshtml.cs new file mode 100644 index 0000000000..499cb6377b --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/EditModal.cshtml.cs @@ -0,0 +1,49 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.RazorPages; + +namespace Volo.Abp.MultiTenancy.Web.Pages.MultiTenancy.Tenants +{ + public class EditModalModel : AbpPageModel + { + [BindProperty] + public TenantInfoModel TenantInfo { get; set; } + + private readonly ITenantAppService _tenantAppService; + + public EditModalModel(ITenantAppService tenantAppService) + { + _tenantAppService = tenantAppService; + } + + public async Task OnGetAsync(Guid id) + { + TenantInfo = ObjectMapper.Map( + await _tenantAppService.GetAsync(id) + ); + } + + public async Task OnPostAsync() + { + ValidateModel(); + + var input = ObjectMapper.Map(TenantInfo); + await _tenantAppService.UpdateAsync(TenantInfo.Id, input); + + return NoContent(); + } + + public class TenantInfoModel + { + [HiddenInput] + public Guid Id { get; set; } + + [Required] + [StringLength(TenantConsts.MaxNameLength)] + [Display(Name = "TenantName")] + public string Name { get; set; } + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/Index.cshtml b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/Index.cshtml index 1bcf45b39c..ca710b1d76 100644 --- a/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/Index.cshtml +++ b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/Tenants/Index.cshtml @@ -1,7 +1,45 @@ @page +@using Microsoft.AspNetCore.Mvc.Localization +@using Volo.Abp.MultiTenancy.Web.Localization.Resources.AbpMultiTenancy @using Volo.Abp.MultiTenancy.Web.Pages.MultiTenancy.Tenants @model IndexModel @{ } +@inject IHtmlLocalizer L +@section styles { + +} + +@section scripts { + + + + + +} -Tenants page... \ No newline at end of file + + + + + @L["Tenants"] + + + + + @L["NewTenant"] + + + + + + + + + @L["Actions"] + @L["Name"] + + + + + \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/_ViewImports.cshtml b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/_ViewImports.cshtml new file mode 100644 index 0000000000..d1ac64721f --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/Pages/MultiTenancy/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/Volo.Abp.MultiTenancy.Web.csproj b/src/Volo.Abp.MultiTenancy.Web/Volo.Abp.MultiTenancy.Web.csproj index b08faeef89..9bf2e7b7d7 100644 --- a/src/Volo.Abp.MultiTenancy.Web/Volo.Abp.MultiTenancy.Web.csproj +++ b/src/Volo.Abp.MultiTenancy.Web/Volo.Abp.MultiTenancy.Web.csproj @@ -16,14 +16,14 @@ + + + + - - - - diff --git a/src/Volo.Abp.MultiTenancy.Web/compilerconfig.json b/src/Volo.Abp.MultiTenancy.Web/compilerconfig.json new file mode 100644 index 0000000000..3104320327 --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/compilerconfig.json @@ -0,0 +1,6 @@ +[ + { + "outputFile": "wwwroot/modules/multi-tenancy/views/tenants/index.css", + "inputFile": "wwwroot/modules/multi-tenancy/views/tenants/index.less" + } +] \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/compilerconfig.json.defaults b/src/Volo.Abp.MultiTenancy.Web/compilerconfig.json.defaults new file mode 100644 index 0000000000..c75eb7d519 --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/compilerconfig.json.defaults @@ -0,0 +1,49 @@ +{ + "compilers": { + "less": { + "autoPrefix": "", + "cssComb": "none", + "ieCompat": true, + "strictMath": false, + "strictUnits": false, + "relativeUrls": true, + "rootPath": "", + "sourceMapRoot": "", + "sourceMapBasePath": "", + "sourceMap": false + }, + "sass": { + "includePath": "", + "indentType": "space", + "indentWidth": 2, + "outputStyle": "nested", + "Precision": 5, + "relativeUrls": true, + "sourceMapRoot": "", + "sourceMap": false + }, + "stylus": { + "sourceMap": false + }, + "babel": { + "sourceMap": false + }, + "coffeescript": { + "bare": false, + "runtimeMode": "node", + "sourceMap": false + } + }, + "minifiers": { + "css": { + "enabled": true, + "termSemicolons": true, + "gzip": false + }, + "javascript": { + "enabled": true, + "termSemicolons": true, + "gzip": false + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.css b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.css new file mode 100644 index 0000000000..41fbd4eaf0 --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.css @@ -0,0 +1,21 @@ +.dataTable { + width: 100% !important; + border-spacing: 0 !important; +} +.table td, +.table th { + padding: 8px 10px; +} +.dataTable tbody tr td button { + cursor: pointer; +} +.dataTable tbody tr td div.dropdown ul.dropdown-menu li { + cursor: pointer; + padding: 5px; +} +.dataTable tbody tr td div.dropdown ul.dropdown-menu li a { + display: block; +} +.dataTable tbody tr td div.dropdown ul.dropdown-menu li:hover { + background: #f4f5f8; +} \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.es5.js b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.es5.js new file mode 100644 index 0000000000..bc6107abbc --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.es5.js @@ -0,0 +1,6 @@ +'use strict'; + +$(function () { + $('#IdentityUsersTable').DataTable(); +}); + diff --git a/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.es5.min.js b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.es5.min.js new file mode 100644 index 0000000000..9a2c19267e --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.es5.min.js @@ -0,0 +1 @@ +"use strict";$(function(){$("#IdentityUsersTable").DataTable()}); \ No newline at end of file diff --git a/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.js b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.js new file mode 100644 index 0000000000..95b253fea6 --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.js @@ -0,0 +1,84 @@ +(function () { + + var l = abp.localization.getResource('AbpMultiTenancy'); + var _tenantAppService = volo.abp.multiTenancy.tenant; + + var _editModal = new abp.ModalManager(abp.appPath + 'MultiTenancy/Tenants/EditModal'); + var _createModal = new abp.ModalManager(abp.appPath + 'MultiTenancy/Tenants/CreateModal'); + + var app = new Vue({ + el: '#TenantsWrapper', + methods: { + openCreateModal: function () { + _createModal.open(); + } + } + }); + + $(function () { + + var _$wrapper = $('#TenantsWrapper'); + var _$table = _$wrapper.find('table'); + + var _dataTable = _$table.DataTable({ + order: [[1, "asc"]], + ajax: abp.libs.datatables.createAjax(_tenantAppService.getList), + columnDefs: [ + { + //TODO: Can we eleminate targets, data, orderable, autoWidth, defaultContent fields or make these values default + targets: 0, + data: null, + orderable: false, + autoWidth: false, + defaultContent: '', + rowAction: { + text: ' ' + l('Actions') + ' ', //TODO: Add icon option and set text as only l('Actions') + items: + [ + { + //TODO: Allow to add icon + text: l('Edit'), + visible: function () { //TODO: Allow visible to be a boolean for simple cases + return true; + }, + action: function (data) { + _editModal.open({ + id: data.record.id + }); + } + }, + { + text: l('Delete'), + visible: function () { + return true; + }, + action: function (data) { + if (confirm(l('TenantDeletionConfirmationMessage', data.record.name))) { + _tenantAppService + .delete(data.record.id) + .then(function () { + _dataTable.ajax.reload(); + }); + } + } + } + ] + } + }, + { + targets: 1, + data: "name" + } + ] + }); + + _createModal.onResult(function () { + _dataTable.ajax.reload(); + }); + + _editModal.onResult(function () { + _dataTable.ajax.reload(); + }); + }); + +})(); diff --git a/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.less b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.less new file mode 100644 index 0000000000..21adf56097 --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.less @@ -0,0 +1,39 @@ +//TODO: This code is duplicated for other pages too. Unify them. +.dataTable { + width: 100% !important; + border-spacing: 0 !important; +} + +.table td, .table th { + padding: 8px 10px; +} + +.dataTable { + tbody { + tr { + td { + + button { + cursor: pointer; + } + + div.dropdown { + ul.dropdown-menu { + li { + cursor: pointer; + padding: 5px; + + a { + display: block; + } + } + + li:hover { + background: #f4f5f8; + } + } + } + } + } + } +} diff --git a/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.min.css b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.min.css new file mode 100644 index 0000000000..e70b9e330b --- /dev/null +++ b/src/Volo.Abp.MultiTenancy.Web/wwwroot/modules/multi-tenancy/views/tenants/index.min.css @@ -0,0 +1 @@ +.dataTable{width:100% !important;border-spacing:0 !important;}.table td,.table th{padding:8px 10px;}.dataTable tbody tr td button{cursor:pointer;}.dataTable tbody tr td div.dropdown ul.dropdown-menu li{cursor:pointer;padding:5px;}.dataTable tbody tr td div.dropdown ul.dropdown-menu li a{display:block;}.dataTable tbody tr td div.dropdown ul.dropdown-menu li:hover{background:#f4f5f8;} \ No newline at end of file