Vue.component('Domain', {
//language=Vue
template: `
{{ domainContacts[row.registrant] ? domainContacts[row.registrant]["name"] : '' }}
{{ domainContacts[row.admin] ? domainContacts[row.admin]["name"] : ''}}
{{ domainContacts[row.tech] ? domainContacts[row.tech]["name"] : ''}}
{{ domainContacts[row.billing] ? domainContacts[row.billing]["name"] : ''}}
| Record Class |
Record Type |
Record Host |
Record Value |
Record TTL |
| {{ record.class }} |
{{ record.type }} {{ record.pri ? '(' + record.pri + ')' : '' }} |
{{ record.host }} |
{{ record.value }} |
{{ record.ttl }} |
`,
data() {
return {
window: window,
domainContacts: {},
reloadDomainsLoading: false,
dnsRecordsModalLoading: null,
dnsRecordsModal: {
domain: null, records: []
},
checkDomainInput: '',
checkDomainResult: null,
checkDomainLoading: false
}
}, created() {
this.fetchDomainContacts().then()
}, computed: {
domainsTableConfig() {
const base = {
headers: [{text: "DNS", key: "inwxRoId", filter: false, sortable: false}, {
text: "Domain",
key: "domain"
}, {
text: "Plesk",
key: "pleskId",
filter: 'iconSelect',
filterOptions: [{value: 1, text: 'Yes', icon: 'fas fa-check text-success'}, {
value: 0,
text: 'No',
icon: 'fas fa-times text-danger'
}],
sortable: false
}, {text: "Created Date", key: "crDate", filter: "date"}, {
text: "Expiration Date",
key: "exDate",
filter: "date"
}, {text: "Renewal Date", key: "reDate", filter: "date"}, {
text: "Updated Date",
key: "upDate",
filter: "date"
}, {
text: "Transfer Lock",
key: "transferLock",
filter: 'iconSelect',
filterOptions: [{value: 1, text: 'Locked', icon: 'fas fa-lock text-danger'}, {
value: 0,
text: 'Unlocked',
icon: 'fas fa-unlock text-success'
}]
}, {text: "Authorization Code", key: "authCode", sortable: false}, {
text: "Registrant ID",
key: "registrant",
sortable: false
}, {text: "Admin ID", key: "admin", sortable: false}, {
text: "Tech ID",
key: "tech",
sortable: false
}, {text: "Billing ID", key: "billing", sortable: false}, {text: "Name Servers", key: "ns"}],
tableHeader: 'Domains',
key: 'Domain'
}
const domainContactsSorted = Object.entries(this.domainContacts).sort(([, a], [, b]) => a.name.localeCompare(b.name))
const domainContactsFilterOptions = domainContactsSorted.map(([, contact]) => {
return {text: contact.name, value: contact.inwxRoId}
})
// for registrant admin tech billing set filter to select with domainContacts if domainContacts is not empty
if (Object.keys(this.domainContacts).length > 0) {
base.headers = base.headers.map(header => {
if (['registrant', 'admin', 'tech', 'billing'].includes(header.key)) {
header.filter = 'select'
header.filterOptions = domainContactsFilterOptions
}
return header
})
}
return base
}
}, methods: {
async showDnsRecordsModal(domain) {
this.dnsRecordsModalLoading = domain
this.dnsRecordsModal = {
domain: null, records: []
}
const response = await axios.get(window['TT_CONFIG']['DOMAIN_API_URL'] + '?do=getDnsRecords&domain=' + domain)
this.dnsRecordsModal.domain = domain
this.dnsRecordsModal.records = response.data.map(record => {
if (typeof record.entries === 'object') {
record.value = record.entries[0]
} else {
record.value = record.target || record.txt || record.ip
}
if (record.type === 'SOA') {
record.value = record.mname + ' ' + record.rname + ' ' + record.serial + ' ' + record.refresh + ' ' + record.retry + ' ' + record.expire
}
return record
})
this.dnsRecordsModalLoading = null
this.$nextTick(() => {
this.$refs.dnsRecordsModal.focus()
})
}, async fetchDomainContacts() {
const response = await axios.get(window['TT_CONFIG']['DOMAIN_API_URL'] + '?do=getDomainContacts')
this.domainContacts = response.data
}, async reloadDomains() {
this.reloadDomainsLoading = true
const response = await axios.get(window['TT_CONFIG']['DOMAIN_API_URL'] + '?do=importAllDomains')
window.notify('success', response.data["importMessages"].join('
'))
await Promise.all([this.fetchDomainContacts(), this.$refs.table.fetchData(this.$refs.table.pagination.page)])
this.reloadDomainsLoading = false
}, //TODO: make this cleaner
async checkDomainAvailability() {
this.checkDomainLoading = true
const response = await axios.get(window['TT_CONFIG']['DOMAIN_API_URL'] + '?do=checkDomain&domain=' + this.checkDomainInput)
const priceInformation = response.data.price.domain[this.checkDomainInput]
window.notify(response.data.status === 'free' ? 'success' : 'error', `Domain ist ${response.data.status === 'free' ? 'verfügbar. Registrieren um' : 'nicht frei. Transfer um'} ${priceInformation.price}${priceInformation.currency}/${priceInformation.period === '1Y' ? 'Jahr' : priceInformation.period}`)
this.checkDomainLoading = false
}
}
})