add new record

This commit is contained in:
AJ ONeal 2018-01-29 11:35:34 -07:00
parent 92056f6d55
commit 656c803720
2 changed files with 29 additions and 23 deletions

View File

@ -261,7 +261,7 @@ module.exports.create = function (cli, engine/*, dnsd*/) {
});
} else {
engine.records.save(record, function (err, record) {
res.send({ success: true });
res.send({ success: true, id: record.id });
});
}
});

View File

@ -361,29 +361,35 @@
});
}
if (change) {
renderRecords();
return window.fetch(
'/api/records/' + record.id
, { method: 'POST'
, headers: new window.Headers({
'Authorization': 'Bearer ' + auth
, 'Content-Type': 'application/json;charset=UTF-8'
})
, body: JSON.stringify(record)
}
).then(function (resp) {
return resp.json().then(function (data) {
if (data.error) {
console.error(data);
window.alert(data.error.message);
return;
}
console.log('result:', data);
});
});
if (!change) {
return;
}
renderRecords();
return window.fetch(
'/api/records/' + record.id
, { method: 'POST'
, headers: new window.Headers({
'Authorization': 'Bearer ' + auth
, 'Content-Type': 'application/json;charset=UTF-8'
})
, body: JSON.stringify(record)
}
).then(function (resp) {
return resp.json().then(function (data) {
if (data.error) {
console.error(data);
window.alert(data.error.message);
return;
}
console.log('result:', data);
if (!record.id) {
record.id = data.id;
renderRecords();
}
});
});
});
$qs('select.js-record-form-type').value = '';