mirror of
https://github.com/1f349/admin.1f349.com.git
synced 2024-11-14 15:41:34 +00:00
Rewrite dns record format
This commit is contained in:
parent
f992ce6575
commit
e2615861b0
@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {DnsTypeA, DnsTypeAAAA, type AaaaRecord, type ARecord} from "../../types/records";
|
import {DnsTypeA, DnsTypeAAAA, type AaaaValue, type ApiRecordFormat, type AValue} from "../../types/records";
|
||||||
import {IPv4, IPv6, parse as parseAddr} from "ipaddr.js";
|
import {IPv4, IPv6, parse as parseAddr} from "ipaddr.js";
|
||||||
|
|
||||||
export let editItem: ARecord | AaaaRecord;
|
export let editItem: ApiRecordFormat<AValue | AaaaValue>;
|
||||||
export let editMode: boolean;
|
export let editMode: boolean;
|
||||||
|
|
||||||
let value: string = "";
|
let value: string = "";
|
||||||
@ -11,14 +11,14 @@
|
|||||||
try {
|
try {
|
||||||
let addr = parseAddr(value);
|
let addr = parseAddr(value);
|
||||||
if (addr instanceof IPv4) {
|
if (addr instanceof IPv4) {
|
||||||
(editItem as ARecord).A = addr.toString();
|
(editItem as ApiRecordFormat<AValue>).value = addr.toString();
|
||||||
editItem.Hdr.Rrtype = DnsTypeA;
|
editItem.type = DnsTypeA;
|
||||||
} else if (addr instanceof IPv6) {
|
} else if (addr instanceof IPv6) {
|
||||||
(editItem as AaaaRecord).AAAA = addr.toString();
|
(editItem as ApiRecordFormat<AaaaValue>).value = addr.toString();
|
||||||
editItem.Hdr.Rrtype = DnsTypeAAAA;
|
editItem.type = DnsTypeAAAA;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
editItem.Hdr.Rrtype = 0;
|
editItem.type = 0;
|
||||||
console.error("Invalid IP address:", value);
|
console.error("Invalid IP address:", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,15 +26,15 @@
|
|||||||
|
|
||||||
<div>Name</div>
|
<div>Name</div>
|
||||||
{#if editMode}
|
{#if editMode}
|
||||||
<div class="code-font">{editItem.Hdr.Name}</div>
|
<div class="code-font">{editItem.name}</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Hdr.Name} size={Math.max(20, editItem.Hdr.Name.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.name} size={Math.max(20, editItem.name.length + 2)} /></div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div>IP Address</div>
|
<div>IP Address</div>
|
||||||
<div><input type="text" class="code-font" bind:value on:keyup={onChange} size={Math.max(20, value.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value on:keyup={onChange} size={Math.max(20, value.length + 2)} /></div>
|
||||||
{#if editItem.Hdr.Rrtype === DnsTypeA}
|
{#if editItem.type === DnsTypeA}
|
||||||
<div>IP address is IPv4</div>
|
<div>IP address is IPv4</div>
|
||||||
{:else if editItem.Hdr.Rrtype === DnsTypeAAAA}
|
{:else if editItem.type === DnsTypeAAAA}
|
||||||
<div>IP address is IPv6</div>
|
<div>IP address is IPv6</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {CaaRecord} from "../../types/records";
|
import type {ApiRecordFormat, CaaValue} from "../../types/records";
|
||||||
|
|
||||||
export let editItem: CaaRecord;
|
export let editItem: ApiRecordFormat<CaaValue>;
|
||||||
export let editMode: boolean;
|
export let editMode: boolean;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>Name</div>
|
<div>Name</div>
|
||||||
{#if editMode}
|
{#if editMode}
|
||||||
<div class="code-font">{editItem.Hdr.Name}</div>
|
<div class="code-font">{editItem.name}</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Hdr.Name} size={Math.max(20, editItem.Hdr.Name.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.name} size={Math.max(20, editItem.name.length + 2)} /></div>
|
||||||
{/if}
|
{/if}
|
||||||
<div>Tag</div>
|
<div>Tag</div>
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Tag} size={Math.max(20, editItem.Tag.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.value.tag} size={Math.max(20, editItem.value.tag.length + 2)} /></div>
|
||||||
<div>Value</div>
|
<div>Value</div>
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Value} size={Math.max(20, editItem.Value.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.value.value} size={Math.max(20, editItem.value.value.length + 2)} /></div>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {CnameRecord} from "../../types/records";
|
import type {ApiRecordFormat, CnameValue} from "../../types/records";
|
||||||
|
|
||||||
export let editItem: CnameRecord;
|
export let editItem: ApiRecordFormat<CnameValue>;
|
||||||
export let editMode: boolean;
|
export let editMode: boolean;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>Name</div>
|
<div>Name</div>
|
||||||
{#if editMode}
|
{#if editMode}
|
||||||
<div class="code-font">{editItem.Hdr.Name}</div>
|
<div class="code-font">{editItem.name}</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Hdr.Name} size={Math.max(20, editItem.Hdr.Name.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.name} size={Math.max(20, editItem.name.length + 2)} /></div>
|
||||||
{/if}
|
{/if}
|
||||||
<div>Target</div>
|
<div>Target</div>
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Target} size={Math.max(20, editItem.Target.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.value} size={Math.max(20, editItem.value.length + 2)} /></div>
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {MxRecord} from "../../types/records";
|
import type {ApiRecordFormat, MxValue} from "../../types/records";
|
||||||
|
|
||||||
export let editItem: MxRecord;
|
export let editItem: ApiRecordFormat<MxValue>;
|
||||||
export let editMode: boolean;
|
export let editMode: boolean;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>Name</div>
|
<div>Name</div>
|
||||||
{#if editMode}
|
{#if editMode}
|
||||||
<div class="code-font">{editItem.Hdr.Name}</div>
|
<div class="code-font">{editItem.name}</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Hdr.Name} size={Math.max(20, editItem.Hdr.Name.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.name} size={Math.max(20, editItem.name.length + 2)} /></div>
|
||||||
{/if}
|
{/if}
|
||||||
<div>Mail Server</div>
|
<div>Mail Server</div>
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Mx} size={Math.max(20, editItem.Mx.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.value.mx} size={Math.max(20, editItem.value.mx.length + 2)} /></div>
|
||||||
<div>Preference</div>
|
<div>Preference</div>
|
||||||
<div><input type="number" class="code-font" bind:value={editItem.Preference} /></div>
|
<div><input type="number" class="code-font" bind:value={editItem.value.preference} /></div>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {NsRecord} from "../../types/records";
|
import type {ApiRecordFormat, NsValue} from "../../types/records";
|
||||||
|
|
||||||
export let editItem: NsRecord;
|
export let editItem: ApiRecordFormat<NsValue>;
|
||||||
export let editMode: boolean;
|
export let editMode: boolean;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>Name</div>
|
<div>Name</div>
|
||||||
{#if editMode}
|
{#if editMode}
|
||||||
<div class="code-font">{editItem.Hdr.Name}</div>
|
<div class="code-font">{editItem.name}</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Hdr.Name} size={Math.max(20, editItem.Hdr.Name.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.name} size={Math.max(20, editItem.name.length + 2)} /></div>
|
||||||
{/if}
|
{/if}
|
||||||
<div>Nameserver</div>
|
<div>Nameserver</div>
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Ns} size={Math.max(20, editItem.Ns.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.value} size={Math.max(20, editItem.value.length + 2)} /></div>
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {SrvRecord} from "../../types/records";
|
import type {ApiRecordFormat, SrvValue} from "../../types/records";
|
||||||
|
|
||||||
export let editItem: SrvRecord;
|
export let editItem: ApiRecordFormat<SrvValue>;
|
||||||
export let editMode: boolean;
|
export let editMode: boolean;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>Name</div>
|
<div>Name</div>
|
||||||
{#if editMode}
|
{#if editMode}
|
||||||
<div class="code-font">{editItem.Hdr.Name}</div>
|
<div class="code-font">{editItem.name}</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Hdr.Name} size={Math.max(20, editItem.Hdr.Name.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.name} size={Math.max(20, editItem.name.length + 2)} /></div>
|
||||||
{/if}
|
{/if}
|
||||||
<div>Priority</div>
|
<div>Priority</div>
|
||||||
<div><input type="number" class="code-font" bind:value={editItem.Priority} /></div>
|
<div><input type="number" class="code-font" bind:value={editItem.value.priority} /></div>
|
||||||
<div>Weight</div>
|
<div>Weight</div>
|
||||||
<div><input type="number" class="code-font" bind:value={editItem.Weight} /></div>
|
<div><input type="number" class="code-font" bind:value={editItem.value.weight} /></div>
|
||||||
<div>Port</div>
|
<div>Port</div>
|
||||||
<div><input type="number" class="code-font" bind:value={editItem.Port} /></div>
|
<div><input type="number" class="code-font" bind:value={editItem.value.port} /></div>
|
||||||
<div>Target</div>
|
<div>Target</div>
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Target} size={Math.max(20, editItem.Target.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.value.target} size={Math.max(20, editItem.value.target.length + 2)} /></div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {TxtRecord} from "../../types/records";
|
import type {ApiRecordFormat, TxtValue} from "../../types/records";
|
||||||
|
|
||||||
export let editItem: TxtRecord;
|
export let editItem: ApiRecordFormat<TxtValue>;
|
||||||
export let editMode: boolean;
|
export let editMode: boolean;
|
||||||
|
|
||||||
function constrain(min: number, max: number, value: number) {
|
function constrain(min: number, max: number, value: number) {
|
||||||
@ -11,9 +11,9 @@
|
|||||||
|
|
||||||
<div>Name</div>
|
<div>Name</div>
|
||||||
{#if editMode}
|
{#if editMode}
|
||||||
<div class="code-font">{editItem.Hdr.Name}</div>
|
<div class="code-font">{editItem.name}</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Hdr.Name} size={Math.max(20, editItem.Hdr.Name.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.name} size={Math.max(20, editItem.name.length + 2)} /></div>
|
||||||
{/if}
|
{/if}
|
||||||
<div>Value</div>
|
<div>Value</div>
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Txt[0]} size={constrain(20, 100, editItem.Txt[0].length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.value} size={constrain(20, 100, editItem.value.length + 2)} /></div>
|
||||||
|
@ -1,44 +1,40 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {isAaaaRecord, isARecord, type AaaaRecord, type ARecord} from "../../types/records";
|
import {isAaaaRecord, isARecord, type AaaaValue, type ApiRecordFormat, type AValue} from "../../types/records";
|
||||||
import type {RestItem} from "../../utils/rest-table";
|
import type {RestItem} from "../../utils/rest-table";
|
||||||
import ActionMenu from "../ActionMenu.svelte";
|
import ActionMenu from "../ActionMenu.svelte";
|
||||||
import ActionPopup from "../ActionPopup.svelte";
|
import ActionPopup from "../ActionPopup.svelte";
|
||||||
import ACreate from "../create-domains/ACreate.svelte";
|
import ACreate from "../create-domains/ACreate.svelte";
|
||||||
|
|
||||||
export let value: RestItem<ARecord | AaaaRecord>;
|
export let item: RestItem<ApiRecordFormat<AValue | AaaaValue>>;
|
||||||
let editItem: ARecord & AaaaRecord = {
|
let editItem: ApiRecordFormat<AValue & AaaaValue> = {
|
||||||
Hdr: {
|
name: item.data.name,
|
||||||
Name: "",
|
type: item.data.type,
|
||||||
Rrtype: 0,
|
ttl: item.data.ttl,
|
||||||
Class: 0,
|
value: "",
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
A: "",
|
|
||||||
AAAA: "",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let editPopup: boolean = false;
|
let editPopup: boolean = false;
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
value.update(editItem);
|
item.update(editItem);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="code-font">{value.data.Hdr.Name}</td>
|
<td class="code-font">{item.data.name}</td>
|
||||||
<td class="code-font">{isARecord(value.data) ? value.data.A : isAaaaRecord(value.data) ? value.data.AAAA : ""}</td>
|
<td class="code-font">{item.data.value}</td>
|
||||||
<td class="code-font">{value.data.Hdr.Ttl}</td>
|
<td class="code-font">{item.data.ttl}</td>
|
||||||
<td>
|
<td>
|
||||||
<ActionMenu
|
<ActionMenu
|
||||||
data={value}
|
data={item}
|
||||||
edit={() => {
|
edit={() => {
|
||||||
editItem = JSON.parse(JSON.stringify(value.data));
|
editItem = JSON.parse(JSON.stringify(item.data));
|
||||||
editPopup = true;
|
editPopup = true;
|
||||||
}}
|
}}
|
||||||
remove={() => value.remove()}
|
remove={() => item.remove()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ActionPopup name="Edit {isARecord(value.data) ? 'A' : 'AAAA'} Record" bind:show={editPopup} on:save={save}>
|
<ActionPopup name="Edit {isARecord(item.data) ? 'A' : 'AAAA'} Record" bind:show={editPopup} on:save={save}>
|
||||||
<ACreate bind:editItem editMode={true} />
|
<ACreate bind:editItem editMode={true} />
|
||||||
</ActionPopup>
|
</ActionPopup>
|
||||||
</td>
|
</td>
|
||||||
|
@ -1,43 +1,42 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {CaaRecord} from "../../types/records";
|
import type {ApiRecordFormat, CaaValue} from "../../types/records";
|
||||||
import type {RestItem} from "../../utils/rest-table";
|
import type {RestItem} from "../../utils/rest-table";
|
||||||
import ActionMenu from "../ActionMenu.svelte";
|
import ActionMenu from "../ActionMenu.svelte";
|
||||||
import ActionPopup from "../ActionPopup.svelte";
|
import ActionPopup from "../ActionPopup.svelte";
|
||||||
import CaaCreate from "../create-domains/CaaCreate.svelte";
|
import CaaCreate from "../create-domains/CaaCreate.svelte";
|
||||||
|
|
||||||
export let value: RestItem<CaaRecord>;
|
export let item: RestItem<ApiRecordFormat<CaaValue>>;
|
||||||
let editItem: CaaRecord = {
|
let editItem: ApiRecordFormat<CaaValue> = {
|
||||||
Hdr: {
|
name: item.data.name,
|
||||||
Name: "",
|
type: item.data.type,
|
||||||
Rrtype: 0,
|
ttl: item.data.ttl,
|
||||||
Class: 0,
|
value: {
|
||||||
Ttl: 0,
|
flag: 0,
|
||||||
|
tag: "",
|
||||||
|
value: "",
|
||||||
},
|
},
|
||||||
Flag: 0,
|
|
||||||
Tag: "",
|
|
||||||
Value: "",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let editPopup: boolean = false;
|
let editPopup: boolean = false;
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
value.update(editItem);
|
item.update(editItem);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="code-font">{value.data.Hdr.Name}</td>
|
<td class="code-font">{item.data.name}</td>
|
||||||
<td class="code-font">{value.data.Tag}</td>
|
<td class="code-font">{item.data.value.tag}</td>
|
||||||
<td class="code-font">{value.data.Value}</td>
|
<td class="code-font">{item.data.value.value}</td>
|
||||||
<td class="code-font">{value.data.Hdr.Ttl}</td>
|
<td class="code-font">{item.data.ttl}</td>
|
||||||
<td>
|
<td>
|
||||||
<ActionMenu
|
<ActionMenu
|
||||||
data={value}
|
data={item}
|
||||||
edit={() => {
|
edit={() => {
|
||||||
editItem = JSON.parse(JSON.stringify(value.data));
|
editItem = JSON.parse(JSON.stringify(item.data));
|
||||||
editPopup = true;
|
editPopup = true;
|
||||||
}}
|
}}
|
||||||
remove={() => value.remove()}
|
remove={() => item.remove()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ActionPopup name="Edit CAA Record" bind:show={editPopup} on:save={save}>
|
<ActionPopup name="Edit CAA Record" bind:show={editPopup} on:save={save}>
|
||||||
|
@ -1,40 +1,37 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {CnameRecord} from "../../types/records";
|
import type {ApiRecordFormat, CnameValue} from "../../types/records";
|
||||||
import type {RestItem} from "../../utils/rest-table";
|
import type {RestItem} from "../../utils/rest-table";
|
||||||
import ActionMenu from "../ActionMenu.svelte";
|
import ActionMenu from "../ActionMenu.svelte";
|
||||||
import ActionPopup from "../ActionPopup.svelte";
|
import ActionPopup from "../ActionPopup.svelte";
|
||||||
import CnameCreate from "../create-domains/CnameCreate.svelte";
|
import CnameCreate from "../create-domains/CnameCreate.svelte";
|
||||||
|
|
||||||
export let value: RestItem<CnameRecord>;
|
export let item: RestItem<ApiRecordFormat<CnameValue>>;
|
||||||
let editItem: CnameRecord = {
|
let editItem: ApiRecordFormat<CnameValue> = {
|
||||||
Hdr: {
|
name: item.data.name,
|
||||||
Name: "",
|
type: item.data.type,
|
||||||
Rrtype: 0,
|
ttl: item.data.ttl,
|
||||||
Class: 0,
|
value: "",
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
Target: "",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let editPopup: boolean = false;
|
let editPopup: boolean = false;
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
value.update(editItem);
|
item.update(editItem);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="code-font">{value.data.Hdr.Name}</td>
|
<td class="code-font">{item.data.name}</td>
|
||||||
<td class="code-font">{value.data.Target}</td>
|
<td class="code-font">{item.data.value}</td>
|
||||||
<td class="code-font">{value.data.Hdr.Ttl}</td>
|
<td class="code-font">{item.data.ttl}</td>
|
||||||
<td>
|
<td>
|
||||||
<ActionMenu
|
<ActionMenu
|
||||||
data={value}
|
data={item}
|
||||||
edit={() => {
|
edit={() => {
|
||||||
editItem = JSON.parse(JSON.stringify(value.data));
|
editItem = JSON.parse(JSON.stringify(item.data));
|
||||||
editPopup = true;
|
editPopup = true;
|
||||||
}}
|
}}
|
||||||
remove={() => value.remove()}
|
remove={() => item.remove()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ActionPopup name="Edit CNAME Record" bind:show={editPopup} on:save={save}>
|
<ActionPopup name="Edit CNAME Record" bind:show={editPopup} on:save={save}>
|
||||||
|
@ -1,42 +1,41 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {MxRecord} from "../../types/records";
|
import type {ApiRecordFormat, MxValue} from "../../types/records";
|
||||||
import type {RestItem} from "../../utils/rest-table";
|
import type {RestItem} from "../../utils/rest-table";
|
||||||
import ActionMenu from "../ActionMenu.svelte";
|
import ActionMenu from "../ActionMenu.svelte";
|
||||||
import ActionPopup from "../ActionPopup.svelte";
|
import ActionPopup from "../ActionPopup.svelte";
|
||||||
import MxCreate from "../create-domains/MxCreate.svelte";
|
import MxCreate from "../create-domains/MxCreate.svelte";
|
||||||
|
|
||||||
export let value: RestItem<MxRecord>;
|
export let item: RestItem<ApiRecordFormat<MxValue>>;
|
||||||
let editItem: MxRecord = {
|
let editItem: ApiRecordFormat<MxValue> = {
|
||||||
Hdr: {
|
name: item.data.name,
|
||||||
Name: "",
|
type: item.data.type,
|
||||||
Rrtype: 0,
|
ttl: item.data.ttl,
|
||||||
Class: 0,
|
value: {
|
||||||
Ttl: 0,
|
mx: "",
|
||||||
|
preference: 0,
|
||||||
},
|
},
|
||||||
Mx: "",
|
|
||||||
Preference: 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let editPopup: boolean = false;
|
let editPopup: boolean = false;
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
value.update(editItem);
|
item.update(editItem);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="code-font">{value.data.Hdr.Name}</td>
|
<td class="code-font">{item.data.name}</td>
|
||||||
<td class="code-font">{value.data.Mx}</td>
|
<td class="code-font">{item.data.value.mx}</td>
|
||||||
<td class="code-font">{value.data.Preference}</td>
|
<td class="code-font">{item.data.value.preference}</td>
|
||||||
<td class="code-font">{value.data.Hdr.Ttl}</td>
|
<td class="code-font">{item.data.ttl}</td>
|
||||||
<td>
|
<td>
|
||||||
<ActionMenu
|
<ActionMenu
|
||||||
data={value}
|
data={item}
|
||||||
edit={() => {
|
edit={() => {
|
||||||
editItem = JSON.parse(JSON.stringify(value.data));
|
editItem = JSON.parse(JSON.stringify(item.data));
|
||||||
editPopup = true;
|
editPopup = true;
|
||||||
}}
|
}}
|
||||||
remove={() => value.remove()}
|
remove={() => item.remove()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ActionPopup name="Edit MX Record" bind:show={editPopup} on:save={save}>
|
<ActionPopup name="Edit MX Record" bind:show={editPopup} on:save={save}>
|
||||||
|
@ -1,42 +1,39 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {NsRecord} from "../../types/records";
|
import type {ApiRecordFormat, NsValue} from "../../types/records";
|
||||||
import type {RestItem} from "../../utils/rest-table";
|
import type {RestItem} from "../../utils/rest-table";
|
||||||
import ActionMenu from "../ActionMenu.svelte";
|
import ActionMenu from "../ActionMenu.svelte";
|
||||||
import ActionPopup from "../ActionPopup.svelte";
|
import ActionPopup from "../ActionPopup.svelte";
|
||||||
import NsCreate from "../create-domains/NsCreate.svelte";
|
import NsCreate from "../create-domains/NsCreate.svelte";
|
||||||
|
|
||||||
export let value: RestItem<NsRecord>;
|
export let item: RestItem<ApiRecordFormat<NsValue>>;
|
||||||
let editItem: NsRecord = {
|
let editItem: ApiRecordFormat<NsValue> = {
|
||||||
Hdr: {
|
name: item.data.name,
|
||||||
Name: "",
|
type: item.data.type,
|
||||||
Rrtype: 0,
|
ttl: item.data.ttl,
|
||||||
Class: 0,
|
value: "",
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
Ns: "",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let editPopup: boolean = false;
|
let editPopup: boolean = false;
|
||||||
export let locked: boolean = false;
|
export let locked: boolean = false;
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
value.update(editItem);
|
item.update(editItem);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="code-font">{value.data.Hdr.Name}</td>
|
<td class="code-font">{item.data.name}</td>
|
||||||
<td class="code-font">{value.data.Ns}</td>
|
<td class="code-font">{item.data.value}</td>
|
||||||
<td class="code-font">{value.data.Hdr.Ttl}</td>
|
<td class="code-font">{item.data.ttl}</td>
|
||||||
<td>
|
<td>
|
||||||
{#if !locked}
|
{#if !locked}
|
||||||
<ActionMenu
|
<ActionMenu
|
||||||
data={value}
|
data={item}
|
||||||
edit={() => {
|
edit={() => {
|
||||||
editItem = JSON.parse(JSON.stringify(value.data));
|
editItem = JSON.parse(JSON.stringify(item.data));
|
||||||
editPopup = true;
|
editPopup = true;
|
||||||
}}
|
}}
|
||||||
remove={() => value.remove()}
|
remove={() => item.remove()}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -1,66 +1,69 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {SoaRecord} from "../../types/records";
|
import type {ApiRecordFormat, SoaValue} from "../../types/records";
|
||||||
import type {RestItem} from "../../utils/rest-table";
|
import type {RestItem} from "../../utils/rest-table";
|
||||||
import ActionMenu from "../ActionMenu.svelte";
|
import ActionMenu from "../ActionMenu.svelte";
|
||||||
import ActionPopup from "../ActionPopup.svelte";
|
import ActionPopup from "../ActionPopup.svelte";
|
||||||
|
|
||||||
export let value: RestItem<SoaRecord>;
|
export let item: RestItem<ApiRecordFormat<SoaValue>>;
|
||||||
let editItem: SoaRecord = {
|
let editItem: ApiRecordFormat<SoaValue> = {
|
||||||
Hdr: {
|
name: item.data.name,
|
||||||
Name: "",
|
type: item.data.type,
|
||||||
Rrtype: 0,
|
ttl: item.data.ttl,
|
||||||
Class: 0,
|
value: {
|
||||||
Ttl: 0,
|
ns: "",
|
||||||
|
mbox: "",
|
||||||
|
serial: 0,
|
||||||
|
refresh: 0,
|
||||||
|
retry: 0,
|
||||||
|
expire: 0,
|
||||||
|
minttl: 0,
|
||||||
},
|
},
|
||||||
Ns: "",
|
|
||||||
Mbox: "",
|
|
||||||
Serial: 0,
|
|
||||||
Refresh: 0,
|
|
||||||
Retry: 0,
|
|
||||||
Expire: 0,
|
|
||||||
Minttl: 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let editPopup: boolean = false;
|
let editPopup: boolean = false;
|
||||||
export let locked: boolean = false;
|
export let locked: boolean = false;
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
value.update(editItem);
|
item.update(editItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
function numLength(n: number) {
|
||||||
|
return n.toString().length + 2;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="code-font">{value.data.Hdr.Name}</td>
|
<td class="code-font">{item.data.name}</td>
|
||||||
<td class="code-font">{value.data.Mbox}</td>
|
<td class="code-font">{item.data.value.mbox}</td>
|
||||||
<td class="code-font">{value.data.Minttl}</td>
|
<td class="code-font">{item.data.value.minttl}</td>
|
||||||
<td class="code-font">{value.data.Refresh}</td>
|
<td class="code-font">{item.data.value.refresh}</td>
|
||||||
<td class="code-font">{value.data.Retry}</td>
|
<td class="code-font">{item.data.value.retry}</td>
|
||||||
<td class="code-font">{value.data.Expire}</td>
|
<td class="code-font">{item.data.value.expire}</td>
|
||||||
<td>
|
<td>
|
||||||
{#if !locked}
|
{#if !locked}
|
||||||
<ActionMenu
|
<ActionMenu
|
||||||
data={value}
|
data={item}
|
||||||
edit={() => {
|
edit={() => {
|
||||||
editItem = JSON.parse(JSON.stringify(value.data));
|
editItem = JSON.parse(JSON.stringify(item.data));
|
||||||
editPopup = true;
|
editPopup = true;
|
||||||
}}
|
}}
|
||||||
remove={() => value.remove()}
|
remove={() => item.remove()}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<ActionPopup name="Edit SOA Record" bind:show={editPopup} on:save={save}>
|
<ActionPopup name="Edit SOA Record" bind:show={editPopup} on:save={save}>
|
||||||
<div>Name</div>
|
<div>Name</div>
|
||||||
<div class="code-font">{editItem.Hdr.Name}</div>
|
<div class="code-font">{item.data.name}</div>
|
||||||
<div>Mailbox</div>
|
<div>Mailbox</div>
|
||||||
<div><input type="text" class="code-font" bind:value={editItem.Mbox} size={Math.max(20, editItem.Mbox.length + 2)} /></div>
|
<div><input type="text" class="code-font" bind:value={editItem.value.mbox} size={Math.max(20, editItem.value.mbox.length + 2)} /></div>
|
||||||
<div>Minimum Time-to-Live</div>
|
<div>Minimum Time-to-Live</div>
|
||||||
<div><input type="number" class="code-font" bind:value={editItem.Minttl} size={Math.max(20, editItem.Minttl.length + 2)} /></div>
|
<div><input type="number" class="code-font" bind:value={editItem.value.minttl} size={Math.max(20, numLength(editItem.value.minttl))} /></div>
|
||||||
<div>Refresh</div>
|
<div>Refresh</div>
|
||||||
<div><input type="number" class="code-font" bind:value={editItem.Refresh} size={Math.max(20, editItem.Refresh.length + 2)} /></div>
|
<div><input type="number" class="code-font" bind:value={editItem.value.refresh} size={Math.max(20, numLength(editItem.value.refresh))} /></div>
|
||||||
<div>Retry</div>
|
<div>Retry</div>
|
||||||
<div><input type="number" class="code-font" bind:value={editItem.Retry} size={Math.max(20, editItem.Retry.length + 2)} /></div>
|
<div><input type="number" class="code-font" bind:value={editItem.value.retry} size={Math.max(20, numLength(editItem.value.retry))} /></div>
|
||||||
<div>Expire</div>
|
<div>Expire</div>
|
||||||
<div><input type="number" class="code-font" bind:value={editItem.Expire} size={Math.max(20, editItem.Expire.length + 2)} /></div>
|
<div><input type="number" class="code-font" bind:value={editItem.value.expire} size={Math.max(20, numLength(editItem.value.expire))} /></div>
|
||||||
</ActionPopup>
|
</ActionPopup>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,46 +1,45 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {SrvRecord} from "../../types/records";
|
import type {ApiRecordFormat, SrvValue} from "../../types/records";
|
||||||
import type {RestItem} from "../../utils/rest-table";
|
import type {RestItem} from "../../utils/rest-table";
|
||||||
import ActionMenu from "../ActionMenu.svelte";
|
import ActionMenu from "../ActionMenu.svelte";
|
||||||
import ActionPopup from "../ActionPopup.svelte";
|
import ActionPopup from "../ActionPopup.svelte";
|
||||||
import SrvCreate from "../create-domains/SrvCreate.svelte";
|
import SrvCreate from "../create-domains/SrvCreate.svelte";
|
||||||
|
|
||||||
export let value: RestItem<SrvRecord>;
|
export let item: RestItem<ApiRecordFormat<SrvValue>>;
|
||||||
let editItem: SrvRecord = {
|
let editItem: ApiRecordFormat<SrvValue> = {
|
||||||
Hdr: {
|
name: item.data.name,
|
||||||
Name: "",
|
type: item.data.type,
|
||||||
Rrtype: 0,
|
ttl: item.data.ttl,
|
||||||
Class: 0,
|
value: {
|
||||||
Ttl: 0,
|
priority: 0,
|
||||||
|
weight: 0,
|
||||||
|
port: 0,
|
||||||
|
target: "",
|
||||||
},
|
},
|
||||||
Priority: 0,
|
|
||||||
Weight: 0,
|
|
||||||
Port: 0,
|
|
||||||
Target: "",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let editPopup: boolean = false;
|
let editPopup: boolean = false;
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
value.update(editItem);
|
item.update(editItem);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="code-font">{value.data.Hdr.Name}</td>
|
<td class="code-font">{item.data.name}</td>
|
||||||
<td class="code-font">{value.data.Priority}</td>
|
<td class="code-font">{item.data.value.priority}</td>
|
||||||
<td class="code-font">{value.data.Weight}</td>
|
<td class="code-font">{item.data.value.weight}</td>
|
||||||
<td class="code-font">{value.data.Port}</td>
|
<td class="code-font">{item.data.value.port}</td>
|
||||||
<td class="code-font">{value.data.Target}</td>
|
<td class="code-font">{item.data.value.target}</td>
|
||||||
<td class="code-font">{value.data.Hdr.Ttl}</td>
|
<td class="code-font">{item.data.ttl}</td>
|
||||||
<td>
|
<td>
|
||||||
<ActionMenu
|
<ActionMenu
|
||||||
data={value}
|
data={item}
|
||||||
edit={() => {
|
edit={() => {
|
||||||
editItem = JSON.parse(JSON.stringify(value.data));
|
editItem = JSON.parse(JSON.stringify(item.data));
|
||||||
editPopup = true;
|
editPopup = true;
|
||||||
}}
|
}}
|
||||||
remove={() => value.remove()}
|
remove={() => item.remove()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ActionPopup name="Edit CNAME Record" bind:show={editPopup} on:save={save}>
|
<ActionPopup name="Edit CNAME Record" bind:show={editPopup} on:save={save}>
|
||||||
|
@ -1,41 +1,38 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {TxtRecord} from "../../types/records";
|
import type {ApiRecordFormat, TxtValue} from "../../types/records";
|
||||||
import type {RestItem} from "../../utils/rest-table";
|
import type {RestItem} from "../../utils/rest-table";
|
||||||
import ActionMenu from "../ActionMenu.svelte";
|
import ActionMenu from "../ActionMenu.svelte";
|
||||||
import ActionPopup from "../ActionPopup.svelte";
|
import ActionPopup from "../ActionPopup.svelte";
|
||||||
import TxtCreate from "../create-domains/TxtCreate.svelte";
|
import TxtCreate from "../create-domains/TxtCreate.svelte";
|
||||||
import TdCutOff from "../CutOffTd.svelte";
|
import TdCutOff from "../CutOffTd.svelte";
|
||||||
|
|
||||||
export let value: RestItem<TxtRecord>;
|
export let item: RestItem<ApiRecordFormat<TxtValue>>;
|
||||||
let editItem: TxtRecord = {
|
let editItem: ApiRecordFormat<TxtValue> = {
|
||||||
Hdr: {
|
name: item.data.name,
|
||||||
Name: "",
|
type: item.data.type,
|
||||||
Rrtype: 0,
|
ttl: item.data.ttl,
|
||||||
Class: 0,
|
value: "",
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
Txt: [""],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let editPopup: boolean = false;
|
let editPopup: boolean = false;
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
value.update(editItem);
|
item.update(editItem);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="code-font">{value.data.Hdr.Name}</td>
|
<td class="code-font">{item.data.name}</td>
|
||||||
<TdCutOff class="code-font">{value.data.Txt.join("\n")}</TdCutOff>
|
<TdCutOff class="code-font">{item.data.value}</TdCutOff>
|
||||||
<td class="code-font">{value.data.Hdr.Ttl}</td>
|
<td class="code-font">{item.data.ttl}</td>
|
||||||
<td>
|
<td>
|
||||||
<ActionMenu
|
<ActionMenu
|
||||||
data={value}
|
data={item}
|
||||||
edit={() => {
|
edit={() => {
|
||||||
editItem = JSON.parse(JSON.stringify(value.data));
|
editItem = JSON.parse(JSON.stringify(item.data));
|
||||||
editPopup = true;
|
editPopup = true;
|
||||||
}}
|
}}
|
||||||
remove={() => value.remove()}
|
remove={() => item.remove()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ActionPopup name="Edit TXT Record" bind:show={editPopup} on:save={save}>
|
<ActionPopup name="Edit TXT Record" bind:show={editPopup} on:save={save}>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import type {IPv4, IPv6} from "ipaddr.js";
|
||||||
|
|
||||||
export const DnsTypeSOA = 6;
|
export const DnsTypeSOA = 6;
|
||||||
export const DnsTypeNS = 2;
|
export const DnsTypeNS = 2;
|
||||||
export const DnsTypeMX = 15;
|
export const DnsTypeMX = 15;
|
||||||
@ -8,105 +10,86 @@ export const DnsTypeTXT = 16;
|
|||||||
export const DnsTypeSRV = 33;
|
export const DnsTypeSRV = 33;
|
||||||
export const DnsTypeCAA = 257;
|
export const DnsTypeCAA = 257;
|
||||||
|
|
||||||
export type AllRecords = SoaRecord | NsRecord | MxRecord | ARecord | AaaaRecord | CnameRecord | TxtRecord | SrvRecord | CaaRecord;
|
export type AnyValue = SoaValue | NsValue | MxValue | AValue | AaaaValue | CnameValue | TxtValue | SrvValue | CaaValue;
|
||||||
|
export type AnyRecord = ApiRecordFormat<AnyValue>;
|
||||||
|
|
||||||
export interface ApiRecordFormat {
|
export interface ApiRecordFormat<T> {
|
||||||
name: string;
|
name: string;
|
||||||
type: number;
|
type: number;
|
||||||
value: any;
|
ttl: number | null;
|
||||||
|
value: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RecordHeader {
|
export interface SoaValue {
|
||||||
Name: string;
|
ns: string;
|
||||||
Rrtype: number;
|
mbox: string;
|
||||||
Class: number;
|
serial: number;
|
||||||
Ttl: number;
|
refresh: number;
|
||||||
|
retry: number;
|
||||||
|
expire: number;
|
||||||
|
minttl: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UnknownRecord {
|
export function isSoaRecord(x: AnyRecord): x is ApiRecordFormat<SoaValue> {
|
||||||
Hdr: RecordHeader;
|
return x.type === DnsTypeSOA;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SoaRecord extends UnknownRecord {
|
export type NsValue = string;
|
||||||
Ns: string;
|
|
||||||
Mbox: string;
|
export function isNsRecord(x: AnyRecord): x is ApiRecordFormat<NsValue> {
|
||||||
Serial: number;
|
return x.type === DnsTypeNS;
|
||||||
Refresh: number;
|
|
||||||
Retry: number;
|
|
||||||
Expire: number;
|
|
||||||
Minttl: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isSoaRecord(x: UnknownRecord): x is SoaRecord {
|
export interface MxValue {
|
||||||
return x.Hdr.Rrtype === DnsTypeSOA;
|
preference: number;
|
||||||
|
mx: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NsRecord extends UnknownRecord {
|
export function isMxRecord(x: AnyRecord): x is ApiRecordFormat<MxValue> {
|
||||||
Ns: string;
|
return x.type === DnsTypeMX;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isNsRecord(x: UnknownRecord): x is NsRecord {
|
export type AValue = string;
|
||||||
return x.Hdr.Rrtype === DnsTypeNS;
|
|
||||||
|
export function isARecord(x: AnyRecord): x is ApiRecordFormat<AValue> {
|
||||||
|
return x.type === DnsTypeA;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MxRecord extends UnknownRecord {
|
export type AaaaValue = string;
|
||||||
Preference: number;
|
|
||||||
Mx: string;
|
export function isAaaaRecord(x: AnyRecord): x is ApiRecordFormat<AaaaValue> {
|
||||||
|
return x.type === DnsTypeAAAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isMxRecord(x: UnknownRecord): x is MxRecord {
|
export type CnameValue = string;
|
||||||
return x.Hdr.Rrtype === DnsTypeMX;
|
|
||||||
|
export function isCnameRecord(x: AnyRecord): x is ApiRecordFormat<CnameValue> {
|
||||||
|
return x.type === DnsTypeCNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ARecord extends UnknownRecord {
|
export type TxtValue = string;
|
||||||
A: string;
|
|
||||||
|
export function isTxtRecord(x: AnyRecord): x is ApiRecordFormat<TxtValue> {
|
||||||
|
return x.type === DnsTypeTXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isARecord(x: UnknownRecord): x is ARecord {
|
export interface SrvValue {
|
||||||
return x.Hdr.Rrtype === DnsTypeA;
|
priority: number;
|
||||||
|
weight: number;
|
||||||
|
port: number;
|
||||||
|
target: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AaaaRecord extends UnknownRecord {
|
export function isSrvRecord(x: AnyRecord): x is ApiRecordFormat<SrvValue> {
|
||||||
AAAA: string;
|
return x.type === DnsTypeSRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isAaaaRecord(x: UnknownRecord): x is AaaaRecord {
|
export interface CaaValue {
|
||||||
return x.Hdr.Rrtype === DnsTypeAAAA;
|
flag: number;
|
||||||
|
tag: string;
|
||||||
|
value: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CnameRecord extends UnknownRecord {
|
export function isCaaRecord(x: AnyRecord): x is ApiRecordFormat<CaaValue> {
|
||||||
Target: string;
|
return x.type === DnsTypeCAA;
|
||||||
}
|
|
||||||
|
|
||||||
export function isCnameRecord(x: UnknownRecord): x is CnameRecord {
|
|
||||||
return x.Hdr.Rrtype === DnsTypeCNAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TxtRecord extends UnknownRecord {
|
|
||||||
Txt: Array<string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isTxtRecord(x: UnknownRecord): x is TxtRecord {
|
|
||||||
return x.Hdr.Rrtype === DnsTypeTXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SrvRecord extends UnknownRecord {
|
|
||||||
Priority: number;
|
|
||||||
Weight: number;
|
|
||||||
Port: number;
|
|
||||||
Target: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isSrvRecord(x: UnknownRecord): x is SrvRecord {
|
|
||||||
return x.Hdr.Rrtype === DnsTypeSRV;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CaaRecord extends UnknownRecord {
|
|
||||||
Flag: number;
|
|
||||||
Tag: string;
|
|
||||||
Value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isCaaRecord(x: UnknownRecord): x is CaaRecord {
|
|
||||||
return x.Hdr.Rrtype === DnsTypeCAA;
|
|
||||||
}
|
}
|
||||||
|
@ -3,24 +3,27 @@
|
|||||||
import type {RestItem, RestTable} from "../utils/rest-table";
|
import type {RestItem, RestTable} from "../utils/rest-table";
|
||||||
import PromiseTable from "../components/PromiseTable.svelte";
|
import PromiseTable from "../components/PromiseTable.svelte";
|
||||||
import PromiseLike from "../components/PromiseLike.svelte";
|
import PromiseLike from "../components/PromiseLike.svelte";
|
||||||
import type {AllRecords, ApiRecordFormat, UnknownRecord} from "../types/records";
|
import type {AnyRecord, AnyValue, ApiRecordFormat} from "../types/records";
|
||||||
import ActionPopup from "../components/ActionPopup.svelte";
|
import ActionPopup from "../components/ActionPopup.svelte";
|
||||||
|
|
||||||
type T = $$Generic<UnknownRecord>;
|
type T = $$Generic<AnyValue>;
|
||||||
|
|
||||||
export let recordName: string;
|
export let recordName: string;
|
||||||
export let table: RestTable<AllRecords>;
|
export let table: RestTable<AnyRecord>;
|
||||||
export let emptyRecord: (() => any) | null;
|
export let emptyRecord: (() => ApiRecordFormat<T>) | null;
|
||||||
export let convert: (t: T) => ApiRecordFormat;
|
export let rowOrdering: (
|
||||||
export let rowOrdering: (rows: RestItem<AllRecords>[], domain: string, isTRecord: (t: UnknownRecord) => t is T) => RestItem<T>[];
|
rows: RestItem<AnyRecord>[],
|
||||||
export let isTRecord: (t: UnknownRecord) => t is T;
|
domain: string,
|
||||||
|
isTRecord: (t: AnyRecord) => t is ApiRecordFormat<T>,
|
||||||
|
) => RestItem<ApiRecordFormat<T>>[];
|
||||||
|
export let isTRecord: (t: AnyRecord) => t is ApiRecordFormat<T>;
|
||||||
|
|
||||||
let createItem: T | null = emptyRecord == null ? null : emptyRecord();
|
let createItem: ApiRecordFormat<T> | null = emptyRecord == null ? null : emptyRecord();
|
||||||
let createPopup: boolean = false;
|
let createPopup: boolean = false;
|
||||||
|
|
||||||
function createRecord() {
|
function createRecord() {
|
||||||
if (createItem == null) return;
|
if (createItem == null) return;
|
||||||
table.addItem(convert(createItem) as any);
|
table.addItem(createItem);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
DnsTypeCNAME,
|
DnsTypeCNAME,
|
||||||
DnsTypeMX,
|
DnsTypeMX,
|
||||||
DnsTypeNS,
|
DnsTypeNS,
|
||||||
DnsTypeSOA,
|
|
||||||
DnsTypeSRV,
|
DnsTypeSRV,
|
||||||
DnsTypeTXT,
|
DnsTypeTXT,
|
||||||
isARecord,
|
isARecord,
|
||||||
@ -18,21 +17,20 @@
|
|||||||
isSoaRecord,
|
isSoaRecord,
|
||||||
isSrvRecord,
|
isSrvRecord,
|
||||||
isTxtRecord,
|
isTxtRecord,
|
||||||
type ARecord,
|
type AValue,
|
||||||
type AaaaRecord,
|
type AaaaValue,
|
||||||
type AllRecords,
|
type AnyRecord,
|
||||||
|
type AnyValue,
|
||||||
type ApiRecordFormat,
|
type ApiRecordFormat,
|
||||||
type CaaRecord,
|
type CaaValue,
|
||||||
type CnameRecord,
|
type CnameValue,
|
||||||
type MxRecord,
|
type MxValue,
|
||||||
type NsRecord,
|
type NsValue,
|
||||||
type SoaRecord,
|
type SoaValue,
|
||||||
type SrvRecord,
|
type SrvValue,
|
||||||
type TxtRecord,
|
type TxtValue,
|
||||||
type UnknownRecord,
|
|
||||||
} from "../types/records";
|
} from "../types/records";
|
||||||
import {RestItem, RestTable} from "../utils/rest-table";
|
import {RestItem, RestTable} from "../utils/rest-table";
|
||||||
import PromiseLike from "../components/PromiseLike.svelte";
|
|
||||||
import SoaRow from "../components/domains/SoaRow.svelte";
|
import SoaRow from "../components/domains/SoaRow.svelte";
|
||||||
import NsRow from "../components/domains/NsRow.svelte";
|
import NsRow from "../components/domains/NsRow.svelte";
|
||||||
import MxRow from "../components/domains/MxRow.svelte";
|
import MxRow from "../components/domains/MxRow.svelte";
|
||||||
@ -42,28 +40,26 @@
|
|||||||
import CaaRow from "../components/domains/CaaRow.svelte";
|
import CaaRow from "../components/domains/CaaRow.svelte";
|
||||||
import SrvRow from "../components/domains/SrvRow.svelte";
|
import SrvRow from "../components/domains/SrvRow.svelte";
|
||||||
import DomainTableView from "./DomainTableView.svelte";
|
import DomainTableView from "./DomainTableView.svelte";
|
||||||
import ActionPopup from "../components/ActionPopup.svelte";
|
|
||||||
import NsCreate from "../components/create-domains/NsCreate.svelte";
|
import NsCreate from "../components/create-domains/NsCreate.svelte";
|
||||||
import MxCreate from "../components/create-domains/MxCreate.svelte";
|
import MxCreate from "../components/create-domains/MxCreate.svelte";
|
||||||
import ACreate from "../components/create-domains/ACreate.svelte";
|
import ACreate from "../components/create-domains/ACreate.svelte";
|
||||||
import CnameCreate from "../components/create-domains/CnameCreate.svelte";
|
import CnameCreate from "../components/create-domains/CnameCreate.svelte";
|
||||||
import CaaCreate from "../components/create-domains/CaaCreate.svelte";
|
import CaaCreate from "../components/create-domains/CaaCreate.svelte";
|
||||||
import TxtCreate from "../components/create-domains/TxtCreate.svelte";
|
import TxtCreate from "../components/create-domains/TxtCreate.svelte";
|
||||||
import PromiseTable from "../components/PromiseTable.svelte";
|
|
||||||
|
|
||||||
const apiAzalea = import.meta.env.VITE_API_AZALEA;
|
const apiAzalea = import.meta.env.VITE_API_AZALEA;
|
||||||
|
|
||||||
const table = new RestTable<AllRecords>(apiAzalea + "/domains/" + $domainOption + "/records", (item: AllRecords) => item.Hdr.Name);
|
const table = new RestTable<AnyRecord>(apiAzalea + "/domains/" + $domainOption + "/records", (item: AnyRecord) => item.name);
|
||||||
|
|
||||||
function rowOrdering<T extends UnknownRecord>(
|
function rowOrdering<T extends AnyValue>(
|
||||||
rows: RestItem<AllRecords>[],
|
rows: RestItem<AnyRecord>[],
|
||||||
domain: string,
|
domain: string,
|
||||||
isTRecord: (t: UnknownRecord) => t is T,
|
isTRecord: (t: AnyRecord) => t is ApiRecordFormat<T>,
|
||||||
): RestItem<T>[] {
|
): RestItem<ApiRecordFormat<T>>[] {
|
||||||
return rows
|
return rows
|
||||||
.filter(x => isTRecord(x.data))
|
.filter(x => isTRecord(x.data))
|
||||||
.filter(x => domainFilter(x.data.Hdr.Name, domain))
|
.filter(x => domainFilter(x.data.name, domain))
|
||||||
.sort((a, b) => a.data.Hdr.Name.localeCompare(b.data.Hdr.Name)) as unknown as RestItem<T>[];
|
.sort((a, b) => a.data.name.localeCompare(b.data.name)) as unknown as RestItem<ApiRecordFormat<T>>[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function domainFilter(src: string, domain: string) {
|
function domainFilter(src: string, domain: string) {
|
||||||
@ -91,7 +87,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let domainTitle: string = "";
|
let domainTitle: string = "";
|
||||||
$: (domainTitle = table.rows.length === 0 ? "Unknown" : getTitleDomain(table.rows[0].data.Hdr.Name)), $table;
|
$: (domainTitle = table.rows.length === 0 ? "Unknown" : getTitleDomain(table.rows[0].data.name)), $table;
|
||||||
let zoneFileUrl: string;
|
let zoneFileUrl: string;
|
||||||
zoneFileUrl = domainTitle ? `${import.meta.env.VITE_API_AZALEA}/domains/${domainTitle}/zone-file` : "";
|
zoneFileUrl = domainTitle ? `${import.meta.env.VITE_API_AZALEA}/domains/${domainTitle}/zone-file` : "";
|
||||||
|
|
||||||
@ -105,11 +101,6 @@
|
|||||||
create: null,
|
create: null,
|
||||||
save: null,
|
save: null,
|
||||||
empty: null,
|
empty: null,
|
||||||
convert: (t: SoaRecord): ApiRecordFormat => ({
|
|
||||||
name: t.Hdr.Name,
|
|
||||||
type: t.Hdr.Rrtype,
|
|
||||||
value: "",
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NS",
|
name: "NS",
|
||||||
@ -118,19 +109,11 @@
|
|||||||
filter: isNsRecord,
|
filter: isNsRecord,
|
||||||
render: NsRow,
|
render: NsRow,
|
||||||
create: NsCreate,
|
create: NsCreate,
|
||||||
empty: (): NsRecord => ({
|
empty: (): ApiRecordFormat<NsValue> => ({
|
||||||
Hdr: {
|
name: "",
|
||||||
Name: "",
|
type: DnsTypeNS,
|
||||||
Rrtype: DnsTypeNS,
|
ttl: null,
|
||||||
Class: 1,
|
value: "",
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
Ns: "",
|
|
||||||
}),
|
|
||||||
convert: (t: NsRecord): ApiRecordFormat => ({
|
|
||||||
name: t.Hdr.Name,
|
|
||||||
type: t.Hdr.Rrtype,
|
|
||||||
value: t.Ns,
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -140,22 +123,13 @@
|
|||||||
filter: isMxRecord,
|
filter: isMxRecord,
|
||||||
render: MxRow,
|
render: MxRow,
|
||||||
create: MxCreate,
|
create: MxCreate,
|
||||||
empty: (): MxRecord => ({
|
empty: (): ApiRecordFormat<MxValue> => ({
|
||||||
Hdr: {
|
name: "",
|
||||||
Name: "",
|
type: DnsTypeMX,
|
||||||
Rrtype: DnsTypeMX,
|
ttl: null,
|
||||||
Class: 1,
|
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
Mx: "",
|
|
||||||
Preference: 0,
|
|
||||||
}),
|
|
||||||
convert: (t: MxRecord): ApiRecordFormat => ({
|
|
||||||
name: t.Hdr.Name,
|
|
||||||
type: t.Hdr.Rrtype,
|
|
||||||
value: {
|
value: {
|
||||||
mx: t.Mx,
|
mx: "",
|
||||||
preference: t.Preference,
|
preference: 0,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -163,23 +137,14 @@
|
|||||||
name: "A/AAAA",
|
name: "A/AAAA",
|
||||||
headers: ["Hostname", "IP Address", "TTL"],
|
headers: ["Hostname", "IP Address", "TTL"],
|
||||||
locked: false,
|
locked: false,
|
||||||
filter: (t: UnknownRecord) => isARecord(t) || isAaaaRecord(t),
|
filter: (t: AnyRecord) => isARecord(t) || isAaaaRecord(t),
|
||||||
render: ARow,
|
render: ARow,
|
||||||
create: ACreate,
|
create: ACreate,
|
||||||
empty: (): ARecord | AaaaRecord => ({
|
empty: (): ApiRecordFormat<AValue | AaaaValue> => ({
|
||||||
Hdr: {
|
name: "",
|
||||||
Name: "",
|
type: 0, // this is on purpose
|
||||||
Rrtype: 0, // this is on purpose
|
ttl: null,
|
||||||
Class: 1,
|
value: "",
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
A: "",
|
|
||||||
AAAA: "",
|
|
||||||
}),
|
|
||||||
convert: (t: ARecord | AaaaRecord): ApiRecordFormat => ({
|
|
||||||
name: t.Hdr.Name,
|
|
||||||
type: t.Hdr.Rrtype,
|
|
||||||
value: isARecord(t) ? t.A : isAaaaRecord(t) ? t.AAAA : "",
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -189,19 +154,11 @@
|
|||||||
filter: isCnameRecord,
|
filter: isCnameRecord,
|
||||||
render: CnameRow,
|
render: CnameRow,
|
||||||
create: CnameCreate,
|
create: CnameCreate,
|
||||||
empty: (): CnameRecord => ({
|
empty: (): ApiRecordFormat<CnameValue> => ({
|
||||||
Hdr: {
|
name: "",
|
||||||
Name: "",
|
type: DnsTypeCNAME,
|
||||||
Rrtype: DnsTypeCNAME,
|
ttl: null,
|
||||||
Class: 1,
|
value: "",
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
Target: "",
|
|
||||||
}),
|
|
||||||
convert: (t: CnameRecord): ApiRecordFormat => ({
|
|
||||||
name: t.Hdr.Name,
|
|
||||||
type: t.Hdr.Rrtype,
|
|
||||||
value: t.Target,
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -211,19 +168,11 @@
|
|||||||
filter: isTxtRecord,
|
filter: isTxtRecord,
|
||||||
render: TxtRow,
|
render: TxtRow,
|
||||||
create: TxtCreate,
|
create: TxtCreate,
|
||||||
empty: (): TxtRecord => ({
|
empty: (): ApiRecordFormat<TxtValue> => ({
|
||||||
Hdr: {
|
name: "",
|
||||||
Name: "",
|
type: DnsTypeTXT,
|
||||||
Rrtype: DnsTypeTXT,
|
ttl: null,
|
||||||
Class: 1,
|
value: "",
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
Txt: [""],
|
|
||||||
}),
|
|
||||||
convert: (t: TxtRecord): ApiRecordFormat => ({
|
|
||||||
name: t.Hdr.Name,
|
|
||||||
type: t.Hdr.Rrtype,
|
|
||||||
value: t.Txt.join("\n"),
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -233,26 +182,15 @@
|
|||||||
filter: isSrvRecord,
|
filter: isSrvRecord,
|
||||||
render: SrvRow,
|
render: SrvRow,
|
||||||
create: null,
|
create: null,
|
||||||
empty: (): SrvRecord => ({
|
empty: (): ApiRecordFormat<SrvValue> => ({
|
||||||
Hdr: {
|
name: "",
|
||||||
Name: "",
|
type: DnsTypeSRV,
|
||||||
Rrtype: DnsTypeSRV,
|
ttl: null,
|
||||||
Class: 1,
|
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
Priority: 0,
|
|
||||||
Weight: 0,
|
|
||||||
Port: 0,
|
|
||||||
Target: "",
|
|
||||||
}),
|
|
||||||
convert: (t: SrvRecord): ApiRecordFormat => ({
|
|
||||||
name: t.Hdr.Name,
|
|
||||||
type: t.Hdr.Rrtype,
|
|
||||||
value: {
|
value: {
|
||||||
priority: t.Priority,
|
priority: 0,
|
||||||
weight: t.Weight,
|
weight: 0,
|
||||||
port: t.Port,
|
port: 0,
|
||||||
target: t.Target,
|
target: "",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -263,24 +201,14 @@
|
|||||||
filter: isCaaRecord,
|
filter: isCaaRecord,
|
||||||
render: CaaRow,
|
render: CaaRow,
|
||||||
create: CaaCreate,
|
create: CaaCreate,
|
||||||
empty: (): CaaRecord => ({
|
empty: (): ApiRecordFormat<CaaValue> => ({
|
||||||
Hdr: {
|
name: "",
|
||||||
Name: "",
|
type: DnsTypeCAA,
|
||||||
Rrtype: DnsTypeCAA,
|
ttl: null,
|
||||||
Class: 1,
|
|
||||||
Ttl: 0,
|
|
||||||
},
|
|
||||||
Flag: 0,
|
|
||||||
Tag: "",
|
|
||||||
Value: "",
|
|
||||||
}),
|
|
||||||
convert: (t: CaaRecord): ApiRecordFormat => ({
|
|
||||||
name: t.Hdr.Name,
|
|
||||||
type: t.Hdr.Rrtype,
|
|
||||||
value: {
|
value: {
|
||||||
flag: t.Flag,
|
flag: 0,
|
||||||
tag: t.Tag,
|
tag: "",
|
||||||
value: t.Value,
|
value: "",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -301,14 +229,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#each recordTypes as recordType}
|
{#each recordTypes as recordType}
|
||||||
<DomainTableView
|
<DomainTableView recordName={recordType.name} {table} emptyRecord={recordType.empty} {rowOrdering} isTRecord={recordType.filter}>
|
||||||
recordName={recordType.name}
|
|
||||||
{table}
|
|
||||||
emptyRecord={recordType.empty}
|
|
||||||
convert={recordType.convert}
|
|
||||||
{rowOrdering}
|
|
||||||
isTRecord={recordType.filter}
|
|
||||||
>
|
|
||||||
<tr slot="headers">
|
<tr slot="headers">
|
||||||
{#each recordType.headers as header}
|
{#each recordType.headers as header}
|
||||||
<th>{header}</th>
|
<th>{header}</th>
|
||||||
@ -322,7 +243,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
|
|
||||||
<svelte:component this={recordType.render} slot="row" let:value {value} locked={recordType.locked} />
|
<svelte:component this={recordType.render} slot="row" let:value item={value} locked={recordType.locked} />
|
||||||
</DomainTableView>
|
</DomainTableView>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user