WIP ui changes to handle services refactoring
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
8c644db42c
commit
18464fac52
8 changed files with 123 additions and 117 deletions
|
@ -28,3 +28,48 @@ export async function getService(domain: Domain, zoneid: string, subdomain: stri
|
||||||
});
|
});
|
||||||
return await handleApiResponse<ServiceCombined>(res);
|
return await handleApiResponse<ServiceCombined>(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO -- behind this line, not worked on
|
||||||
|
export async function addServiceRecord(domain: Domain | DomainInList, id: string, service: ServiceCombined, record): Promise<Zone> {
|
||||||
|
let subdomain = service._domain;
|
||||||
|
if (subdomain === '') subdomain = '@';
|
||||||
|
|
||||||
|
const dnid = encodeURIComponent(domain.id);
|
||||||
|
id = encodeURIComponent(id);
|
||||||
|
subdomain = encodeURIComponent(subdomain);
|
||||||
|
|
||||||
|
const res = await fetch(`/api/domains/${dnid}/zone/${id}/${subdomain}/services`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {'Accept': 'application/json'},
|
||||||
|
body: JSON.stringify(service)
|
||||||
|
});
|
||||||
|
return await handleApiResponse<Zone>(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateServiceRecord(domain: Domain | DomainInList, id: string, service: ServiceCombined, record): Promise<Zone> {
|
||||||
|
const dnid = encodeURIComponent(domain.id);
|
||||||
|
id = encodeURIComponent(id);
|
||||||
|
|
||||||
|
const res = await fetch(`/api/domains/${dnid}/zone/${id}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: {'Accept': 'application/json'},
|
||||||
|
body: JSON.stringify(service),
|
||||||
|
});
|
||||||
|
return await handleApiResponse<Zone>(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteServiceRecord(domain: Domain | DomainInList, id: string, service: ServiceMeta, record): Promise<Zone> {
|
||||||
|
let subdomain = service._domain;
|
||||||
|
if (subdomain === '') subdomain = '@';
|
||||||
|
|
||||||
|
const dnid = encodeURIComponent(domain.id);
|
||||||
|
id = encodeURIComponent(id);
|
||||||
|
subdomain = encodeURIComponent(subdomain);
|
||||||
|
const svcid = service._id?encodeURIComponent(service._id):undefined;
|
||||||
|
|
||||||
|
const res = await fetch(`/api/domains/${dnid}/zone/${id}/${subdomain}/services/${svcid}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {'Accept': 'application/json'}
|
||||||
|
});
|
||||||
|
return await handleApiResponse<Zone>(res);
|
||||||
|
}
|
||||||
|
|
|
@ -22,106 +22,37 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import { createEventDispatcher } from 'svelte';
|
||||||
Button,
|
|
||||||
Col,
|
|
||||||
Icon,
|
|
||||||
Input,
|
|
||||||
Row,
|
|
||||||
} from '@sveltestrap/sveltestrap';
|
|
||||||
|
|
||||||
import { nsclass, nsrrtype, rdatatostr } from '$lib/dns';
|
import { nsrrtype, rdatatostr } from '$lib/dns';
|
||||||
import type { ServiceRecord } from '$lib/model/zone';
|
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
export { className as class };
|
||||||
|
let className;
|
||||||
|
|
||||||
export let actBtn = false;
|
|
||||||
export let expand: boolean = false;
|
|
||||||
export let record;
|
export let record;
|
||||||
|
|
||||||
|
function openRecord() {
|
||||||
|
dispatch('show-record', record);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !record.edit}
|
<div
|
||||||
<div
|
class="record d-flex gap-1 {className}"
|
||||||
class="d-flex gap-1"
|
on:click={openRecord}
|
||||||
on:click={() => {expand = !expand}}
|
on:keypress={openRecord}
|
||||||
on:keypress={() => {expand = !expand}}
|
>
|
||||||
|
<span
|
||||||
|
class="font-monospace text-truncate"
|
||||||
|
title={rdatatostr(record)}
|
||||||
>
|
>
|
||||||
<Icon
|
{record.Hdr.Name?record.Hdr.Name:'@'} {nsrrtype(record.Hdr.Rrtype)} {rdatatostr(record)}
|
||||||
name={expand ? "chevron-down" : "chevron-right"}
|
</span>
|
||||||
/>
|
</div>
|
||||||
<span
|
|
||||||
class="font-monospace text-truncate"
|
<style>
|
||||||
title={rdatatostr(record)}
|
.record:hover {
|
||||||
>
|
background: #ccc;
|
||||||
{record.Hdr.Name?record.Hdr.Name:'@'} {nsrrtype(record.Hdr.Rrtype)} {rdatatostr(record)}
|
}
|
||||||
</span>
|
</style>
|
||||||
</div>
|
|
||||||
{#if expand}
|
|
||||||
<div class="grid mr-2">
|
|
||||||
<dl class="g-col-md-4 grid ms-2 mb-0 mt-1" style="--bs-columns: 2; --bs-gap: 0 .5rem;">
|
|
||||||
<dt class="text-end">
|
|
||||||
Class
|
|
||||||
</dt>
|
|
||||||
<dd class="text-muted font-monospace mb-1">
|
|
||||||
{nsclass(record.Hdr.Class)}
|
|
||||||
</dd>
|
|
||||||
<dt class="text-end">
|
|
||||||
TTL
|
|
||||||
</dt>
|
|
||||||
<dd class="text-muted font-monospace mb-1">
|
|
||||||
{record.Hdr.Ttl}
|
|
||||||
</dd>
|
|
||||||
<dt class="text-end">
|
|
||||||
RRType
|
|
||||||
</dt>
|
|
||||||
<dd class="text-muted font-monospace mb-1">
|
|
||||||
{nsrrtype(record.Hdr.Rrtype)} (<span title={record.Hdr.Rrtype}>0x{record.Hdr.Rrtype.toString(16)}</span>)
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<dl class="g-col-md-8 grid me-2" style="--bs-gap: 0 .5rem;">
|
|
||||||
{#each Object.keys(record) as k}
|
|
||||||
{#if k != "Hdr"}
|
|
||||||
{@const v = record[k]}
|
|
||||||
<dt class="g-col-4 text-end">
|
|
||||||
{k}
|
|
||||||
</dt>
|
|
||||||
<dd
|
|
||||||
class="g-col-8 text-muted font-monospace text-truncate mb-1"
|
|
||||||
title={v}
|
|
||||||
>
|
|
||||||
{v}
|
|
||||||
</dd>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
{:else}
|
|
||||||
<form
|
|
||||||
submit="$emit('save-rr')"
|
|
||||||
>
|
|
||||||
<Input
|
|
||||||
autofocus
|
|
||||||
class="font-monospace"
|
|
||||||
bsSize="sm"
|
|
||||||
bind:value={record.str}
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
{/if}
|
|
||||||
{#if record.edit || actBtn}
|
|
||||||
{#if record.edit}
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
color="success"
|
|
||||||
click="$emit('save-rr')"
|
|
||||||
>
|
|
||||||
<Icon name="check" aria-hidden="true" />
|
|
||||||
</Button>
|
|
||||||
{:else if record.rr.Hdr.Rrtype != 6}
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
color="danger"
|
|
||||||
click="$emit('delete-rr')"
|
|
||||||
>
|
|
||||||
<Icon name="trash-fill" aria-hidden="true" />
|
|
||||||
</Button>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
let showDetails = false;
|
let showDetails = false;
|
||||||
function toggleDetails() {
|
function toggleDetails() {
|
||||||
if (component == Card) {
|
if ($userSession.settings.zoneview === ZoneViewGrid || $userSession.settings.zoneview === ZoneViewRecords) {
|
||||||
dispatch("show-service", service);
|
dispatch("show-service", service);
|
||||||
} else if (service) {
|
} else if (service) {
|
||||||
showDetails = !showDetails;
|
showDetails = !showDetails;
|
||||||
|
@ -147,15 +147,16 @@
|
||||||
</CardBody>
|
</CardBody>
|
||||||
{:else if service && ($userSession.settings.zoneview === ZoneViewList || $userSession.settings.zoneview === ZoneViewRecords)}
|
{:else if service && ($userSession.settings.zoneview === ZoneViewList || $userSession.settings.zoneview === ZoneViewRecords)}
|
||||||
<ListGroupItem
|
<ListGroupItem
|
||||||
|
class="px-2"
|
||||||
on:click={toggleDetails}
|
on:click={toggleDetails}
|
||||||
>
|
>
|
||||||
<strong title={$servicesSpecs[service._svctype].description}>
|
<strong title={$servicesSpecs[service._svctype].description}>
|
||||||
{$servicesSpecs[service._svctype].name}
|
{$servicesSpecs[service._svctype].name}
|
||||||
</strong>
|
</strong>
|
||||||
{#if $servicesSpecs[service._svctype].description}
|
{#if $servicesSpecs[service._svctype].description}
|
||||||
<span class="text-muted">
|
<small class="text-muted">
|
||||||
{$servicesSpecs[service._svctype].description}
|
{$servicesSpecs[service._svctype].description}
|
||||||
</span>
|
</small>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $servicesSpecs[service._svctype].categories}
|
{#if $servicesSpecs[service._svctype].categories}
|
||||||
{#each $servicesSpecs[service._svctype].categories as category}
|
{#each $servicesSpecs[service._svctype].categories as category}
|
||||||
|
@ -165,7 +166,7 @@
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
{#if service._comment}
|
{#if service._comment}
|
||||||
<span class="float-end text-muted">
|
<span class="fst-italic float-end text-muted">
|
||||||
{service._comment}
|
{service._comment}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -184,7 +185,10 @@
|
||||||
</ListGroupItem>
|
</ListGroupItem>
|
||||||
{:else if $userSession.settings.zoneview === ZoneViewRecords}
|
{:else if $userSession.settings.zoneview === ZoneViewRecords}
|
||||||
<ListGroupItem class="p-0">
|
<ListGroupItem class="p-0">
|
||||||
<TableRecords service={service.Service} />
|
<TableRecords
|
||||||
|
service={service.Service}
|
||||||
|
on:show-record={(e) => dispatch("show-record", {record: e.detail, service})}
|
||||||
|
/>
|
||||||
</ListGroupItem>
|
</ListGroupItem>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -78,6 +78,10 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showRecordModal({record, service}) {
|
||||||
|
dispatch("show-record", {record, service});
|
||||||
|
}
|
||||||
|
|
||||||
function showServiceModal(service: ServiceCombined) {
|
function showServiceModal(service: ServiceCombined) {
|
||||||
dispatch("show-service", service);
|
dispatch("show-service", service);
|
||||||
}
|
}
|
||||||
|
@ -305,6 +309,7 @@
|
||||||
{origin}
|
{origin}
|
||||||
{service}
|
{service}
|
||||||
{zoneId}
|
{zoneId}
|
||||||
|
on:show-record={(event) => showRecordModal(event.detail)}
|
||||||
on:show-service={(event) => showServiceModal(event.detail)}
|
on:show-service={(event) => showServiceModal(event.detail)}
|
||||||
on:update-zone-services={(event) => dispatch("update-zone-services", event.detail)}
|
on:update-zone-services={(event) => dispatch("update-zone-services", event.detail)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
import AliasModal, { controls as ctrlAlias } from '$lib/components/domains/AliasModal.svelte';
|
import AliasModal, { controls as ctrlAlias } from '$lib/components/domains/AliasModal.svelte';
|
||||||
import { controls as ctrlNewService } from '$lib/components/NewServicePath.svelte';
|
import { controls as ctrlNewService } from '$lib/components/NewServicePath.svelte';
|
||||||
|
import { controls as ctrlRecord } from '$lib/components/domains/RecordModal.svelte';
|
||||||
import { controls as ctrlService } from '$lib/components/domains/ServiceModal.svelte';
|
import { controls as ctrlService } from '$lib/components/domains/ServiceModal.svelte';
|
||||||
import SubdomainItem from '$lib/components/domains/SubdomainItem.svelte';
|
import SubdomainItem from '$lib/components/domains/SubdomainItem.svelte';
|
||||||
import type { Domain } from '$lib/model/domain';
|
import type { Domain } from '$lib/model/domain';
|
||||||
|
@ -65,6 +66,10 @@
|
||||||
ctrlNewSubdomain.Open();
|
ctrlNewSubdomain.Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showRecordModal(event) {
|
||||||
|
ctrlRecord.Open(event.detail);
|
||||||
|
}
|
||||||
|
|
||||||
function showServiceModal(event: CustomEvent<ServiceCombined>) {
|
function showServiceModal(event: CustomEvent<ServiceCombined>) {
|
||||||
ctrlService.Open(event.detail);
|
ctrlService.Open(event.detail);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +84,7 @@
|
||||||
services={zone.services[dn]?zone.services[dn]:[]}
|
services={zone.services[dn]?zone.services[dn]:[]}
|
||||||
on:new-alias={() => ctrlAlias.Open(dn)}
|
on:new-alias={() => ctrlAlias.Open(dn)}
|
||||||
on:new-service={() => ctrlNewService.Open(dn)}
|
on:new-service={() => ctrlNewService.Open(dn)}
|
||||||
|
on:show-record={showRecordModal}
|
||||||
on:show-service={showServiceModal}
|
on:show-service={showServiceModal}
|
||||||
on:update-zone-services={(event) => dispatch("update-zone-services", event.detail)}
|
on:update-zone-services={(event) => dispatch("update-zone-services", event.detail)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -22,22 +22,12 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import { createEventDispatcher } from 'svelte';
|
||||||
Badge,
|
|
||||||
Card,
|
|
||||||
CardBody,
|
|
||||||
CardText,
|
|
||||||
CardTitle,
|
|
||||||
CardSubtitle,
|
|
||||||
Icon,
|
|
||||||
ListGroup,
|
|
||||||
ListGroupItem,
|
|
||||||
Table,
|
|
||||||
Spinner,
|
|
||||||
} from '@sveltestrap/sveltestrap';
|
|
||||||
|
|
||||||
import Record from '$lib/components/domains/Record.svelte';
|
import Record from '$lib/components/domains/Record.svelte';
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
export let service = null;
|
export let service = null;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -53,7 +43,11 @@
|
||||||
class="bg-light p-1 border-1 border-bottom"
|
class="bg-light p-1 border-1 border-bottom"
|
||||||
style="border-color: darkgray"
|
style="border-color: darkgray"
|
||||||
>
|
>
|
||||||
<Record {record} />
|
<Record
|
||||||
|
class="mx-1"
|
||||||
|
{record}
|
||||||
|
on:show-record={(e) => dispatch("show-record", e.detail)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{:else if record && record.length}
|
{:else if record && record.length}
|
||||||
{#each record as r}
|
{#each record as r}
|
||||||
|
@ -61,7 +55,11 @@
|
||||||
class="bg-light p-1 border-1 border-bottom"
|
class="bg-light p-1 border-1 border-bottom"
|
||||||
style="border-color: darkgray"
|
style="border-color: darkgray"
|
||||||
>
|
>
|
||||||
<Record record={r} />
|
<Record
|
||||||
|
class="mx-1"
|
||||||
|
record={r}
|
||||||
|
on:show-record={(e) => dispatch("show-record", e.detail)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
},
|
},
|
||||||
"domains": {
|
"domains": {
|
||||||
"kind": "domain",
|
"kind": "domain",
|
||||||
|
"subdomain": "subdomain",
|
||||||
"actions": {
|
"actions": {
|
||||||
"audit": "View changes logs",
|
"audit": "View changes logs",
|
||||||
"do-migration": "Migrate now",
|
"do-migration": "Migrate now",
|
||||||
|
@ -303,6 +304,16 @@
|
||||||
"ttl-long": "Time-To-Live",
|
"ttl-long": "Time-To-Live",
|
||||||
"ttl-tip": "0 means default TTL, others values are exprimed in seconds"
|
"ttl-tip": "0 means default TTL, others values are exprimed in seconds"
|
||||||
},
|
},
|
||||||
|
"records": {
|
||||||
|
"add": "Add record",
|
||||||
|
"class": "Class",
|
||||||
|
"delete": "Delete this record",
|
||||||
|
"update": "Update this record",
|
||||||
|
"form-new": "Add a new record to {{domain}}",
|
||||||
|
"new": "New record",
|
||||||
|
"rrtype": "type",
|
||||||
|
"ttl": "Time-to-live"
|
||||||
|
},
|
||||||
"sessions": {
|
"sessions": {
|
||||||
"close-all": "Terminate all sessions",
|
"close-all": "Terminate all sessions",
|
||||||
"create": "Create API key",
|
"create": "Create API key",
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
} from '@sveltestrap/sveltestrap';
|
} from '@sveltestrap/sveltestrap';
|
||||||
|
|
||||||
import NewServicePath from '$lib/components/NewServicePath.svelte';
|
import NewServicePath from '$lib/components/NewServicePath.svelte';
|
||||||
|
import RecordModal from '$lib/components/domains/RecordModal.svelte';
|
||||||
import ServiceModal from '$lib/components/domains/ServiceModal.svelte';
|
import ServiceModal from '$lib/components/domains/ServiceModal.svelte';
|
||||||
import type { Domain } from '$lib/model/domain';
|
import type { Domain } from '$lib/model/domain';
|
||||||
import { domains_idx } from '$lib/stores/domains';
|
import { domains_idx } from '$lib/stores/domains';
|
||||||
|
@ -63,6 +64,11 @@
|
||||||
origin={data.domain}
|
origin={data.domain}
|
||||||
zone={zone}
|
zone={zone}
|
||||||
/>
|
/>
|
||||||
|
<RecordModal
|
||||||
|
origin={data.domain}
|
||||||
|
zone={zone}
|
||||||
|
on:update-zone-services={(event) => thisZone.set(event.detail)}
|
||||||
|
/>
|
||||||
<ServiceModal
|
<ServiceModal
|
||||||
origin={data.domain}
|
origin={data.domain}
|
||||||
zone={zone}
|
zone={zone}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue