Feat: Global config override (#1720)
* be able to change dns. implement global override * link donate to readme * implement global config for allowed ips * change translations, fix generation * improve docs
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-2">
|
||||
<div v-if="data === null">
|
||||
{{ emptyText || $t('form.nullNoItems') }}
|
||||
</div>
|
||||
<div v-for="(item, i) in data" v-else :key="i">
|
||||
<div class="mt-1 flex flex-row gap-1">
|
||||
<input
|
||||
:value="item"
|
||||
:name="name"
|
||||
type="text"
|
||||
class="rounded-lg border-2 border-gray-100 text-gray-500 focus:border-red-800 focus:outline-0 focus:ring-0 dark:border-neutral-800 dark:bg-neutral-700 dark:text-neutral-200 dark:placeholder:text-neutral-400"
|
||||
@input="update($event, i)"
|
||||
/>
|
||||
<BaseButton
|
||||
as="input"
|
||||
type="button"
|
||||
class="rounded-lg"
|
||||
value="-"
|
||||
@click="del(i)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<BaseButton
|
||||
as="input"
|
||||
type="button"
|
||||
class="rounded-lg"
|
||||
:value="$t('form.add')"
|
||||
@click="add"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const data = defineModel<string[] | null>();
|
||||
defineProps<{ emptyText?: string[]; name: string }>();
|
||||
|
||||
function update(e: Event, i: number) {
|
||||
const v = (e.target as HTMLInputElement).value;
|
||||
if (!data.value) {
|
||||
return;
|
||||
}
|
||||
data.value[i] = v;
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (data.value === undefined) {
|
||||
return;
|
||||
}
|
||||
if (data.value === null) {
|
||||
data.value = [''];
|
||||
} else {
|
||||
data.value.push('');
|
||||
}
|
||||
}
|
||||
|
||||
function del(i: number) {
|
||||
if (!data.value) {
|
||||
return;
|
||||
}
|
||||
data.value.splice(i, 1);
|
||||
if (data.value.length === 0) {
|
||||
data.value = null;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -24,7 +24,7 @@
|
||||
·
|
||||
<a
|
||||
class="hover:underline"
|
||||
href="https://github.com/sponsors/WeeJeWel"
|
||||
href="https://github.com/wg-easy/wg-easy#donate"
|
||||
target="_blank"
|
||||
>{{ $t('layout.donate') }}</a
|
||||
>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<FormHeading :description="$t('admin.config.dnsDesc')">{{
|
||||
$t('admin.config.dns')
|
||||
$t('general.dns')
|
||||
}}</FormHeading>
|
||||
<FormArrayField v-model="data.defaultDns" name="defaultDns" />
|
||||
</FormGroup>
|
||||
|
||||
@@ -41,21 +41,26 @@
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<FormHeading :description="$t('client.allowedIpsDesc')">{{
|
||||
$t('general.allowedIps')
|
||||
}}</FormHeading>
|
||||
<FormArrayField v-model="data.allowedIps" name="allowedIps" />
|
||||
<FormHeading :description="$t('client.allowedIpsDesc')">
|
||||
{{ $t('general.allowedIps') }}
|
||||
</FormHeading>
|
||||
<FormNullArrayField v-model="data.allowedIps" name="allowedIps" />
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<FormHeading :description="$t('client.serverAllowedIpsDesc')">{{
|
||||
$t('client.serverAllowedIps')
|
||||
}}</FormHeading>
|
||||
<FormHeading :description="$t('client.serverAllowedIpsDesc')">
|
||||
{{ $t('client.serverAllowedIps') }}
|
||||
</FormHeading>
|
||||
<FormArrayField
|
||||
v-model="data.serverAllowedIps"
|
||||
name="serverAllowedIps"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup></FormGroup>
|
||||
<FormGroup>
|
||||
<FormHeading :description="$t('client.dnsDesc')">
|
||||
{{ $t('general.dns') }}
|
||||
</FormHeading>
|
||||
<FormNullArrayField v-model="data.dns" name="dns" />
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<FormHeading>{{ $t('form.sectionAdvanced') }}</FormHeading>
|
||||
<FormNumberField
|
||||
@@ -142,8 +147,12 @@ const _submit = useSubmit(
|
||||
method: 'post',
|
||||
},
|
||||
{
|
||||
revert: async () => {
|
||||
await navigateTo('/');
|
||||
revert: async (success) => {
|
||||
if (success) {
|
||||
await navigateTo('/');
|
||||
} else {
|
||||
await revert();
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user