diff --git a/components.d.ts b/components.d.ts index b2a3519..bc504fa 100644 --- a/components.d.ts +++ b/components.d.ts @@ -40,9 +40,11 @@ declare module 'vue' { NGrid: typeof import('naive-ui')['NGrid'] NH3: typeof import('naive-ui')['NH3'] NH4: typeof import('naive-ui')['NH4'] + NIcon: typeof import('naive-ui')['NIcon'] NInput: typeof import('naive-ui')['NInput'] NInputGroup: typeof import('naive-ui')['NInputGroup'] NInputGroupLabel: typeof import('naive-ui')['NInputGroupLabel'] + NInputNum: typeof import('naive-ui')['NInputNum'] NInputNumber: typeof import('naive-ui')['NInputNumber'] NLayout: typeof import('naive-ui')['NLayout'] NLayoutSider: typeof import('naive-ui')['NLayoutSider'] diff --git a/components/buckets/info.vue b/components/buckets/info.vue index 92aec12..e6abf41 100644 --- a/components/buckets/info.vue +++ b/components/buckets/info.vue @@ -1,24 +1,25 @@ - + - 访问策略 + {{ t("Access Policy") }} {{ policyOptions.find((item) => item.value === bucketPolicy)?.label }} + - 加密类型 + {{ t("Encryption") }} - 禁用 + {{ t("Disabled") }} - 标签 + {{ t("Tag") }} @@ -48,7 +49,7 @@ - 对象锁 + {{ t("Object Lock") }} - 版本控制 + {{ t("Version Control") }} + + + + + + {{ t("Retention") }} + + {{ t("Enabled") }} + + + + + + {{ t("Disabled") }} + + + + + + + {{ t("Retention Mode") }} + {{ t(retentionFormValue.retentionMode || "") }} + - 保留 - - - - - - {{ t("Retention Mode") }}: - - Compliance - Governance - - - - {{ t("Validity") }}* - - - - - - - - + {{ t("Retention Unit") }} + {{ t(retentionFormValue.retentionUnit || "") }} + + + {{ t("Retention Period") }} + {{ retentionFormValue.retentionPeriod || "" }} - + - - + + - + - 确认 - 取消 + {{ t("Confirm") }} + {{ t("Cancel") }} - + - + - - + + - 确认 - 取消 + {{ t("Confirm") }} + {{ t("Cancel") }} @@ -139,21 +151,57 @@ - - + + - 确认 - 取消 + {{ t("Confirm") }} + {{ t("Cancel") }} + + + + + + + + + + Compliance + Governance + + + + + + {{ t("DAYS") }} + {{ t("YEARS") }} + + + + + + + + + {{ t("Confirm") }} + {{ t("Cancel") }} @@ -161,7 +209,7 @@ - +/********retention ***********************/ +interface RetentionFormValue { + retentionMode: string | null; + retentionPeriod: number | null; + retentionUnit: string | null; +} + +const showRetentionModal = ref(false); +const retentionFormValue = ref({ + retentionMode: null, + retentionPeriod: null, + retentionUnit: null, +}); + +const editRetention = () => { + showRetentionModal.value = true; +}; + +const submitRetentionForm = () => { + console.log(retentionFormValue.value); + if ( + retentionFormValue.value.retentionMode == null || + retentionFormValue.value.retentionPeriod == null || + retentionFormValue.value.retentionUnit == null + ) { + message.error("请填写完整的保留信息"); + return; + } + + putObjectLockConfiguration(bucketName.value, { + ObjectLockEnabled: "Enabled", + Rule: { + DefaultRetention: { + Mode: retentionFormValue.value.retentionMode, + Days: retentionFormValue.value.retentionUnit == "Days" ? retentionFormValue.value.retentionPeriod : null, + Years: retentionFormValue.value.retentionUnit == "Years" ? retentionFormValue.value.retentionPeriod : null, + }, + }, + }).then(() => { + message.success("修改成功"); + showRetentionModal.value = false; + getObjectLockConfig(); + }); +}; + +/********retention ***********************/ + diff --git a/composables/useBucket.ts b/composables/useBucket.ts index 6893809..a4e5ed1 100644 --- a/composables/useBucket.ts +++ b/composables/useBucket.ts @@ -17,7 +17,9 @@ import { PutObjectLockConfigurationCommand, PutObjectRetentionCommand, GetObjectRetentionCommand, - // GetBucketEncryptionCommand, + GetBucketEncryptionCommand, + PutBucketEncryptionCommand, + DeleteBucketEncryptionCommand, GetBucketLifecycleConfigurationCommand, PutBucketLifecycleConfigurationCommand, DeleteBucketLifecycleCommand, @@ -173,6 +175,26 @@ export function useBucket({ region }: { region?: string }) { return await $client.send(new GetObjectRetentionCommand(params)); }; + const getBucketEncryption = async (bucket: string) => { + const params = { + Bucket: bucket, + }; + return await $client.send(new GetBucketEncryptionCommand(params)); + }; + const putBucketEncryption = async (bucket: string, encryption: any) => { + const params = { + Bucket: bucket, + ServerSideEncryptionConfiguration: encryption, + }; + return await $client.send(new PutBucketEncryptionCommand(params)); + }; + const deleteBucketEncryption = async (bucket: string) => { + const params = { + Bucket: bucket, + }; + return await $client.send(new DeleteBucketEncryptionCommand(params)); + }; + return { listBuckets, createBucket, @@ -193,5 +215,8 @@ export function useBucket({ region }: { region?: string }) { deleteBucketLifecycle, putObjectRetention, getObjectRetention, + getBucketEncryption, + putBucketEncryption, + deleteBucketEncryption, }; } diff --git a/i18n/locales/en-US.json b/i18n/locales/en-US.json index e2f3d26..215ec78 100644 --- a/i18n/locales/en-US.json +++ b/i18n/locales/en-US.json @@ -305,5 +305,27 @@ "Retention Mode": "Mode", "Validity": "Validity", "Day": "Day", - "Year": "Year" + "Year": "Year", + "DAYS": "DAYS", + "YEARS": "YEARS", + "Access Policy": "Access Policy", + "Encryption": "Encryption", + "Tag": "Tag", + "Set Policy": "Set Policy", + "Policy": "Policy", + "Policy Content": "Policy Content", + "Public": "Public", + "Private": "Private", + "Custom": "Custom", + "Set Tag": "Set Tag", + "Please enter tag value": "Please enter tag value", + "Enable Storage Encryption": "Enable Storage Encryption", + "Encryption Type": "Encryption Type", + "COMPLIANCE": "COMPLIANCE", + "GOVERNANCE": "GOVERNANCE", + "Retention Unit": "Retention Unit", + "Retention Period": "Retention Period", + "Please enter retention period": "Please enter retention period", + "Please select retention unit": "Please select retention unit", + "Set Retention": "Set Retention" } diff --git a/i18n/locales/zh-CN.json b/i18n/locales/zh-CN.json index 7d63d27..4824337 100644 --- a/i18n/locales/zh-CN.json +++ b/i18n/locales/zh-CN.json @@ -497,5 +497,27 @@ "Retention Mode": "保留模式", "Validity": "有效期", "Day": "天", - "Year": "年" + "Year": "年", + "DAYS": "天", + "YEARS": "年", + "Access Policy": "访问策略", + "Encryption": "加密", + "Tag": "标签", + "Set Policy": "设置策略", + "Policy": "策略", + "Policy Content": "策略原文", + "Public": "公有", + "Private": "私有", + "Custom": "自定义", + "Set Tag": "设置标签", + "Please enter tag value": "请输入标签值", + "Enable Storage Encryption": "启用存储空间加密", + "Encryption Type": "加密类型", + "COMPLIANCE": "合规", + "GOVERNANCE": "治理", + "Retention Unit": "保留单位", + "Retention Period": "保留期限", + "Please enter retention period": "请输入保留期限", + "Please select retention unit": "请选择保留单位", + "Set Retention": "设置保留" }