cache.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('缓存监控')" />
  5. </head>
  6. <body class="gray-bg">
  7. <div class="wrapper wrapper-content">
  8. <input type="hidden" id="cacheName">
  9. <div class="col-sm-12">
  10. <div class="row">
  11. <div class="col-sm-4">
  12. <div class="ibox float-e-margins">
  13. <div class="ibox-title">
  14. <h5>缓存列表</h5>
  15. <div class="ibox-tools">
  16. <a href="javascript:getCacheNames()"><i class="fa fa-refresh"></i></a>
  17. </div>
  18. </div>
  19. <div class="ibox-content">
  20. <table class="table table-hover no-margins">
  21. <thead>
  22. <tr>
  23. <th></th>
  24. <th>缓存名称</th>
  25. <th>操作</th>
  26. </tr>
  27. </thead>
  28. <tbody id="cacheNames">
  29. <tr th:fragment="fragment-cache-names" th:each="cacheName, stat : ${cacheNames}">
  30. <td>[[${stat.index + 1}]]</td>
  31. <td style="word-wrap:break-word;word-break:break-all;" th:onclick="getCacheKeys([[${cacheName}]])">[[${cacheName}]]</td>
  32. <td style="width: 50px"><a href="#" th:onclick="clearCacheName([[${cacheName}]])" title="清空"><i class="fa fa-trash-o text-danger"></i></a></td>
  33. </tr>
  34. </tbody>
  35. </table>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="col-sm-4">
  40. <div class="ibox float-e-margins">
  41. <div class="ibox-title">
  42. <h5>键名列表</h5>
  43. <div class="ibox-tools">
  44. <a href="javascript:getCacheKeys('', true)"><i class="fa fa-refresh"></i></a>
  45. </div>
  46. </div>
  47. <div class="ibox-content">
  48. <table class="table table-hover no-margins">
  49. <thead>
  50. <tr>
  51. <th></th>
  52. <th>缓存键名</th>
  53. <th>操作</th>
  54. </tr>
  55. </thead>
  56. <tbody id="cacheKyes">
  57. <tr th:fragment="fragment-cache-kyes" th:each="cacheKey, stat : ${cacheKyes}">
  58. <td>[[${stat.index + 1}]]</td>
  59. <td style="word-wrap:break-word;word-break:break-all;" th:onclick="getCacheValue([[${cacheName}]], [[${cacheKey}]])">[[${cacheKey}]]</td>
  60. <td style="width: 50px"><a href="#" th:onclick="clearCacheKey([[${cacheName}]], [[${cacheKey}]])" title="清空"><i class="fa fa-trash-o text-danger"></i></a></td>
  61. </tr>
  62. </tbody>
  63. </div>
  64. </table>
  65. </div>
  66. </div>
  67. </div>
  68. <div class="col-sm-4">
  69. <div class="ibox float-e-margins">
  70. <div class="ibox-title">
  71. <h5>缓存内容</h5>
  72. <div class="ibox-tools">
  73. <a href="javascript:clearAll()"><i class="fa fa-refresh"></i> 清理全部</a>
  74. </div>
  75. </div>
  76. <div class="ibox-content">
  77. <div class="row" id="cacheValue">
  78. <div class="col-sm-12" th:fragment="fragment-cache-value">
  79. <div class="form-group">
  80. <label>缓存名称:</label>
  81. <input type="text" class="form-control" th:value="${cacheName}">
  82. </div>
  83. <div class="form-group">
  84. <label>缓存键名:</label>
  85. <input type="text"class="form-control" th:value="${cacheKey}">
  86. </div>
  87. <div class="form-group">
  88. <label>缓存内容:</label>
  89. <textarea class="form-control" style="height: 100px">[[${cacheValue}]]</textarea>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. </body>
  100. <th:block th:include="include :: footer" />
  101. <script th:inline="javascript">
  102. var prefix = ctx + "monitor/cache";
  103. function getCacheNames() {
  104. $.ajax({
  105. type: "post",
  106. url: prefix + "/getNames",
  107. data: {
  108. "fragment": 'fragment-cache-names'
  109. },
  110. success: function(data) {
  111. $("#cacheNames").html(data);
  112. $.modal.msgSuccess("刷新缓存列表成功");
  113. }
  114. });
  115. }
  116. function getCacheKeys(cacheName, isMsg) {
  117. var _cacheName = $.common.isNotEmpty(cacheName) ? cacheName : $("#cacheName").val();
  118. $.ajax({
  119. type: "post",
  120. url: prefix + "/getKeys",
  121. data: {
  122. "cacheName": _cacheName,
  123. "fragment": 'fragment-cache-kyes'
  124. },
  125. success: function(data) {
  126. $("#cacheKyes").html(data);
  127. $("#cacheName").val(_cacheName);
  128. if (isMsg) {
  129. $.modal.msgSuccess("刷新键名列表成功");
  130. }
  131. }
  132. });
  133. }
  134. function getCacheValue(cacheName, cacheKey) {
  135. $.ajax({
  136. type: "post",
  137. url: prefix + "/getValue",
  138. data: {
  139. "cacheName": cacheName,
  140. "cacheKey": cacheKey,
  141. "fragment": 'fragment-cache-value'
  142. },
  143. success: function(data) {
  144. $("#cacheValue").html(data);
  145. }
  146. });
  147. }
  148. function clearCacheName(cacheName){
  149. $.post(prefix + "/clearCacheName", {cacheName: cacheName}, function(result) {
  150. if (result.code == web_status.SUCCESS) {
  151. $.modal.msgSuccess("清理缓存[" + cacheName + "]成功")
  152. getCacheKeys(cacheName);
  153. } else {
  154. $.modal.msgError(result.msg);
  155. }
  156. });
  157. }
  158. function clearCacheKey(cacheName, cacheKey) {
  159. $.post(prefix + "/clearCacheKey", {cacheName: cacheName, cacheKey: cacheKey}, function(result) {
  160. if (result.code == web_status.SUCCESS) {
  161. $.modal.msgSuccess("清理缓存[" + cacheKey + "]成功")
  162. getCacheKeys(cacheName);
  163. } else {
  164. $.modal.msgError(result.msg);
  165. }
  166. });
  167. }
  168. function clearAll(){
  169. $.get(prefix + "/clearAll", function(result) {
  170. if (result.code == web_status.SUCCESS) {
  171. $.modal.msgSuccess("清理缓存成功")
  172. } else {
  173. $.modal.msgError(result.msg);
  174. }
  175. });
  176. }
  177. </script>
  178. </html>