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:
		| @@ -3,6 +3,7 @@ import * as paths from '../paths.js'; | ||||
| import type { Cloudly } from 'ts/classes.cloudly.js'; | ||||
| import type { ExternalRegistryManager } from './classes.externalregistrymanager.js'; | ||||
|  | ||||
| @plugins.smartdata.managed() | ||||
| export class ExternalRegistry extends plugins.smartdata.SmartDataDbDoc<ExternalRegistry, plugins.servezoneInterfaces.data.IExternalRegistry, ExternalRegistryManager> { | ||||
|   // STATIC | ||||
|   public static async getRegistryById(registryIdArg: string) { | ||||
| @@ -27,7 +28,7 @@ export class ExternalRegistry extends plugins.smartdata.SmartDataDbDoc<ExternalR | ||||
|  | ||||
|   public static async createExternalRegistry(registryDataArg: Partial<plugins.servezoneInterfaces.data.IExternalRegistry['data']>) { | ||||
|     const externalRegistry = new ExternalRegistry(); | ||||
|     externalRegistry.id = await ExternalRegistry.getNewId(); | ||||
|     externalRegistry.id = await this.getNewId(); | ||||
|     externalRegistry.data = { | ||||
|       type: registryDataArg.type || 'docker', | ||||
|       name: registryDataArg.name || '', | ||||
| @@ -48,7 +49,7 @@ export class ExternalRegistry extends plugins.smartdata.SmartDataDbDoc<ExternalR | ||||
|      | ||||
|     // If this is set as default, unset other defaults of the same type | ||||
|     if (externalRegistry.data.isDefault) { | ||||
|       const existingDefaults = await ExternalRegistry.getInstances({ | ||||
|       const existingDefaults = await this.getInstances({ | ||||
|         'data.type': externalRegistry.data.type, | ||||
|         'data.isDefault': true, | ||||
|       }); | ||||
| @@ -73,7 +74,7 @@ export class ExternalRegistry extends plugins.smartdata.SmartDataDbDoc<ExternalR | ||||
|      | ||||
|     // If setting as default, unset other defaults of the same type | ||||
|     if (registryDataArg.isDefault && !externalRegistry.data.isDefault) { | ||||
|       const existingDefaults = await ExternalRegistry.getInstances({ | ||||
|       const existingDefaults = await this.getInstances({ | ||||
|         'data.type': externalRegistry.data.type, | ||||
|         'data.isDefault': true, | ||||
|       }); | ||||
|   | ||||
| @@ -24,7 +24,7 @@ export class ExternalRegistryManager { | ||||
|           this.cloudlyRef.authManager.validIdentityGuard, | ||||
|         ]); | ||||
|          | ||||
|         const registry = await ExternalRegistry.getRegistryById(dataArg.id); | ||||
|         const registry = await this.CExternalRegistry.getRegistryById(dataArg.id); | ||||
|         if (!registry) { | ||||
|           throw new Error(`Registry with id ${dataArg.id} not found`); | ||||
|         } | ||||
| @@ -41,7 +41,7 @@ export class ExternalRegistryManager { | ||||
|           this.cloudlyRef.authManager.validIdentityGuard, | ||||
|         ]); | ||||
|          | ||||
|         const registries = await ExternalRegistry.getRegistries(); | ||||
|         const registries = await this.CExternalRegistry.getRegistries(); | ||||
|         return { | ||||
|           registries: await Promise.all( | ||||
|             registries.map((registry) => registry.createSavableObject()) | ||||
| @@ -57,7 +57,7 @@ export class ExternalRegistryManager { | ||||
|           this.cloudlyRef.authManager.validIdentityGuard, | ||||
|         ]); | ||||
|          | ||||
|         const registry = await ExternalRegistry.createExternalRegistry(dataArg.registryData); | ||||
|         const registry = await this.CExternalRegistry.createExternalRegistry(dataArg.registryData); | ||||
|         return { | ||||
|           registry: await registry.createSavableObject(), | ||||
|         }; | ||||
| @@ -71,7 +71,7 @@ export class ExternalRegistryManager { | ||||
|           this.cloudlyRef.authManager.validIdentityGuard, | ||||
|         ]); | ||||
|          | ||||
|         const registry = await ExternalRegistry.updateExternalRegistry( | ||||
|         const registry = await this.CExternalRegistry.updateExternalRegistry( | ||||
|           dataArg.registryId, | ||||
|           dataArg.registryData | ||||
|         ); | ||||
| @@ -88,7 +88,7 @@ export class ExternalRegistryManager { | ||||
|           this.cloudlyRef.authManager.validIdentityGuard, | ||||
|         ]); | ||||
|          | ||||
|         const success = await ExternalRegistry.deleteExternalRegistry(dataArg.registryId); | ||||
|         const success = await this.CExternalRegistry.deleteExternalRegistry(dataArg.registryId); | ||||
|         return { | ||||
|           ok: success, | ||||
|         }; | ||||
| @@ -102,7 +102,7 @@ export class ExternalRegistryManager { | ||||
|           this.cloudlyRef.authManager.validIdentityGuard, | ||||
|         ]); | ||||
|          | ||||
|         const registry = await ExternalRegistry.getRegistryById(dataArg.registryId); | ||||
|         const registry = await this.CExternalRegistry.getRegistryById(dataArg.registryId); | ||||
|         if (!registry) { | ||||
|           return { | ||||
|             success: false, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user