2025-01-27 22:20:26 +01:00
|
|
|
<script setup>
|
|
|
|
|
|
|
|
|
|
const API_ORIGIN = import.meta.env.VITE_API_ORIGIN ? import.meta.env.VITE_API_ORIGIN : window.location.origin;
|
|
|
|
|
|
2025-01-28 13:55:58 +01:00
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
const i18n = useI18n();
|
|
|
|
|
const t = i18n.t;
|
|
|
|
|
|
|
|
|
|
import { ref, onMounted, useTemplateRef, computed } from 'vue';
|
2025-01-28 21:25:12 +01:00
|
|
|
import { Button, ButtonGroup, TableView, TextInput, InputDialog } from 'pankow';
|
2025-01-27 22:20:26 +01:00
|
|
|
import Certificates from '../components/Certificates.vue';
|
|
|
|
|
import SyncDns from '../components/SyncDns.vue';
|
2025-01-28 13:55:58 +01:00
|
|
|
import DomainDialog from '../components/DomainDialog.vue';
|
2025-01-27 22:20:26 +01:00
|
|
|
import DashboardDomain from '../components/DashboardDomain.vue';
|
2025-01-30 14:29:46 +01:00
|
|
|
import WellKnownDialog from '../components/WellKnownDialog.vue';
|
2025-01-27 22:20:26 +01:00
|
|
|
import Section from '../components/Section.vue';
|
|
|
|
|
import DashboardModel from '../models/DashboardModel.js';
|
|
|
|
|
import DomainsModel from '../models/DomainsModel.js';
|
|
|
|
|
|
|
|
|
|
const dashboardModel = DashboardModel.create(API_ORIGIN, localStorage.token);
|
|
|
|
|
const domainsModel = DomainsModel.create(API_ORIGIN, localStorage.token);
|
|
|
|
|
|
|
|
|
|
const domains = ref([]);
|
2025-01-28 13:55:58 +01:00
|
|
|
const search = ref('');
|
2025-01-27 22:20:26 +01:00
|
|
|
const dashboardDomain = ref('');
|
2025-01-28 13:55:58 +01:00
|
|
|
const domainDialog = useTemplateRef('domainDialog');
|
2025-01-30 14:29:46 +01:00
|
|
|
const wellKnownDialog = useTemplateRef('wellKnownDialog');
|
2025-01-27 22:20:26 +01:00
|
|
|
|
|
|
|
|
function prettyProviderName(domain) {
|
|
|
|
|
switch (domain.provider) {
|
|
|
|
|
case 'bunny': return 'Bunny';
|
|
|
|
|
case 'route53': return 'AWS Route53';
|
|
|
|
|
case 'cloudflare': return 'Cloudflare';
|
|
|
|
|
case 'desec': return 'deSEC';
|
|
|
|
|
case 'digitalocean': return 'DigitalOcean';
|
|
|
|
|
case 'dnsimple': return 'dnsimple';
|
|
|
|
|
case 'gandi': return 'Gandi LiveDNS';
|
|
|
|
|
case 'hetzner': return 'Hetzner DNS';
|
|
|
|
|
case 'inwx': return 'INWX';
|
|
|
|
|
case 'linode': return 'Linode';
|
|
|
|
|
case 'namecom': return 'Name.com';
|
|
|
|
|
case 'namecheap': return 'Namecheap';
|
|
|
|
|
case 'netcup': return 'Netcup';
|
|
|
|
|
case 'ovh': return 'OVH';
|
|
|
|
|
case 'gcdns': return 'Google Cloud';
|
|
|
|
|
case 'godaddy': return 'GoDaddy';
|
|
|
|
|
case 'vultr': return 'Vultr';
|
|
|
|
|
case 'manual': return 'Manual';
|
|
|
|
|
case 'porkbun': return 'Porkbun';
|
|
|
|
|
case 'wildcard': return 'Wildcard';
|
|
|
|
|
case 'noop': return 'No-op';
|
|
|
|
|
default: return 'Unknown';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function onAdd () {
|
2025-01-28 13:55:58 +01:00
|
|
|
domainDialog.value.open(null);
|
2025-01-27 22:20:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onEdit(domain) {
|
2025-01-28 13:55:58 +01:00
|
|
|
domainDialog.value.open(domain);
|
2025-01-27 22:20:26 +01:00
|
|
|
}
|
|
|
|
|
|
2025-01-28 21:25:12 +01:00
|
|
|
const inputDialog = useTemplateRef('inputDialog');
|
2025-01-27 22:20:26 +01:00
|
|
|
|
2025-01-28 21:25:12 +01:00
|
|
|
async function onRemove(domain) {
|
|
|
|
|
const yes = await inputDialog.value.confirm({
|
|
|
|
|
message: t('domains.removeDialog.title', { domain: domain.domain }),
|
|
|
|
|
confirmStyle: 'danger',
|
|
|
|
|
confirmLabel: t('domains.removeDialog.removeAction'),
|
|
|
|
|
rejectLabel: t('main.dialog.cancel')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!yes) return;
|
|
|
|
|
|
|
|
|
|
const [error] = await domainsModel.remove(domain.domain);
|
2025-01-29 16:29:21 +01:00
|
|
|
if (error) {
|
|
|
|
|
if (error.status === 409) window.pankow.notify({ text: `Domain ${domain} is still in use.`, type: 'danger', persistent: true });
|
|
|
|
|
return console.error(error);
|
|
|
|
|
}
|
2025-01-28 21:25:12 +01:00
|
|
|
|
|
|
|
|
await refreshDomains();
|
2025-01-27 22:20:26 +01:00
|
|
|
}
|
|
|
|
|
|
2025-01-28 13:55:58 +01:00
|
|
|
const columns = ref({
|
|
|
|
|
domain: {
|
|
|
|
|
label: t('domains.domain'),
|
|
|
|
|
sort: true
|
|
|
|
|
},
|
|
|
|
|
provider: {
|
|
|
|
|
label: t('domains.provider'),
|
|
|
|
|
sort: true
|
|
|
|
|
},
|
|
|
|
|
actions: {
|
|
|
|
|
label: '',
|
|
|
|
|
sort: false
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const filteredDomains = computed(() => {
|
|
|
|
|
if (!search.value) return domains.value;
|
|
|
|
|
|
|
|
|
|
return domains.value.filter(d => {
|
|
|
|
|
return d.domain.indexOf(search.value) !== -1 || d.provider.indexOf(search.value) !== -1;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2025-01-28 21:25:12 +01:00
|
|
|
async function refreshDomains() {
|
|
|
|
|
const [error, result] = await domainsModel.list();
|
2025-01-27 22:20:26 +01:00
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
domains.value = result;
|
2025-01-28 21:25:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await refreshDomains();
|
2025-01-27 22:20:26 +01:00
|
|
|
|
2025-01-28 21:25:12 +01:00
|
|
|
const [error, result] = await dashboardModel.getConfig();
|
2025-01-27 22:20:26 +01:00
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
dashboardDomain.value = result.adminDomain;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="content">
|
2025-01-28 21:25:12 +01:00
|
|
|
<InputDialog ref="inputDialog" />
|
2025-01-29 16:29:21 +01:00
|
|
|
<DomainDialog ref="domainDialog" @success="refreshDomains()"/>
|
2025-01-30 14:29:46 +01:00
|
|
|
<WellKnownDialog ref="wellKnownDialog" @success="refreshDomains()"/>
|
2025-01-28 13:55:58 +01:00
|
|
|
|
2025-01-27 22:20:26 +01:00
|
|
|
<Section :title="$t('domains.title')">
|
|
|
|
|
<template #header-buttons>
|
2025-01-28 13:55:58 +01:00
|
|
|
<TextInput v-model="search" :placeholder="$t('main.searchPlaceholder')"/>
|
|
|
|
|
<Button @click="onAdd()" icon="fa-solid fa-plus"> {{ $t('domains.addDomain') }}</Button>
|
2025-01-27 22:20:26 +01:00
|
|
|
</template>
|
|
|
|
|
|
2025-01-29 16:29:21 +01:00
|
|
|
<p>{{ $t('domains.domainDialog.addDescription') }}</p>
|
|
|
|
|
|
2025-01-31 13:02:47 +01:00
|
|
|
<TableView :model="filteredDomains" :columns="columns" style="max-height: 200px;" @row-click="onEdit" :hover="false">
|
2025-01-28 13:55:58 +01:00
|
|
|
<template #provider="domain">
|
|
|
|
|
{{ prettyProviderName(domain) }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #actions="domain">
|
|
|
|
|
<div class="table-actions">
|
|
|
|
|
<ButtonGroup>
|
2025-01-30 14:29:46 +01:00
|
|
|
<Button tool outline small secondary @click.stop="wellKnownDialog.open(domain)" v-tooltip="$t('domains.tooltipWellKnown')" icon="fa-solid fa-atlas" />
|
2025-01-29 20:35:56 +01:00
|
|
|
<Button tool outline small secondary @click.stop="onEdit(domain)" v-tooltip="$t('domains.tooltipEdit')" icon="fa-solid fa-pencil-alt" />
|
2025-01-28 13:55:58 +01:00
|
|
|
</ButtonGroup>
|
2025-01-29 20:35:56 +01:00
|
|
|
<Button tool outline small danger @click.stop="onRemove(domain)" v-tooltip="$t('domains.tooltipRemove')" :disabled="domain.domain === dashboardDomain" icon="fa-solid fa-trash-alt" />
|
2025-01-28 13:55:58 +01:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</TableView>
|
2025-01-27 22:20:26 +01:00
|
|
|
</Section>
|
|
|
|
|
|
|
|
|
|
<Certificates />
|
|
|
|
|
<SyncDns />
|
|
|
|
|
<DashboardDomain />
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|