mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
完善定时任务视图拖拽
This commit is contained in:
parent
4e389865b5
commit
e31c2c0955
|
@ -1,13 +1,20 @@
|
||||||
import { Service, Inject } from 'typedi';
|
import { Service, Inject } from 'typedi';
|
||||||
import winston from 'winston';
|
import winston from 'winston';
|
||||||
import { CrontabView, CrontabViewModel } from '../data/cronView';
|
import { CrontabView, CrontabViewModel } from '../data/cronView';
|
||||||
|
import { initEnvPosition } from '../data/env';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class CronViewService {
|
export default class CronViewService {
|
||||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
constructor(@Inject('logger') private logger: winston.Logger) {}
|
||||||
|
|
||||||
public async create(payload: CrontabView): Promise<CrontabView> {
|
public async create(payload: CrontabView): Promise<CrontabView> {
|
||||||
const tab = new CrontabView(payload);
|
let position = initEnvPosition;
|
||||||
|
const views = await this.list();
|
||||||
|
if (views && views.length > 0 && views[views.length - 1].position) {
|
||||||
|
position = views[views.length - 1].position as number;
|
||||||
|
}
|
||||||
|
position = position / 2;
|
||||||
|
const tab = new CrontabView({ ...payload, position });
|
||||||
const doc = await this.insert(tab);
|
const doc = await this.insert(tab);
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +39,10 @@ export default class CronViewService {
|
||||||
|
|
||||||
public async list(): Promise<CrontabView[]> {
|
public async list(): Promise<CrontabView[]> {
|
||||||
try {
|
try {
|
||||||
const result = await CrontabViewModel.findAll({});
|
const result = await CrontabViewModel.findAll({
|
||||||
|
where: {},
|
||||||
|
order: [['position', 'DESC']],
|
||||||
|
});
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
|
|
||||||
.crontab-view {
|
.crontab-view {
|
||||||
.ant-tabs-nav-wrap {
|
.ant-tabs-nav-wrap {
|
||||||
|
min-width: 200px;
|
||||||
flex: unset !important;
|
flex: unset !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,3 +155,11 @@
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr.drop-over-downward td {
|
||||||
|
border-bottom: 2px dashed #1890ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.drop-over-upward td {
|
||||||
|
border-top: 2px dashed #1890ff;
|
||||||
|
}
|
||||||
|
|
|
@ -187,8 +187,8 @@ const ViewManageModal = ({
|
||||||
}
|
}
|
||||||
const dragRow = list[dragIndex];
|
const dragRow = list[dragIndex];
|
||||||
request
|
request
|
||||||
.put(`${config.apiPrefix}envs/${dragRow.id}/move`, {
|
.put(`${config.apiPrefix}crons/views/move`, {
|
||||||
data: { fromIndex: dragIndex, toIndex: hoverIndex },
|
data: { fromIndex: dragIndex, toIndex: hoverIndex, id: dragRow.id },
|
||||||
})
|
})
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
if (data.code === 200) {
|
if (data.code === 200) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user