2020-06-17 15:47:19 +00:00
|
|
|
{{ define "content" }}
|
|
|
|
<h1 class="title is-1">{{ .Title }}</h1>
|
|
|
|
<div id="mynetwork" style="height:800px"></div>
|
|
|
|
|
|
|
|
<script src="https://unpkg.com/vis-network" type="application/javascript"></script>
|
|
|
|
<script src="https://unpkg.com/vis-data" type="application/javascript"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
// create an array with nodes
|
|
|
|
var nodes = new vis.DataSet({{ .Nodes }});
|
|
|
|
|
|
|
|
// create an array with edges
|
|
|
|
var edges = new vis.DataSet({{ .Edges }});
|
|
|
|
|
|
|
|
// create a network
|
|
|
|
var container = document.getElementById('mynetwork');
|
|
|
|
|
|
|
|
// provide the data in the vis format
|
|
|
|
var data = {
|
|
|
|
nodes: nodes,
|
|
|
|
edges: edges
|
|
|
|
};
|
|
|
|
var options = {
|
|
|
|
edges: {
|
|
|
|
arrows: 'to',
|
2020-06-17 16:13:38 +00:00
|
|
|
color: {
|
|
|
|
highlight: 'green'
|
|
|
|
}
|
2020-06-17 15:47:19 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
nodes: {
|
2020-06-17 16:13:38 +00:00
|
|
|
shape: 'dot',
|
|
|
|
size: 15,
|
|
|
|
font: {
|
|
|
|
background: 'white'
|
|
|
|
}
|
2020-06-17 19:20:03 +00:00
|
|
|
},
|
|
|
|
layout: {
|
|
|
|
improvedLayout: false
|
2020-06-17 15:47:19 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// initialize your network!
|
|
|
|
var network = new vis.Network(container, data, options);
|
|
|
|
network.on('doubleClick', function (props) {
|
|
|
|
console.log(props)
|
2020-06-17 18:49:03 +00:00
|
|
|
if (props.nodes.length) {
|
|
|
|
let nodeId = props.nodes[0]
|
|
|
|
let node = nodes.get(nodeId)
|
|
|
|
window.location.href = '/edit/'+node.label
|
|
|
|
}
|
2020-06-17 15:47:19 +00:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ define "navbar" }}
|
|
|
|
{{ if $.Session.LoggedIn }}
|
|
|
|
<a href="/edit/{{ .Name }}" class="navbar-item">Edit</a>
|
|
|
|
<a href="/history/{{ .Name }}" class="navbar-item">History</a>
|
|
|
|
<a href="/recent/" class="navbar-item">Recent Changes</a>
|
|
|
|
<a href="/graph/" class="navbar-item">Graph</a>
|
|
|
|
<a href="/auth/logout" class="navbar-item">Logout</a>
|
|
|
|
<span class="navbar-item"><b>{{ $.Session.Me }}</b></span>
|
|
|
|
{{ else }}
|
|
|
|
<a href="/auth/login" class="navbar-item">Login</a>
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ define "content_head" }}
|
|
|
|
<style>
|
|
|
|
.edit {
|
|
|
|
color: red;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tag {
|
|
|
|
color: #444;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
{{ end }}
|