1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 04:30:55 +00:00
Beego/adminui.go

357 lines
13 KiB
Go
Raw Normal View History

2014-08-18 08:41:43 +00:00
// Copyright 2014 beego Author. All Rights Reserved.
//
2014-08-18 08:41:43 +00:00
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
2014-08-18 08:41:43 +00:00
// http://www.apache.org/licenses/LICENSE-2.0
//
2014-08-18 08:41:43 +00:00
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2014-08-14 09:35:23 +00:00
package beego
var indexTpl = `
{{define "content"}}
<h1>Beego Admin Dashboard</h1>
<p>
For detail usage please check our document:
</p>
<p>
<a target="_blank" href="http://beego.me/docs/module/toolbox.md">Toolbox</a>
</p>
<p>
<a target="_blank" href="http://beego.me/docs/advantage/monitor.md">Live Monitor</a>
</p>
{{.Content}}
{{end}}`
var profillingTpl = `
{{define "content"}}
<h1>{{.Title}}</h1>
2014-08-15 06:24:55 +00:00
<pre id="content">
<div>{{.Content}}</div>
2014-08-14 09:35:23 +00:00
</pre>
{{end}}`
2014-08-15 06:24:55 +00:00
var defaultScriptsTpl = ``
var gcAjaxTpl = `
{{define "scripts"}}
<script type="text/javascript">
var app = app || {};
(function() {
app.$el = $('#content');
app.getGc = function() {
var that = this;
$.ajax("/prof?command=gc%20summary&format=json").done(function(data) {
that.$el.append($('<p>' + data.Content + '</p>'));
});
};
$(document).ready(function() {
setInterval(function() {
app.getGc();
}, 3000);
});
})();
</script>
{{end}}
`
2014-08-24 17:37:11 +00:00
var qpsTpl = `{{define "content"}}
2014-08-14 09:35:23 +00:00
<h1>Requests statistics</h1>
<table class="table table-striped table-hover ">
2014-08-24 17:37:11 +00:00
<thead>
<tr>
{{range .Content.Fields}}
<th>
{{.}}
</th>
{{end}}
</tr>
</thead>
<tbody>
{{range $i, $elem := .Content.Data}}
<tr>
2016-09-13 14:43:40 +00:00
<td>{{index $elem 0}}</td>
<td>{{index $elem 1}}</td>
<td>{{index $elem 2}}</td>
<td data-order="{{index $elem 3}}">{{index $elem 4}}</td>
<td data-order="{{index $elem 5}}">{{index $elem 6}}</td>
<td data-order="{{index $elem 7}}">{{index $elem 8}}</td>
<td data-order="{{index $elem 9}}">{{index $elem 10}}</td>
2014-08-24 17:37:11 +00:00
</tr>
{{end}}
</tbody>
2014-08-14 09:35:23 +00:00
</table>
2014-08-24 17:37:11 +00:00
{{end}}`
2014-08-14 09:35:23 +00:00
var configTpl = `
{{define "content"}}
<h1>Configurations</h1>
<pre>
{{range $index, $elem := .Content}}
{{$index}}={{$elem}}
{{end}}
</pre>
{{end}}
`
2014-08-24 17:37:11 +00:00
var routerAndFilterTpl = `{{define "content"}}
2014-08-14 09:35:23 +00:00
<h1>{{.Title}}</h1>
2014-08-24 17:37:11 +00:00
{{range .Content.Methods}}
<div class="panel panel-default">
<div class="panel-heading lead success"><strong>{{.}}</strong></div>
<div class="panel-body">
<table class="table table-striped table-hover ">
<thead>
<tr>
{{range $.Content.Fields}}
<th>
{{.}}
</th>
2014-08-14 09:35:23 +00:00
{{end}}
2014-08-24 17:37:11 +00:00
</tr>
</thead>
<tbody>
{{$slice := index $.Content.Data .}}
{{range $i, $elem := $slice}}
<tr>
{{range $elem}}
<td>
{{.}}
</td>
{{end}}
</tr>
2014-08-14 09:35:23 +00:00
{{end}}
2014-08-24 17:37:11 +00:00
</tbody>
2014-08-14 09:35:23 +00:00
</table>
2014-08-24 17:37:11 +00:00
</div>
</div>
2014-08-14 09:35:23 +00:00
{{end}}
2014-08-24 17:37:11 +00:00
{{end}}`
var tasksTpl = `{{define "content"}}
2014-08-14 09:35:23 +00:00
<h1>{{.Title}}</h1>
{{if .Message }}
{{ $messageType := index .Message 0}}
<p class="message
{{if eq "error" $messageType}}
bg-danger
{{else if eq "success" $messageType}}
bg-success
{{else}}
bg-warning
{{end}}
">
{{index .Message 1}}
</p>
{{end}}
<table class="table table-striped table-hover ">
2014-08-24 17:37:11 +00:00
<thead>
2014-08-14 09:35:23 +00:00
<tr>
2014-08-24 17:37:11 +00:00
{{range .Content.Fields}}
<th>
{{.}}
</th>
{{end}}
</tr>
</thead>
2014-08-14 09:35:23 +00:00
2014-08-24 17:37:11 +00:00
<tbody>
{{range $i, $slice := .Content.Data}}
<tr>
{{range $slice}}
2014-08-14 09:35:23 +00:00
<td>
2014-08-24 17:37:11 +00:00
{{.}}
2014-08-14 09:35:23 +00:00
</td>
{{end}}
<td>
<a class="btn btn-primary btn-sm" href="/task?taskname={{index $slice 0}}">Run</a>
2014-08-14 09:35:23 +00:00
</td>
</tr>
{{end}}
2014-08-24 17:37:11 +00:00
</tbody>
2014-08-14 09:35:23 +00:00
</table>
2014-08-24 17:37:11 +00:00
{{end}}`
2014-08-14 09:35:23 +00:00
var healthCheckTpl = `
{{define "content"}}
<h1>{{.Title}}</h1>
<table class="table table-striped table-hover ">
2014-08-24 17:37:11 +00:00
<thead>
2014-08-14 09:35:23 +00:00
<tr>
2014-08-24 17:37:11 +00:00
{{range .Content.Fields}}
2014-08-14 09:35:23 +00:00
<th>
2014-08-24 17:37:11 +00:00
{{.}}
2014-08-14 09:35:23 +00:00
</th>
2014-08-24 17:37:11 +00:00
{{end}}
2014-08-14 09:35:23 +00:00
</tr>
2014-08-24 17:37:11 +00:00
</thead>
<tbody>
{{range $i, $slice := .Content.Data}}
{{ $header := index $slice 0}}
2014-08-14 09:35:23 +00:00
{{ if eq "success" $header}}
<tr class="success">
{{else if eq "error" $header}}
<tr class="danger">
{{else}}
<tr>
{{end}}
{{range $j, $elem := $slice}}
{{if ne $j 0}}
<td>
{{$elem}}
</td>
{{end}}
{{end}}
2014-08-24 17:37:11 +00:00
<td>
{{$header}}
</td>
2014-08-14 09:35:23 +00:00
</tr>
{{end}}
2014-08-24 17:37:11 +00:00
</tbody>
2014-08-14 09:35:23 +00:00
</table>
{{end}}`
// The base dashboardTpl
var dashboardTpl = `
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
Welcome to Beego Admin Dashboard
</title>
2014-08-24 17:40:23 +00:00
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
2014-08-24 17:37:11 +00:00
<link href="//cdn.datatables.net/plug-ins/725b2a2115b/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">
2014-08-14 09:35:23 +00:00
<style type="text/css">
ul.nav li.dropdown:hover > ul.dropdown-menu {
display: block;
}
#logo {
width: 102px;
height: 32px;
margin-top: 5px;
}
.message {
padding: 15px;
}
</style>
</head>
<body>
<header class="navbar navbar-default navbar-static-top bs-docs-nav" id="top" role="banner">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="/">
<img id="logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPYAAABNCAYAAACVH5l+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAV/QAAFf0BzXBRYQAAABZ0RVh0Q3JlYXRpb24gVGltZQAxMi8xMy8xM+ovEHIAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzbovLKMAAAQAklEQVR4nO2de7RcVXnAfzM3MckmhLdKtZYqoimtERVtXSjFNvYE6rsnFMFKy2MJC4tGdNECalFsKxRQ5GGDClUjzS6lltcuUmiryxRqFaEaCkgVqAkSakKSneTm3rn949uHOTNzzp1zZs5j7mT/1pqVmzMze39z73xnf/vb36OBx+OZFRuEvwusBp4fu7wROE0ZfUs9UiUzMz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InAEnpUC+GHhXHbLlweVfn0D75hTfWuxGbpy5Yz/KKGY4iTQdS+pw0KD4Fduzh9JqtR4F/o7OPTbu5wXAScP2yKqA85GMLuhcracRHbpskIKRZRUztEhCeRKvK2NOTy3cRmfyQqW4I60vAP9Lsof8RUhFlZHEtfU9is72QHGH2SeV0XkCxZ6lTDPq9pTrh5Y4p6dCXNbX24FvIdFeWxIeZcvwJLIHjRcuiJR8HnD8KK7arsHGxxBPeES8RPK/K6MHDokt80jgwZTrI/dL9gyOMvpm0n0qVfUJ10gwz6H0Nsd7IfCHwMUly5AZV4Tk/UiMfpLDbCuzl37uS5nFDLcixe+6GShbxeNJQxm9CVm1d9J7BtxEVu1Rqo77y8DvkZxDPgXcpIxOW
</a>
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<li>
<a href="/qps">
Requests statistics
</a>
</li>
<li>
<li class="dropdown">
<a href="#" class="dropdown-toggle disabled" data-toggle="dropdown">Performance profiling<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="/prof?command=lookup goroutine">lookup goroutine</a></li>
<li><a href="/prof?command=lookup heap">lookup heap</a></li>
<li><a href="/prof?command=lookup threadcreate">lookup threadcreate</a></li>
<li><a href="/prof?command=lookup block">lookup block</a></li>
2014-08-15 07:19:35 +00:00
<li><a href="/prof?command=get cpuprof">get cpuprof</a></li>
2014-08-14 09:35:23 +00:00
<li><a href="/prof?command=get memprof">get memprof</a></li>
<li><a href="/prof?command=gc summary">gc summary</a></li>
</ul>
</li>
<li>
<a href="/healthcheck">
Healthcheck
</a>
</li>
<li>
<a href="/task" class="dropdown-toggle disabled" data-toggle="dropdown">Tasks</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle disabled" data-toggle="dropdown">Config Status<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="/listconf?command=conf">Configs</a></li>
<li><a href="/listconf?command=router">Routers</a></li>
<li><a href="/listconf?command=filter">Filters</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</header>
<div class="container">
{{template "content" .}}
</div>
2014-08-24 17:40:23 +00:00
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
2014-08-24 17:37:11 +00:00
<script src="//cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script>
<script src="//cdn.datatables.net/plug-ins/725b2a2115b/integration/bootstrap/3/dataTables.bootstrap.js
"></script>
2014-08-14 09:35:23 +00:00
2014-08-24 17:37:11 +00:00
<script type="text/javascript">
$(document).ready(function() {
$('.table').dataTable();
});
</script>
2014-08-15 06:24:55 +00:00
{{template "scripts" .}}
2014-08-14 09:35:23 +00:00
</body>
</html>
`