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