feat: Enhance API client integration across web and CLI
- Added typedRequestInterfaces import to plugins.ts for better type handling. - Updated CLI client to utilize environment variables for Cloudly API credentials and improved authentication flow. - Refactored appstate.ts to use a shared API client instance, reducing redundancy in API calls for various actions. - Simplified external registry actions in appstate.ts by leveraging the shared API client. - Updated CloudlyDashboard and CloudlyViewSettings components to utilize the shared API client for fetching settings and managing connections. - Removed redundant TypedRequest instances in favor of direct API client calls for improved performance and maintainability. - Exposed the API client in plugins.ts for easier access in UI components.
This commit is contained in:
@@ -93,13 +93,8 @@ export class CloudlyViewSettings extends DeesElement {
|
||||
private async loadSettings() {
|
||||
this.isLoading = true;
|
||||
try {
|
||||
const trRequest = new plugins.deesDomtools.plugins.typedrequest.TypedRequest<
|
||||
plugins.interfaces.requests.settings.IRequest_GetSettings
|
||||
>(
|
||||
'/typedrequest',
|
||||
'getSettings'
|
||||
);
|
||||
const response = await trRequest.fire({});
|
||||
// Use shared API client
|
||||
const response = await appstate.apiClient.settings.getSettings();
|
||||
this.settings = response.settings;
|
||||
} catch (error) {
|
||||
console.error('Failed to load settings:', error);
|
||||
@@ -128,13 +123,7 @@ export class CloudlyViewSettings extends DeesElement {
|
||||
}
|
||||
console.log('Updates to send:', updates);
|
||||
|
||||
const trRequest = new plugins.deesDomtools.plugins.typedrequest.TypedRequest<
|
||||
plugins.interfaces.requests.settings.IRequest_UpdateSettings
|
||||
>(
|
||||
'/typedrequest',
|
||||
'updateSettings'
|
||||
);
|
||||
const response = await trRequest.fire({ updates });
|
||||
const response = await appstate.apiClient.settings.updateSettings(updates);
|
||||
|
||||
if (response.success) {
|
||||
plugins.deesCatalog.DeesToast.createAndShow({
|
||||
@@ -159,13 +148,7 @@ export class CloudlyViewSettings extends DeesElement {
|
||||
private async testConnection(provider: string) {
|
||||
this.isLoading = true;
|
||||
try {
|
||||
const trRequest = new plugins.deesDomtools.plugins.typedrequest.TypedRequest<
|
||||
plugins.interfaces.requests.settings.IRequest_TestProviderConnection
|
||||
>(
|
||||
'/typedrequest',
|
||||
'testProviderConnection'
|
||||
);
|
||||
const response = await trRequest.fire({ provider: provider as any });
|
||||
const response = await appstate.apiClient.settings.testProviderConnection(provider);
|
||||
|
||||
this.testResults = {
|
||||
...this.testResults,
|
||||
@@ -475,4 +458,4 @@ export class CloudlyViewSettings extends DeesElement {
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user