cleanup
This commit is contained in:
parent
b0a12260ea
commit
9ca66313ec
|
@ -11,14 +11,14 @@
|
||||||
<button class="js-jwt" type="button">Authorize</button>
|
<button class="js-jwt" type="button">Authorize</button>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><a href="/api/peers">/api/peers</a></p>
|
<p><a class="js-peers" data-href="/api/peers?access_token=:token">/api/peers</a></p>
|
||||||
<p><a href="/api/zones">/api/zones</a></p>
|
<p><a class="js-zones" data-href="/api/zones?access_token=:token">/api/zones</a></p>
|
||||||
<p><a data-href="/api/zones/:zone/records" class="js-zone">/api/zones/<code
|
<p><a data-href="/api/zones/:zone/records?access_token=:token" class="js-zone">/api/zones/<code
|
||||||
class="js-zone">:zone</code>/records</a>
|
class="js-zone">:zone</code>/records</a>
|
||||||
<input class="js-zone"
|
<input class="js-zone"
|
||||||
type="text" placeholder="example.com" /></p>
|
type="text" placeholder="example.com" /></p>
|
||||||
<p><a href="/api/records">/api/records</a></p>
|
<p><a class="js-records" data-href="/api/records?access_token=:token">/api/records</a></p>
|
||||||
<p><a data-href="/api/records/:name" class="js-name">/api/records/<code class="js-name">:name</code></a>
|
<p><a data-href="/api/records/:name?access_token=:token" class="js-name">/api/records/<code class="js-name">:name</code></a>
|
||||||
<input class="js-name"
|
<input class="js-name"
|
||||||
type="text" placeholder="example.com"/></p>
|
type="text" placeholder="example.com"/></p>
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
<input type="text" class="js-record-minimum" placeholder="[minimum nxdomain] 5">
|
<input type="text" class="js-record-minimum" placeholder="[minimum nxdomain] 5">
|
||||||
<input type="text" class="js-recordx-serial" placeholder="[serial] YYYYMMDDxx" disabled>
|
<input type="text" class="js-recordx-serial" placeholder="[serial] YYYYMMDDxx" disabled>
|
||||||
<input type="text" class="js-record-retry" placeholder="[retry] 1800 (how quickly to retry on failed update)">
|
<input type="text" class="js-record-retry" placeholder="[retry] 1800 (how quickly to retry on failed update)">
|
||||||
<input type="text" class="js-record-refresh" placeholder="[retry] 7200 (how often to check for updates)">
|
<input type="text" class="js-record-refresh" placeholder="[refresh] 7200 (how often to check for updates)">
|
||||||
<input type="text" class="js-record-ttl" placeholder="[default record ttl] 86400">
|
<input type="text" class="js-record-ttl" placeholder="[default record ttl] 86400">
|
||||||
</form>
|
</form>
|
||||||
<span class="js-record-type">Vanity Nameservers:</span>
|
<span class="js-record-type">Vanity Nameservers:</span>
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
localStorage.setItem('auth', auth);
|
localStorage.setItem('auth', auth);
|
||||||
|
changeAuth();
|
||||||
|
|
||||||
return fetchPeers(auth).then(function () {
|
return fetchPeers(auth).then(function () {
|
||||||
return fetchZones(auth);
|
return fetchZones(auth);
|
||||||
|
@ -83,9 +84,6 @@
|
||||||
return resp.json().then(function (data) {
|
return resp.json().then(function (data) {
|
||||||
var tpl = '';
|
var tpl = '';
|
||||||
var el;
|
var el;
|
||||||
if (!tpls.peer) {
|
|
||||||
tpls.peer = $qs('.js-peer-tpl').innerHTML;
|
|
||||||
}
|
|
||||||
cache.peers = data.peers;
|
cache.peers = data.peers;
|
||||||
cache.peers.forEach(function (peer) {
|
cache.peers.forEach(function (peer) {
|
||||||
el = document.createElement('div');
|
el = document.createElement('div');
|
||||||
|
@ -140,23 +138,6 @@
|
||||||
function renderRecords() {
|
function renderRecords() {
|
||||||
var tpl = '';
|
var tpl = '';
|
||||||
var el;
|
var el;
|
||||||
if (!tpls.recordsMap) {
|
|
||||||
//tpls.recordTypes = Array.prototype.slice.call($qsa('.js-record-tpl li'));
|
|
||||||
//.innerHTML;
|
|
||||||
tpls.recordsMap = {};
|
|
||||||
tpls.recordsMap.soa = $qs('.js-record-soa').outerHTML;
|
|
||||||
tpls.recordsMap.ns = $qs('.js-record-ns').outerHTML;
|
|
||||||
tpls.recordsMap.a = $qs('.js-record-a').outerHTML;
|
|
||||||
tpls.recordsMap.aaaa = $qs('.js-record-aaaa').outerHTML;
|
|
||||||
tpls.recordsMap.aname = $qs('.js-record-aname').outerHTML;
|
|
||||||
tpls.recordsMap.cname = $qs('.js-record-cname').outerHTML;
|
|
||||||
tpls.recordsMap.caa = $qs('.js-record-caa').outerHTML;
|
|
||||||
tpls.recordsMap.ptr = $qs('.js-record-ptr').outerHTML;
|
|
||||||
tpls.recordsMap.mx = $qs('.js-record-mx').outerHTML;
|
|
||||||
tpls.recordsMap.txt = $qs('.js-record-txt').outerHTML;
|
|
||||||
tpls.recordsMap.srv = $qs('.js-record-srv').outerHTML;
|
|
||||||
//tpls.recordsMap.typex = $qs('.js-record-typex').outerHTML;
|
|
||||||
}
|
|
||||||
console.log('tpls.recordsMap:');
|
console.log('tpls.recordsMap:');
|
||||||
console.log(tpls.recordsMap);
|
console.log(tpls.recordsMap);
|
||||||
cache.records.forEach(function (record) {
|
cache.records.forEach(function (record) {
|
||||||
|
@ -216,18 +197,32 @@
|
||||||
|
|
||||||
$on('button.js-jwt', 'click', verifyAuth);
|
$on('button.js-jwt', 'click', verifyAuth);
|
||||||
|
|
||||||
$on('input.js-zone', 'keyup', function (ev) {
|
function changeAuth() {
|
||||||
$qs('code.js-zone').innerHTML = ev.target.value || ':zone';
|
$qs('a.js-peers').href =
|
||||||
|
$qs('a.js-peers').dataset.href.replace(/:token/, auth);
|
||||||
|
$qs('a.js-zones').href =
|
||||||
|
$qs('a.js-zones').dataset.href.replace(/:token/, auth);
|
||||||
|
$qs('a.js-records').href =
|
||||||
|
$qs('a.js-records').dataset.href.replace(/:token/, auth);
|
||||||
|
changeZone();
|
||||||
|
changeRecord();
|
||||||
|
}
|
||||||
|
function changeZone(ev) {
|
||||||
|
var val = (ev && ev.target.value || $qs('input.js-zone').value) || ':zone';
|
||||||
|
$qs('code.js-zone').innerHTML = val;
|
||||||
// $qs('a.js-zone').setAttribute('data-href', ...)
|
// $qs('a.js-zone').setAttribute('data-href', ...)
|
||||||
$qs('a.js-zone').href =
|
$qs('a.js-zone').href =
|
||||||
$qs('a.js-zone').dataset.href.replace(/:zone/, ev.target.value || ':zone');
|
$qs('a.js-zone').dataset.href.replace(/:zone/, val).replace(/:token/, auth);
|
||||||
});
|
}
|
||||||
|
$on('input.js-zone', 'keyup', changeZone);
|
||||||
|
|
||||||
$on('input.js-name', 'keyup', function (ev) {
|
function changeRecord(ev) {
|
||||||
$qs('code.js-name').innerHTML = ev.target.value || ':name';
|
var val = (ev && ev.target.value || $qs('input.js-name').value) || ':name';
|
||||||
|
$qs('code.js-name').innerHTML = val;
|
||||||
$qs('a.js-name').href =
|
$qs('a.js-name').href =
|
||||||
$qs('a.js-name').dataset.href.replace(/:name/, ev.target.value || ':name');
|
$qs('a.js-name').dataset.href.replace(/:name/, val).replace(/:token/, auth);
|
||||||
});
|
}
|
||||||
|
$on('input.js-name', 'keyup', changeRecord);
|
||||||
$on('button.js-zone-destroy', 'click', function (ev) {
|
$on('button.js-zone-destroy', 'click', function (ev) {
|
||||||
var zoneId = ev.target.parentElement.dataset.id;
|
var zoneId = ev.target.parentElement.dataset.id;
|
||||||
var zoneName = ev.target.parentElement.dataset.name;
|
var zoneName = ev.target.parentElement.dataset.name;
|
||||||
|
@ -322,9 +317,13 @@
|
||||||
$qs('.js-record-ttl', $vns).value = 7200;
|
$qs('.js-record-ttl', $vns).value = 7200;
|
||||||
});
|
});
|
||||||
|
|
||||||
[ 'name', 'admin', 'expiration', 'minimum', 'serial', 'retry', 'refresh', 'ttl' ].forEach(function (key) {
|
[ 'name', 'admin', 'expiration', 'minimum', 'retry', 'refresh', 'ttl' ].forEach(function (key) {
|
||||||
$qs('.js-zone-form-tpl .js-record-' + key).value = zone[key];
|
$qs('.js-zone-form-tpl .js-record-' + key).value = zone[key];
|
||||||
});
|
});
|
||||||
|
[ 'primary', 'serial' ].forEach(function (key) {
|
||||||
|
$qs('.js-zone-form-tpl .js-recordx-' + key).value = zone[key];
|
||||||
|
});
|
||||||
|
$qs('input.js-zone-form-vanityns').checked = zone.vanity;
|
||||||
|
|
||||||
$qs('input.js-zone-form-vanityns').dispatchEvent(new Event('change', { bubbles: true }));
|
$qs('input.js-zone-form-vanityns').dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
|
|
||||||
|
@ -357,6 +356,7 @@
|
||||||
$on('button.js-zone-edit', 'click', function (ev) {
|
$on('button.js-zone-edit', 'click', function (ev) {
|
||||||
//var zoneId = ev.target.parentElement.dataset.id;
|
//var zoneId = ev.target.parentElement.dataset.id;
|
||||||
var zoneName = ev.target.parentElement.dataset.name;
|
var zoneName = ev.target.parentElement.dataset.name;
|
||||||
|
myZone = zoneName;
|
||||||
openZoneForm(zoneName, cache.peers);
|
openZoneForm(zoneName, cache.peers);
|
||||||
});
|
});
|
||||||
$on('button.js-zone-save', 'click', function (/*ev*/) {
|
$on('button.js-zone-save', 'click', function (/*ev*/) {
|
||||||
|
@ -416,21 +416,6 @@
|
||||||
var type = ev.target.value;
|
var type = ev.target.value;
|
||||||
var $tpl;
|
var $tpl;
|
||||||
console.log("form type:", type);
|
console.log("form type:", type);
|
||||||
if (!tpls.formsMap) {
|
|
||||||
tpls.formsMap = {};
|
|
||||||
tpls.formsMap.SOA = $qs('.js-record-form-soa').outerHTML;
|
|
||||||
tpls.formsMap.NS = $qs('.js-record-form-ns').outerHTML;
|
|
||||||
tpls.formsMap.A = $qs('.js-record-form-a').outerHTML;
|
|
||||||
tpls.formsMap.AAAA = $qs('.js-record-form-aaaa').outerHTML;
|
|
||||||
tpls.formsMap.ANAME = $qs('.js-record-form-aname').outerHTML;
|
|
||||||
tpls.formsMap.CAA = $qs('.js-record-form-caa').outerHTML;
|
|
||||||
tpls.formsMap.CNAME = $qs('.js-record-form-cname').outerHTML;
|
|
||||||
tpls.formsMap.MX = $qs('.js-record-form-mx').outerHTML;
|
|
||||||
tpls.formsMap.PTR = $qs('.js-record-form-ptr').outerHTML;
|
|
||||||
tpls.formsMap.SRV = $qs('.js-record-form-srv').outerHTML;
|
|
||||||
tpls.formsMap.TXT = $qs('.js-record-form-txt').outerHTML;
|
|
||||||
tpls.formsMap.typeX = $qs('.js-record-form-typex').outerHTML;
|
|
||||||
}
|
|
||||||
$tpl = $qs('.js-record-form-tpl');
|
$tpl = $qs('.js-record-form-tpl');
|
||||||
$tpl.innerHTML = tpls.formsMap[type] || '';
|
$tpl.innerHTML = tpls.formsMap[type] || '';
|
||||||
if (!tpls.formsMap[type]) {
|
if (!tpls.formsMap[type]) {
|
||||||
|
@ -612,12 +597,40 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$qs('select.js-record-form-type').value = '';
|
|
||||||
// Create a new 'change' event and dispatch it.
|
|
||||||
$qs('select.js-record-form-type').dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
tpls.newNs = $qs('.js-zone-form-tpl .js-zone-form-vns-tpl').innerHTML;
|
tpls.newNs = $qs('.js-zone-form-tpl .js-zone-form-vns-tpl').innerHTML;
|
||||||
$qs('.js-zone-form-tpl .js-zone-form-vns-tpl').innerHTML = '';
|
$qs('.js-zone-form-tpl .js-zone-form-vns-tpl').innerHTML = '';
|
||||||
tpls.newZone = $qs('.js-zone-form-tpl').innerHTML;
|
tpls.newZone = $qs('.js-zone-form-tpl').innerHTML;
|
||||||
|
tpls.peer = $qs('.js-peer-tpl').innerHTML;
|
||||||
|
$qs('.js-peer-tpl').innerHTML = '';
|
||||||
|
tpls.formsMap = {};
|
||||||
|
tpls.formsMap.SOA = $qs('.js-record-form-soa').outerHTML;
|
||||||
|
tpls.formsMap.NS = $qs('.js-record-form-ns').outerHTML;
|
||||||
|
tpls.formsMap.A = $qs('.js-record-form-a').outerHTML;
|
||||||
|
tpls.formsMap.AAAA = $qs('.js-record-form-aaaa').outerHTML;
|
||||||
|
tpls.formsMap.ANAME = $qs('.js-record-form-aname').outerHTML;
|
||||||
|
tpls.formsMap.CAA = $qs('.js-record-form-caa').outerHTML;
|
||||||
|
tpls.formsMap.CNAME = $qs('.js-record-form-cname').outerHTML;
|
||||||
|
tpls.formsMap.MX = $qs('.js-record-form-mx').outerHTML;
|
||||||
|
tpls.formsMap.PTR = $qs('.js-record-form-ptr').outerHTML;
|
||||||
|
tpls.formsMap.SRV = $qs('.js-record-form-srv').outerHTML;
|
||||||
|
tpls.formsMap.TXT = $qs('.js-record-form-txt').outerHTML;
|
||||||
|
tpls.formsMap.typeX = $qs('.js-record-form-typex').outerHTML;
|
||||||
|
tpls.recordsMap = {};
|
||||||
|
tpls.recordsMap.soa = $qs('.js-record-soa').outerHTML;
|
||||||
|
tpls.recordsMap.ns = $qs('.js-record-ns').outerHTML;
|
||||||
|
tpls.recordsMap.a = $qs('.js-record-a').outerHTML;
|
||||||
|
tpls.recordsMap.aaaa = $qs('.js-record-aaaa').outerHTML;
|
||||||
|
tpls.recordsMap.aname = $qs('.js-record-aname').outerHTML;
|
||||||
|
tpls.recordsMap.cname = $qs('.js-record-cname').outerHTML;
|
||||||
|
tpls.recordsMap.caa = $qs('.js-record-caa').outerHTML;
|
||||||
|
tpls.recordsMap.ptr = $qs('.js-record-ptr').outerHTML;
|
||||||
|
tpls.recordsMap.mx = $qs('.js-record-mx').outerHTML;
|
||||||
|
tpls.recordsMap.txt = $qs('.js-record-txt').outerHTML;
|
||||||
|
tpls.recordsMap.srv = $qs('.js-record-srv').outerHTML;
|
||||||
|
$qs('.js-record-tpl').innerHTML = '';
|
||||||
$qs('.js-zone-form-tpl').innerHTML = '';
|
$qs('.js-zone-form-tpl').innerHTML = '';
|
||||||
|
$qs('select.js-record-form-type').value = '';
|
||||||
|
// Create a new 'change' event and dispatch it.
|
||||||
|
$qs('select.js-record-form-type').dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in New Issue