Create new records
This commit is contained in:
parent
7d7c0c9570
commit
3763367510
6 changed files with 117 additions and 19 deletions
|
|
@ -97,6 +97,11 @@ export class Application {
|
|||
this.recordsTree = document.createElement('div')
|
||||
this.recordsTree.id = 'records-tree'
|
||||
|
||||
this.createIcon = document.createElement('img')
|
||||
this.createIcon.id = 'create-icon'
|
||||
this.createIcon.src = `/images/${_VERSION}/icon_create.svg`
|
||||
this.createIcon.addEventListener('click', () => new RecordDialog(new Record()).show())
|
||||
|
||||
this.settingsIcon = document.createElement('img')
|
||||
this.settingsIcon.id = 'settings-icon'
|
||||
this.settingsIcon.src = `/images/${_VERSION}/icon_settings.svg`
|
||||
|
|
@ -104,8 +109,8 @@ export class Application {
|
|||
|
||||
document.body.appendChild(this.recordsTree)
|
||||
document.body.appendChild(this.settingsIcon)
|
||||
document.body.appendChild(this.createIcon)
|
||||
}
|
||||
//this.recordsTree.replaceChildren()
|
||||
|
||||
// Top root folder doesn't have to be shown.
|
||||
const folders = Array.from(this.topFolder.subfolders.values())
|
||||
|
|
@ -273,7 +278,7 @@ class Folder {
|
|||
|
||||
class Record {
|
||||
constructor(data) {// {{{
|
||||
this.data = data
|
||||
this.data = data || {}
|
||||
|
||||
this.imgIcon = null
|
||||
this.divFQDN = null
|
||||
|
|
@ -283,7 +288,7 @@ class Record {
|
|||
}// }}}
|
||||
|
||||
id() {// {{{
|
||||
return this.data['.id']
|
||||
return this.data['.id'] || ''
|
||||
}// }}}
|
||||
disabled() {// {{{
|
||||
return this.data.Disabled === 'true'
|
||||
|
|
@ -292,16 +297,16 @@ class Record {
|
|||
return this.data.Dynamic === 'true'
|
||||
}// }}}
|
||||
name() {// {{{
|
||||
return this.data.Name.toLowerCase()
|
||||
return this.data.Name?.toLowerCase() || ''
|
||||
}// }}}
|
||||
ttl() {// {{{
|
||||
return this.data.TTL
|
||||
return this.data.TTL || '30m'
|
||||
}// }}}
|
||||
type() {// {{{
|
||||
return this.data.Type.toUpperCase()
|
||||
return this.data.Type?.toUpperCase() || 'A'
|
||||
}// }}}
|
||||
value() {// {{{
|
||||
return this.data.ParsedValue
|
||||
return this.data.ParsedValue || ''
|
||||
}// }}}
|
||||
matchSubdomain() {// {{{
|
||||
return this.data.MatchSubdomain === 'true'
|
||||
|
|
@ -384,6 +389,8 @@ class Record {
|
|||
return [this.imgIcon, this.divFQDN, this.divType, this.divValue, this.divSeparator]
|
||||
}// }}}
|
||||
save() {// {{{
|
||||
const created = (this.id() == '')
|
||||
|
||||
fetch('/record/save', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(this.data),
|
||||
|
|
@ -394,6 +401,13 @@ class Record {
|
|||
alert(json.Error)
|
||||
return
|
||||
}
|
||||
|
||||
// The data is read from the server/routeros device
|
||||
// since it could have manipulated the data.
|
||||
this.data = json.Record
|
||||
if (created)
|
||||
_app.records.push(this)
|
||||
|
||||
_app.cleanFolders()
|
||||
_app.renderFolders()
|
||||
_app.render()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue