EnVisageOnline/Main-RMO/Source/EnVisage/Views/User/Index.cshtml

98 lines
3.6 KiB
Plaintext

@using EnVisage.Code.HtmlHelpers
@using Microsoft.AspNet.Identity
@using EnVisage.Code
@{
ViewBag.Title = "Users";
}
@section scripts
{
<script type="text/javascript">
var ctr = 0;
init.push(function () {
$('#users').dataTable({
"bProcessing": true,
"bServerSide": true,
"bAutoWidth" : false,
"sAjaxSource": document.URL,
"sServerMethod": "POST",
"aoColumns": [
{
"sTitle": "User Name",
"mData": "LastName",
"mRender": function (data, type, full) {
return full.Name || full.UserName
}
},
{
"mDataProp": "UserName"
},
{ "mDataProp": "Email" },
{ "mDataProp": "Roles" },
{
"mData": function (data, type, full) {
@if (SecurityManager.CheckSecurityObjectPermission(Areas.Users, AccessLevel.Write))
{
<text>
ctr++;
return ('<a id="btnEdit' + ctr + '" onclick="return CheckLock(this.id, \'User\', \'_rplcmnt_\')" data-toggle="popover" data-placement="left" class="btn btn-sm btn-primary popover-warning popover-dark" href="@Url.Action("Edit", "User", new {@id = "_rplcmnt_"})"><i class="fa fa-edit"></i> Edit</a> ' +
'<a id="btnDelete' + ctr + '" onclick="return CheckLock(this.id, \'User\', \'_rplcmnt_\')" data-toggle="popover" data-placement="left" class="btn btn-sm btn-danger popover-warning popover-dark" href="@Url.Action("Delete", "User", new {@id = "_rplcmnt_"})"><i class="fa fa-trash-o"></i> Delete</a> ' +
'<a id="btnRestorePwd' + ctr + '" onclick="return restorePwd(this.id, \'_rplcmnt_\')" data-toggle="popover" data-placement="left" class="btn btn-sm btn-primary popover-warning popover-dark" href="javascript:void(0)"><i class="fa fa-mail-forward"></i> Reset password</a>')
.replace(/_rplcmnt_/g, data.Id);
</text>
}
else
{
<text>
return "";
</text>
}
}
,'bSortable':false}],
});
@if (SecurityManager.CheckSecurityObjectPermission(Areas.Users, AccessLevel.Write))
{
<text>
$('#users_wrapper .table-caption').html('<a class="btn btn-primary" href="@Url.Action("Edit", "User")"><i class="fa fa-plus"></i> Add User</a>');
</text>
}
$('#users_wrapper .dataTables_filter input').attr('placeholder', 'Search...');
$('#users_wrapper .dataTables_processing').addClass("table-caption");
$('#users_wrapper .dataTables_processing').html('<span class="h3"><img class="valign-middle" src="../Content/images/loadFA.gif"/></span>');
});
function restorePwd(btnId, id) {
if (!CheckLock(btnId, 'User', id))
return false;
$.post('/Account/ResetPwd', { 'id':id }, function (data) {
if (data != undefined && 'OK' == data.status) {
alert('Email with reset password link has been sent to user\'s email.');
}
});
return true;
}
</script>
}
<div class="table-light table-responsive">
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="users">
<thead>
<tr>
<th>
User Name
</th>
<th>
User ID
</th>
<th>
Email
</th>
<th>
Roles
</th>
<th></th>
</tr>
</thead>
</table>
</div>