feat: Implement Cloudly Task Manager with predefined tasks and execution tracking
- Added CloudlyTaskManager class for managing tasks, including registration, execution, scheduling, and cancellation. - Created predefined tasks: DNS Sync, Certificate Renewal, Cleanup, Health Check, Resource Report, Database Maintenance, Security Scan, and Docker Cleanup. - Introduced ITaskExecution interface for tracking task execution details and outcomes. - Developed API request interfaces for task management operations (getTasks, getTaskExecutions, triggerTask, cancelTask). - Implemented CloudlyViewTasks web component for displaying tasks and their execution history, including filtering and detailed views.
This commit is contained in:
@@ -663,6 +663,89 @@ export const verifyExternalRegistryAction = dataState.createAction(
|
||||
}
|
||||
);
|
||||
|
||||
// Task Actions
|
||||
export const taskActions = {
|
||||
getTasks: dataState.createAction(
|
||||
async (statePartArg, payloadArg: {}) => {
|
||||
const currentState = statePartArg.getState();
|
||||
const trGetTasks =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_GetTasks>(
|
||||
'/typedrequest',
|
||||
'getTasks'
|
||||
);
|
||||
const response = await trGetTasks.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
});
|
||||
return response as any;
|
||||
}
|
||||
),
|
||||
|
||||
getTaskExecutions: dataState.createAction(
|
||||
async (statePartArg, payloadArg: { filter?: any }) => {
|
||||
const currentState = statePartArg.getState();
|
||||
const trGetTaskExecutions =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_GetTaskExecutions>(
|
||||
'/typedrequest',
|
||||
'getTaskExecutions'
|
||||
);
|
||||
const response = await trGetTaskExecutions.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
filter: payloadArg.filter,
|
||||
});
|
||||
return response as any;
|
||||
}
|
||||
),
|
||||
|
||||
getTaskExecutionById: dataState.createAction(
|
||||
async (statePartArg, payloadArg: { executionId: string }) => {
|
||||
const currentState = statePartArg.getState();
|
||||
const trGetTaskExecutionById =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_GetTaskExecutionById>(
|
||||
'/typedrequest',
|
||||
'getTaskExecutionById'
|
||||
);
|
||||
const response = await trGetTaskExecutionById.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
executionId: payloadArg.executionId,
|
||||
});
|
||||
return response as any;
|
||||
}
|
||||
),
|
||||
|
||||
triggerTask: dataState.createAction(
|
||||
async (statePartArg, payloadArg: { taskName: string; userId?: string }) => {
|
||||
const currentState = statePartArg.getState();
|
||||
const trTriggerTask =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_TriggerTask>(
|
||||
'/typedrequest',
|
||||
'triggerTask'
|
||||
);
|
||||
const response = await trTriggerTask.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
taskName: payloadArg.taskName,
|
||||
userId: payloadArg.userId,
|
||||
});
|
||||
return currentState;
|
||||
}
|
||||
),
|
||||
|
||||
cancelTask: dataState.createAction(
|
||||
async (statePartArg, payloadArg: { executionId: string }) => {
|
||||
const currentState = statePartArg.getState();
|
||||
const trCancelTask =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_CancelTask>(
|
||||
'/typedrequest',
|
||||
'cancelTask'
|
||||
);
|
||||
const response = await trCancelTask.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
executionId: payloadArg.executionId,
|
||||
});
|
||||
return currentState;
|
||||
}
|
||||
),
|
||||
};
|
||||
|
||||
// cluster
|
||||
export const addClusterAction = dataState.createAction(
|
||||
async (
|
||||
|
Reference in New Issue
Block a user