mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-28 20:04:26 +00:00
feat(dashboard): add workflow tasks monitoring and stopping to team dashboard (#489)
* feat(dashboard): add workflow tasks monitoring and stopping to team dashboard * fix(asset): retain workflow tasks on asset purge and mark active tasks as failed * style(webui): add edge padding to audit logs and workflow tasks tables * fix(workflow): atomically update asset status to failed when task is stopped * fix(workflow): propagate cancellation errors, guard concurrent task stop, and localize UI * docs(changelog): keep only added log for workflow tasks dashboard * test(provider): mock upstream catalog api calls using saved fixtures * feat(dashboard): show file name, size, and project name in workflow tasks list
This commit is contained in:
@@ -16,6 +16,8 @@ import {
|
||||
updateTeamMemberRoleRequestSchema,
|
||||
createApiTokenRequestSchema,
|
||||
listAuditLogsQuerySchema,
|
||||
listWorkflowTasksQuerySchema,
|
||||
batchWorkflowTaskStatusSchema,
|
||||
} from '@shumai/dtos'
|
||||
import {
|
||||
updateUserMetadataRequestSchema,
|
||||
@@ -25,6 +27,7 @@ import {
|
||||
import { apiTokenService } from '@shumai/core/src/user/api-token'
|
||||
import { aiUsageService } from '@shumai/core/src/ai-usage/ai-usage'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import { workflowTaskService } from '@shumai/core/src/workflowTask/workflowTask'
|
||||
import { turntableService } from '@shumai/core/src/turntable/turntable'
|
||||
import { gotenbergService } from '@shumai/core/src/gotenberg/gotenberg'
|
||||
import { NotificationType } from '@shumai/db'
|
||||
@@ -517,5 +520,73 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
|
||||
return c.json(logs)
|
||||
})
|
||||
.get(
|
||||
'/teams/:teamId/workflow-tasks',
|
||||
zValidator('query', listWorkflowTasksQuerySchema),
|
||||
async (c) => {
|
||||
const user = c.get('user')
|
||||
const teamId = c.req.param('teamId')
|
||||
const query = c.req.valid('query')
|
||||
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Admin,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
|
||||
const tasks = await workflowTaskService.listWorkflowTasks({
|
||||
teamId,
|
||||
status: query.status,
|
||||
types: query.types,
|
||||
first: query.first,
|
||||
after: query.after,
|
||||
})
|
||||
|
||||
return c.json(tasks)
|
||||
},
|
||||
)
|
||||
.post(
|
||||
'/teams/:teamId/workflow-tasks/batch-status',
|
||||
zValidator('json', batchWorkflowTaskStatusSchema),
|
||||
async (c) => {
|
||||
const user = c.get('user')
|
||||
const teamId = c.req.param('teamId')
|
||||
const req = c.req.valid('json')
|
||||
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Admin,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
|
||||
const result = await workflowTaskService.getBatchWorkflowTaskStatus({
|
||||
teamId,
|
||||
taskIds: req.taskIds,
|
||||
})
|
||||
|
||||
return c.json(result)
|
||||
},
|
||||
)
|
||||
.post('/teams/:teamId/workflow-tasks/:taskId/stop', async (c) => {
|
||||
const user = c.get('user')
|
||||
const teamId = c.req.param('teamId')
|
||||
const taskId = c.req.param('taskId')
|
||||
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Admin,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
|
||||
const result = await workflowTaskService.stopWorkflowTask({
|
||||
teamId,
|
||||
taskId,
|
||||
})
|
||||
|
||||
return c.json(result)
|
||||
})
|
||||
|
||||
export default route
|
||||
|
||||
Reference in New Issue
Block a user