Skip to content

Commit 7c6efb4

Browse files
committed
Implemented MPA users page.
1 parent 061428a commit 7c6efb4

File tree

8 files changed

+1551
-3
lines changed

8 files changed

+1551
-3
lines changed

src/AbpCompanyName.AbpProjectName.WebMpa/AbpCompanyName.AbpProjectName.WebMpa.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@
413413
</Content>
414414
<Content Include="Views\Account\Register.js" />
415415
<Content Include="Views\Tenants\Index.js" />
416+
<Content Include="Views\Users\Index.js" />
416417
<Content Include="Web.config">
417418
<SubType>Designer</SubType>
418419
</Content>
@@ -431,6 +432,7 @@
431432
<Compile Include="Controllers\HomeController.cs" />
432433
<Compile Include="Controllers\Results\ChallengeResult.cs" />
433434
<Compile Include="Controllers\TenantsController.cs" />
435+
<Compile Include="Controllers\UsersController.cs" />
434436
<Compile Include="Models\Layout\UserMenuOrLoginLinkViewModel.cs" />
435437
<Compile Include="Models\Account\LoginFormViewModel.cs" />
436438
<Compile Include="Models\Account\LoginViewModel.cs" />
@@ -463,6 +465,7 @@
463465
<Content Include="Views\Account\TenantSelection.cshtml" />
464466
<Content Include="Views\Layout\_UserMenuOrLoginLink.cshtml" />
465467
<Content Include="Views\Tenants\Index.cshtml" />
468+
<Content Include="Views\Users\Index.cshtml" />
466469
<None Include="Web.Debug.config">
467470
<DependentUpon>Web.config</DependentUpon>
468471
</None>
@@ -488,6 +491,7 @@
488491
<Name>AbpCompanyName.AbpProjectName.WebApi</Name>
489492
</ProjectReference>
490493
</ItemGroup>
494+
<ItemGroup />
491495
<PropertyGroup>
492496
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
493497
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

