onlinemanager_list.jsp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  4. <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
  5. <%
  6. String path = request.getContextPath();
  7. String basePath = request.getScheme() + "://"
  8. + request.getServerName() + ":" + request.getServerPort()
  9. + path + "/";
  10. %>
  11. <!DOCTYPE html>
  12. <html lang="en">
  13. <head>
  14. <base href="<%=basePath%>">
  15. <!-- jsp文件头和头部 -->
  16. <%@ include file="../index/top.jsp"%>
  17. </head>
  18. <body class="no-skin">
  19. <!-- /section:basics/navbar.layout -->
  20. <div class="main-container" id="main-container">
  21. <!-- /section:basics/sidebar -->
  22. <div class="main-content">
  23. <div class="main-content-inner">
  24. <div class="page-content">
  25. <div class="row">
  26. <div class="col-xs-12">
  27. <table style="margin-top:10px;">
  28. <tr bgcolor="#E0E0E0" style="height:26px;">
  29. <td style="padding-left: 15px;">在线人数:</td>
  30. <td>
  31. <div style="width:39px;" id="onlineCount">0</div>
  32. </td>
  33. </tr>
  34. </table>
  35. <table id="simple-table" class="table table-striped table-bordered table-hover" style="margin-top:5px;">
  36. <thead>
  37. <tr>
  38. <th class="center" style="width: 30px;">
  39. <label><input class="ace" type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
  40. </th>
  41. <th class='center' style="width:50px;">序号</th>
  42. <th>用户名</th>
  43. <th class="center" style="width: 100px;">操作</th>
  44. </tr>
  45. </thead>
  46. <tbody id="userlist">
  47. </tbody>
  48. </table>
  49. <div class="page-header position-relative">
  50. <table style="width:100%;">
  51. <tr>
  52. <td style="vertical-align:top;">
  53. <c:if test="${QX.del == 1 }">
  54. <a title="批量强制下线" class="btn btn-mini btn-danger" onclick="makeAll('确定要把这些用户强制下线吗?');" >强制下线</a>
  55. </c:if>
  56. </td>
  57. </tr>
  58. </table>
  59. </div>
  60. </div>
  61. <!-- /.col -->
  62. </div>
  63. <!-- /.row -->
  64. </div>
  65. <!-- /.page-content -->
  66. </div>
  67. </div>
  68. <!-- /.main-content -->
  69. <!-- 返回顶部 -->
  70. <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
  71. <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
  72. </a>
  73. </div>
  74. <!-- /.main-container -->
  75. <!-- basic scripts -->
  76. <!-- 页面底部js¨ -->
  77. <%@ include file="../index/foot.jsp"%>
  78. <!-- 删除时确认窗口 -->
  79. <script src="static/ace/js/bootbox.js"></script>
  80. <!-- ace scripts -->
  81. <script src="static/ace/js/ace/ace.js"></script>
  82. <!--提示框-->
  83. <script type="text/javascript" src="static/js/jquery.tips.js"></script>
  84. <script type="text/javascript">
  85. $(top.hangge());
  86. </script>
  87. <c:if test="${QX.cha == 1 }">
  88. <script type="text/javascript">
  89. //初始化
  90. $(function(){
  91. online();
  92. //复选框全选控制
  93. var active_class = 'active';
  94. $('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function(){
  95. var th_checked = this.checked;//checkbox inside "TH" table header
  96. $(this).closest('table').find('tbody > tr').each(function(){
  97. var row = this;
  98. if(th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
  99. else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
  100. });
  101. });
  102. });
  103. var websocketonline;//websocke对象
  104. var userCount = 0; //在线总数
  105. function online(){
  106. if (window.WebSocket) {
  107. websocketonline = new WebSocket(encodeURI('ws://'+top.oladress)); //oladress在main.jsp页面定义
  108. websocketonline.onopen = function() {
  109. websocketonline.send('[QQ313596790]fhadmin');//连接成功
  110. };
  111. websocketonline.onerror = function() {
  112. //连接失败
  113. };
  114. websocketonline.onclose = function() {
  115. //连接断开
  116. };
  117. //消息接收
  118. websocketonline.onmessage = function(message) {
  119. var message = JSON.parse(message.data);
  120. if (message.type == 'count') {
  121. userCount = message.msg;
  122. }else if(message.type == 'userlist'){
  123. $("#userlist").html('');
  124. $.each(message.list, function(i, user){
  125. $("#userlist").append(
  126. '<tr>'+
  127. '<td class="center">'+
  128. '<label><input type="checkbox" name="ids" value="'+user+'" class="ace" /><span class="lbl"></span></label>'+
  129. '</td>'+
  130. '<td class="center">'+(i+1)+'</td>'+
  131. '<td><a onclick="editUser(\''+user+'\')" style="cursor:pointer;">'+user+'</a></td>'+
  132. '<td class="center">'+
  133. '<button class="btn btn-mini btn-danger" onclick="goOutTUser(\''+user+'\')">强制下线</button>'+
  134. '</td>'+
  135. '</tr>'
  136. );
  137. userCount = i+1;
  138. });
  139. $("#onlineCount").html(userCount);
  140. }else if(message.type == 'addUser'){
  141. $("#userlist").append(
  142. '<tr>'+
  143. '<td class="center">'+
  144. '<label><input type="checkbox" name="ids" value="'+message.user+'" class="ace" /><span class="lbl"></span></label>'+
  145. '</td>'+
  146. '<td class="center">'+(userCount+1)+'</td>'+
  147. '<td><a onclick="editUser(\''+message.user+'\')" style="cursor:pointer;">'+message.user+'</a></td>'+
  148. '<td class="center">'+
  149. '<button class="btn btn-mini btn-danger" onclick="goOutTUser(\''+message.user+'\')">强制下线</button>'+
  150. '</td>'+
  151. '</tr>'
  152. );
  153. userCount = userCount+1;
  154. $("#onlineCount").html(userCount);
  155. }
  156. };
  157. }
  158. }
  159. //强制某用户下线
  160. function goOutUser(theuser){
  161. websocketonline.send('[goOut]'+theuser);
  162. }
  163. //强制某用户下线
  164. function goOutTUser(theuser){
  165. if('admin' == theuser){
  166. bootbox.dialog({
  167. message: "<span class='bigger-110'>不能强制下线admin用户!</span>",
  168. buttons:
  169. { "button":{ "label":"确定", "className":"btn-sm btn-success"}}
  170. });
  171. return;
  172. }
  173. bootbox.confirm("确定要强制["+theuser+"]下线吗?", function(result) {
  174. if(result) {
  175. goOutUser(theuser);
  176. }
  177. });
  178. }
  179. //查看修改用户
  180. function editUser(USERNAME){
  181. if('admin' == USERNAME){
  182. bootbox.dialog({
  183. message: "<span class='bigger-110'>不能查看修改admin用户!</span>",
  184. buttons:
  185. { "button":{ "label":"确定", "className":"btn-sm btn-success"}}
  186. });
  187. return;
  188. }
  189. top.jzts();
  190. var diag = new top.Dialog();
  191. diag.Drag=true;
  192. diag.Title ="资料";
  193. diag.URL = '<%=basePath%>user/goEditUfromOnline.do?USERNAME='+USERNAME;
  194. diag.Width = 469;
  195. diag.Height = 580;
  196. diag.CancelEvent = function(){ //关闭事件
  197. diag.close();
  198. };
  199. diag.show();
  200. }
  201. //批量操作
  202. function makeAll(msg){
  203. bootbox.confirm(msg, function(result) {
  204. if(result) {
  205. var str = '';
  206. for(var i=0;i < document.getElementsByName('ids').length;i++)
  207. {
  208. if(document.getElementsByName('ids')[i].checked){
  209. if('admin' != document.getElementsByName('ids')[i].value){
  210. if(str=='') str += document.getElementsByName('ids')[i].value;
  211. else str += ',' + document.getElementsByName('ids')[i].value;
  212. }else{
  213. document.getElementsByName('ids')[i].checked = false;
  214. $("#zcheckbox").tips({
  215. side:3,
  216. msg:'admin用户不能强制下线',
  217. bg:'#AE81FF',
  218. time:5
  219. });
  220. }
  221. }
  222. }
  223. if(str==''){
  224. bootbox.dialog({
  225. message: "<span class='bigger-110'>您没有选择任何用户!</span>",
  226. buttons:
  227. { "button":{ "label":"确定", "className":"btn-sm btn-success"}}
  228. });
  229. $("#zcheckbox").tips({
  230. side:1,
  231. msg:'点这里全选',
  232. bg:'#AE81FF',
  233. time:3
  234. });
  235. return;
  236. }else{
  237. top.jzts();
  238. var arField = str.split(',');
  239. for(var i=0;i<arField.length;i++){
  240. websocketonline.send('[goOut]'+arField[i]);
  241. }
  242. top.hangge();
  243. }
  244. }
  245. });
  246. }
  247. </script>
  248. </c:if>
  249. <c:if test="${QX.cha == 0 }">
  250. <script type="text/javascript">
  251. alert("您无权查看");
  252. </script>
  253. </c:if>
  254. </body>
  255. </html>