Log.cshtml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. 
  2. @using Microsoft.AspNetCore.Mvc.Rendering
  3. @using VberAdmin.Web.Models.Search
  4. @using VberAdmin.Web.Models.Table
  5. @using VberZero
  6. @using VberZero.Authorization
  7. @using VberZero.Tools.StringModel
  8. @{
  9. string activeMenu = PermissionNames.VberSystemMgLogMg; //The menu item will be active for this page.
  10. ViewBag.ActiveMenu = activeMenu;
  11. string serviceNames = ViewBag.ServiceNames;
  12. string loginResult = $"<option value=\"\">请选择登录结果</option>" +
  13. $"<option value=\"{VzLoginResultType.Success.ToStr()}\">{VzLoginResultType.Success}</option>" +
  14. //$"<option value=\"{VzLoginResultType.InvaliduserNameOrEmailOrPhone.ToStr()}\">{VzLoginResultType.InvaliduserNameOrEmailOrPhone}</option>" +
  15. $"<option value=\"{VzLoginResultType.InvalidPassword.ToStr()}\">{VzLoginResultType.InvalidPassword}</option>" +
  16. $"<option value=\"{VzLoginResultType.UserIsNotActive.ToStr()}\">{VzLoginResultType.UserIsNotActive}</option>" +
  17. $"<option value=\"{VzLoginResultType.LockedOut.ToStr()}\">{VzLoginResultType.LockedOut}</option>";
  18. }
  19. @{
  20. /**/
  21. ViewBag.Title = "系统日志管理";
  22. var table1 = new VmTable(VzConsts.ApiAppUrl + "AuditLog/GetAllLogin", activeMenu, new VmSearch(new List<VmSearchItem>()
  23. {
  24. new VmSearchItem("userName", L("realName")),
  25. new VmSearchItem("result",L("loginResult")).WithSelect(loginResult),
  26. new VmSearchItem("creationTime",L("loginTime")).WithDateRange(),
  27. new VmSearchItem("clientIpAddress", (L("clientIpAddress"))),
  28. new VmSearchItem("clientName", L("clientName")),
  29. })).AddItems(new List<VmTableItem>()
  30. {
  31. new VmTableItem("userName", L("realName")),
  32. new VmTableItem("userNameOrEmailOrPhone", L("userNameOrEmailOrPhone")),
  33. new VmTableItem("loginResult", (L("loginResult"))).WithFormatter("LoginResultFormatter"),
  34. new VmTableItem("creationTime", (L("loginTime"))).WithFormatter("DateTimeFormatter"),
  35. new VmTableItem("clientIpAddress", (L("clientIpAddress"))),
  36. new VmTableItem("clientName", (L("clientName"))),
  37. new VmTableItem("browserInfo", (L("browserInfo"))).WithTip(40),
  38. }).WithPage(15, 30, 50);
  39. var table2 = new VmTable(VzConsts.ApiAppUrl + "AuditLog/GetAll",null, new VmSearch(new List<VmSearchItem>()
  40. {
  41. new VmSearchItem("userName", L("realName")),
  42. new VmSearchItem("executionTime",L("executionTime")).WithDateRange(),
  43. new VmSearchItem("serviceName",L("serviceName")).WithSelect(serviceNames,other:"onchange=\"QueryMethodName(this)\""),
  44. new VmSearchItem("methodName",L("methodName")).WithSelect(""),
  45. new VmSearchItem("clientIpAddress", (L("clientIpAddress"))),
  46. new VmSearchItem("clientName", L("clientName")),
  47. },"vber_search2"),"table2").AddItems(new List<VmTableItem>()
  48. {
  49. new VmTableItem("userName", (L("realName"))),
  50. new VmTableItem("serviceName", (L("serviceName"))),
  51. new VmTableItem("methodName", (L("methodName"))),
  52. new VmTableItem("executionTime", (L("executionTime"))).WithFormatter("DateTimeFormatter"),
  53. new VmTableItem("clientIpAddress", (L("clientIpAddress"))),
  54. new VmTableItem("clientName", (L("clientName"))),
  55. new VmTableItem("browserInfo", (L("browserInfo"))).WithTip(40),
  56. }).WithPage(15, 30, 50);
  57. }
  58. <ul class="nav nav-tabs nav-line-tabs mb-5 fs-5">
  59. <li class="nav-item">
  60. <a class="nav-link active" data-bs-toggle="tab" data-bs-target="#tab_pane_login">登录日志</a>
  61. </li>
  62. <li class="nav-item">
  63. <a class="nav-link" data-bs-toggle="tab" data-bs-target="#tab_pane_log">操作日志</a>
  64. </li>
  65. </ul>
  66. <div class="tab-content">
  67. <div class="tab-pane fade show active " id="tab_pane_login">
  68. @await Html.PartialAsync("_Table", table1)
  69. </div>
  70. <div class="tab-pane fade" id="tab_pane_log">
  71. @await Html.PartialAsync("_Table", table2)
  72. </div>
  73. </div>
  74. @section scripts
  75. {
  76. <script type="text/javascript">
  77. $(function () {
  78. LoadTable();
  79. LoadTable({
  80. table:'table2',
  81. searchForm:"vber_search2"
  82. });
  83. });
  84. function QueryMethodName(_this) {
  85. var value = $(_this).val();
  86. if (value) {
  87. $.vbAjax4({
  88. url: abp.appUrl + "Query/GetLogMethodSelectStr",
  89. data: { ServiceName: value },
  90. success: (res) => {
  91. if (res) {
  92. $('#vber_search2 [name="methodName"]').html(res).select2();
  93. }
  94. }
  95. });
  96. }
  97. }
  98. </script>
  99. <script>
  100. function LoginResultFormatter(v, r) {
  101. switch (r.result) {
  102. case @(VzLoginResultType.Success.ToStr()):
  103. return '<span class="badge badge-light-success">'+ v + '</span>';
  104. default:
  105. return '<span class="badge badge-light-danger">'+ v + '</span>';
  106. }
  107. }
  108. </script>
  109. }