зеркало из https://github.com/github/vitess-gh.git
Move schema editor to templates
This commit is contained in:
Родитель
db29641f99
Коммит
5b0fdb260c
|
@ -73,7 +73,7 @@ func HandleExplorer(name, url, templateName string, exp Explorer) {
|
|||
|
||||
explorer = exp
|
||||
explorerName = name
|
||||
|
||||
indexContent.ToplevelLinks[name+" Explorer"] = url
|
||||
http.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) {
|
||||
if err := r.ParseForm(); err != nil {
|
||||
httpError(w, "cannot parse form: %s", err)
|
||||
|
|
|
@ -143,7 +143,7 @@ type TemplateLoader struct {
|
|||
}
|
||||
|
||||
func (loader *TemplateLoader) compile() (*template.Template, error) {
|
||||
return template.New("main").Funcs(FuncMap).ParseGlob(path.Join(loader.Directory, "[a-z]*"))
|
||||
return template.New("main").Funcs(FuncMap).ParseGlob(path.Join(loader.Directory, "[a-z]*.html"))
|
||||
}
|
||||
|
||||
func (loader *TemplateLoader) makeErrorTemplate(errorMessage string) *template.Template {
|
||||
|
|
|
@ -15,24 +15,24 @@ angular.module('app', ['ngRoute'])
|
|||
.controller('SubmitController', SubmitController)
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider
|
||||
.when('/',{
|
||||
templateUrl: "editor/keyspace.html",
|
||||
.when('/editor',{
|
||||
templateUrl: "/content/editor/keyspace.html",
|
||||
controller: "KeyspaceController"
|
||||
})
|
||||
.when('/editor/:keyspaceName',{
|
||||
templateUrl: "editor/keyspace.html",
|
||||
templateUrl: "/content/editor/keyspace.html",
|
||||
controller: "KeyspaceController"
|
||||
})
|
||||
.when('/editor/:keyspaceName/class/:className',{
|
||||
templateUrl: "editor/class/class.html",
|
||||
templateUrl: "/content/editor/class/class.html",
|
||||
controller: "ClassController"
|
||||
})
|
||||
.when('/load',{
|
||||
templateUrl: "load/load.html",
|
||||
templateUrl: "/content/load/load.html",
|
||||
controller: "LoadController"
|
||||
})
|
||||
.when('/submit',{
|
||||
templateUrl: "submit/submit.html",
|
||||
templateUrl: "/content/submit/submit.html",
|
||||
controller: "SubmitController"
|
||||
})
|
||||
.otherwise({redirectTo: '/'});
|
|
@ -1,6 +1,6 @@
|
|||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div data-ng-include="'editor/sidebar.html'"></div>
|
||||
<div data-ng-include="'/content/editor/sidebar.html'"></div>
|
||||
<div data-ng-show="className">
|
||||
<div class="col-md-9">
|
||||
<h4 data-ng-show="keyspaceName">Class:
|
|
@ -57,4 +57,4 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -1,7 +1,7 @@
|
|||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div data-ng-include="'editor/sidebar.html'"></div>
|
||||
<div class="col-md-10">
|
||||
<div data-ng-include="'/content/editor/sidebar.html'"></div>
|
||||
<div class="col-md-4">
|
||||
<h4 data-ng-show="keyspaceName">
|
||||
Keyspace: {{keyspaceName}} <span class="btn-group ">
|
||||
<button type="button"
|
||||
|
@ -21,13 +21,13 @@
|
|||
</div>
|
||||
<div data-ng-switch="keyspace.Sharded">
|
||||
<div data-ng-switch-when="true">
|
||||
<div data-ng-include="'editor/tables.html'"></div>
|
||||
<div data-ng-include="'editor/classes.html'"></div>
|
||||
<div data-ng-include="'editor/vindexes.html'"></div>
|
||||
<div data-ng-include="'/content/editor/tables.html'"></div>
|
||||
<div data-ng-include="'/content/editor/classes.html'"></div>
|
||||
<div data-ng-include="'/content/editor/vindexes.html'"></div>
|
||||
</div>
|
||||
<div data-ng-switch-default>
|
||||
<div data-ng-include="'editor/unsharded_tables.html'"></div>
|
||||
<div data-ng-include="'/content/editor/unsharded_tables.html'"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -3,9 +3,9 @@
|
|||
<div class="panel-heading">Commands</div>
|
||||
<div class="panel-body">
|
||||
<ul class="nav nav-sidebar">
|
||||
<li><a href="#/load">load</a></li>
|
||||
<li><a href="#/submit">submit...</a></li>
|
||||
<li><a href="#" data-ng-click="reset()">reset</a></li>
|
||||
<li><a href="#/load">Load</a></li>
|
||||
<li><a href="#/submit">Submit</a></li>
|
||||
<li><a href="#/editor" data-ng-click="reset()">Reset</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -9,7 +9,7 @@ license that can be found in the LICENSE file.
|
|||
<link rel="stylesheet"
|
||||
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
||||
<head>
|
||||
<base href="/schema_editor/" />
|
||||
<base href="/" />
|
||||
<meta charset="US-ASCII">
|
||||
<title>VTGate schema editor</title>
|
||||
</head>
|
||||
|
@ -23,10 +23,13 @@ license that can be found in the LICENSE file.
|
|||
<ul class="nav navbar-nav">
|
||||
<li><a href="/dbtopo">Topology</a></li>
|
||||
<li><a href="/serving_graph">Serving graph</a></li>
|
||||
<li><a href="/etcd">etcd browser</a></li>
|
||||
<li><a href="/zk">zk browser</a></li>
|
||||
<li><a href="/schema_editor">Schema editor</a></li>
|
||||
<li><a href="#/editor">Schema editor</a></li>
|
||||
<li><a href="/vschema">Schema View</a></li>
|
||||
{{with .ToplevelLinks}}
|
||||
{{range $name, $href := .}}
|
||||
<li><a href="{{$href}}">{{$name}}</a></li>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -51,28 +54,28 @@ license that can be found in the LICENSE file.
|
|||
type="text/javascript">
|
||||
|
||||
</script>
|
||||
<script src="vindex_info.js" type="text/javascript">
|
||||
<script src="content/vindex_info.js" type="text/javascript">
|
||||
|
||||
</script>
|
||||
<script src="curschema.js" type="text/javascript">
|
||||
<script src="content/curschema.js" type="text/javascript">
|
||||
|
||||
</script>
|
||||
<script src="editor/sidebar.js" type="text/javascript">
|
||||
<script src="content/editor/sidebar.js" type="text/javascript">
|
||||
|
||||
</script>
|
||||
<script src="editor/keyspace.js" type="text/javascript">
|
||||
<script src="content/editor/keyspace.js" type="text/javascript">
|
||||
|
||||
</script>
|
||||
<script src="editor/class/class.js" type="text/javascript">
|
||||
<script src="content/editor/class/class.js" type="text/javascript">
|
||||
|
||||
</script>
|
||||
<script src="load/load.js" type="text/javascript">
|
||||
<script src="content/load/load.js" type="text/javascript">
|
||||
|
||||
</script>
|
||||
<script src="submit/submit.js" type="text/javascript">
|
||||
<script src="content/submit/submit.js" type="text/javascript">
|
||||
|
||||
</script>
|
||||
<script src="app.js" type="text/javascript">
|
||||
<script src="content/app.js" type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -1,6 +1,6 @@
|
|||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div data-ng-include="'editor/sidebar.html'"></div>
|
||||
<div data-ng-include="'/content/editor/sidebar.html'"></div>
|
||||
<div class="col-md-6">
|
||||
<button type="button" class="btn btn-primary"
|
||||
data-ng-click="loadFromTopo()">Load from topo</button>
|
||||
|
@ -18,4 +18,4 @@
|
|||
<pre>{{loadedJSON}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,6 +1,6 @@
|
|||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div data-ng-include="'editor/sidebar.html'"></div>
|
||||
<div data-ng-include="'/content/editor/sidebar.html'"></div>
|
||||
<div class="col-md-8">
|
||||
<button type="button" class="btn btn-primary pull-right"
|
||||
data-ng-click="submitToTopo()">Submit to topo</button>
|
||||
|
@ -26,4 +26,4 @@
|
|||
<pre>{{keyspacesJSON}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -18,9 +18,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
templateDir = flag.String("templates", "", "directory containing templates")
|
||||
debug = flag.Bool("debug", false, "recompile templates for every request")
|
||||
schemaEditorDir = flag.String("schema-editor-dir", "", "directory containing schema_editor/")
|
||||
templateDir = flag.String("templates", "", "directory containing templates")
|
||||
debug = flag.Bool("debug", false, "recompile templates for every request")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -48,6 +47,9 @@ type IndexContent struct {
|
|||
// used at runtime by plug-ins
|
||||
var templateLoader *TemplateLoader
|
||||
var actionRepo *ActionRepository
|
||||
var indexContent = IndexContent{
|
||||
ToplevelLinks: map[string]string{},
|
||||
}
|
||||
|
||||
var ts topo.Server
|
||||
|
||||
|
@ -265,12 +267,12 @@ func main() {
|
|||
|
||||
// vschema editor
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, *schemaEditorDir+"/schema_editor/index.html")
|
||||
templateLoader.ServeTemplate("index.html", indexContent, w, r)
|
||||
})
|
||||
|
||||
// vschema editor
|
||||
http.HandleFunc("/schema_editor/", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, *schemaEditorDir+r.URL.Path)
|
||||
http.HandleFunc("/content/", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, *templateDir+r.URL.Path[8:])
|
||||
})
|
||||
|
||||
// vschema viewer
|
||||
|
|
|
@ -695,7 +695,6 @@ class Vtctld(object):
|
|||
args = environment.binary_args('vtctld') + [
|
||||
'-debug',
|
||||
'-templates', environment.vttop + '/go/cmd/vtctld/templates',
|
||||
'-schema-editor-dir', environment.vttop + '/go/cmd/vtctld',
|
||||
'-log_dir', environment.vtlogroot,
|
||||
'-port', str(self.port),
|
||||
] + \
|
||||
|
|
Загрузка…
Ссылка в новой задаче