|
|
|
@ -332,6 +332,31 @@
|
|
|
|
|
<el-input clearable v-model.trim="dialogData.rowData!.url" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
<el-form-item prop="hasAlert" v-if="alertTypes.includes(dialogData.rowData!.type)"> |
|
|
|
|
<el-checkbox v-model="dialogData.rowData!.hasAlert" :label="$t('alert.isAlert')" /> |
|
|
|
|
<span class="input-help">{{ $t('alert.cronJobHelper') }}</span> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item |
|
|
|
|
prop="alertCount" |
|
|
|
|
v-if="dialogData.rowData!.hasAlert && isProductPro" |
|
|
|
|
:label="$t('alert.alertCount')" |
|
|
|
|
> |
|
|
|
|
<el-input-number |
|
|
|
|
style="width: 200px" |
|
|
|
|
:min="1" |
|
|
|
|
step-strictly |
|
|
|
|
:step="1" |
|
|
|
|
v-model.number="dialogData.rowData!.alertCount" |
|
|
|
|
></el-input-number> |
|
|
|
|
<span class="input-help">{{ $t('alert.alertCountHelper') }}</span> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item v-if="dialogData.rowData!.hasAlert && !isProductPro"> |
|
|
|
|
<span>{{ $t('alert.licenseHelper') }}</span> |
|
|
|
|
<el-button link type="primary" @click="toUpload"> |
|
|
|
|
{{ $t('license.levelUpPro') }} |
|
|
|
|
</el-button> |
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
<el-form-item |
|
|
|
|
v-if="hasExclusionRules()" |
|
|
|
|
:label="$t('cronjob.exclusionRules')" |
|
|
|
@ -357,6 +382,7 @@
|
|
|
|
|
</el-button> |
|
|
|
|
</span> |
|
|
|
|
</template> |
|
|
|
|
<LicenseImport ref="licenseRef" /> |
|
|
|
|
</el-drawer> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
@ -378,6 +404,9 @@ import { listContainer } from '@/api/modules/container';
|
|
|
|
|
import { Database } from '@/api/interface/database'; |
|
|
|
|
import { ListAppInstalled } from '@/api/modules/app'; |
|
|
|
|
import { loadDefaultSpec, specOptions, transObjToSpec, transSpecToObj, weekOptions } from './../helper'; |
|
|
|
|
import { storeToRefs } from 'pinia'; |
|
|
|
|
import { GlobalStore } from '@/store'; |
|
|
|
|
import LicenseImport from '@/components/license-import/index.vue'; |
|
|
|
|
|
|
|
|
|
const router = useRouter(); |
|
|
|
|
|
|
|
|
@ -393,6 +422,11 @@ const dialogData = ref<DialogProps>({
|
|
|
|
|
title: '', |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const globalStore = GlobalStore(); |
|
|
|
|
const licenseRef = ref(); |
|
|
|
|
const { isProductPro } = storeToRefs(globalStore); |
|
|
|
|
const alertTypes = ['app', 'website', 'database', 'directory', 'log', 'snapshot']; |
|
|
|
|
|
|
|
|
|
const acceptParams = (params: DialogProps): void => { |
|
|
|
|
dialogData.value = params; |
|
|
|
|
if (dialogData.value.rowData?.spec) { |
|
|
|
@ -419,6 +453,8 @@ const acceptParams = (params: DialogProps): void => {
|
|
|
|
|
if (dialogData.value.rowData.dbName) { |
|
|
|
|
dialogData.value.rowData.dbNameList = dialogData.value.rowData.dbName.split(','); |
|
|
|
|
} |
|
|
|
|
dialogData.value.rowData.hasAlert = dialogData.value.rowData!.alertCount > 0; |
|
|
|
|
dialogData.value.rowData!.alertCount = dialogData.value.rowData!.alertCount || 3; |
|
|
|
|
dialogData.value.rowData!.command = dialogData.value.rowData!.command || 'sh'; |
|
|
|
|
dialogData.value.rowData!.isCustom = |
|
|
|
|
dialogData.value.rowData!.command !== 'sh' && |
|
|
|
@ -556,6 +592,18 @@ const verifySpec = (rule: any, value: any, callback: any) => {
|
|
|
|
|
callback(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function checkSendCount(rule: any, value: any, callback: any) { |
|
|
|
|
if (value === '') { |
|
|
|
|
callback(); |
|
|
|
|
} |
|
|
|
|
const regex = /^(?:[1-9]|[12][0-9]|30)$/; |
|
|
|
|
if (!regex.test(value)) { |
|
|
|
|
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 30]))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callback(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const rules = reactive({ |
|
|
|
|
name: [Rules.requiredInput, Rules.noSpace], |
|
|
|
|
type: [Rules.requiredSelect], |
|
|
|
@ -574,6 +622,7 @@ const rules = reactive({
|
|
|
|
|
backupAccounts: [Rules.requiredSelect], |
|
|
|
|
defaultDownload: [Rules.requiredSelect], |
|
|
|
|
retainCopies: [Rules.number], |
|
|
|
|
alertCount: [Rules.integerNumber, { validator: checkSendCount, trigger: 'blur' }], |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
type FormInstance = InstanceType<typeof ElForm>; |
|
|
|
@ -752,6 +801,17 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
|
|
|
|
if (dialogData.value?.rowData?.exclusionRules) { |
|
|
|
|
dialogData.value.rowData.exclusionRules = dialogData.value.rowData.exclusionRules.replaceAll('\n', ','); |
|
|
|
|
} |
|
|
|
|
if (alertTypes.includes(dialogData.value.rowData.type)) { |
|
|
|
|
dialogData.value.rowData.alertCount = |
|
|
|
|
dialogData.value.rowData!.hasAlert && isProductPro.value ? dialogData.value.rowData.alertCount : 0; |
|
|
|
|
dialogData.value.rowData.alertTitle = |
|
|
|
|
dialogData.value.rowData!.hasAlert && isProductPro.value |
|
|
|
|
? i18n.global.t('cronjob.alertTitle', [ |
|
|
|
|
i18n.global.t('cronjob.' + dialogData.value.rowData.type), |
|
|
|
|
dialogData.value.rowData.name, |
|
|
|
|
]) |
|
|
|
|
: ''; |
|
|
|
|
} |
|
|
|
|
if (!dialogData.value.rowData) return; |
|
|
|
|
if (dialogData.value.title === 'create') { |
|
|
|
|
await addCronjob(dialogData.value.rowData); |
|
|
|
@ -766,6 +826,10 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const toUpload = () => { |
|
|
|
|
licenseRef.value.acceptParams(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
defineExpose({ |
|
|
|
|
acceptParams, |
|
|
|
|
}); |
|
|
|
|