Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions agent/app/service/cronjob_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,17 @@ func (u *CronjobService) handleShell(cronjob model.Cronjob, taskItem *task.Task)
}

func (u *CronjobService) handleCurl(cronjob model.Cronjob, taskItem *task.Task) {
taskItem.AddSubTaskWithOps(i18n.GetWithName("HandleShell", cronjob.Name), func(t *task.Task) error {
cmdMgr := cmd.NewCommandMgr(cmd.WithTask(*taskItem))
return cmdMgr.Run("curl", cronjob.URL)
}, nil, int(cronjob.RetryTimes), time.Duration(cronjob.Timeout)*time.Second)
urls := strings.Split(cronjob.URL, ",")
for _, url := range urls {
if len(strings.TrimSpace(url)) == 0 {
continue
}
taskItem.AddSubTaskWithOps(i18n.GetWithName("HandleCurl", url), func(t *task.Task) error {
taskItem.LogStart(i18n.GetWithName("HandleCurl", url))
cmdMgr := cmd.NewCommandMgr(cmd.WithTask(*taskItem))
return cmdMgr.Run("curl", url)
}, nil, int(cronjob.RetryTimes), time.Duration(cronjob.Timeout)*time.Second)
}
}

func (u *CronjobService) handleNtpSync(cronjob model.Cronjob, taskItem *task.Task) {
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ ErrUserFindErr: 'User {{ .name }} search failed {{ .err }}'
#cronjob
CutWebsiteLogSuccess: '{{ .name }} website log cut successfully, backup path {{ .path }}'
HandleShell: 'Execute script {{ .name }}'
HandleCurl: "Access URL {{ .name }}"
HandleNtpSync: 'System time synchronization'
HandleSystemClean: 'System cache cleanup'
SystemLog: 'System Log'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/es-ES.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ ErrUserFindErr: 'Búsqueda del usuario {{ .name }} fallida {{ .err }}'
#cronjob
CutWebsiteLogSuccess: 'Log del sitio web {{ .name }} cortado con éxito, ruta de respaldo {{ .path }}'
HandleShell: 'Ejecutar script {{ .name }}'
HandleCurl: "URL {{ .name }} にアクセス"
HandleNtpSync: 'Sincronizar hora del sistema'
HandleSystemClean: 'Limpiar caché del sistema'
SystemLog: 'Log del sistema'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ ErrUserFindErr: 'ユーザー {{ .name }} の検索に失敗しました {{ .err
#cronjob
CutWebsiteLogSuccess: '{{ .name }} ウェブサイトのログが正常にカットされました。バックアップ パス {{ .path }}'
HandleShell: 'スクリプト {{ .name }} を実行します'
HandleCurl: "URL {{ .name }} にアクセス"
HandleNtpSync: 'システム時刻の同期'
HandleSystemClean: 'システム キャッシュのクリーンアップ'
SystemLog: 'システムログ'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ ErrUserFindErr: '사용자 {{ .name }} 검색에 실패했습니다 {{ .err }}'
#크론잡
CutWebsiteLogSuccess: '{{ .name }} 웹사이트 로그가 성공적으로 잘렸습니다. 백업 경로 {{ .path }}'
HandleShell: '스크립트 {{ .name }} 실행'
HandleCurl: "URL {{ .name }} 접근"
HandleNtpSync: '시스템 시간 동기화'
HandleSystemClean: '시스템 캐시 정리'
SystemLog: '시스템 로그'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/ms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ ErrUserFindErr: 'Pengguna {{ .name }} carian gagal {{ .err }}'
#cronjob
CutWebsiteLogSuccess: '{{ .name }} log tapak web berjaya dipotong, laluan sandaran {{ .path }}'
HandleShell: 'Laksanakan skrip {{ .name }}'
HandleCurl: "Akses URL {{ .name }}"
HandleNtpSync: 'Penyegerakan masa sistem'
HandleSystemClean: 'Pembersihan cache sistem'
SystemLog: 'Log Sistem'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/pt-BR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ ErrUserFindErr: 'Falha na pesquisa do usuário {{ .name }} {{ .err }}'
#cronjob
CutWebsiteLogSuccess: '{{ .name }} registro do site cortado com sucesso, caminho de backup {{ .path }}'
HandleShell: 'Executar script {{ .name }}'
HandleCurl: "Acessar URL {{ .name }}"
HandleNtpSync: 'Sincronização de hora do sistema'
HandleSystemClean: 'Limpeza de cache do sistema'
SystemLog: 'Log do Sistema'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ ErrUserFindErr: 'Поиск пользователя {{ .name }} не удалс
#cronjob
CutWebsiteLogSuccess: 'Журнал веб-сайта {{ .name }} успешно вырезан, путь к резервной копии {{ .path }}'
HandleShell: 'Выполнить скрипт {{ .name }}'
HandleCurl: "Доступ к URL {{ .name }}"
HandleNtpSync: 'Синхронизация системного времени'
HandleSystemClean: 'Очистка системного кэша'
SystemLog: 'Системный лог'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/tr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ ErrUserFindErr: 'Kullanıcı {{ .name }} arama başarısız {{ .err }}'
#cronjob
CutWebsiteLogSuccess: '{{ .name }} web sitesi günlüğü başarıyla kesildi, yedekleme yolu {{ .path }}'
HandleShell: 'Betik {{ .name }} yürüt'
HandleCurl: "URL'ye Eriş {{ .name }}"
HandleNtpSync: 'Sistem zaman senkronizasyonu'
HandleSystemClean: 'Sistem önbellek temizliği'
SystemLog: 'Sistem Günlüğü'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/zh-Hant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ ErrUserFindErr: '使用者{{ .name }} 尋找失敗{{ .err }}'
#cronjob
CutWebsiteLogSuccess: '{{ .name }} 網站日誌切割成功,備份路徑{{ .path }}'
HandleShell: '執行腳本{{ .name }}'
HandleCurl: "存取 URL {{ .name }}"
HandleNtpSync: '系統時間同步'
HandleSystemClean: '系統快取清理'
SystemLog: '系統日誌'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ ErrUserFindErr: "用户 {{ .name }} 查找失败 {{ .err }}"
#cronjob
CutWebsiteLogSuccess: "{{ .name }} 网站日志切割成功,备份路径 {{ .path }}"
HandleShell: "执行脚本 {{ .name }}"
HandleCurl: "访问 URL {{ .name }}"
HandleNtpSync: "系统时间同步"
HandleSystemClean: "系统缓存清理"
SystemLog: "系统日志"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/api/interface/cronjob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export namespace Cronjob {
dbType: string;
dbName: string;
url: string;
urlItems: Array<string>;
isDir: boolean;
files: Array<Item>;
sourceDir: string;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ const message = {
default_download_path: 'Default download link',
saveLocal: 'Retain local backups (the same as the number of cloud storage copies)',
url: 'URL Address',
urlHelper: 'Please enter a valid URL address',
targetHelper: 'Backup accounts are maintained in panel settings.',
withImageHelper: 'Backup app store images, but this will increase the snapshot file size.',
ignoreApp: 'Exclude apps',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/es-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ const message = {
default_download_path: 'Enlace de descarga predeterminado',
saveLocal: 'Retener respaldos locales (igual al número de copias en la nube)',
url: 'Dirección URL',
urlHelper: 'Por favor ingrese una dirección URL válida',
targetHelper: 'Las cuentas de respaldo se gestionan en los ajustes del panel.',
withImageHelper:
'Respalda imágenes de la tienda de aplicaciones, pero esto aumentará el tamaño del archivo de la instantánea.',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@ const message = {
default_download_path: 'デフォルトのダウンロードリンク',
saveLocal: 'ローカルバックアップを保持します(クラウドストレージコピーの数と同じ)',
url: 'URLアドレス',
urlHelper: '正しいURLアドレスを入力してください',
targetHelper: 'バックアップアカウントは、パネル設定で維持されます。',
withImageHelper:
'アプリストアのイメージをバックアップしますが、スナップショットファイルのサイズが大きくなります。',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ const message = {
default_download_path: '기본 다운로드 링크',
saveLocal: '로컬 백업 보관 (클라우드 저장소 복사본 수와 동일)',
url: 'URL 주소',
urlHelper: '올바른 URL 주소를 입력해 주세요',
targetHelper: '백업 계정은 패널 설정에서 관리됩니다.',
withImageHelper: '앱 스토어 이미지를 백업하지만 스냅샷 파일 크기가 증가합니다.',
ignoreApp: '앱 제외',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ const message = {
default_download_path: 'Pautan muat turun lalai',
saveLocal: 'Simpan sandaran tempatan (sama seperti bilangan salinan storan awan)',
url: 'Alamat URL',
urlHelper: 'Sila masukkan alamat URL yang sah',
targetHelper: 'Akaun sandaran diselenggara dalam tetapan panel.',
withImageHelper: 'Sandarkan imej kedai aplikasi, tetapi ini akan meningkatkan saiz fail snapshot.',
ignoreApp: 'Kecualikan aplikasi',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,7 @@ const message = {
default_download_path: 'Link de download padrão',
saveLocal: 'Manter backups locais (o mesmo número de cópias na nuvem)',
url: 'Endereço URL',
urlHelper: 'Por favor insira um endereço URL válido',
targetHelper: 'As contas de backup são mantidas nas configurações do painel.',
withImageHelper:
'Fazer backup das imagens da loja de aplicativos, mas isso aumentará o tamanho do arquivo de snapshot.',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ const message = {
default_download_path: 'Ссылка для скачивания по умолчанию',
saveLocal: 'Сохранять локальные резервные копии (столько же, сколько копий в облачном хранилище)',
url: 'URL-адрес',
urlHelper: 'Пожалуйста, введите действительный URL-адрес',
targetHelper: 'Учетные записи резервного копирования управляются в настройках панели.',
withImageHelper: 'Резервное копирование образов из магазина приложений увеличит размер файла снимка.',
ignoreApp: 'Исключить приложения',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ const message = {
default_download_path: 'Varsayılan indirme bağlantısı',
saveLocal: 'Yerel yedeklemeleri sakla (bulut depolama kopyalarının sayısı ile aynı)',
url: 'URL Adresi',
urlHelper: 'Lütfen geçerli bir URL adresi girin',
targetHelper: 'Yedekleme hesapları panel ayarlarında sürdürülür.',
withImageHelper: 'Uygulama mağazası imajlarını yedekle, ancak bu anlık görüntü dosya boyutunu artıracaktır.',
ignoreApp: 'Uygulamaları hariç tut',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ const message = {
default_download_path: '預設下載網址',
saveLocal: '同時保留本機備份(和雲端儲存保留份數一致)',
url: 'URL 地址',
urlHelper: '請輸入正確的 URL 地址',
targetHelper: '備份帳號可在面板設定中維護',
ignoreApp: '排除應用',
withImage: '備份所有應用鏡像',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@ const message = {
default_download_path: '默认下载地址',
saveLocal: '同时保留本地备份(和云存储保留份数一致)',
url: 'URL 地址',
urlHelper: '请输入正确的 URL 地址',
targetHelper: '备份账号可在面板设置中维护',
withImageHelper: '备份应用商店镜像,但是会增大快照文件体积。',
ignoreApp: '排除应用',
Expand Down
35 changes: 32 additions & 3 deletions frontend/src/views/cronjob/cronjob/operate/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,21 @@
</el-form-item>
</LayoutCol>
<LayoutCol v-if="form.type === 'curl'">
<el-form-item :label="$t('cronjob.url')" prop="url">
<el-input clearable v-model.trim="form.url" />
<el-form-item :label="$t('cronjob.url')" prop="urlItems">
<div v-for="(_, index) of form.urlItems" :key="index" class="w-full">
<el-input class="mt-2" v-model="form.urlItems[index]">
<template #append>
<el-button
link
icon="Delete"
@click="form.urlItems.splice(index, 1)"
/>
</template>
</el-input>
</div>
<el-button class="mt-2" @click="form.urlItems.push('')">
{{ $t('commons.button.add') }}
</el-button>
</el-form-item>
</LayoutCol>
</el-row>
Expand Down Expand Up @@ -837,6 +850,7 @@ const form = reactive<Cronjob.CronjobInfo>({
dbType: 'mysql',
dbName: '',
url: '',
urlItems: [],
isDir: true,
files: [],
sourceDir: '',
Expand Down Expand Up @@ -896,6 +910,7 @@ const search = async () => {

form.script = res.data.script;
form.scriptMode = res.data.scriptMode;
form.urlItems = res.data.url.split(',') || [];

form.containerName = res.data.containerName;
form.user = res.data.user;
Expand Down Expand Up @@ -1012,6 +1027,19 @@ const verifyScript = (rule: any, value: any, callback: any) => {
}
callback();
};
const verifyUrlItems = (rule: any, value: any, callback: any) => {
if (!form.urlItems || form.urlItems.length === 0) {
callback(new Error(i18n.global.t('commons.rule.requiredInput')));
return;
}
for (const item of form.urlItems) {
if (!item) {
callback(new Error(i18n.global.t('cronjob.urlHelper')));
return;
}
}
callback();
};

const verifySpec = (rule: any, value: any, callback: any) => {
if (form.specCustom) {
Expand Down Expand Up @@ -1151,7 +1179,7 @@ const rules = reactive({
websiteList: [Rules.requiredSelect],
appIdList: [Rules.requiredSelect],
dbNameList: [Rules.requiredSelect],
url: [Rules.requiredInput],
urlItems: [{ validator: verifyUrlItems, trigger: 'blur', required: true }],
files: [{ validator: verifyFiles, trigger: 'blur', required: true }],
sourceDir: [Rules.requiredInput],
sourceAccountItems: [Rules.requiredSelect],
Expand Down Expand Up @@ -1449,6 +1477,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
}
form.sourceDir = files.join(',');
}
form.url = form.urlItems.join(',');
form.sourceAccountIDs = form.sourceAccountItems.join(',');
form.spec = specs.join('&&');
if (!formEl) return;
Expand Down
Loading