<script setup>
// Copyright 2024 FlexCDN root@flexcdn.cn. All rights reserved. Official site: https://flexcdn.cn .

import PopupLayout from "@/layouts/PopupLayout.vue";
import ctxRef from "@/utils/ctx_ref.js"
import Context from "./removeDeniedIPPopup.js"
import PostForm from "@/components/form/PostForm.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";
import TSelect from "@/components/ui/TSelect.vue";
import TOption from "@/components/ui/TOption.vue";
import TInputText from "@/components/ui/TInputText.vue";
import {ref} from "vue";

const ipRef = ref()
const serverNameRef = ref()
const ctx = ctxRef(new Context(), {
	refs: {ipRef, serverNameRef}
})

</script>

<template>
	<PopupLayout>
		<header>快速解除黑名单</header>

		<PostForm action="$" @success="ctx.success">
			<DefinitionTable>
				<tbody>
				<tr>
					<td>对象类型</td>
					<td>
						<TSelect name="targetType" v-model="ctx.targetType" @change="ctx.changeTargetType">
							<TOption name="单个IP" value="ip"></TOption>
							<TOption name="网站" value="server"></TOption>
						</TSelect>
					</td>
				</tr>
				<tr v-if="ctx.targetType == 'ip'">
					<td>IP</td>
					<td>
						<TInputText name="ip" maxlength="64" class="w-full" ref="ipRef" autofocus/>
					</td>
				</tr>
				<tr v-if="ctx.targetType == 'server'">
					<td>网站域名</td>
					<td>
						<TInputText name="serverName" maxlength="64" class="w-full" ref="serverNameRef"/>
					</td>
				</tr>
				</tbody>
			</DefinitionTable>
			<SubmitButton>解除</SubmitButton>
		</PostForm>
	</PopupLayout>
</template>

<style lang="postcss" scoped>
</style>