This commit is contained in:
Sense T
2024-04-19 15:10:08 +08:00
parent af9d966376
commit a394259f0a
11 changed files with 125 additions and 104 deletions

View File

@@ -13,6 +13,7 @@ export class Domain {
negative_ttl?: number
}
// example data for development
const domainDevData: Domain[] = [
{
id: 1,

View File

@@ -184,15 +184,22 @@ export class Record<T = RecordT> {
static validateName(name: string): true | Error {
if (name === '') return new Error(t('common.mandatory'))
// RR should not contain space, and should not start or end with '-' or '.'
if (name.includes(' ')) return new Error(t('records.errors.hasSpace'))
if (name.startsWith('.') || name.endsWith('.')) return new Error(t('records.errors.badName.dotAndMinus'))
if (name.startsWith('-') || name.endsWith('.')) return new Error(t('records.errors.badName.dotAndMinus'))
// RR should not have continuous dots
if (name.includes('..')) new Error(t('records.errors.badName.doubleDots'))
// RR should not longer than 63 characters for every section seprated by '.'
if (name.split('.').filter(e => e.length > 63).length > 0) return new Error(t('records.errors.badName.longerThan63'))
return true
}
}
// example data for development
const recordDevData = new Map<string, Record[]>([
['example.com', [
{

View File

@@ -68,12 +68,12 @@ export default function DomainsView() {
<>
<Space direction="vertical" >
{
domainStore.domains.map(e => (
<DomainCard domain={e}
onDeleteClick={() => openDeleteModal(e)}
onRecordClick={() => go(`/records/${e.domain_name}`)}
onEditClick={() => openEditModal(e)}
key={e.id}
domainStore.domains.map(domain => (
<DomainCard domain={domain}
onDeleteClick={() => openDeleteModal(domain)}
onRecordClick={() => go(`/records/${domain.domain_name}`)}
onEditClick={() => openEditModal(domain)}
key={domain.id}
/>
))
}

View File

@@ -110,8 +110,8 @@ export default function RecordsView() {
</Layout>
<RecordEditModal open={editModalShow} onCancel={closeEditModal}
onOk={closeEditModal} record={currentRecord}
editRecord={v => recordStore.updateRecord(domain!, v)}
createRecord={v => recordStore.addRecord(domain!, v)} />
editRecord={record => recordStore.updateRecord(domain!, record)}
createRecord={record => recordStore.addRecord(domain!, record)} />
</>
}
</>