adminui.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. // Copyright 2014 beego Author. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package beego
  15. var indexTpl = `
  16. {{define "content"}}
  17. <h1>Beego Admin Dashboard</h1>
  18. <p>
  19. For detail usage please check our document:
  20. </p>
  21. <p>
  22. <a target="_blank" href="http://beego.me/docs/module/toolbox.md">Toolbox</a>
  23. </p>
  24. <p>
  25. <a target="_blank" href="http://beego.me/docs/advantage/monitor.md">Live Monitor</a>
  26. </p>
  27. {{.Content}}
  28. {{end}}`
  29. var profillingTpl = `
  30. {{define "content"}}
  31. <h1>{{.Title}}</h1>
  32. <pre id="content">
  33. <div>{{.Content}}</div>
  34. </pre>
  35. {{end}}`
  36. var defaultScriptsTpl = ``
  37. var gcAjaxTpl = `
  38. {{define "scripts"}}
  39. <script type="text/javascript">
  40. var app = app || {};
  41. (function() {
  42. app.$el = $('#content');
  43. app.getGc = function() {
  44. var that = this;
  45. $.ajax("/prof?command=gc%20summary&format=json").done(function(data) {
  46. that.$el.append($('<p>' + data.Content + '</p>'));
  47. });
  48. };
  49. $(document).ready(function() {
  50. setInterval(function() {
  51. app.getGc();
  52. }, 3000);
  53. });
  54. })();
  55. </script>
  56. {{end}}
  57. `
  58. var qpsTpl = `{{define "content"}}
  59. <h1>Requests statistics</h1>
  60. <table class="table table-striped table-hover ">
  61. <thead>
  62. <tr>
  63. {{range .Content.Fields}}
  64. <th>
  65. {{.}}
  66. </th>
  67. {{end}}
  68. </tr>
  69. </thead>
  70. <tbody>
  71. {{range $i, $elem := .Content.Data}}
  72. <tr>
  73. <td>{{index $elem 0}}</td>
  74. <td>{{index $elem 1}}</td>
  75. <td>{{index $elem 2}}</td>
  76. <td data-order="{{index $elem 3}}">{{index $elem 4}}</td>
  77. <td data-order="{{index $elem 5}}">{{index $elem 6}}</td>
  78. <td data-order="{{index $elem 7}}">{{index $elem 8}}</td>
  79. <td data-order="{{index $elem 9}}">{{index $elem 10}}</td>
  80. </tr>
  81. {{end}}
  82. </tbody>
  83. </table>
  84. {{end}}`
  85. var configTpl = `
  86. {{define "content"}}
  87. <h1>Configurations</h1>
  88. <pre>
  89. {{range $index, $elem := .Content}}
  90. {{$index}}={{$elem}}
  91. {{end}}
  92. </pre>
  93. {{end}}
  94. `
  95. var routerAndFilterTpl = `{{define "content"}}
  96. <h1>{{.Title}}</h1>
  97. {{range .Content.Methods}}
  98. <div class="panel panel-default">
  99. <div class="panel-heading lead success"><strong>{{.}}</strong></div>
  100. <div class="panel-body">
  101. <table class="table table-striped table-hover ">
  102. <thead>
  103. <tr>
  104. {{range $.Content.Fields}}
  105. <th>
  106. {{.}}
  107. </th>
  108. {{end}}
  109. </tr>
  110. </thead>
  111. <tbody>
  112. {{$slice := index $.Content.Data .}}
  113. {{range $i, $elem := $slice}}
  114. <tr>
  115. {{range $elem}}
  116. <td>
  117. {{.}}
  118. </td>
  119. {{end}}
  120. </tr>
  121. {{end}}
  122. </tbody>
  123. </table>
  124. </div>
  125. </div>
  126. {{end}}
  127. {{end}}`
  128. var tasksTpl = `{{define "content"}}
  129. <h1>{{.Title}}</h1>
  130. {{if .Message }}
  131. {{ $messageType := index .Message 0}}
  132. <p class="message
  133. {{if eq "error" $messageType}}
  134. bg-danger
  135. {{else if eq "success" $messageType}}
  136. bg-success
  137. {{else}}
  138. bg-warning
  139. {{end}}
  140. ">
  141. {{index .Message 1}}
  142. </p>
  143. {{end}}
  144. <table class="table table-striped table-hover ">
  145. <thead>
  146. <tr>
  147. {{range .Content.Fields}}
  148. <th>
  149. {{.}}
  150. </th>
  151. {{end}}
  152. </tr>
  153. </thead>
  154. <tbody>
  155. {{range $i, $slice := .Content.Data}}
  156. <tr>
  157. {{range $slice}}
  158. <td>
  159. {{.}}
  160. </td>
  161. {{end}}
  162. <td>
  163. <a class="btn btn-primary btn-sm" href="/task?taskname={{index $slice 0}}">Run</a>
  164. </td>
  165. </tr>
  166. {{end}}
  167. </tbody>
  168. </table>
  169. {{end}}`
  170. var healthCheckTpl = `
  171. {{define "content"}}
  172. <h1>{{.Title}}</h1>
  173. <table class="table table-striped table-hover ">
  174. <thead>
  175. <tr>
  176. {{range .Content.Fields}}
  177. <th>
  178. {{.}}
  179. </th>
  180. {{end}}
  181. </tr>
  182. </thead>
  183. <tbody>
  184. {{range $i, $slice := .Content.Data}}
  185. {{ $header := index $slice 0}}
  186. {{ if eq "success" $header}}
  187. <tr class="success">
  188. {{else if eq "error" $header}}
  189. <tr class="danger">
  190. {{else}}
  191. <tr>
  192. {{end}}
  193. {{range $j, $elem := $slice}}
  194. {{if ne $j 0}}
  195. <td>
  196. {{$elem}}
  197. </td>
  198. {{end}}
  199. {{end}}
  200. <td>
  201. {{$header}}
  202. </td>
  203. </tr>
  204. {{end}}
  205. </tbody>
  206. </table>
  207. {{end}}`
  208. // The base dashboardTpl
  209. var dashboardTpl = `
  210. <!DOCTYPE html>
  211. <html lang="en">
  212. <head>
  213. <!-- Meta, title, CSS, favicons, etc. -->
  214. <meta charset="utf-8">
  215. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  216. <meta name="viewport" content="width=device-width, initial-scale=1">
  217. <title>
  218. Welcome to Beego Admin Dashboard
  219. </title>
  220. <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
  221. <link href="//cdn.datatables.net/plug-ins/725b2a2115b/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">
  222. <style type="text/css">
  223. ul.nav li.dropdown:hover > ul.dropdown-menu {
  224. display: block;
  225. }
  226. #logo {
  227. width: 102px;
  228. height: 32px;
  229. margin-top: 5px;
  230. }
  231. .message {
  232. padding: 15px;
  233. }
  234. </style>
  235. </head>
  236. <body>
  237. <header class="navbar navbar-default navbar-static-top bs-docs-nav" id="top" role="banner">
  238. <div class="container">
  239. <div class="navbar-header">
  240. <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
  241. <span class="sr-only">Toggle navigation</span>
  242. <span class="icon-bar"></span>
  243. <span class="icon-bar"></span>
  244. <span class="icon-bar"></span>
  245. </button>
  246. <a href="/">
  247. <img id="logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPYAAABNCAYAAACVH5l+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAV/QAAFf0BzXBRYQAAABZ0RVh0Q3JlYXRpb24gVGltZQAxMi8xMy8xM+ovEHIAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzbovLKMAAAQAklEQVR4nO2de7RcVXnAfzM3MckmhLdKtZYqoimtERVtXSjFNvYE6rsnFMFKy2MJC4tGdNECalFsKxRQ5GGDClUjzS6lltcuUmiryxRqFaEaCkgVqAkSakKSneTm3rn949uHOTNzzp1zZs5j7mT/1pqVmzMze39z73xnf/vb36OBx+OZFRuEvwusBp4fu7wROE0ZfUs9UiUzMzMDQLNmOTyeucB1dCo17v/XVS5JRrxiezz9OSDn9drxiu3xjCFesT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Ugac7w+W7Q92IbUAizceVlVyt3d1HzUMCDPYQ6k/jkGltW176ni7zMDnKmMLj1xxGVEbSL56CspvqJwXE+x99LZ1jceYWbK6rJSRfmYrwCnj1LvpJwkOX9GlYFlVUbfaIPwTMrrnNFClPrOksZPIjr26o7w6vneu7iLw5Fwz+cjyr8L6a+13Y21M/bvM4iDbguy8u6I96x2EWbnIFZQd+XRGUpwmMUpU7HvB853SQJzmSq/iMMylKzK6KttED6OpEKmmeWD8CPk5n5XgWNmIR47HhHV6wbABuEBiH/hWOB5iEJHCSTx9yTRMa4NwvhcDcSK6h5nBvGLfFUZvTHn58lMkYq9EcnoWgfcrIxeV+DYdfAYcIky+u66BclAYbIqo2+xQfgSxIRcARyBKHme78pOYAPwbaSlk46vZhUSrdjdit10ZvJKZA+8P+JU617ZI9KuZ6F77hYS0164wyzOMAJ7PCONDcKPIllUcV/SDHLjsUhySJNOPYgfRQ1L92rdcvOeX9aWZGZGRJ9rJVo9njx0r9iRib0QyWOIVzft7tZZBN2r9W7gX6rwM3jF9owzu+hVLkhW3CRPfZqC57V0W4hS/w9QST82r9ieccaSrIRpjrG4uRx15ZhAzPXoEa360f+hM6Ksm0kko3E98Lm8zfUGxSu2Z5x5Glkp59OrdElm8n8jOd3fUUYnJcYk4o62FrrHXu6hEP2yyNHYJhcvUAlesT3jzEbkDHoJnUdYcZN8J3IcN3BIrvP4b3OPTcMIXBResT3jzONIqaGFtE3qiB3AD5AAqnUul3ts8IrtGWc2IDHw5yAtdOYjoZzfRRoN3FdGnPYo4M+xPWONK2C4H+1FbArYXFPATOlE59j/D6WId7YitGZUAAAAAElFTkSuQmCC"/>
  248. </a>
  249. </div>
  250. <nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
  251. <ul class="nav navbar-nav">
  252. <li>
  253. <a href="/qps">
  254. Requests statistics
  255. </a>
  256. </li>
  257. <li>
  258. <li class="dropdown">
  259. <a href="#" class="dropdown-toggle disabled" data-toggle="dropdown">Performance profiling<span class="caret"></span></a>
  260. <ul class="dropdown-menu" role="menu">
  261. <li><a href="/prof?command=lookup goroutine">lookup goroutine</a></li>
  262. <li><a href="/prof?command=lookup heap">lookup heap</a></li>
  263. <li><a href="/prof?command=lookup threadcreate">lookup threadcreate</a></li>
  264. <li><a href="/prof?command=lookup block">lookup block</a></li>
  265. <li><a href="/prof?command=get cpuprof">get cpuprof</a></li>
  266. <li><a href="/prof?command=get memprof">get memprof</a></li>
  267. <li><a href="/prof?command=gc summary">gc summary</a></li>
  268. </ul>
  269. </li>
  270. <li>
  271. <a href="/healthcheck">
  272. Healthcheck
  273. </a>
  274. </li>
  275. <li>
  276. <a href="/task" class="dropdown-toggle disabled" data-toggle="dropdown">Tasks</a>
  277. </li>
  278. <li class="dropdown">
  279. <a href="#" class="dropdown-toggle disabled" data-toggle="dropdown">Config Status<span class="caret"></span></a>
  280. <ul class="dropdown-menu" role="menu">
  281. <li><a href="/listconf?command=conf">Configs</a></li>
  282. <li><a href="/listconf?command=router">Routers</a></li>
  283. <li><a href="/listconf?command=filter">Filters</a></li>
  284. </ul>
  285. </li>
  286. </ul>
  287. </nav>
  288. </div>
  289. </header>
  290. <div class="container">
  291. {{template "content" .}}
  292. </div>
  293. <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  294. <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  295. <script src="//cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script>
  296. <script src="//cdn.datatables.net/plug-ins/725b2a2115b/integration/bootstrap/3/dataTables.bootstrap.js
  297. "></script>
  298. <script type="text/javascript">
  299. $(document).ready(function() {
  300. $('.table').dataTable();
  301. });
  302. </script>
  303. {{template "scripts" .}}
  304. </body>
  305. </html>
  306. `