WIP authority vs regular records, fix query param
This commit is contained in:
parent
0e74e2db18
commit
b0a12260ea
|
@ -98,7 +98,7 @@ module.exports.create = function (cli, engine/*, dnsd*/) {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use('/api', function (req, res, next) {
|
app.use('/api', function (req, res, next) {
|
||||||
var auth = (req.headers.authorization || req.query.token || '').split(/\s+/)[1];
|
var auth = ((req.headers.authorization || '').split(/\s+/)[1] || req.query.access_token);
|
||||||
var token;
|
var token;
|
||||||
|
|
||||||
if (!auth) {
|
if (!auth) {
|
||||||
|
@ -200,6 +200,7 @@ module.exports.create = function (cli, engine/*, dnsd*/) {
|
||||||
function mapRecord(r) {
|
function mapRecord(r) {
|
||||||
return {
|
return {
|
||||||
id: r.id
|
id: r.id
|
||||||
|
, soa: r.soa
|
||||||
, zone: r.zone
|
, zone: r.zone
|
||||||
, name: r.name
|
, name: r.name
|
||||||
, tld: r.tld
|
, tld: r.tld
|
||||||
|
@ -228,6 +229,7 @@ module.exports.create = function (cli, engine/*, dnsd*/) {
|
||||||
var zone = engine.zones._toSoa(zones[0]);
|
var zone = engine.zones._toSoa(zones[0]);
|
||||||
zone.class = zone.className;
|
zone.class = zone.className;
|
||||||
zone.type = zone.typeName;
|
zone.type = zone.typeName;
|
||||||
|
zone.soa = true;
|
||||||
engine.records.all(function (err, records) {
|
engine.records.all(function (err, records) {
|
||||||
records = records.filter(function (r) {
|
records = records.filter(function (r) {
|
||||||
return r.zone === zonename;
|
return r.zone === zonename;
|
||||||
|
|
|
@ -160,6 +160,9 @@
|
||||||
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) {
|
||||||
|
if (record.soa) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
el = document.createElement('div');
|
el = document.createElement('div');
|
||||||
console.log('record.type:', record.type);
|
console.log('record.type:', record.type);
|
||||||
el.innerHTML = tpls.recordsMap[record.type.toLowerCase()];
|
el.innerHTML = tpls.recordsMap[record.type.toLowerCase()];
|
||||||
|
@ -288,15 +291,27 @@
|
||||||
});
|
});
|
||||||
$qs('.js-zone-form-tpl .js-recordx-primary').value = 'nsx.' + zone;
|
$qs('.js-zone-form-tpl .js-recordx-primary').value = 'nsx.' + zone;
|
||||||
}
|
}
|
||||||
function openZoneForm() {
|
function openZoneForm(myZone, ns) {
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
myZone = $qs('.js-zone-form-name').value;
|
var zone = {
|
||||||
|
name: myZone.name || myZone
|
||||||
|
, admin: myZone.admin || ('admin.' + myZone)
|
||||||
|
, expiration: myZone.expiration || 2419200 // 4 weeks
|
||||||
|
, minimum: myZone.expiration || 5
|
||||||
|
, serial: myZone.serial || (d.getFullYear()
|
||||||
|
+ '' + (d.getMonth() + 1)
|
||||||
|
+ '' + d.getDate()
|
||||||
|
+ '' + (Math.round(Math.random() * 99)))
|
||||||
|
, retry: myZone.retry || 1800
|
||||||
|
, refresh: myZone.refresh || 7200
|
||||||
|
, ttl: myZone.ttl || 300
|
||||||
|
};
|
||||||
$qs('.js-zone-form-tpl').innerHTML = tpls.newZone;
|
$qs('.js-zone-form-tpl').innerHTML = tpls.newZone;
|
||||||
|
|
||||||
cache.peers.forEach(function () {
|
ns.forEach(function () {
|
||||||
$qs('.js-zone-form-vns-tpl').innerHTML += tpls.newNs;
|
$qs('.js-zone-form-vns-tpl').innerHTML += tpls.newNs;
|
||||||
});
|
});
|
||||||
cache.peers.forEach(function (p, i) {
|
ns.forEach(function (p, i) {
|
||||||
var $vns = $qsa('.js-zone-form-tpl .js-zone-form-vns')[i];
|
var $vns = $qsa('.js-zone-form-tpl .js-zone-form-vns')[i];
|
||||||
$qs('.js-record-host', $vns).value = 'ns' + (i + 1);
|
$qs('.js-record-host', $vns).value = 'ns' + (i + 1);
|
||||||
//$qs('.js-record-name', $vns).value = 'ns' + (i + 1) + '.' + myZone;
|
//$qs('.js-record-name', $vns).value = 'ns' + (i + 1) + '.' + myZone;
|
||||||
|
@ -307,18 +322,9 @@
|
||||||
$qs('.js-record-ttl', $vns).value = 7200;
|
$qs('.js-record-ttl', $vns).value = 7200;
|
||||||
});
|
});
|
||||||
|
|
||||||
$qs('.js-zone-form-tpl .js-record-name').value = myZone;
|
[ 'name', 'admin', 'expiration', 'minimum', 'serial', 'retry', 'refresh', 'ttl' ].forEach(function (key) {
|
||||||
$qs('.js-zone-form-tpl .js-record-admin').value = 'admin.' + myZone;
|
$qs('.js-zone-form-tpl .js-record-' + key).value = zone[key];
|
||||||
$qs('.js-zone-form-tpl .js-record-expiration').value = 2419200; // 4 weeks
|
});
|
||||||
$qs('.js-zone-form-tpl .js-record-minimum').value = 5;
|
|
||||||
$qs('.js-zone-form-tpl .js-recordx-serial').value = d.getFullYear()
|
|
||||||
+ '' + (d.getMonth() + 1)
|
|
||||||
+ '' + d.getDate()
|
|
||||||
+ '' + (Math.round(Math.random() * 99))
|
|
||||||
;
|
|
||||||
$qs('.js-zone-form-tpl .js-record-retry').value = 1800;
|
|
||||||
$qs('.js-zone-form-tpl .js-record-refresh').value = 7200;
|
|
||||||
$qs('.js-zone-form-tpl .js-record-ttl').value = 300;
|
|
||||||
|
|
||||||
$qs('input.js-zone-form-vanityns').dispatchEvent(new Event('change', { bubbles: true }));
|
$qs('input.js-zone-form-vanityns').dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
|
|
||||||
|
@ -338,16 +344,20 @@
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
console.log('form submit enter');
|
console.log('form submit enter');
|
||||||
openZoneForm();
|
var myZone = $qs('.js-zone-form-name').value;
|
||||||
|
openZoneForm(myZone, cache.peers);
|
||||||
});
|
});
|
||||||
$on('button.js-zone-new', 'click', function (/*ev*/) {
|
$on('button.js-zone-new', 'click', function (/*ev*/) {
|
||||||
//$qs('select.js-record-form-type').value = 'SOA';
|
//$qs('select.js-record-form-type').value = 'SOA';
|
||||||
//$qs('select.js-record-form-type').dispatchEvent(new Event('change', { bubbles: true }));
|
//$qs('select.js-record-form-type').dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
console.log('form submit click');
|
console.log('form submit click');
|
||||||
openZoneForm();
|
var myZone = $qs('.js-zone-form-name').value;
|
||||||
|
openZoneForm(myZone, cache.peers);
|
||||||
});
|
});
|
||||||
$on('button.js-zone-edit', 'click', function (/*ev*/) {
|
$on('button.js-zone-edit', 'click', function (ev) {
|
||||||
openZoneForm();
|
//var zoneId = ev.target.parentElement.dataset.id;
|
||||||
|
var zoneName = ev.target.parentElement.dataset.name;
|
||||||
|
openZoneForm(zoneName, cache.peers);
|
||||||
});
|
});
|
||||||
$on('button.js-zone-save', 'click', function (/*ev*/) {
|
$on('button.js-zone-save', 'click', function (/*ev*/) {
|
||||||
var zone = {};
|
var zone = {};
|
||||||
|
|
Loading…
Reference in New Issue