Skip to content

Commit c131061

Browse files
authored
fix: Fix grouping exception issue for cronjob (1Panel-dev#9841)
1 parent 6a5e1eb commit c131061

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

agent/app/model/cronjob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Cronjob struct {
1111

1212
Name string `gorm:"not null" json:"name"`
1313
Type string `gorm:"not null" json:"type"`
14-
GroupID uint `json:"groupID"`
14+
GroupID uint `gorm:"not null;default:0" json:"groupID"`
1515
SpecCustom bool `json:"specCustom"`
1616
Spec string `gorm:"not null" json:"spec"`
1717

agent/app/service/cronjob.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ func (u *CronjobService) Update(id uint, req dto.CronjobOperate) error {
710710
upMap["status"] = constant.StatusEnable
711711
}
712712
upMap["name"] = req.Name
713+
upMap["group_id"] = req.GroupID
713714
upMap["spec_custom"] = req.SpecCustom
714715
upMap["spec"] = spec
715716
upMap["script"] = req.Script

frontend/src/api/interface/cronjob.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export namespace Cronjob {
7171
export interface CronjobOperate {
7272
id: number;
7373
name: string;
74+
groupID: number;
7475
type: string;
7576
specCustom: boolean;
7677
spec: string;

frontend/src/views/cronjob/cronjob/index.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,16 +398,20 @@ const onSubmitExport = async () => {
398398
const loadGroups = async () => {
399399
const res = await getGroupList('cronjob');
400400
groupOptions.value = res.data || [];
401+
for (const group of groupOptions.value) {
402+
if (group.name === 'Default') {
403+
defaultGroupID.value = group.id;
404+
break;
405+
}
406+
}
401407
for (const item of data.value) {
402408
if (item.groupID === 0) {
403409
item.groupBelong = 'Default';
410+
item.groupID = defaultGroupID.value;
404411
continue;
405412
}
406413
let hasGroup = false;
407414
for (const group of groupOptions.value) {
408-
if (group.name === 'Default') {
409-
defaultGroupID.value = group.id;
410-
}
411415
if (item.groupID === group.id) {
412416
hasGroup = true;
413417
item.groupBelong = group.name;

frontend/src/views/cronjob/cronjob/operate/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ const search = async () => {
852852
.then((res) => {
853853
loading.value = false;
854854
form.name = res.data.name;
855+
form.groupID = res.data.groupID || null;
855856
form.type = res.data.type;
856857
form.specCustom = res.data.specCustom;
857858
form.spec = res.data.spec;

frontend/src/views/login/components/login-form.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@
182182

183183
<script setup lang="ts">
184184
import { ref, reactive, onMounted, computed } from 'vue';
185-
import { useRouter } from 'vue-router';
186185
import type { ElForm } from 'element-plus';
187186
import { loginApi, getCaptcha, mfaLoginApi, getLoginSetting } from '@/api/modules/auth';
188187
import { GlobalStore, MenuStore, TabsStore } from '@/store';
@@ -269,7 +268,6 @@ const captcha = reactive({
269268
270269
const loading = ref<boolean>(false);
271270
const mfaShow = ref<boolean>(false);
272-
const router = useRouter();
273271
const dropdownText = ref('中文(简体)');
274272
275273
function handleCommand(command: string) {

0 commit comments

Comments
 (0)