<script setup>
import TInputText from "@/components/ui/TInputText.vue";
import CodeLabel from "@/components/common/CodeLabel.vue";
import TSelect from "@/components/ui/TSelect.vue";
import TOption from "@/components/ui/TOption.vue";
import TInputGroup from "@/components/ui/TInputGroup.vue";
import TInputGroupAddon from "@/components/ui/TInputGroupAddon.vue";
import HTTPOSSBucketParams from "@/components/server/HTTPOSSBucketParams.vue";

const props = defineProps(["ctx"])
</script>

<template>
	<!-- 腾讯云COS -->
	<tbody v-if="ctx.origin.protocol == 'oss:tencentCOS'">
	<tr>
		<td>密钥ID *<br/><em>(Secret Id)</em></td>
		<td>
			<TInputText type="text" name="tencentCOSSecretId" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.secretId"/>
			<p class="comment">访问存储桶需要的密钥ID。</p>
		</td>
	</tr>
	<tr>
		<td>密钥Key *<br/><em>(Secret Key)</em></td>
		<td>
			<TInputText type="text" name="tencentCOSSecretKey" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.secretKey"/>
			<p class="comment">访问存储桶需要的密钥Key。</p>
		</td>
	</tr>
	<tr>
		<td>所属区域代号 *</td>
		<td>
			<TInputText type="text" name="tencentCOSRegion" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.region"/>
			<p class="comment">COS服务所属区域代号，类似于
				<CodeLabel>ap-beijing</CodeLabel>
				。
			</p>
		</td>
	</tr>
	</tbody>

	<!-- 阿里云OSS -->
	<tbody v-if="ctx.origin.protocol == 'oss:aliyunOSS'">
	<tr>
		<td>密钥ID *<br/><em>(AccessKey Id)</em></td>
		<td>
			<TInputText type="text" name="aliyunOSSAccessKeyId" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.accessKeyId"/>
			<p class="comment">访问存储空间需要的密钥ID。</p>
		</td>
	</tr>
	<tr>
		<td>密钥Key *<br/><em>(AccessKey Secret)</em></td>
		<td>
			<TInputText type="text" name="aliyunOSSAccessKeySecret" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.accessKeySecret"/>
			<p class="comment">访问存储空间需要的密钥Key。</p>
		</td>
	</tr>
	<tr>
		<td>地域节点 *</td>
		<td>
			<TInputText type="text" name="aliyunOSSEndpoint" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.endpoint"/>
			<p class="comment">地域节点域名（Endpoint），类似于
				<CodeLabel>oss-cn-shanghai.aliyuncs.com</CodeLabel>
				。
			</p>
		</td>
	</tr>
	</tbody>

	<!-- 华为云 -->
	<tbody v-if="ctx.origin.protocol == 'oss:huaweiOBS'">
	<tr>
		<td>密钥ID *<br/><em>(AccessKey Id)</em></td>
		<td>
			<TInputText type="text" name="huaweiOBSAccessKeyId" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.accessKeyId"/>
			<p class="comment">访问存储桶需要的密钥ID。</p>
		</td>
	</tr>
	<tr>
		<td>密钥Key *<br/><em>(AccessKey Secret)</em></td>
		<td>
			<TInputText type="text" name="huaweiOBSAccessKeySecret" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.accessKeySecret"/>
			<p class="comment">访问存储桶需要的密钥Key。</p>
		</td>
	</tr>
	<tr>
		<td>区域Endpoint *</td>
		<td>
			<TInputGroup>
				<TInputGroupAddon>
					<span>https://</span>
				</TInputGroupAddon>
				<TInputText type="text" name="huaweiOBSEndpoint" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.endpoint"/>
			</TInputGroup>
			<p class="comment">区域Endpoint域名，类似于
				<CodeLabel>obs.cn-north-4.myhuaweicloud.com</CodeLabel>
				。
			</p>
		</td>
	</tr>
	</tbody>

	<!-- 百度云 -->
	<tbody v-if="ctx.origin.protocol == 'oss:baiduBOS'">
	<tr>
		<td>Access Key *</td>
		<td>
			<TInputText type="text" name="baiduBOSAccessKey" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.accessKey"/>
			<p class="comment">访问Bucket需要的Access Key。</p>
		</td>
	</tr>
	<tr>
		<td>Secret Key *</td>
		<td>
			<TInputText type="text" name="baiduBOSSecretKey" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.secretKey"/>
			<p class="comment">访问存储桶需要的Secret Key。</p>
		</td>
	</tr>
	<tr>
		<td>区域Endpoint *</td>
		<td>
			<TInputGroup>
				<TInputGroupAddon>
					<span>https://</span>
				</TInputGroupAddon>
				<TInputText type="text" name="baiduBOSEndpoint" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.endpoint"/>
			</TInputGroup>
			<p class="comment">区域Endpoint域名，类似于
				<CodeLabel>bj.bcebos.com</CodeLabel>
				。
			</p>
		</td>
	</tr>
	</tbody>

	<!-- 七牛云 -->
	<tbody v-if="ctx.origin.protocol == 'oss:qiniuKodo'">
	<tr>
		<td>AccessKey *<br/><em>(AccessKey)</em></td>
		<td>
			<TInputText type="text" name="qiniuKodoAccessKey" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.accessKey"/>
			<p class="comment">访问存储空间需要的密钥ID。</p>
		</td>
	</tr>
	<tr>
		<td>SecretKey *<br/><em>(SecretKey)</em></td>
		<td>
			<TInputText type="text" name="qiniuKodoSecretKey" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.secretKey"/>
			<p class="comment">访问存储空间需要的密钥Key。</p>
		</td>
	</tr>
	<tr>
		<td>域名</td>
		<td>
			<div class="ui fields inline">
				<div class="ui field">
					<TSelect name="qiniuKodoProtocol" v-model="ctx.origin.oss.options.protocol">
						<TOption value="http">http://</TOption>
						<TOption value="https">https://</TOption>
					</TSelect>
				</div>
				<div class="ui field">
					<TInputText type="text" name="qiniuKodoDomain" v-model="ctx.origin.oss.options.domain" style="width: 20em"/>
				</div>
			</div>
		</td>
	</tr>
	<tr>
		<td>访问控制</td>
		<td>
			<TSelect name="qiniuKodoIsPublic" v-model="ctx.origin.oss.options.isPublic">
				<TOption :value="false">私有</TOption>
				<TOption :value="true">公开</TOption>
			</TSelect>
		</td>
	</tr>
	</tbody>

	<!-- Amazon S3 -->
	<tbody v-if="ctx.origin.protocol == 'oss:amazonS3' || ctx.origin.protocol == 'oss:b2'">
	<tr>
		<td>密钥ID *<br/><em>(AK)</em></td>
		<td>
			<TInputText type="text" name="amazonS3AccessKeyId" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.accessKeyId"/>
			<p class="comment">访问存储桶需要的密钥ID。</p>
		</td>
	</tr>
	<tr>
		<td>密钥Key *<br/><em>(SK)</em></td>
		<td>
			<TInputText type="text" name="amazonS3AccessKeySecret" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.accessKeySecret"/>
			<p class="comment">访问存储桶需要的密钥Key。</p>
		</td>
	</tr>
	<tr>
		<td>区域代号 *<br/><em>(Region)</em></td>
		<td>
			<TInputText type="text" name="amazonS3Region" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.region"/>
			<p class="comment">所属区域代号，类似于
				<CodeLabel>us-east-2</CodeLabel>
				。
			</p>
		</td>
	</tr>
	<tr>
		<td>Endpoint<span v-if="ctx.origin.protocol != 'oss:amazonS3'">*</span></td>
		<td>
			<TInputText type="text" name="amazonS3Endpoint" maxlength="100" class="w-full" v-model="ctx.origin.oss.options.endpoint"/>
			<p class="comment">Endpoint域名，只有非AWS应用时才需要填写。</p>
		</td>
	</tr>
	<tr>
		<td>Endpoint中存储桶访问样式</td>
		<td>
			<TSelect name="bucketAddressStyle" v-model="ctx.origin.oss.options.bucketAddressStyle">
				<TOption value="path">路径</TOption>
				<TOption value="domain">子域名</TOption>
			</TSelect>
		</td>
	</tr>
	</tbody>

	<!-- 存储桶名称 -->
	<template v-for="ossType in ctx.ossTypes">
		<HTTPOSSBucketParams v-if="ctx.origin.protocol == ossType.code" :v-params="ctx.ossBucketParams" :name="ossType.bucketOptionName" :v-oss-config="ctx.origin.oss"></HTTPOSSBucketParams>
	</template>

</template>