gui.htpl (6184B)
1 {{define "main"}} 2 <!doctype html> 3 <html lang="en"> 4 <head> 5 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 6 {{template "css" .NumRR}} 7 </head> 8 <body> 9 <h1>GNUnet Zone Master</h1> 10 <hr/> 11 {{.Content}} 12 <script> 13 function notify(msg) { 14 if ('Notification' in window) { 15 if (Notification.permission !== 'denied') { 16 Notification.requestPermission(function (permission) { 17 if (permission === 'granted') { 18 var note = new Notification('GNUnet Zone Master', { 19 body: msg, 20 actions: [] 21 }); 22 } 23 }); 24 } 25 } 26 } 27 </script> 28 </body> 29 </html> 30 {{end}} 31 32 {{define "dashboard"}} 33 <div> 34 <ul id="dashboard"> 35 {{if .Zones}} 36 {{$plugins := .Plugins}} 37 {{range $zi, $zone := .Zones}} 38 <li> 39 {{$z := $zone.Zone}} 40 <span class="caret"><b>{{$z.Name}}</b></span> [{{keytype $z.Key.Type}}: {{$zone.PubID}}] 41 <a href="/edit/zone/{{$z.ID}}" title="Edit zone"><button class="icon blue">✎</button></a> 42 <a href="/del/zone/{{$z.ID}}" title="Remove zone"><button class="icon red">✖</button></a> 43 (Created: {{date $z.Created}}, Modified: {{date $z.Modified}}) 44 <ul class="nested"> 45 {{if $zone.Labels}} 46 {{range $li, $label := $zone.Labels}} 47 <li> 48 {{$l := $label.Label}} 49 <span class="caret"><b>{{$l.Name}}</b></span> 50 <a href="/edit/label/{{$l.ID}}" title="Edit label"><button class="icon blue">✎</button></a> 51 <a href="/del/label/{{$l.ID}}" title="Remove label"><button class="icon red">✖</button></a> 52 (Created: {{date $l.Created}}, Modified: {{date $l.Modified}}) 53 <ul class="nested"> 54 {{if $label.Records}} 55 <li> 56 <table class="rowed"> 57 <tr class="header"> 58 <th>Type</th> 59 <th>Value</th> 60 <th>Flags</th> 61 <th>Expires</th> 62 <th>Created</th> 63 <th>Modified</th> 64 <th>Actions</th> 65 </tr> 66 {{range $ri, $rec := $label.Records}} 67 <tr class="row"> 68 <td>{{rrtype $rec.RType}}</td> 69 <td>{{rrdata $rec.RType $rec.Data}}</td> 70 <td>{{rrflags $rec.Flags}}</td> 71 <td>{{dateExp $rec.Expire $rec.Flags}}</td> 72 <td>{{date $rec.Created}}</td> 73 <td>{{date $rec.Modified}}</td> 74 <td> 75 <a href="/edit/rr/{{$rec.ID}}" title="Edit record"><button class="icon blue">✎</button></a> 76 <a href="/del/rr/{{$rec.ID}}" title="Remove record"><button class="icon red">✖</button></a> 77 </td> 78 </tr> 79 {{end}} 80 </table> 81 </li> 82 {{else}} 83 <li><h3>No resource records for label defined yet.</h3></li> 84 {{end}} 85 <li> 86 <form action="/new/rr/{{$l.ID}}" method="get"> 87 <select name="mode"> 88 <option value="GNS" selected>GNS</option> 89 {{range $i,$v := $plugins}} 90 <option value="{{$i}}">{{$v}}</option> 91 {{end}} 92 </select> 93 <button id="submit" class="icon blue">✚</button> 94 </form> 95 </li> 96 </ul> 97 </li> 98 {{end}} 99 {{else}} 100 <li><h3>No labels for zone defined yet.</h3></li> 101 {{end}} 102 <li> 103 <a href="/new/label/{{$z.ID}}" title="Add new label..."><button class="icon blue">✚</button></a> 104 </li> 105 </ul> 106 </li> 107 {{end}} 108 {{else}} 109 <li> 110 <h3>No zones defined yet.</h3> 111 </li> 112 {{end}} 113 <li> 114 <a href="/new/zone/0" title="Add new zone..."><button class="icon blue">✚</button></a> 115 </li> 116 </ul> 117 </div> 118 <script> 119 var toggler = document.getElementsByClassName("caret"); 120 for (var i = 0; i < toggler.length; i++) { 121 toggler[i].addEventListener("click", function() { 122 this.parentElement.querySelector(".nested").classList.toggle("active"); 123 this.classList.toggle("caret-down"); 124 }); 125 } 126 127 for (var i = 0; i < toggler.length; i++) { 128 if (localStorage.getItem("t"+i) == "true") { 129 toggler[i].parentElement.querySelector(".nested").classList.toggle("active"); 130 toggler[i].classList.toggle("caret-down"); 131 } 132 } 133 document.documentElement.scrollTop = document.body.scrollTop = localStorage.getItem("top"); 134 135 window.addEventListener('beforeunload', function (e) { 136 for (var i = 0; i < toggler.length; i++) { 137 localStorage.setItem("t"+i, toggler[i].classList.contains("caret-down")); 138 } 139 localStorage.setItem("top", window.pageYOffset || document.documentElement.scrollTop); 140 }); 141 </script> 142 {{end}}