online.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
  3. <head>
  4. <th:block th:include="include :: header('在线用户列表')" />
  5. </head>
  6. <body class="gray-bg">
  7. <div class="container-div">
  8. <div class="row">
  9. <div class="col-sm-12 search-collapse">
  10. <form id="online-form">
  11. <div class="select-list">
  12. <ul>
  13. <li>
  14. 登录地址:<input type="text" name="ipaddr"/>
  15. </li>
  16. <li>
  17. 登录名称:<input type="text" name="loginName"/>
  18. </li>
  19. <li>
  20. <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
  21. <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
  22. </li>
  23. </ul>
  24. </div>
  25. </form>
  26. </div>
  27. <div class="btn-group-sm" id="toolbar" role="group">
  28. <a class="btn btn-danger multiple disabled" onclick="javascript:batchForceLogout()" shiro:hasPermission="monitor:online:batchForceLogout">
  29. <i class="fa fa-sign-out"></i> 强退
  30. </a>
  31. </div>
  32. <div class="col-sm-12 select-table table-striped">
  33. <table id="bootstrap-table"></table>
  34. </div>
  35. </div>
  36. </div>
  37. <th:block th:include="include :: footer" />
  38. <th:block th:include="include :: bootstrap-table-export-js" />
  39. <script th:inline="javascript">
  40. var forceFlag = [[${@permission.hasPermi('monitor:online:forceLogout')}]];
  41. var prefix = ctx + "monitor/online";
  42. $(function() {
  43. var options = {
  44. uniqueId: "sessionId",
  45. url: prefix + "/list",
  46. exportUrl: prefix + "/export",
  47. sortName: "lastAccessTime",
  48. sortOrder: "desc",
  49. showExport: true,
  50. escape: true,
  51. columns: [{
  52. checkbox: true
  53. },
  54. {
  55. title: "序号",
  56. formatter: function (value, row, index) {
  57. return $.table.serialNumber(index);
  58. }
  59. },
  60. {
  61. field: 'sessionId',
  62. title: '会话编号',
  63. formatter: function(value, row, index) {
  64. return $.table.tooltip(value);
  65. }
  66. },
  67. {
  68. field: 'loginName',
  69. title: '登录名称',
  70. sortable: true
  71. },
  72. {
  73. field: 'deptName',
  74. title: '部门名称'
  75. },
  76. {
  77. field: 'ipaddr',
  78. title: '主机'
  79. },
  80. {
  81. field: 'loginLocation',
  82. title: '登录地点'
  83. },
  84. {
  85. field: 'browser',
  86. title: '浏览器'
  87. },
  88. {
  89. field: 'os',
  90. title: '操作系统'
  91. },
  92. {
  93. field: 'status',
  94. title: '会话状态',
  95. align: 'center',
  96. formatter: function(value, row, index) {
  97. if (value == 'on_line') {
  98. return '<span class="badge badge-primary">在线</span>';
  99. } else if (value == 'off_line') {
  100. return '<span class="badge badge-danger">离线</span>';
  101. }
  102. }
  103. },
  104. {
  105. field: 'startTimestamp',
  106. title: '登录时间',
  107. sortable: true
  108. },
  109. {
  110. field: 'lastAccessTime',
  111. title: '最后访问时间',
  112. sortable: true
  113. },
  114. {
  115. title: '操作',
  116. align: 'center',
  117. formatter: function(value, row, index) {
  118. var msg = '<a class="btn btn-danger btn-xs ' + forceFlag + '" href="javascript:void(0)" onclick="forceLogout(\'' + row.sessionId + '\')"><i class="fa fa-sign-out"></i>强退</a> ';
  119. return msg;
  120. }
  121. }]
  122. };
  123. $.table.init(options);
  124. });
  125. // 单条强退
  126. function forceLogout(sessionId) {
  127. $.modal.confirm("确定要强制选中用户下线吗?", function() {
  128. var data = { "ids": sessionId };
  129. $.operate.post(prefix + "/batchForceLogout", data);
  130. })
  131. }
  132. // 批量强退
  133. function batchForceLogout() {
  134. var rows = $.table.selectColumns("sessionId");
  135. if (rows.length == 0) {
  136. $.modal.alertWarning("请选择要强退的用户");
  137. return;
  138. }
  139. $.modal.confirm("确认要强退选中的" + rows.length + "条数据吗?", function() {
  140. var url = prefix + "/batchForceLogout";
  141. var data = { "ids": rows.join() };
  142. $.operate.post(url, data);
  143. });
  144. }
  145. </script>
  146. </body>
  147. </html>