feat(dns): Implement DNS management functionality

- Added DnsManager and DnsEntry classes to handle DNS entries.
- Introduced new interfaces for DNS entry requests and data structures.
- Updated Cloudly class to include DnsManager instance.
- Enhanced app state to manage DNS entries and actions for creating, updating, and deleting DNS records.
- Created UI components for DNS management, including forms for adding and editing DNS entries.
- Updated overview and services views to reflect DNS entries.
- Added validation and formatting methods for DNS entries.
This commit is contained in:
2025-09-09 15:08:28 +00:00
parent 38e8b4086d
commit 766191899c
19 changed files with 2174 additions and 99 deletions

View File

@@ -50,7 +50,8 @@ export interface IDataState {
images?: any[];
services?: plugins.interfaces.data.IService[];
deployments?: plugins.interfaces.data.IDeployment[];
dns?: any[];
domains?: plugins.interfaces.data.IDomain[];
dnsEntries?: plugins.interfaces.data.IDnsEntry[];
mails?: any[];
logs?: any[];
s3?: any[];
@@ -66,7 +67,8 @@ export const dataState = await appstate.getStatePart<IDataState>(
images: [],
services: [],
deployments: [],
dns: [],
domains: [],
dnsEntries: [],
mails: [],
logs: [],
s3: [],
@@ -180,6 +182,50 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
};
}
// Domains
const trGetDomains =
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_GetDomains>(
'/typedrequest',
'getDomains'
);
try {
const responseDomains = await trGetDomains.fire({
identity: loginStatePart.getState().identity,
});
currentState = {
...currentState,
domains: responseDomains?.domains || [],
};
} catch (error) {
console.error('Failed to fetch domains:', error);
currentState = {
...currentState,
domains: [],
};
}
// DNS Entries
const trGetDnsEntries =
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.dns.IRequest_Any_Cloudly_GetDnsEntries>(
'/typedrequest',
'getDnsEntries'
);
try {
const responseDnsEntries = await trGetDnsEntries.fire({
identity: loginStatePart.getState().identity,
});
currentState = {
...currentState,
dnsEntries: responseDnsEntries?.dnsEntries || [],
};
} catch (error) {
console.error('Failed to fetch DNS entries:', error);
currentState = {
...currentState,
dnsEntries: [],
};
}
return currentState;
});
@@ -389,6 +435,130 @@ export const deleteDeploymentAction = dataState.createAction(
}
);
// DNS Actions
export const createDnsEntryAction = dataState.createAction(
async (statePartArg, payloadArg: { dnsEntryData: plugins.interfaces.data.IDnsEntry['data'] }) => {
let currentState = statePartArg.getState();
const trCreateDnsEntry =
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.dns.IRequest_Any_Cloudly_CreateDnsEntry>(
'/typedrequest',
'createDnsEntry'
);
const response = await trCreateDnsEntry.fire({
identity: loginStatePart.getState().identity,
dnsEntryData: payloadArg.dnsEntryData,
});
currentState = await dataState.dispatchAction(getAllDataAction, null);
return currentState;
}
);
export const updateDnsEntryAction = dataState.createAction(
async (statePartArg, payloadArg: { dnsEntryId: string; dnsEntryData: plugins.interfaces.data.IDnsEntry['data'] }) => {
let currentState = statePartArg.getState();
const trUpdateDnsEntry =
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.dns.IRequest_Any_Cloudly_UpdateDnsEntry>(
'/typedrequest',
'updateDnsEntry'
);
const response = await trUpdateDnsEntry.fire({
identity: loginStatePart.getState().identity,
dnsEntryId: payloadArg.dnsEntryId,
dnsEntryData: payloadArg.dnsEntryData,
});
currentState = await dataState.dispatchAction(getAllDataAction, null);
return currentState;
}
);
export const deleteDnsEntryAction = dataState.createAction(
async (statePartArg, payloadArg: { dnsEntryId: string }) => {
let currentState = statePartArg.getState();
const trDeleteDnsEntry =
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.dns.IRequest_Any_Cloudly_DeleteDnsEntry>(
'/typedrequest',
'deleteDnsEntry'
);
const response = await trDeleteDnsEntry.fire({
identity: loginStatePart.getState().identity,
dnsEntryId: payloadArg.dnsEntryId,
});
currentState = await dataState.dispatchAction(getAllDataAction, null);
return currentState;
}
);
// Domain Actions
export const createDomainAction = dataState.createAction(
async (statePartArg, payloadArg: { domainData: plugins.interfaces.data.IDomain['data'] }) => {
let currentState = statePartArg.getState();
const trCreateDomain =
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_CreateDomain>(
'/typedrequest',
'createDomain'
);
const response = await trCreateDomain.fire({
identity: loginStatePart.getState().identity,
domainData: payloadArg.domainData,
});
currentState = await dataState.dispatchAction(getAllDataAction, null);
return currentState;
}
);
export const updateDomainAction = dataState.createAction(
async (statePartArg, payloadArg: { domainId: string; domainData: plugins.interfaces.data.IDomain['data'] }) => {
let currentState = statePartArg.getState();
const trUpdateDomain =
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_UpdateDomain>(
'/typedrequest',
'updateDomain'
);
const response = await trUpdateDomain.fire({
identity: loginStatePart.getState().identity,
domainId: payloadArg.domainId,
domainData: payloadArg.domainData,
});
currentState = await dataState.dispatchAction(getAllDataAction, null);
return currentState;
}
);
export const deleteDomainAction = dataState.createAction(
async (statePartArg, payloadArg: { domainId: string }) => {
let currentState = statePartArg.getState();
const trDeleteDomain =
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_DeleteDomain>(
'/typedrequest',
'deleteDomain'
);
const response = await trDeleteDomain.fire({
identity: loginStatePart.getState().identity,
domainId: payloadArg.domainId,
});
currentState = await dataState.dispatchAction(getAllDataAction, null);
return currentState;
}
);
export const verifyDomainAction = dataState.createAction(
async (statePartArg, payloadArg: { domainId: string; verificationMethod?: 'dns' | 'http' | 'email' | 'manual' }) => {
let currentState = statePartArg.getState();
const trVerifyDomain =
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_VerifyDomain>(
'/typedrequest',
'verifyDomain'
);
const response = await trVerifyDomain.fire({
identity: loginStatePart.getState().identity,
domainId: payloadArg.domainId,
verificationMethod: payloadArg.verificationMethod,
});
currentState = await dataState.dispatchAction(getAllDataAction, null);
return currentState;
}
);
// cluster
export const addClusterAction = dataState.createAction(
async (