feat(web): Add deployments API typings and web UI improvements: services & deployments management with CRUD and actions
This commit is contained in:
@@ -48,8 +48,8 @@ export interface IDataState {
|
||||
secretBundles?: plugins.interfaces.data.ISecretBundle[];
|
||||
clusters?: plugins.interfaces.data.ICluster[];
|
||||
images?: any[];
|
||||
services?: any[];
|
||||
deployments?: any[];
|
||||
services?: plugins.interfaces.data.IService[];
|
||||
deployments?: plugins.interfaces.data.IDeployment[];
|
||||
dns?: any[];
|
||||
mails?: any[];
|
||||
logs?: any[];
|
||||
@@ -136,9 +136,90 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
||||
clusters: responseClusters.clusters,
|
||||
}
|
||||
|
||||
// Services
|
||||
const trGetServices =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.service.IRequest_Any_Cloudly_GetServices>(
|
||||
'/typedrequest',
|
||||
'getServices'
|
||||
);
|
||||
const responseServices = await trGetServices.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
});
|
||||
currentState = {
|
||||
...currentState,
|
||||
services: responseServices.services,
|
||||
};
|
||||
|
||||
// Deployments
|
||||
const trGetDeployments =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.deployment.IReq_Any_Cloudly_GetDeployments>(
|
||||
'/typedrequest',
|
||||
'getDeployments'
|
||||
);
|
||||
const responseDeployments = await trGetDeployments.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
});
|
||||
currentState = {
|
||||
...currentState,
|
||||
deployments: responseDeployments.deployments,
|
||||
};
|
||||
|
||||
return currentState;
|
||||
});
|
||||
|
||||
// Service Actions
|
||||
export const createServiceAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { serviceData: plugins.interfaces.data.IService['data'] }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trCreateService =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.service.IRequest_Any_Cloudly_CreateService>(
|
||||
'/typedrequest',
|
||||
'createService'
|
||||
);
|
||||
const response = await trCreateService.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
serviceData: payloadArg.serviceData,
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
export const updateServiceAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { serviceId: string; serviceData: plugins.interfaces.data.IService['data'] }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trUpdateService =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.service.IRequest_Any_Cloudly_UpdateService>(
|
||||
'/typedrequest',
|
||||
'updateService'
|
||||
);
|
||||
const response = await trUpdateService.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
serviceId: payloadArg.serviceId,
|
||||
serviceData: payloadArg.serviceData,
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
export const deleteServiceAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { serviceId: string }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trDeleteService =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.service.IRequest_Any_Cloudly_DeleteServiceById>(
|
||||
'/typedrequest',
|
||||
'deleteServiceById'
|
||||
);
|
||||
const response = await trDeleteService.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
serviceId: payloadArg.serviceId,
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
// SecretGroup Actions
|
||||
export const createSecretGroupAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: plugins.interfaces.data.ISecretGroup) => {
|
||||
@@ -239,6 +320,59 @@ export const deleteImageAction = dataState.createAction(
|
||||
}
|
||||
);
|
||||
|
||||
// Deployment Actions
|
||||
export const createDeploymentAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { deploymentData: Partial<plugins.interfaces.data.IDeployment> }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trCreateDeployment =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.deployment.IReq_Any_Cloudly_CreateDeployment>(
|
||||
'/typedrequest',
|
||||
'createDeployment'
|
||||
);
|
||||
const response = await trCreateDeployment.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
deploymentData: payloadArg.deploymentData,
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
export const updateDeploymentAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { deploymentId: string; deploymentData: Partial<plugins.interfaces.data.IDeployment> }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trUpdateDeployment =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.deployment.IReq_Any_Cloudly_UpdateDeployment>(
|
||||
'/typedrequest',
|
||||
'updateDeployment'
|
||||
);
|
||||
const response = await trUpdateDeployment.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
deploymentId: payloadArg.deploymentId,
|
||||
deploymentData: payloadArg.deploymentData,
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
export const deleteDeploymentAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { deploymentId: string }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trDeleteDeployment =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.deployment.IReq_Any_Cloudly_DeleteDeploymentById>(
|
||||
'/typedrequest',
|
||||
'deleteDeploymentById'
|
||||
);
|
||||
const response = await trDeleteDeployment.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
deploymentId: payloadArg.deploymentId,
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
// cluster
|
||||
export const addClusterAction = dataState.createAction(
|
||||
async (
|
||||
|
Reference in New Issue
Block a user