src/AbpCompanyName.AbpProjectName.WebMpa/App_Start/AbpProjectNameNavigationProvider.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ public override void SetNavigation(INavigationProviderContext context)
3131
icon: "fa fa-globe",
3232
requiredPermissionName: PermissionNames.Pages_Tenants
3333
)
34+
).AddItem(
35+
new MenuItemDefinition(
36+
"Users",
37+
L("Users"),
38+
url: "/Users",
39+
icon: "fa fa-users",
40+
requiredPermissionName: PermissionNames.Pages_Users
41+
)
3442
).AddItem(
3543
new MenuItemDefinition(
3644
"About",

src/AbpCompanyName.AbpProjectName.WebMpa/Controllers/LayoutController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Abp.Application.Navigation;
33
using Abp.Configuration.Startup;
44
using Abp.Localization;
5+
using Abp.Runtime.Session;
56
using Abp.Threading;
67
using AbpCompanyName.AbpProjectName.Sessions;
78
using AbpCompanyName.AbpProjectName.WebMpa.Models.Layout;
@@ -32,7 +33,7 @@ public PartialViewResult TopMenu(string activeMenu = "")
3233
{
3334
var model = new TopMenuViewModel
3435
{
35-
MainMenu = AsyncHelper.RunSync(() => _userNavigationManager.GetMenuAsync("MainMenu", AbpSession.UserId)),
36+
MainMenu = AsyncHelper.RunSync(() => _userNavigationManager.GetMenuAsync("MainMenu", AbpSession.ToUserIdentifier())),
3637
ActiveMenuItemName = activeMenu
3738
};
3839

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Threading.Tasks;
2+
using System.Web.Mvc;
3+
using Abp.Web.Mvc.Authorization;
4+
using AbpCompanyName.AbpProjectName.Authorization;
5+
using AbpCompanyName.AbpProjectName.Users;
6+
7+
namespace AbpCompanyName.AbpProjectName.WebMpa.Controllers
8+
{
9+
[AbpMvcAuthorize(PermissionNames.Pages_Users)]
10+
public class UsersController : Controller
11+
{
12+
private readonly IUserAppService _userAppService;
13+
14+
public UsersController(IUserAppService userAppService)
15+
{
16+
_userAppService = userAppService;
17+
}
18+
19+
public async Task<ActionResult> Index()
20+
{
21+
var output = await _userAppService.GetUsers();
22+
return View(output);
23+
}
24+
}
25+
}

src/AbpCompanyName.AbpProjectName.WebMpa/Logs/Logs.txt

Lines changed: 1390 additions & 0 deletions
Large diffs are not rendered by default.

src/AbpCompanyName.AbpProjectName.WebMpa/Views/Tenants/Index.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
<div class="form-group">
6060
<label>@L("DatabaseConnectionString")</label>
61-
<input type="text" name="Name" class="form-control" maxlength="@AbpTenantBase.MaxConnectionStringLength">
61+
<input type="text" name="ConnectionString" class="form-control" maxlength="@AbpTenantBase.MaxConnectionStringLength">
6262
</div>
6363

6464
<div class="form-group">
@@ -71,7 +71,7 @@
7171
</div>
7272
<div class="modal-footer">
7373
<button type="button" class="btn btn-default" data-dismiss="modal">@L("Cancel")</button>
74-
<button type="submit" class="btn btn-primary blue" ng-disabled="tenantCreateForm.$invalid"><i class="fa fa-save"></i> <span>@L("Save")</span></button>
74+
<button type="submit" class="btn btn-primary blue"><i class="fa fa-save"></i> <span>@L("Save")</span></button>
7575
</div>
7676
</form>
7777
</div>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
@using Abp.Authorization.Users
2+
@using Abp.Web.Mvc.Extensions
3+
@model Abp.Application.Services.Dto.ListResultOutput<AbpCompanyName.AbpProjectName.Users.Dto.UserListDto>
4+
@{
5+
ViewBag.ActiveMenu = "Users"; //The menu item will be active for this page.
6+
}
7+
@section scripts
8+
{
9+
@Html.IncludeScript("~/Views/Users/Index.js")
10+
}
11+
<div>
12+
<h1>@L("Users")</h1>
13+
<div class="row">
14+
<div class="col-md-12">
15+
<button data-toggle="modal" data-target="#UserCreateModal" class="btn btn-primary pull-right"><i class="fa fa-plus"></i> @L("CreateNewUser")</button>
16+
<table class="table">
17+
<thead>
18+
<tr>
19+
<th>@L("UserName")</th>
20+
<th>@L("FullName")</th>
21+
<th>@L("EmailAddress")</th>
22+
<th>@L("IsActive")</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
@foreach (var user in Model.Items)
27+
{
28+
<tr>
29+
<td>@user.UserName</td>
30+
<td>@user.FullName</td>
31+
<td>@user.EmailAddress</td>
32+
<td>@L(user.IsActive ? "Yes" : "No")</td>
33+
</tr>
34+
}
35+
</tbody>
36+
</table>
37+
</div>
38+
</div>
39+
</div>
40+
41+
<div class="modal fade" id="UserCreateModal" tabindex="-1" role="dialog" aria-labelledby="UserCreateModalLabel" data-backdrop="static">
42+
<div class="modal-dialog" role="document">
43+
<div class="modal-content">
44+
<form name="userCreateForm" role="form" novalidate class="form-validation">
45+
<div class="modal-header">
46+
<h4 class="modal-title">
47+
<span>@L("CreateNewUser")</span>
48+
</h4>
49+
</div>
50+
<div class="modal-body">
51+
52+
<div class="form-group">
53+
<label>@L("UserName")</label>
54+
<input class="form-control" type="text" name="UserName" required maxlength="@AbpUserBase.MaxUserNameLength" minlength="2">
55+
</div>
56+
57+
<div class="form-group">
58+
<label>@L("Name")</label>
59+
<input type="text" name="Name" class="form-control" required maxlength="@AbpCompanyName.AbpProjectName.Users.User.MaxNameLength">
60+
</div>
61+
62+
<div class="form-group">
63+
<label>@L("Surname")</label>
64+
<input type="text" name="Surname" class="form-control" required maxlength="@AbpCompanyName.AbpProjectName.Users.User.MaxSurnameLength">
65+
</div>
66+
67+
<div class="form-group">
68+
<label>@L("EmailAddress")</label>
69+
<input type="email" name="EmailAddress" class="form-control" maxlength="@AbpUserBase.MaxEmailAddressLength">
70+
</div>
71+
72+
<div class="form-group">
73+
<label>@L("Password")</label>
74+
<input type="password" name="Password" class="form-control" required maxlength="@AbpCompanyName.AbpProjectName.Users.User.MaxPlainPasswordLength">
75+
</div>
76+
77+
<div class="checkbox">
78+
<label>
79+
<input type="checkbox" name="IsActive" value="true" value="true" checked="checked"> @L("IsActive")
80+
</label>
81+
</div>
82+
83+
</div>
84+
<div class="modal-footer">
85+
<button type="button" class="btn btn-default" data-dismiss="modal">@L("Cancel")</button>
86+
<button type="submit" class="btn btn-primary blue"><i class="fa fa-save"></i> <span>@L("Save")</span></button>
87+
</div>
88+
</form>
89+
</div>
90+
</div>
91+
</div>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(function() {
2+
$(function() {
3+
4+
var _userService = abp.services.app.user;
5+
var _$modal = $('#UserCreateModal');
6+
var _$form = _$modal.find('form');
7+
8+
_$form.validate();
9+
10+
_$form.find('button[type="submit"]').click(function (e) {
11+
e.preventDefault();
12+
13+
if (!_$form.valid()) {
14+
return;
15+
}
16+
17+
var user = _$form.serializeFormToObject(); //serializeFormToObject is defined in main.js
18+
19+
_userService.createUser(user).done(function () {
20+
_$modal.modal('hide');
21+
location.reload(true); //reload page to see new user!
22+
});
23+
});
24+
25+
_$modal.on('shown.bs.modal', function () {
26+
_$modal.find('input:not([type=hidden]):first').focus();
27+
});
28+
});
29+
})();

0 commit comments

Comments
 (0)