Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: refactored job schedules page (#1545)
Kyle Mendelle77227ab83b0
diff --git a/backend/internal/bootstrap/bootstrap.go b/backend/internal/bootstrap/bootstrap.goindex 02906149f..200fdd4b4 100644--- a/backend/internal/bootstrap/bootstrap.go+++ b/backend/internal/bootstrap/bootstrap.go@@ -106,6 +106,7 @@ func Bootstrap(ctx context.Context) error {}scheduler := scheduler.NewJobScheduler(appCtx)+ appServices.JobSchedule.SetScheduler(scheduler)registerJobs(appCtx, scheduler, appServices, cfg)router, tunnelServer := setupRouter(appCtx, cfg, appServices)diff --git a/backend/internal/bootstrap/jobs_bootstrap.go b/backend/internal/bootstrap/jobs_bootstrap.goindex 1c74cdf7d..4fef08211 100644--- a/backend/internal/bootstrap/jobs_bootstrap.go+++ b/backend/internal/bootstrap/jobs_bootstrap.go@@ -37,45 +37,53 @@ func registerJobs(appCtx context.Context, newScheduler *pkg_scheduler.JobSchedulgitOpsSyncJob := pkg_scheduler.NewGitOpsSyncJob(appServices.GitOpsSync, appServices.Settings)newScheduler.RegisterJob(gitOpsSyncJob)- setupJobScheduleCallbacks(appServices, appConfig, environmentHealthJob, analyticsJob, eventCleanupJob)- setupSettingsCallbacks(appServices, appConfig, imagePollingJob, autoUpdateJob, environmentHealthJob, fsWatcherJob, scheduledPruneJob)+ setupJobScheduleCallbacks(appServices, appConfig, newScheduler, environmentHealthJob, analyticsJob, eventCleanupJob)+ setupSettingsCallbacks(appServices, appConfig, newScheduler, imagePollingJob, autoUpdateJob, environmentHealthJob, fsWatcherJob, scheduledPruneJob)}-func setupJobScheduleCallbacks(appServices *Services, appConfig *config.Config, environmentHealthJob *pkg_scheduler.EnvironmentHealthJob, analyticsJob *pkg_scheduler.AnalyticsJob, eventCleanupJob *pkg_scheduler.EventCleanupJob) {+func setupJobScheduleCallbacks(appServices *Services, appConfig *config.Config, newScheduler *pkg_scheduler.JobScheduler, environmentHealthJob *pkg_scheduler.EnvironmentHealthJob, analyticsJob *pkg_scheduler.AnalyticsJob, eventCleanupJob *pkg_scheduler.EventCleanupJob) {if appServices.JobSchedule != nil {- appServices.JobSchedule.OnJobSchedulesChanged = func(ctx context.Context) {- if !appConfig.AgentMode {- if err := environmentHealthJob.Reschedule(ctx); err != nil {- slog.WarnContext(ctx, "Failed to reschedule environment-health job", "error", err)+ appServices.JobSchedule.OnJobSchedulesChanged = func(ctx context.Context, changedKeys []string) {+ for _, key := range changedKeys {+ switch key {+ case "environmentHealthInterval":+ if appConfig.AgentMode {+ continue+ }+ if err := newScheduler.RescheduleJob(ctx, environmentHealthJob); err != nil {+ slog.WarnContext(ctx, "Failed to reschedule environment-health job", "error", err)+ }+ case "analyticsHeartbeatInterval":+ if err := newScheduler.RescheduleJob(ctx, analyticsJob); err != nil {+ slog.WarnContext(ctx, "Failed to reschedule analytics heartbeat job", "error", err)+ }+ case "eventCleanupInterval":+ if err := newScheduler.RescheduleJob(ctx, eventCleanupJob); err != nil {+ slog.WarnContext(ctx, "Failed to reschedule event cleanup job", "error", err)+ }}}- if err := analyticsJob.Reschedule(ctx); err != nil {- slog.WarnContext(ctx, "Failed to reschedule analytics heartbeat job", "error", err)- }- if err := eventCleanupJob.Reschedule(ctx); err != nil {- slog.WarnContext(ctx, "Failed to reschedule event cleanup job", "error", err)- }}}}-func setupSettingsCallbacks(appServices *Services, appConfig *config.Config, imagePollingJob *pkg_scheduler.ImagePollingJob, autoUpdateJob *pkg_scheduler.AutoUpdateJob, environmentHealthJob *pkg_scheduler.EnvironmentHealthJob, fsWatcherJob *pkg_scheduler.FilesystemWatcherJob, scheduledPruneJob *pkg_scheduler.ScheduledPruneJob) {+func setupSettingsCallbacks(appServices *Services, appConfig *config.Config, newScheduler *pkg_scheduler.JobScheduler, imagePollingJob *pkg_scheduler.ImagePollingJob, autoUpdateJob *pkg_scheduler.AutoUpdateJob, environmentHealthJob *pkg_scheduler.EnvironmentHealthJob, fsWatcherJob *pkg_scheduler.FilesystemWatcherJob, scheduledPruneJob *pkg_scheduler.ScheduledPruneJob) {appServices.Settings.OnImagePollingSettingsChanged = func(ctx context.Context) {- if err := imagePollingJob.Reschedule(ctx); err != nil {+ if err := newScheduler.RescheduleJob(ctx, imagePollingJob); err != nil {slog.WarnContext(ctx, "Failed to reschedule image-polling job", "error", err)}- if err := autoUpdateJob.Reschedule(ctx); err != nil {+ if err := newScheduler.RescheduleJob(ctx, autoUpdateJob); err != nil {slog.WarnContext(ctx, "Failed to reschedule auto-update job", "error", err)}if !appConfig.AgentMode {- if err := environmentHealthJob.Reschedule(ctx); err != nil {+ if err := newScheduler.RescheduleJob(ctx, environmentHealthJob); err != nil {slog.WarnContext(ctx, "Failed to reschedule environment-health job", "error", err)}}}appServices.Settings.OnAutoUpdateSettingsChanged = func(ctx context.Context) {slog.DebugContext(ctx, "AutoUpdateSettingsChanged callback triggered")- if err := autoUpdateJob.Reschedule(ctx); err != nil {+ if err := newScheduler.RescheduleJob(ctx, autoUpdateJob); err != nil {slog.WarnContext(ctx, "Failed to reschedule auto-update job", "error", err)}}@@ -87,7 +95,7 @@ func setupSettingsCallbacks(appServices *Services, appConfig *config.Config, ima}}appServices.Settings.OnScheduledPruneSettingsChanged = func(ctx context.Context) {- if err := scheduledPruneJob.Reschedule(ctx); err != nil {+ if err := newScheduler.RescheduleJob(ctx, scheduledPruneJob); err != nil {slog.WarnContext(ctx, "Failed to reschedule scheduled-prune job", "error", err)}}diff --git a/backend/internal/huma/handlers/job_schedules.go b/backend/internal/huma/handlers/job_schedules.goindex 35f11495f..cd71dd477 100644--- a/backend/internal/huma/handlers/job_schedules.go+++ b/backend/internal/huma/handlers/job_schedules.go@@ -22,6 +22,18 @@ type UpdateJobSchedulesOutput struct {Body base.ApiResponse[jobschedule.Config]}+type GetJobsOutput struct {+ Body jobschedule.JobListResponse+}++type RunJobInput struct {+ JobID string `path:"jobId" minLength:"1" doc:"Job ID to run"`+}++type RunJobOutput struct {+ Body jobschedule.JobRunResponse+}+func RegisterJobSchedules(api huma.API, jobSvc *services.JobService) {h := &JobSchedulesHandler{jobService: jobSvc}@@ -50,12 +62,69 @@ func RegisterJobSchedules(api huma.API, jobSvc *services.JobService) {{"ApiKeyAuth": {}},},}, h.Update)++ huma.Register(api, huma.Operation{+ OperationID: "list-jobs",+ Method: http.MethodGet,+ Path: "/jobs",+ Summary: "List all background jobs",+ Description: "Get status, schedule, and metadata for all background jobs",+ Tags: []string{"JobSchedules"},+ Security: []map[string][]string{+ {"BearerAuth": {}},+ {"ApiKeyAuth": {}},+ },+ }, h.ListJobs)++ huma.Register(api, huma.Operation{+ OperationID: "run-job",+ Method: http.MethodPost,+ Path: "/jobs/{jobId}/run",+ Summary: "Run a job now",+ Description: "Manually trigger a background job to run immediately",+ Tags: []string{"JobSchedules"},+ Security: []map[string][]string{+ {"BearerAuth": {}},+ {"ApiKeyAuth": {}},+ },+ }, h.RunJob)}type JobSchedulesHandler struct {jobService *services.JobService}+func (h *JobSchedulesHandler) ListJobs(ctx context.Context, _ *struct{}) (*GetJobsOutput, error) {+ if h.jobService == nil {+ return nil, huma.Error500InternalServerError("service not available")+ }++ jobs, err := h.jobService.ListJobs(ctx)+ if err != nil {+ return nil, huma.Error500InternalServerError(err.Error())+ }++ return &GetJobsOutput{Body: *jobs}, nil+}++func (h *JobSchedulesHandler) RunJob(ctx context.Context, input *RunJobInput) (*RunJobOutput, error) {+ if h.jobService == nil {+ return nil, huma.Error500InternalServerError("service not available")+ }++ err := h.jobService.RunJobNowInline(ctx, input.JobID)+ if err != nil {+ return nil, huma.Error400BadRequest(err.Error())+ }++ return &RunJobOutput{+ Body: jobschedule.JobRunResponse{+ Success: true,+ Message: "Job completed successfully",+ },+ }, nil+}+func (h *JobSchedulesHandler) Get(ctx context.Context, _ *struct{}) (*GetJobSchedulesOutput, error) {if h.jobService == nil {return nil, huma.Error500InternalServerError("service not available")diff --git a/backend/internal/models/settings.go b/backend/internal/models/settings.goindex 4cdc17ad5..98b2a7684 100644--- a/backend/internal/models/settings.go+++ b/backend/internal/models/settings.go@@ -49,7 +49,7 @@ type Settings struct {BaseServerURL SettingVariable `key:"baseServerUrl" meta:"label=Base Server URL;type=text;keywords=base,url,server,domain,host,endpoint,address,link;category=general;description=Set the base URL for the application"`EnableGravatar SettingVariable `key:"enableGravatar" meta:"label=Enable Gravatar;type=boolean;keywords=gravatar,avatar,profile,picture,image,user,photo;category=general;description=Enable Gravatar profile pictures for users"`DefaultShell SettingVariable `key:"defaultShell" meta:"label=Default Shell;type=text;keywords=shell,default,shellpath,path,login;category=general;description=Default shell to use for commands"`- EnvironmentHealthInterval SettingVariable `key:"environmentHealthInterval" meta:"label=Environment Health Check Interval;type=cron;keywords=environment,health,check,interval,frequency,heartbeat,status,monitoring,uptime,jobs,schedule;category=jobschedule;description=How often to check environment connectivity (cron expression)" catmeta:"id=jobschedule;title=Job Schedule;icon=jobs;url=/settings/jobs;description=Configure how often Arcane background jobs run"`+ EnvironmentHealthInterval SettingVariable `key:"environmentHealthInterval" meta:"label=Environment Health Check Interval;type=cron;keywords=environment,health,check,interval,frequency,heartbeat,status,monitoring,uptime,jobs,schedule;description=How often to check environment connectivity (cron expression)" catmeta:"id=jobschedule;title=Job Schedule;icon=jobs;url=/settings/jobs;description=Configure how often Arcane background jobs run"`AccentColor SettingVariable `key:"accentColor,public,local" meta:"label=Accent Color;type=text;keywords=color,accent,theme,css,appearance,ui;category=general;description=Primary accent color for UI"`// Docker category@@ -57,8 +57,8 @@ type Settings struct {AutoUpdateInterval SettingVariable `key:"autoUpdateInterval" meta:"label=Auto Update Interval;type=cron;keywords=auto,update,interval,frequency,schedule,automatic,timing;category=internal;description=How often to check for automatic updates (cron expression)"`PollingEnabled SettingVariable `key:"pollingEnabled" meta:"label=Enable Polling;type=boolean;keywords=polling,check,monitor,watch,scan,detection,automatic;category=internal;description=Enable automatic checking for image updates"`PollingInterval SettingVariable `key:"pollingInterval" meta:"label=Polling Interval;type=cron;keywords=interval,frequency,schedule,time,minutes,period,delay;category=internal;description=How often to check for image updates (cron expression)"`- EventCleanupInterval SettingVariable `key:"eventCleanupInterval" meta:"label=Event Cleanup Interval;type=cron;keywords=events,cleanup,retention,interval,frequency,schedule,history,logs,jobs;category=jobschedule;description=How often to delete old events (cron expression)"`- AnalyticsHeartbeatInterval SettingVariable `key:"analyticsHeartbeatInterval" meta:"label=Analytics Heartbeat Interval;type=cron;keywords=analytics,heartbeat,interval,frequency,schedule,telemetry,jobs;category=jobschedule;description=How often to send the anonymous analytics heartbeat (cron expression)"`+ EventCleanupInterval SettingVariable `key:"eventCleanupInterval" meta:"label=Event Cleanup Interval;type=cron;keywords=events,cleanup,retention,interval,frequency,schedule,history,logs,jobs;description=How often to delete old events (cron expression)"`+ AnalyticsHeartbeatInterval SettingVariable `key:"analyticsHeartbeatInterval" meta:"label=Analytics Heartbeat Interval;type=cron;keywords=analytics,heartbeat,interval,frequency,schedule,telemetry,jobs;description=How often to send the anonymous analytics heartbeat (cron expression)"`AutoInjectEnv SettingVariable `key:"autoInjectEnv" meta:"label=Auto Inject Env Variables;type=boolean;keywords=auto,inject,env,environment,variables,interpolation;category=internal;description=Automatically inject project .env variables into all containers (default: false)"`PruneMode SettingVariable `key:"dockerPruneMode" meta:"label=Docker Prune Action;type=select;keywords=prune,cleanup,clean,remove,delete,unused,dangling,space,disk;category=internal;description=Configure how unused Docker images are cleaned up"`ScheduledPruneEnabled SettingVariable `key:"scheduledPruneEnabled" meta:"label=Scheduled Prune Enabled;type=boolean;keywords=prune,cleanup,maintenance,schedule,automatic;category=internal;description=Enable scheduled pruning of unused Docker resources"`diff --git a/backend/internal/services/job_service.go b/backend/internal/services/job_service.goindex 3783c2fb9..964153f7d 100644--- a/backend/internal/services/job_service.go+++ b/backend/internal/services/job_service.go@@ -3,15 +3,22 @@ package servicesimport ("context""fmt"+ "time""github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/types/jobschedule"+ "github.com/getarcaneapp/arcane/types/meta"+ schedulertypes "github.com/getarcaneapp/arcane/types/scheduler""github.com/robfig/cron/v3""gorm.io/gorm")+type JobRunner interface {+ GetJob(jobID string) (schedulertypes.Job, bool)+}+// JobService manages configuration for background job schedules.//// Intervals are persisted in the existing settings table as individual keys.@@ -21,17 +28,22 @@ import (// NOTE: This is intentionally separate from SettingsService to keep the API// surface job-focused and to centralize schedule validation/rescheduling.type JobService struct {- db *database.DB- settings *SettingsService- cfg *config.Config+ db *database.DB+ settings *SettingsService+ cfg *config.Config+ scheduler JobRunner- OnJobSchedulesChanged func(ctx context.Context)+ OnJobSchedulesChanged func(ctx context.Context, changedKeys []string)}func NewJobService(db *database.DB, settings *SettingsService, cfg *config.Config) *JobService {return &JobService{db: db, settings: settings, cfg: cfg}}+func (s *JobService) SetScheduler(scheduler JobRunner) {+ s.scheduler = scheduler+}+func (s *JobService) GetJobSchedules(ctx context.Context) jobschedule.Config {// Use SettingsService cache for fast reads.return jobschedule.Config{@@ -73,6 +85,7 @@ func (s *JobService) UpdateJobSchedules(ctx context.Context, updates jobschedule}changed := false+ changedKeys := make([]string, 0, 3)upsert := func(tx *gorm.DB, key string, v *string, currentVal string) error {if v == nil {return nil@@ -81,6 +94,7 @@ func (s *JobService) UpdateJobSchedules(ctx context.Context, updates jobschedulereturn nil}changed = true+ changedKeys = append(changedKeys, key)return tx.Save(&models.SettingVariable{Key: key, Value: *v}).Error}@@ -107,9 +121,144 @@ func (s *JobService) UpdateJobSchedules(ctx context.Context, updates jobschedule}if s.OnJobSchedulesChanged != nil {- s.OnJobSchedulesChanged(ctx)+ s.OnJobSchedulesChanged(ctx, changedKeys)}}return s.GetJobSchedules(ctx), nil}++func (s *JobService) ListJobs(ctx context.Context) (*jobschedule.JobListResponse, error) {+ if s == nil || s.settings == nil {+ return nil, fmt.Errorf("job service not initialized")+ }++ allMetadata := meta.GetAllJobMetadata()+ jobs := make([]jobschedule.JobStatus, 0, len(allMetadata))++ for _, meta := range allMetadata {+ schedule := s.getJobScheduleInternal(ctx, meta)+ nextRun := s.calculateNextRunInternal(schedule)+ enabled := s.isJobEnabledInternal(ctx, meta)+ prerequisites := s.evaluatePrerequisitesInternal(ctx, meta)++ jobStatus := meta.ToJobStatus(schedule, nextRun, enabled, prerequisites)+ jobs = append(jobs, jobStatus)+ }++ isAgent := s.cfg != nil && s.cfg.AgentMode++ return &jobschedule.JobListResponse{+ Jobs: jobs,+ IsAgent: isAgent,+ }, nil+}++func (s *JobService) RunJobNowInline(ctx context.Context, jobID string) error {+ job, err := s.getRunnableJobInternal(jobID)+ if err != nil {+ return err+ }++ runCtx := context.WithoutCancel(ctx)+ job.Run(runCtx)++ return nil+}++func (s *JobService) getRunnableJobInternal(jobID string) (schedulertypes.Job, error) {+ if s == nil || s.scheduler == nil {+ return nil, fmt.Errorf("job service or scheduler not initialized")+ }++ meta, ok := meta.GetJobMetadata(jobID)+ if !ok {+ return nil, fmt.Errorf("unknown job: %s", jobID)+ }++ if !meta.CanRunManually {+ return nil, fmt.Errorf("job %s cannot be run manually", jobID)+ }++ if s.cfg != nil && s.cfg.AgentMode && meta.ManagerOnly {+ return nil, fmt.Errorf("job %s is manager-only and cannot run in agent mode", jobID)+ }++ job, ok := s.scheduler.GetJob(jobID)+ if !ok {+ return nil, fmt.Errorf("job %s not found in scheduler", jobID)+ }++ return job, nil+}++func (s *JobService) getJobScheduleInternal(ctx context.Context, meta meta.JobMetadata) string {+ if meta.IsContinuous {+ return "continuous"+ }++ if meta.SettingsKey == "" {+ return ""+ }++ defaultSchedules := map[string]string{+ "environmentHealthInterval": "0 */2 * * * *",+ "eventCleanupInterval": "0 0 */6 * * *",+ "analyticsHeartbeatInterval": "0 0 0 * * *",+ "autoUpdateInterval": "0 0 0 * * *",+ "pollingInterval": "0 */15 * * * *",+ "scheduledPruneInterval": "0 0 0 * * *",+ "gitopsSyncInterval": "0 */5 * * * *",+ }++ defaultSchedule := defaultSchedules[meta.SettingsKey]+ if defaultSchedule == "" {+ defaultSchedule = "0 0 0 * * *"+ }++ return s.settings.GetStringSetting(ctx, meta.SettingsKey, defaultSchedule)+}++func (s *JobService) isJobEnabledInternal(ctx context.Context, meta meta.JobMetadata) bool {+ if meta.IsContinuous {+ return true+ }++ if meta.EnabledKey != "" {+ return s.settings.GetBoolSetting(ctx, meta.EnabledKey, false)+ }++ return true+}++func (s *JobService) evaluatePrerequisitesInternal(ctx context.Context, meta meta.JobMetadata) []jobschedule.JobPrerequisite {+ prerequisites := make([]jobschedule.JobPrerequisite, 0, len(meta.Prerequisites))++ for _, prereq := range meta.Prerequisites {+ isMet := s.settings.GetBoolSetting(ctx, prereq.SettingKey, false)++ prerequisites = append(prerequisites, jobschedule.JobPrerequisite{+ SettingKey: prereq.SettingKey,+ Label: prereq.Label,+ IsMet: isMet,+ SettingsURL: prereq.SettingsURL,+ })+ }++ return prerequisites+}++func (s *JobService) calculateNextRunInternal(schedule string) *time.Time {+ if schedule == "" || schedule == "continuous" {+ return nil+ }++ parser := cron.NewParser(cron.Second | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow)+ sched, err := parser.Parse(schedule)+ if err != nil {+ return nil+ }++ nextRun := sched.Next(time.Now())+ return &nextRun+}diff --git a/backend/internal/utils/edge/client.go b/backend/internal/utils/edge/client.goindex af7fe71d4..f904c824e 100644--- a/backend/internal/utils/edge/client.go+++ b/backend/internal/utils/edge/client.go@@ -83,11 +83,6 @@ func NewTunnelClient(cfg *config.Config, handler http.Handler) *TunnelClient {}}-// Start begins the tunnel client, attempting to connect and reconnect as needed-func (c *TunnelClient) Start(ctx context.Context) {- c.StartWithErrorChan(ctx, nil)-}-// StartWithErrorChan runs the tunnel client and optionally emits connection errors.func (c *TunnelClient) StartWithErrorChan(ctx context.Context, errCh chan error) {slog.InfoContext(ctx, "Starting edge tunnel client", "manager_url", c.managerURL)@@ -518,29 +513,6 @@ func (r *responseRecorder) WriteHeader(statusCode int) {r.statusCode = statusCode}-// StartTunnelClient starts the edge tunnel client in a goroutine-// This is called from bootstrap when in edge mode-func StartTunnelClient(ctx context.Context, cfg *config.Config, handler http.Handler) {- if !cfg.EdgeAgent {- slog.WarnContext(ctx, "StartTunnelClient called but EDGE_AGENT is disabled")- return- }-- if cfg.ManagerApiUrl == "" {- slog.ErrorContext(ctx, "Cannot start edge tunnel: MANAGER_API_URL is required")- return- }-- if cfg.AgentToken == "" {- slog.ErrorContext(ctx, "Cannot start edge tunnel: AGENT_TOKEN is required")- return- }-- client := NewTunnelClient(cfg, handler)- // Run in background - this will auto-reconnect- go client.Start(ctx)-}-// StartTunnelClientWithErrors starts the tunnel client and returns a channel for connection errors.func StartTunnelClientWithErrors(ctx context.Context, cfg *config.Config, handler http.Handler) (<-chan error, error) {if !cfg.EdgeAgent {diff --git a/backend/internal/utils/edge/client_test.go b/backend/internal/utils/edge/client_test.goindex 7fa9c95a9..e0e758dac 100644--- a/backend/internal/utils/edge/client_test.go+++ b/backend/internal/utils/edge/client_test.go@@ -71,7 +71,7 @@ func TestTunnelClient_HandleRequest(t *testing.T) {defer cancel()// Run client in background- go client.Start(ctx)+ go client.StartWithErrorChan(ctx, nil)// Wait for process to finish or timeouttime.Sleep(100 * time.Millisecond)@@ -148,7 +148,7 @@ func TestTunnelClient_WebSocketProxy(t *testing.T) {ctx, cancel := context.WithCancel(context.Background())defer cancel()- go client.Start(ctx)+ go client.StartWithErrorChan(ctx, nil)time.Sleep(100 * time.Millisecond)}@@ -198,7 +198,7 @@ func TestTunnelClient_HandleRequest_Errors(t *testing.T) {ctx, cancel := context.WithCancel(context.Background())defer cancel()- go client.Start(ctx)+ go client.StartWithErrorChan(ctx, nil)time.Sleep(100 * time.Millisecond)}@@ -245,17 +245,3 @@ func TestTunnelClient_InternalHelpers(t *testing.T) {// Test sendErrorResponseclient.sendErrorResponse("req-1", 500, "error")}--func TestStartTunnelClient(t *testing.T) {- // Just test the configuration checks- ctx := context.Background()-- // Disabled- StartTunnelClient(ctx, &config.Config{EdgeAgent: false}, nil)-- // Missing URL- StartTunnelClient(ctx, &config.Config{EdgeAgent: true, ManagerApiUrl: ""}, nil)-- // Missing Token- StartTunnelClient(ctx, &config.Config{EdgeAgent: true, ManagerApiUrl: "http://x", AgentToken: ""}, nil)-}diff --git a/backend/pkg/scheduler/analytics_job.go b/backend/pkg/scheduler/analytics_job.goindex 94a385e20..6cadf5942 100644--- a/backend/pkg/scheduler/analytics_job.go+++ b/backend/pkg/scheduler/analytics_job.go@@ -19,7 +19,6 @@ import (const (AnalyticsJobName = "analytics-heartbeat"defaultHeartbeatEndpoint = "https://checkin.getarcane.app/heartbeat"- defaultAnalyticsInterval = 24 * time.Hour)type AnalyticsJob struct {diff --git a/backend/pkg/scheduler/event_cleanup_job.go b/backend/pkg/scheduler/event_cleanup_job.goindex 00a0b69d1..96429970f 100644--- a/backend/pkg/scheduler/event_cleanup_job.go+++ b/backend/pkg/scheduler/event_cleanup_job.go@@ -10,7 +10,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/services")-const EventCleanupJobName = "EventCleanup"+const EventCleanupJobName = "event-cleanup"type EventCleanupJob struct {eventService *services.EventServicediff --git a/backend/pkg/scheduler/scheduler.go b/backend/pkg/scheduler/scheduler.goindex 5969ee2e0..5959178bc 100644--- a/backend/pkg/scheduler/scheduler.go+++ b/backend/pkg/scheduler/scheduler.go@@ -9,21 +9,31 @@ import ()type JobScheduler struct {- cron *cron.Cron- jobs []schedulertypes.Job- context context.Context+ cron *cron.Cron+ jobs []schedulertypes.Job+ jobsByID map[string]schedulertypes.Job+ entryIDs map[string]cron.EntryID+ context context.Context}func NewJobScheduler(ctx context.Context) *JobScheduler {return &JobScheduler{- cron: cron.New(cron.WithSeconds()),- jobs: []schedulertypes.Job{},- context: ctx,+ cron: cron.New(cron.WithSeconds()),+ jobs: []schedulertypes.Job{},+ jobsByID: make(map[string]schedulertypes.Job),+ entryIDs: make(map[string]cron.EntryID),+ context: ctx,}}func (js *JobScheduler) RegisterJob(job schedulertypes.Job) {js.jobs = append(js.jobs, job)+ js.jobsByID[job.Name()] = job+}++func (js *JobScheduler) GetJob(jobID string) (schedulertypes.Job, bool) {+ job, ok := js.jobsByID[jobID]+ return job, ok}func (js *JobScheduler) StartScheduler() {@@ -33,17 +43,41 @@ func (js *JobScheduler) StartScheduler() {slog.InfoContext(js.context, "Starting Job", "name", currentJob.Name(), "schedule", schedule)- if _, err := js.cron.AddFunc(schedule, func() {- slog.InfoContext(js.context, "Job starting", "name", currentJob.Name())+ entryID, err := js.cron.AddFunc(schedule, func() {+ slog.InfoContext(js.context, "Job starting", "name", currentJob.Name(), "schedule", schedule)currentJob.Run(js.context)slog.InfoContext(js.context, "Job finished", "name", currentJob.Name())- }); err != nil {+ })+ if err != nil {slog.ErrorContext(js.context, "Failed to schedule job", "name", currentJob.Name(), "error", err)+ continue}++ js.entryIDs[currentJob.Name()] = entryID}js.cron.Start()}+func (js *JobScheduler) RescheduleJob(ctx context.Context, job schedulertypes.Job) error {+ schedule := job.Schedule(ctx)++ if entryID, ok := js.entryIDs[job.Name()]; ok {+ js.cron.Remove(entryID)+ }++ entryID, err := js.cron.AddFunc(schedule, func() {+ slog.InfoContext(ctx, "Job starting", "name", job.Name(), "schedule", schedule)+ job.Run(ctx)+ slog.InfoContext(ctx, "Job finished", "name", job.Name())+ })+ if err != nil {+ return err+ }++ js.entryIDs[job.Name()] = entryID+ return nil+}+func (js *JobScheduler) Run(ctx context.Context) error {js.StartScheduler()<-ctx.Done()diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex c07524b0d..82b595221 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -898,6 +898,13 @@"jobs_monitoring_heading": "Monitoring","jobs_maintenance_heading": "Maintenance","jobs_telemetry_heading": "Telemetry",+ "jobs_updates_heading": "Updates",+ "jobs_sync_heading": "Sync",+ "jobs_moved_title": "Job schedules moved",+ "jobs_moved_description": "Job schedules are now managed per environment. Select an environment to edit schedules and run jobs.",+ "jobs_moved_cta": "Go to Environments",+ "jobs_environment_scope_title": "Environment-specific schedules",+ "jobs_environment_scope_description": "These schedules and controls apply only to the currently selected environment.","jobs_event_cleanup_title": "Event Cleanup","jobs_event_cleanup_description": "How often Arcane deletes events older than 36 hours","jobs_event_cleanup_interval_label": "Event Cleanup Interval (minutes)",@@ -906,6 +913,42 @@"jobs_analytics_description": "Only runs in production, and only if analytics are enabled","jobs_analytics_interval_label": "Analytics Heartbeat Interval (minutes)","jobs_analytics_interval_help": "Minimum 60 minutes",+ "jobs_run_now": "Run Now",+ "jobs_next_run": "Next run",+ "jobs_schedule": "Schedule",+ "jobs_continuous": "Continuous",+ "jobs_manager_only": "Manager Only",+ "jobs_edit_schedule": "Edit Schedule",+ "jobs_schedule_updated": "Job schedule updated",+ "jobs_schedule_update_failed": "Failed to update job schedule",+ "jobs_run_success": "Job started successfully",+ "jobs_run_failed": "Failed to start job",+ "jobs_environment_health_name": "Environment Health",+ "jobs_environment_health_description": "Checks the health and connectivity of all enabled environments",+ "jobs_event_cleanup_name": "Event Cleanup",+ "jobs_event_cleanup_name_description": "Removes old system events to maintain database performance",+ "jobs_analytics_heartbeat_name": "Analytics Heartbeat",+ "jobs_analytics_heartbeat_description": "Sends usage statistics and telemetry data",+ "jobs_auto_update_name": "Auto Update",+ "jobs_auto_update_description": "Automatically updates containers when new images are available",+ "jobs_image_polling_name": "Image Polling",+ "jobs_image_polling_description": "Checks container registries for new image versions",+ "jobs_scheduled_prune_name": "Scheduled Prune",+ "jobs_scheduled_prune_description": "Removes unused containers, images, volumes, and networks",+ "jobs_gitops_sync_name": "GitOps Sync",+ "jobs_gitops_sync_description": "Synchronizes project state with configured git repositories",+ "jobs_filesystem_watcher_name": "Filesystem Watcher",+ "jobs_filesystem_watcher_description": "Monitors project directory for changes and syncs automatically",+ "jobs_cron_expression": "Cron Expression",+ "jobs_cron_expression_help": "Enter a valid cron expression (seconds minutes hours day month weekday)",+ "jobs_cron_required": "Cron expression is required",+ "jobs_cron_invalid": "Cron expression must have 6 parts (seconds minutes hours day month weekday)",+ "jobs_cron_examples": "Examples",+ "jobs_cron_example_every_15min": "Every 15 minutes",+ "jobs_cron_example_hourly": "Every hour",+ "jobs_cron_example_daily": "Daily at midnight",+ "jobs_cron_example_every_6hours": "Every 6 hours",+ "jobs_schedule_update_unavailable": "Schedule updates are not available for this job","_comment_settings_docker": "=== SETTINGS - DOCKER ===","docker_title": "Docker","docker_default_shell_label": "Default Shell",diff --git a/frontend/src/app.css b/frontend/src/app.cssindex 2b5341bfa..7ef62bb44 100644--- a/frontend/src/app.css+++ b/frontend/src/app.css@@ -64,8 +64,8 @@--sidebar-accent-foreground: oklch(0.21 0.006 285.885);--sidebar-border: oklch(0.92 0.004 286.32);--sidebar-ring: oklch(0.606 0.25 292.717);+ --surface: oklch(0.21 0.006 285.885);- --bg-surface: oklch(1 0 0);--glass-base: var(--bg-surface);--glass-tint: var(--primary);--glass-shadow-color: oklch(0 0 0 / 0.12);@@ -145,6 +145,7 @@--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);--color-sidebar-border: var(--sidebar-border);--color-sidebar-ring: var(--sidebar-ring);+ --color-surface: var(--surface);--font-sans: 'Geist', system-ui, sans-serif;--font-mono: 'Geist Mono', monospace;diff --git a/frontend/src/lib/components/job-card/job-card.svelte b/frontend/src/lib/components/job-card/job-card.sveltenew file mode 100644index 000000000..a4ebca728--- /dev/null+++ b/frontend/src/lib/components/job-card/job-card.svelte@@ -0,0 +1,141 @@+<script lang="ts">+ import { StartIcon, EditIcon, ClockIcon } from '$lib/icons';+ import { m } from '$lib/paraglide/messages';+ import { Badge } from '$lib/components/ui/badge';+ import { Button } from '$lib/components/ui/button';+ import * as Card from '$lib/components/ui/card';+ import { Spinner } from '$lib/components/ui/spinner';+ import { tryCatch } from '$lib/utils/try-catch';+ import { jobScheduleService } from '$lib/services/job-schedule-service';+ import { formatDistanceToNow } from 'date-fns';+ import type { Snippet } from 'svelte';+ import type { JobStatus } from '$lib/types/job-schedule.type';+ import JobScheduleDialog from './job-schedule-dialog.svelte';++ let {+ job,+ isAgent = false,+ onScheduleUpdate,+ children,+ enabledOverride,+ headerAccessory+ }: {+ job: JobStatus;+ isAgent?: boolean;+ onScheduleUpdate?: () => void;+ children?: Snippet;+ enabledOverride?: boolean;+ headerAccessory?: Snippet;+ } = $props();++ let isRunning = $state(false);+ let showScheduleDialog = $state(false);++ const nextRunText = $derived.by(() => {+ if (!job.nextRun) return null;+ const nextRunDate = new Date(job.nextRun);+ const relative = formatDistanceToNow(nextRunDate, { addSuffix: true });+ const absolute = nextRunDate.toLocaleString();+ return `${relative} (${absolute})`;+ });++ const isEnabled = $derived.by(() => enabledOverride ?? job.enabled);++ const canRun = $derived(isEnabled && job.canRunManually && !isRunning && !(isAgent && job.managerOnly));++ async function runJobNow() {+ if (!canRun) return;++ isRunning = true;+ const result = await tryCatch(jobScheduleService.runJob(job.id));+ isRunning = false;++ if (result.error || !result.data?.success) {+ return;+ }+ }++ function openScheduleDialog() {+ showScheduleDialog = true;+ }++ function handleScheduleUpdated() {+ showScheduleDialog = false;+ onScheduleUpdate?.();+ }+</script>++<Card.Root class="bg-background/60 h-full rounded-xl border border-white/10 shadow-none backdrop-blur-md">+ <Card.Header class="flex flex-row items-center justify-between space-y-0 px-4 py-4">+ <div class="flex flex-col gap-1.5">+ <div class="flex items-center gap-2">+ <Card.Title class="text-sm leading-none font-medium">{job.name}</Card.Title>+ {#if job.isContinuous}+ <Badge variant="outline" class="h-4.5 border-white/10 px-1.5 text-[0.6rem] font-medium">{m.jobs_continuous()}</Badge>+ {/if}+ </div>+ <Card.Description class="text-muted-foreground/80 line-clamp-1 text-xs">{job.description}</Card.Description>+ </div>+ <div class="flex items-center gap-2">+ {#if headerAccessory}+ {@render headerAccessory()}+ {/if}+ {#if isEnabled && !job.isContinuous && job.settingsKey}+ <Button+ variant="ghost"+ size="icon"+ onclick={openScheduleDialog}+ disabled={isAgent && job.managerOnly}+ class="size-7 opacity-75 hover:bg-white/5 hover:opacity-100"+ >+ <EditIcon class="size-3.5" />+ </Button>+ {/if}+ {#if isEnabled && job.canRunManually}+ <Button+ variant="outline"+ size="sm"+ onclick={runJobNow}+ disabled={!canRun}+ class="h-7 border-white/10 bg-transparent px-2.5 text-xs font-medium shadow-none hover:bg-white/5"+ >+ {#if isRunning}+ <Spinner class="mr-1.5 size-3" />+ {m.common_running()}+ {:else}+ <StartIcon class="mr-1.5 size-3.5" />+ {m.jobs_run_now()}+ {/if}+ </Button>+ {/if}+ </div>+ </Card.Header>+ <Card.Content class="space-y-2 px-4 pt-0 pb-4">+ {#if isEnabled}+ <div class="text-muted-foreground grid gap-2 text-xs">+ {#if !job.isContinuous}+ <div class="flex items-center gap-2">+ <ClockIcon class="h-3.5 w-3.5" />+ <span>{m.jobs_schedule()}:</span>+ <code class="bg-muted rounded px-2 py-0.5 text-[0.65rem]">{job.schedule}</code>+ </div>+ {#if nextRunText}+ <div>+ {m.jobs_next_run()}: {nextRunText}+ </div>+ {/if}+ {:else}+ <div>{m.jobs_continuous()}</div>+ {/if}+ </div>+ {/if}++ {#if children}+ {@render children()}+ {/if}+ </Card.Content>+</Card.Root>++{#if showScheduleDialog}+ <JobScheduleDialog {job} bind:open={showScheduleDialog} onUpdate={handleScheduleUpdated} />+{/if}diff --git a/frontend/src/lib/components/job-card/job-schedule-dialog.svelte b/frontend/src/lib/components/job-card/job-schedule-dialog.sveltenew file mode 100644index 000000000..fb303e869--- /dev/null+++ b/frontend/src/lib/components/job-card/job-schedule-dialog.svelte@@ -0,0 +1,133 @@+<script lang="ts">+ import { toast } from 'svelte-sonner';+ import { m } from '$lib/paraglide/messages';+ import { Button } from '$lib/components/ui/button';+ import { ResponsiveDialog } from '$lib/components/ui/responsive-dialog';+ import { Label } from '$lib/components/ui/label';+ import { Input } from '$lib/components/ui/input';+ import { tryCatch } from '$lib/utils/try-catch';+ import { jobScheduleService } from '$lib/services/job-schedule-service';+ import type { JobStatus } from '$lib/types/job-schedule.type';++ let {+ job,+ open = $bindable(false),+ onUpdate+ }: {+ job: JobStatus;+ open?: boolean;+ onUpdate?: () => void;+ } = $props();++ let scheduleValue = $state('');+ let error = $state<string | null>(null);+ let isLoading = $state(false);++ const cronExamples = [+ { label: m.jobs_cron_example_every_15min(), value: '0 */15 * * * *' },+ { label: m.jobs_cron_example_hourly(), value: '0 0 * * * *' },+ { label: m.jobs_cron_example_every_6hours(), value: '0 0 */6 * * *' },+ { label: m.jobs_cron_example_daily(), value: '0 0 0 * * *' }+ ];++ function validateCron(value: string): boolean {+ if (!value.trim()) {+ error = m.jobs_cron_required();+ return false;+ }++ const parts = value.trim().split(/\s+/);+ if (parts.length !== 6) {+ error = m.jobs_cron_invalid();+ return false;+ }++ error = null;+ return true;+ }++ async function save() {+ if (!validateCron(scheduleValue)) {+ return;+ }++ if (!job.settingsKey) {+ toast.error(m.jobs_schedule_update_unavailable());+ return;+ }++ isLoading = true;+ const update = { [job.settingsKey]: scheduleValue };+ const result = await tryCatch(jobScheduleService.updateJobSchedules(update));+ isLoading = false;++ if (result.error) {+ toast.error(result.error.message || m.jobs_schedule_update_failed());+ return;+ }++ toast.success(m.jobs_schedule_updated());+ onUpdate?.();+ }++ function useCronExample(value: string) {+ scheduleValue = value;+ error = null;+ }++ function handleOpenChange(isOpen: boolean) {+ if (isOpen) {+ scheduleValue = job.schedule;+ error = null;+ }+ }++ handleOpenChange(open);+</script>++<ResponsiveDialog+ bind:open+ onOpenChange={handleOpenChange}+ title={m.jobs_edit_schedule()}+ description={job.name}+ contentClass="sm:max-w-[500px]"+>+ <div class="space-y-4 py-4">+ <div class="space-y-2">+ <Label for="schedule">{m.jobs_cron_expression()}</Label>+ <Input id="schedule" bind:value={scheduleValue} placeholder="0 */15 * * * *" class={error ? 'border-destructive' : ''} />+ {#if error}+ <p class="text-destructive text-sm">{error}</p>+ {:else}+ <p class="text-muted-foreground text-sm">{m.jobs_cron_expression_help()}</p>+ {/if}+ </div>++ <div class="space-y-2">+ <Label>{m.jobs_cron_examples()}</Label>+ <div class="grid grid-cols-2 gap-3 pt-2">+ {#each cronExamples as example (example.value)}+ <Button+ variant="outline"+ onclick={() => useCronExample(example.value)}+ class="min-h-12 items-start justify-start px-3 py-2 whitespace-normal"+ >+ <div class="text-left">+ <div class="text-xs leading-4 font-medium">{example.label}</div>+ <div class="text-muted-foreground font-mono text-xs leading-4">{example.value}</div>+ </div>+ </Button>+ {/each}+ </div>+ </div>+ </div>++ {#snippet footer()}+ <Button variant="outline" onclick={() => (open = false)} disabled={isLoading}>+ {m.common_cancel()}+ </Button>+ <Button onclick={save} disabled={isLoading}>+ {isLoading ? m.common_saving() : m.common_save()}+ </Button>+ {/snippet}+</ResponsiveDialog>diff --git a/frontend/src/lib/components/ui/card/card.svelte b/frontend/src/lib/components/ui/card/card.svelteindex b159ce60b..3abc3bfb6 100644--- a/frontend/src/lib/components/ui/card/card.svelte+++ b/frontend/src/lib/components/ui/card/card.svelte@@ -28,13 +28,13 @@function getVariantClasses(variant: 'default' | 'subtle' | 'outlined') {switch (variant) {case 'default':- return 'backdrop-blur-sm bg-card/90 shadow-sm';+ return 'backdrop-blur-sm bg-surface/40 shadow-sm';case 'subtle':- return 'backdrop-blur-sm bg-card/60';+ return 'backdrop-blur-sm bg-surface/40';case 'outlined':- return 'backdrop-blur-lg bg-card/60 border-border/50';+ return 'backdrop-blur-lg bg-surface/40 border-border/50';default:- return 'backdrop-blur-sm bg-card/90 shadow-sm';+ return 'backdrop-blur-sm bg-surface/40 shadow-sm';}}</script>diff --git a/frontend/src/lib/components/ui/tabs/tabs-list.svelte b/frontend/src/lib/components/ui/tabs/tabs-list.svelteindex e8e11db5b..ee91a794e 100644--- a/frontend/src/lib/components/ui/tabs/tabs-list.svelte+++ b/frontend/src/lib/components/ui/tabs/tabs-list.svelte@@ -7,6 +7,9 @@<TabsPrimitive.Listbind:ref- class={cn('bg-muted text-muted-foreground inline-flex h-10 items-center justify-center rounded-md p-1', className)}+ class={cn(+ 'text-muted-foreground inline-flex h-10 items-center justify-center rounded-lg bg-black/5 p-1 backdrop-blur-lg dark:bg-white/5',+ className+ )}{...restProps}/>diff --git a/frontend/src/lib/components/ui/tabs/tabs-trigger.svelte b/frontend/src/lib/components/ui/tabs/tabs-trigger.svelteindex c6c1f105b..80eebf8f4 100644--- a/frontend/src/lib/components/ui/tabs/tabs-trigger.svelte+++ b/frontend/src/lib/components/ui/tabs/tabs-trigger.svelte@@ -8,7 +8,7 @@<TabsPrimitive.Triggerbind:refclass={cn(- 'ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-sm px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm',+ 'ring-offset-background focus-visible:ring-ring hover:bg-primary/5 data-[state=active]:bg-primary/15 data-[state=active]:text-primary inline-flex items-center justify-center rounded-md px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm',className)}{...restProps}diff --git a/frontend/src/lib/config/navigation-config.ts b/frontend/src/lib/config/navigation-config.tsindex 17e45473e..42b7f2066 100644--- a/frontend/src/lib/config/navigation-config.ts+++ b/frontend/src/lib/config/navigation-config.ts@@ -15,7 +15,6 @@ import {VolumesIcon,EventsIcon,SettingsIcon,- JobsIcon,GitBranchIcon} from '$lib/icons';import { m } from '$lib/paraglide/messages';@@ -53,7 +52,6 @@ export const navigationItems: Record<string, NavigationItem[]> = {items: [{ title: m.api_key_page_title(), url: '/settings/api-keys', icon: ApiKeyIcon },{ title: m.appearance_title(), url: '/settings/appearance', icon: ApperanceIcon },- { title: m.jobs_title(), url: '/settings/jobs', icon: JobsIcon },{ title: m.notifications_title(), url: '/settings/notifications', icon: NotificationsIcon },{ title: m.security_title(), url: '/settings/security', icon: SecurityIcon },{ title: m.users_title(), url: '/settings/users', icon: UsersIcon }diff --git a/frontend/src/lib/services/job-schedule-service.ts b/frontend/src/lib/services/job-schedule-service.tsindex 59a62195a..c89fdb3b9 100644--- a/frontend/src/lib/services/job-schedule-service.ts+++ b/frontend/src/lib/services/job-schedule-service.ts@@ -1,5 +1,5 @@import BaseAPIService from './api-service';-import type { JobSchedules, JobSchedulesUpdate } from '$lib/types/job-schedule.type';+import type { JobSchedules, JobSchedulesUpdate, JobListResponse, JobRunResponse } from '$lib/types/job-schedule.type';class JobScheduleService extends BaseAPIService {async getJobSchedules(): Promise<JobSchedules> {@@ -9,6 +9,14 @@ class JobScheduleService extends BaseAPIService {async updateJobSchedules(update: JobSchedulesUpdate): Promise<JobSchedules> {return this.handleResponse(this.api.put('/job-schedules', update));}++ async listJobs(): Promise<JobListResponse> {+ return this.handleResponse(this.api.get('/jobs'));+ }++ async runJob(jobId: string): Promise<JobRunResponse> {+ return this.handleResponse(this.api.post(`/jobs/${jobId}/run`));+ }}export const jobScheduleService = new JobScheduleService();diff --git a/frontend/src/lib/types/job-schedule.type.ts b/frontend/src/lib/types/job-schedule.type.tsindex d115ec053..ed769508c 100644--- a/frontend/src/lib/types/job-schedule.type.ts+++ b/frontend/src/lib/types/job-schedule.type.ts@@ -5,3 +5,35 @@ export type JobSchedules = {};export type JobSchedulesUpdate = Partial<JobSchedules>;++export type JobPrerequisite = {+ settingKey: string;+ label: string;+ isMet: boolean;+ settingsUrl?: string;+};++export type JobStatus = {+ id: string;+ name: string;+ description: string;+ category: string;+ schedule: string;+ nextRun?: string;+ enabled: boolean;+ managerOnly: boolean;+ isContinuous: boolean;+ canRunManually: boolean;+ prerequisites: JobPrerequisite[];+ settingsKey?: string;+};++export type JobListResponse = {+ jobs: JobStatus[];+ isAgent: boolean;+};++export type JobRunResponse = {+ success: boolean;+ message: string;+};diff --git a/frontend/src/routes/(app)/environments/[id]/+page.svelte b/frontend/src/routes/(app)/environments/[id]/+page.svelteindex c6d79e8e5..014f7d190 100644--- a/frontend/src/routes/(app)/environments/[id]/+page.svelte+++ b/frontend/src/routes/(app)/environments/[id]/+page.svelte@@ -1,41 +1,33 @@<script lang="ts">import { z } from 'zod/v4';- import * as Card from '$lib/components/ui/card/index.js';import * as Tabs from '$lib/components/ui/tabs/index.js';import { TabBar, type TabItem } from '$lib/components/tab-bar';import { ArcaneButton } from '$lib/components/arcane-button/index.js';import * as AlertDialog from '$lib/components/ui/alert-dialog';- import * as ArcaneTooltip from '$lib/components/arcane-tooltip';import { goto, invalidateAll } from '$app/navigation';- import StatusBadge from '$lib/components/badges/status-badge.svelte';+ import { page } from '$app/state';import { toast } from 'svelte-sonner';- import Label from '$lib/components/ui/label/label.svelte';- import { Input } from '$lib/components/ui/input/index.js';- import { Switch } from '$lib/components/ui/switch/index.js';- import { Badge } from '$lib/components/ui/badge/index.js';import { m } from '$lib/paraglide/messages';import { environmentManagementService } from '$lib/services/env-mgmt-service.js';import { settingsService } from '$lib/services/settings-service';import { environmentStore } from '$lib/stores/environment.store.svelte';- import { Spinner } from '$lib/components/ui/spinner/index.js';- import { CopyButton } from '$lib/components/ui/copy-button';import type { AppVersionInformation } from '$lib/types/application-configuration';- import SelectWithLabel from '$lib/components/form/select-with-label.svelte';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';import MobileFloatingFormActions from '$lib/components/form/mobile-floating-form-actions.svelte';import { createSettingsForm } from '$lib/utils/settings-form.util';+ import DetailsTab from './components/DetailsTab.svelte';+ import GeneralTab from './components/GeneralTab.svelte';+ import DockerTab from './components/DockerTab.svelte';+ import JobsTab from './components/JobsTab.svelte';+ import AgentTab from './components/AgentTab.svelte';import {ArrowLeftIcon,EnvironmentsIcon,AlertIcon,- TestIcon,RefreshIcon,- ResetIcon,ApiKeyIcon,DockerBrandIcon,SettingsIcon,GitBranchIcon,- ArrowRightIcon,JobsIcon} from '$lib/icons';@@ -44,9 +36,14 @@let currentEnvironment = $derived(environmentStore.selected);- let activeTab = $state('general');+ let activeTab = $state('details');const tabItems: TabItem[] = [+ {+ value: 'details',+ label: m.environments_overview_title(),+ icon: EnvironmentsIcon+ },{value: 'general',label: m.general_title(),@@ -58,12 +55,44 @@icon: DockerBrandIcon},{- value: 'maintenance',- label: m.maintenance_title(),+ value: 'jobs',+ label: m.jobs_title(),icon: JobsIcon+ },+ {+ value: 'agent',+ label: m.environments_agent_config_title(),+ icon: ApiKeyIcon+ },+ {+ value: 'gitops',+ label: m.git_syncs_title(),+ icon: GitBranchIcon}];+ const tabValues = new Set(tabItems.map((tab) => tab.value));++ $effect(() => {+ const tabFromUrl = page.url.searchParams.get('tab');+ if (!tabFromUrl || !tabValues.has(tabFromUrl) || tabFromUrl === activeTab) {+ return;+ }+ if (tabFromUrl === 'gitops') {+ goto(`/environments/${environment.id}/gitops`);+ return;+ }+ activeTab = tabFromUrl;+ });++ function handleTabChange(value: string) {+ if (value === 'gitops') {+ goto(`/environments/${environment.id}/gitops`);+ return;+ }+ activeTab = value;+ }+let isRefreshing = $state(false);let isTestingConnection = $state(false);let isSyncing = $state(false);@@ -91,9 +120,7 @@apiUrl: z.string(),// SettingspollingEnabled: z.boolean(),- pollingInterval: z.coerce.number(),autoUpdate: z.boolean(),- autoUpdateInterval: z.coerce.number(),autoInjectEnv: z.boolean(),dockerPruneMode: z.enum(['all', 'dangling']),defaultShell: z.string(),@@ -102,7 +129,6 @@maxImageUploadSize: z.coerce.number(),baseServerUrl: z.string(),scheduledPruneEnabled: z.boolean(),- scheduledPruneInterval: z.coerce.number().min(60).max(10080),scheduledPruneContainers: z.boolean(),scheduledPruneImages: z.boolean(),scheduledPruneVolumes: z.boolean(),@@ -116,9 +142,7 @@enabled: environment.enabled,apiUrl: environment.apiUrl,pollingEnabled: settings?.pollingEnabled ?? false,- pollingInterval: settings?.pollingInterval ?? 60,autoUpdate: settings?.autoUpdate ?? false,- autoUpdateInterval: settings?.autoUpdateInterval ?? 1440,autoInjectEnv: settings?.autoInjectEnv ?? false,dockerPruneMode: (settings?.dockerPruneMode as 'all' | 'dangling') || 'dangling',defaultShell: settings?.defaultShell || '/bin/sh',@@ -127,7 +151,6 @@maxImageUploadSize: settings?.maxImageUploadSize || 500,baseServerUrl: settings?.baseServerUrl || 'http://localhost',scheduledPruneEnabled: settings?.scheduledPruneEnabled ?? false,- scheduledPruneInterval: settings?.scheduledPruneInterval ?? 1440,scheduledPruneContainers: settings?.scheduledPruneContainers ?? true,scheduledPruneImages: settings?.scheduledPruneImages ?? true,scheduledPruneVolumes: settings?.scheduledPruneVolumes ?? false,@@ -137,8 +160,6 @@// Custom save handler for environment-specific settingsasync function saveEnvironmentSettings(formData: z.infer<typeof formSchema>) {- const sanitizedScheduledPruneInterval = Math.min(Math.max(formData.scheduledPruneInterval || 0, 60), 10080);-// Update environment basic infoawait environmentManagementService.update(environment.id, {name: formData.name,@@ -150,9 +171,7 @@if (settings) {await settingsService.updateSettingsForEnvironment(environment.id, {pollingEnabled: formData.pollingEnabled,- pollingInterval: formData.pollingInterval,autoUpdate: formData.autoUpdate,- autoUpdateInterval: formData.autoUpdateInterval,autoInjectEnv: formData.autoInjectEnv,dockerPruneMode: formData.dockerPruneMode,defaultShell: formData.defaultShell,@@ -161,7 +180,6 @@maxImageUploadSize: formData.maxImageUploadSize,baseServerUrl: formData.baseServerUrl,scheduledPruneEnabled: formData.scheduledPruneEnabled,- scheduledPruneInterval: sanitizedScheduledPruneInterval,scheduledPruneContainers: formData.scheduledPruneContainers,scheduledPruneImages: formData.scheduledPruneImages,scheduledPruneVolumes: formData.scheduledPruneVolumes,@@ -184,7 +202,7 @@}}- let { formInputs, settingsForm, resetForm, onSubmit } = $derived(+ let { formInputs, settingsForm, resetForm, onSubmit, registerOnMount } = $derived(createSettingsForm({schema: formSchema,currentSettings,@@ -196,29 +214,6 @@}));- type PollingIntervalMode = 'hourly' | 'daily' | 'weekly' | 'custom';-- const imagePollingOptions: Array<{- value: PollingIntervalMode;- label: string;- description: string;- minutes?: number;- }> = [- { value: 'hourly', minutes: 60, label: m.hourly(), description: m.polling_hourly_description() },- { value: 'daily', minutes: 1440, label: m.daily(), description: m.polling_daily_description() },- { value: 'weekly', minutes: 10080, label: m.weekly(), description: m.polling_weekly_description() },- { value: 'custom', label: m.custom(), description: m.use_custom_polling_value() }- ];-- const presetToMinutes = Object.fromEntries(- imagePollingOptions.filter((o) => o.value !== 'custom').map((o) => [o.value, o.minutes!])- ) as Record<Exclude<PollingIntervalMode, 'custom'>, number>;-- let pollingIntervalMode = $derived.by((): PollingIntervalMode => {- if (!settings) return 'custom';- return imagePollingOptions.find((o) => o.minutes === settings.pollingInterval)?.value ?? 'custom';- });-const pruneModeOptions = [{ value: 'all', label: m.docker_prune_all(), description: m.docker_prune_all_description() },{ value: 'dangling', label: m.docker_prune_dangling(), description: m.docker_prune_dangling_description() }@@ -240,12 +235,6 @@return shellOptions.find((o) => o.value === settings.defaultShell)?.value ?? 'custom';});- function handlePollingIntervalModeChange(value: string) {- if (value !== 'custom') {- $formInputs.pollingInterval.value = presetToMinutes[value as Exclude<PollingIntervalMode, 'custom'>];- }- }-function handleShellSelectChange(value: string) {if (value !== 'custom') {$formInputs.defaultShell.value = value;@@ -423,19 +412,6 @@</div></div>- <div class="flex flex-wrap items-center gap-2">- <Badge variant="outline" class="gap-1">- <div class="size-2 rounded-full {currentStatus === 'online' ? 'bg-green-500' : 'bg-red-500'}"></div>- {currentStatus === 'online' ? m.common_online() : m.common_offline()}- </Badge>- <Badge variant="outline" class="gap-1">- {environment.enabled ? m.common_enabled() : m.common_disabled()}- </Badge>- {#if environment.id === '0'}- <Badge variant="outline">{m.environments_local_badge()}</Badge>- {/if}- </div>-{#if !environment.enabled || currentStatus === 'offline' || !settings}<divclass="flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-4 text-amber-900 dark:text-amber-200"@@ -456,496 +432,53 @@{/if}</div>- <div class="grid gap-6 gap-x-6 gap-y-6 lg:grid-cols-2">- <Card.Root class="flex flex-col">- <Card.Header icon={EnvironmentsIcon}>- <div class="flex flex-col space-y-1.5">- <Card.Title>- <h2>{m.environments_overview_title()}</h2>- </Card.Title>- <Card.Description>{m.environments_basic_info_description()}</Card.Description>- </div>- </Card.Header>- <Card.Content class="space-y-4 p-4">- <div>- <Label for="env-name" class="text-sm font-medium">{m.common_name()}</Label>- <Input- id="env-name"- type="text"- bind:value={$formInputs.name.value}- class="mt-1.5 w-full {$formInputs.name.error ? 'border-destructive' : ''}"- placeholder={m.environments_name_placeholder()}- />- {#if $formInputs.name.error}- <p class="text-destructive mt-1 text-[0.8rem] font-medium">{$formInputs.name.error}</p>- {/if}- </div>-- <div>- <Label for="api-url" class="text-sm font-medium">{m.environments_api_url()}</Label>- <div class="mt-1.5 flex items-center gap-2">- {#if environment.id === '0'}- <ArcaneTooltip.Root>- <ArcaneTooltip.Trigger class="w-full">- <Input- id="api-url"- type="url"- bind:value={$formInputs.apiUrl.value}- class="w-full font-mono"- placeholder={m.environments_api_url_placeholder()}- disabled={true}- required- />- </ArcaneTooltip.Trigger>- <ArcaneTooltip.Content>- <p>{m.environments_local_setting_disabled()}</p>- </ArcaneTooltip.Content>- </ArcaneTooltip.Root>- {:else}- <Input- id="api-url"- type="url"- bind:value={$formInputs.apiUrl.value}- class="w-full font-mono"- placeholder={m.environments_api_url_placeholder()}- required- />- {/if}- <ArcaneButton- action="base"- onclick={testConnection}- disabled={isTestingConnection}- loading={isTestingConnection}- icon={TestIcon}- customLabel={m.environments_test_connection()}- loadingLabel={m.environments_testing_connection()}- class="shrink-0"- />- </div>- <p class="text-muted-foreground mt-1.5 text-xs">{m.environments_api_url_help()}</p>- </div>-- <div class="flex items-center justify-between rounded-lg border p-4">- <div class="space-y-0.5">- <Label for="env-enabled" class="text-sm font-medium">{m.common_enabled()}</Label>- <div class="text-muted-foreground text-xs">{m.environments_enable_disable_description()}</div>- </div>- {#if environment.id === '0'}- <ArcaneTooltip.Root>- <ArcaneTooltip.Trigger>- <Switch id="env-enabled" disabled={true} bind:checked={$formInputs.enabled.value} />- </ArcaneTooltip.Trigger>- <ArcaneTooltip.Content>- <p>{m.environments_local_setting_disabled()}</p>- </ArcaneTooltip.Content>- </ArcaneTooltip.Root>- {:else}- <Switch id="env-enabled" bind:checked={$formInputs.enabled.value} />- {/if}- </div>+ <Tabs.Root bind:value={activeTab} class="w-full">+ <div class="my-4">+ <TabBar items={tabItems} value={activeTab} onValueChange={handleTabChange} class="w-full" />+ </div>- <div class="grid grid-cols-2 gap-4 rounded-lg border p-4">- <div>- <Label class="text-muted-foreground text-xs font-medium">{m.environments_environment_id_label()}</Label>- <div class="mt-1 font-mono text-sm">{environment.id}</div>- </div>- <div>- <Label class="text-muted-foreground text-xs font-medium">{m.common_status()}</Label>- <div class="mt-1">- <StatusBadge- text={currentStatus === 'online' ? m.common_online() : m.common_offline()}- variant={currentStatus === 'online' ? 'green' : 'red'}- />- </div>- </div>- <div class="col-span-2 border-t pt-4">- <Label class="text-muted-foreground text-xs font-medium">{m.version_info_version()}</Label>- <div class="mt-1 flex items-center gap-2">- {#if environment.id === '0'}- <span class="font-mono text-sm">{versionInformation?.currentVersion || 'Unknown'}</span>- {#if versionInformation?.updateAvailable}- <Badge variant="secondary" class="bg-amber-500/10 text-amber-600 hover:bg-amber-500/20 dark:text-amber-400">- {m.sidebar_update_available()}: {versionInformation.newestVersion}- </Badge>- {/if}- {:else if isLoadingVersion}- <Spinner />- <span class="text-muted-foreground text-sm">{m.common_action_checking()}</span>- {:else if remoteVersion}- <span class="font-mono text-sm">{remoteVersion.currentVersion}</span>- {#if remoteVersion.updateAvailable}- <Badge variant="secondary" class="bg-amber-500/10 text-amber-600 hover:bg-amber-500/20 dark:text-amber-400">- {m.sidebar_update_available()}: {remoteVersion.newestVersion}- </Badge>- {#if remoteVersion.releaseUrl}- <a- href={remoteVersion.releaseUrl}- target="_blank"- rel="noopener noreferrer"- class="text-xs text-blue-500 hover:underline"- >- {m.version_info_view_release()}- </a>- {/if}- {/if}- {:else if currentStatus === 'online'}- <span class="text-muted-foreground text-sm">Version information unavailable</span>- {:else}- <span class="text-muted-foreground text-sm">{m.common_offline()}</span>- {/if}- </div>- </div>- </div>- </Card.Content>- </Card.Root>+ <Tabs.Content value="details">+ <DetailsTab+ {environment}+ {formInputs}+ {currentStatus}+ {isLoadingVersion}+ {remoteVersion}+ {versionInformation}+ {isTestingConnection}+ {testConnection}+ />+ </Tabs.Content>{#if settings}- <Card.Root class="flex flex-col">- <Card.Header icon={SettingsIcon}>- <div class="flex flex-col space-y-1.5">- <Card.Title>- <h2>{m.settings_title()}</h2>- </Card.Title>- <Card.Description>{m.environments_config_description()}</Card.Description>- </div>- </Card.Header>- <Card.Content class="p-0">- <Tabs.Root bind:value={activeTab} class="w-full">- <div class="border-b px-4 py-2">- <div class="w-fit">- <TabBar items={tabItems} value={activeTab} onValueChange={(value) => (activeTab = value)} />- </div>- </div>- <Tabs.Content value="general" class="space-y-6 p-4">- <div class="grid gap-6 sm:grid-cols-2">- <div class="space-y-2">- <TextInputWithLabel- id="projects-directory"- label={m.general_projects_directory_label()}- bind:value={$formInputs.projectsDirectory.value}- error={$formInputs.projectsDirectory.error}- helpText={m.general_projects_directory_help()}- />- </div>- <div class="space-y-2">- <TextInputWithLabel- id="disk-usage-path"- label={m.disk_usage_settings()}- bind:value={$formInputs.diskUsagePath.value}- error={$formInputs.diskUsagePath.error}- helpText={m.disk_usage_settings_description()}- />- </div>- <div class="space-y-2">- <TextInputWithLabel- id="base-server-url"- label={m.general_base_url_label()}- bind:value={$formInputs.baseServerUrl.value}- error={$formInputs.baseServerUrl.error}- helpText={m.general_base_url_help()}- />- </div>- <div class="space-y-2">- <TextInputWithLabel- id="max-upload-size"- type="number"- label={m.docker_max_upload_size_label()}- bind:value={$formInputs.maxImageUploadSize.value}- error={$formInputs.maxImageUploadSize.error}- helpText={m.docker_max_upload_size_description()}- />- </div>- </div>- </Tabs.Content>- <Tabs.Content value="docker" class="space-y-6 p-4">- <div class="grid gap-6 sm:grid-cols-2">- <!-- Polling Settings -->- <div class="space-y-4 rounded-lg border p-4">- <div class="flex items-center justify-between">- <div class="space-y-0.5">- <Label for="polling-enabled" class="text-sm font-medium">{m.docker_enable_polling_label()}</Label>- <div class="text-muted-foreground text-xs">{m.docker_enable_polling_description()}</div>- </div>- <Switch id="polling-enabled" bind:checked={$formInputs.pollingEnabled.value} />- </div>-- {#if $formInputs.pollingEnabled.value}- <div class="space-y-3 pt-2">- <SelectWithLabel- id="pollingIntervalMode"- name="pollingIntervalMode"- bind:value={pollingIntervalMode}- onValueChange={handlePollingIntervalModeChange}- label={m.docker_polling_interval_label()}- placeholder={m.docker_polling_interval_placeholder_select()}- options={imagePollingOptions.map(({ value, label, description }) => ({- value,- label,- description- }))}- />-- {#if pollingIntervalMode === 'custom'}- <TextInputWithLabel- bind:value={$formInputs.pollingInterval.value}- error={$formInputs.pollingInterval.error}- label={m.custom_polling_interval()}- placeholder={m.docker_polling_interval_placeholder()}- helpText={m.docker_polling_interval_description()}- type="number"- />- {/if}-- {#if $formInputs.pollingInterval.value < 30}- <div- class="flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-amber-900 dark:text-amber-200"- >- <AlertIcon class="mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400" />- <div class="flex-1 space-y-1">- <p class="text-sm font-medium">{m.docker_rate_limit_warning_title()}</p>- <p class="text-xs">{m.docker_rate_limit_warning_description()}</p>- </div>- </div>- {/if}- </div>- {/if}- </div>-- <!-- Auto Update Settings -->- <div class="space-y-4 rounded-lg border p-4">- <div class="flex items-center justify-between">- <div class="space-y-0.5">- <Label for="auto-update" class="text-sm font-medium">{m.docker_auto_update_label()}</Label>- <div class="text-muted-foreground text-xs">{m.docker_auto_update_description()}</div>- </div>- <Switch- id="auto-update"- bind:checked={$formInputs.autoUpdate.value}- disabled={!$formInputs.pollingEnabled.value}- />- </div>-- {#if $formInputs.autoUpdate.value && $formInputs.pollingEnabled.value}- <div class="pt-2">- <TextInputWithLabel- bind:value={$formInputs.autoUpdateInterval.value}- error={$formInputs.autoUpdateInterval.error}- label={m.docker_auto_update_interval_label()}- placeholder={m.docker_auto_update_interval_placeholder()}- helpText={m.docker_auto_update_interval_description()}- type="number"- />- </div>- {/if}- </div>-- <!-- Prune Mode -->- <div class="space-y-2">- <SelectWithLabel- id="dockerPruneMode"- name="pruneMode"- bind:value={$formInputs.dockerPruneMode.value}- label={m.docker_prune_action_label()}- description={pruneModeDescription}- placeholder={m.docker_prune_placeholder()}- options={pruneModeOptions}- onValueChange={(v) => ($formInputs.dockerPruneMode.value = v as 'all' | 'dangling')}- />- </div>-- <!-- Default Shell -->- <div class="space-y-2">- <SelectWithLabel- id="shellSelectValue"- name="shellSelectValue"- bind:value={shellSelectValue}- onValueChange={handleShellSelectChange}- label={m.docker_default_shell_label()}- description={m.docker_default_shell_description()}- placeholder={m.docker_default_shell_placeholder()}- options={[- ...shellOptions,- { value: 'custom', label: m.custom(), description: m.docker_shell_custom_description() }- ]}- />-- {#if shellSelectValue === 'custom'}- <div class="pt-2">- <TextInputWithLabel- bind:value={$formInputs.defaultShell.value}- error={$formInputs.defaultShell.error}- label={m.custom()}- placeholder={m.docker_shell_custom_path_placeholder()}- helpText={m.docker_shell_custom_path_help()}- type="text"- />- </div>- {/if}- </div>-- <div class="space-y-4 rounded-lg border p-4">- <div class="flex items-center justify-between">- <div class="space-y-0.5">- <Label for="auto-inject-env" class="text-sm font-medium">{m.docker_auto_inject_env_label()}</Label>- <div class="text-muted-foreground text-xs">{m.docker_auto_inject_env_description()}</div>- </div>- <Switch id="auto-inject-env" bind:checked={$formInputs.autoInjectEnv.value} />- </div>- </div>- </div>- </Tabs.Content>- <Tabs.Content value="maintenance" class="space-y-6 p-4">- <div class="space-y-4 rounded-lg border p-4">- <div class="flex items-center justify-between">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_title()}</Label>- <div class="text-muted-foreground text-xs">- {m.scheduled_prune_description()}- </div>- </div>- <Switch bind:checked={$formInputs.scheduledPruneEnabled.value} />- </div>-- {#if $formInputs.scheduledPruneEnabled.value}- <div class="space-y-4 pt-2">- <TextInputWithLabel- id="scheduled-prune-interval"- label={m.scheduled_prune_interval_label()}- bind:value={$formInputs.scheduledPruneInterval.value}- error={$formInputs.scheduledPruneInterval.error}- placeholder="1440"- helpText={m.scheduled_prune_interval_description()}- type="number"- />-- <div class="grid gap-3 sm:grid-cols-2">- <div class="flex items-start justify-between rounded-lg border p-3">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_containers_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_containers_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneContainers.value} />- </div>- <div class="flex items-start justify-between rounded-lg border p-3">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_images_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_images_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneImages.value} />- </div>- <div class="flex items-start justify-between rounded-lg border p-3">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_volumes_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_volumes_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneVolumes.value} />- </div>- <div class="flex items-start justify-between rounded-lg border p-3">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_networks_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_networks_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneNetworks.value} />- </div>- <div class="flex items-start justify-between rounded-lg border p-3">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_build_cache_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_build_cache_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneBuildCache.value} />- </div>- </div>-- {#if $formInputs.scheduledPruneVolumes.value}- <div- class="flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-amber-900 dark:text-amber-200"- >- <AlertIcon class="mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400" />- <div class="space-y-1 text-sm">- <p class="font-medium">{m.scheduled_prune_volumes_warning()}</p>- </div>- </div>- {/if}- </div>- {/if}- </div>- </Tabs.Content>- </Tabs.Root>- </Card.Content>- </Card.Root>+ <Tabs.Content value="general">+ <GeneralTab {formInputs} />+ </Tabs.Content>++ <Tabs.Content value="docker">+ <DockerTab+ {formInputs}+ {shellSelectValue}+ {handleShellSelectChange}+ {shellOptions}+ {pruneModeDescription}+ {pruneModeOptions}+ />+ </Tabs.Content>++ <Tabs.Content value="jobs">+ <JobsTab {formInputs} environmentId={environment.id} />+ </Tabs.Content>{/if}{#if environment.id !== '0'}- <Card.Root class="flex flex-col">- <Card.Header icon={ApiKeyIcon}>- <div class="flex flex-col space-y-1.5">- <Card.Title>- <h2>{m.environments_agent_config_title()}</h2>- </Card.Title>- <Card.Description>{m.environments_agent_config_description()}</Card.Description>- </div>- </Card.Header>- <Card.Content class="space-y-4 p-4">- {#if regeneratedApiKey}- <div class="space-y-4">- <div class="space-y-2">- <div class="text-sm font-medium">{m.environments_new_api_key()}</div>- <div class="flex items-center gap-2">- <code class="bg-muted flex-1 rounded-md px-3 py-2 font-mono text-sm break-all">- {regeneratedApiKey}- </code>- <CopyButton text={regeneratedApiKey} size="icon" class="size-7" />- </div>- <p class="text-muted-foreground text-xs">{m.environments_api_key_save_warning()}</p>- </div>- <ArcaneButton- action="base"- tone="outline"- onclick={() => (regeneratedApiKey = null)}- customLabel={m.common_dismiss()}- class="w-full"- />- </div>- {:else}- <div class="rounded-lg border border-amber-500/30 bg-amber-500/10 p-4 text-sm text-amber-900 dark:text-amber-200">- <p class="font-medium">{m.environments_regenerate_warning_title()}</p>- <p class="mt-1">{m.environments_regenerate_warning_message()}</p>- </div>- <ArcaneButton- action="remove"- onclick={() => (showRegenerateDialog = true)}- disabled={isRegeneratingKey}- loading={isRegeneratingKey}- icon={ResetIcon}- customLabel={m.environments_regenerate_api_key()}- class="w-full"- />- {/if}- </Card.Content>- </Card.Root>+ <Tabs.Content value="agent">+ <AgentTab bind:regeneratedApiKey {isRegeneratingKey} bind:showRegenerateDialog />+ </Tabs.Content>{/if}- <Card.Root class="flex flex-col">- <Card.Header icon={GitBranchIcon}>- <div class="flex flex-col space-y-1.5">- <Card.Title>- <h2>{m.git_syncs_title()}</h2>- </Card.Title>- <Card.Description>{m.git_subtitle()}</Card.Description>- </div>- </Card.Header>- <Card.Content class="p-4">- <p class="text-muted-foreground mb-4 text-sm">{m.git_environment_card_description()}</p>- <ArcaneButton- action="base"- onclick={() => goto(`/environments/${environment.id}/gitops`)}- icon={ArrowRightIcon}- customLabel={m.git_manage_syncs()}- class="w-full"- />- </Card.Content>- </Card.Root>- </div>+ <Tabs.Content value="gitops" />+ </Tabs.Root><AlertDialog.Root bind:open={showRegenerateDialog}><AlertDialog.Content>diff --git a/frontend/src/routes/(app)/environments/[id]/components/AgentTab.svelte b/frontend/src/routes/(app)/environments/[id]/components/AgentTab.sveltenew file mode 100644index 000000000..18098adb6--- /dev/null+++ b/frontend/src/routes/(app)/environments/[id]/components/AgentTab.svelte@@ -0,0 +1,59 @@+<script lang="ts">+ import * as Card from '$lib/components/ui/card/index.js';+ import { ArcaneButton } from '$lib/components/arcane-button/index.js';+ import { CopyButton } from '$lib/components/ui/copy-button';+ import { m } from '$lib/paraglide/messages';+ import { ApiKeyIcon, ResetIcon } from '$lib/icons';++ let { regeneratedApiKey = $bindable(), isRegeneratingKey, showRegenerateDialog = $bindable() } = $props();+</script>++<Card.Root class="flex flex-col">+ <Card.Header icon={ApiKeyIcon}>+ <div class="flex flex-col space-y-1.5">+ <Card.Title>+ <h2>{m.environments_agent_config_title()}</h2>+ </Card.Title>+ <Card.Description>{m.environments_agent_config_description()}</Card.Description>+ </div>+ </Card.Header>+ <Card.Content class="space-y-4 p-4">+ {#if regeneratedApiKey}+ <div class="space-y-4">+ <div class="space-y-2">+ <div class="text-sm font-medium">{m.environments_new_api_key()}</div>+ <div class="flex items-center gap-2">+ <code class="bg-muted flex-1 rounded-md px-3 py-2 font-mono text-sm break-all">+ {regeneratedApiKey}+ </code>+ <CopyButton text={regeneratedApiKey} size="icon" class="size-7" />+ </div>+ <p class="text-muted-foreground text-xs">{m.environments_api_key_save_warning()}</p>+ </div>+ <ArcaneButton+ action="base"+ tone="outline"+ onclick={() => (regeneratedApiKey = null)}+ customLabel={m.common_dismiss()}+ class="w-full"+ />+ </div>+ {:else}+ <div class="rounded-lg border border-amber-500/30 bg-amber-500/10 p-4 text-sm text-amber-900 dark:text-amber-200">+ <p class="font-medium">{m.environments_regenerate_warning_title()}</p>+ <p class="mt-1">{m.environments_regenerate_warning_message()}</p>+ </div>+ <ArcaneButton+ action="remove"+ onclick={() => {+ showRegenerateDialog = true;+ }}+ disabled={isRegeneratingKey}+ loading={isRegeneratingKey}+ icon={ResetIcon}+ customLabel={m.environments_regenerate_api_key()}+ class="w-full"+ />+ {/if}+ </Card.Content>+</Card.Root>diff --git a/frontend/src/routes/(app)/environments/[id]/components/DetailsTab.svelte b/frontend/src/routes/(app)/environments/[id]/components/DetailsTab.sveltenew file mode 100644index 000000000..76b51d305--- /dev/null+++ b/frontend/src/routes/(app)/environments/[id]/components/DetailsTab.svelte@@ -0,0 +1,166 @@+<script lang="ts">+ import * as Card from '$lib/components/ui/card/index.js';+ import Label from '$lib/components/ui/label/label.svelte';+ import { Input } from '$lib/components/ui/input/index.js';+ import { Switch } from '$lib/components/ui/switch/index.js';+ import { Badge } from '$lib/components/ui/badge/index.js';+ import { ArcaneButton } from '$lib/components/arcane-button/index.js';+ import * as ArcaneTooltip from '$lib/components/arcane-tooltip';+ import StatusBadge from '$lib/components/badges/status-badge.svelte';+ import { Spinner } from '$lib/components/ui/spinner/index.js';+ import { m } from '$lib/paraglide/messages';+ import { EnvironmentsIcon, TestIcon } from '$lib/icons';++ let {+ environment,+ formInputs,+ currentStatus,+ isLoadingVersion,+ remoteVersion,+ versionInformation,+ isTestingConnection,+ testConnection+ } = $props();+</script>++<Card.Root class="flex flex-col">+ <Card.Header icon={EnvironmentsIcon}>+ <div class="flex flex-col space-y-1.5">+ <Card.Title>+ <h2>{m.environments_overview_title()}</h2>+ </Card.Title>+ <Card.Description>{m.environments_basic_info_description()}</Card.Description>+ </div>+ </Card.Header>+ <Card.Content class="space-y-4 p-4">+ <div>+ <Label for="env-name" class="text-sm font-medium">{m.common_name()}</Label>+ <Input+ id="env-name"+ type="text"+ bind:value={$formInputs.name.value}+ class="mt-1.5 w-full {$formInputs.name.error ? 'border-destructive' : ''}"+ placeholder={m.environments_name_placeholder()}+ />+ {#if $formInputs.name.error}+ <p class="text-destructive mt-1 text-[0.8rem] font-medium">{$formInputs.name.error}</p>+ {/if}+ </div>++ <div>+ <Label for="api-url" class="text-sm font-medium">{m.environments_api_url()}</Label>+ <div class="mt-1.5 flex items-center gap-2">+ {#if environment.id === '0'}+ <ArcaneTooltip.Root>+ <ArcaneTooltip.Trigger class="w-full">+ <Input+ id="api-url"+ type="url"+ bind:value={$formInputs.apiUrl.value}+ class="w-full font-mono"+ placeholder={m.environments_api_url_placeholder()}+ disabled={true}+ required+ />+ </ArcaneTooltip.Trigger>+ <ArcaneTooltip.Content>+ <p>{m.environments_local_setting_disabled()}</p>+ </ArcaneTooltip.Content>+ </ArcaneTooltip.Root>+ {:else}+ <Input+ id="api-url"+ type="url"+ bind:value={$formInputs.apiUrl.value}+ class="w-full font-mono"+ placeholder={m.environments_api_url_placeholder()}+ required+ />+ {/if}+ <ArcaneButton+ action="base"+ onclick={testConnection}+ disabled={isTestingConnection}+ loading={isTestingConnection}+ icon={TestIcon}+ customLabel={m.environments_test_connection()}+ loadingLabel={m.environments_testing_connection()}+ class="shrink-0"+ />+ </div>+ <p class="text-muted-foreground mt-1.5 text-xs">{m.environments_api_url_help()}</p>+ </div>++ <div class="flex items-center justify-between rounded-lg border p-4">+ <div class="space-y-0.5">+ <Label for="env-enabled" class="text-sm font-medium">{m.common_enabled()}</Label>+ <div class="text-muted-foreground text-xs">{m.environments_enable_disable_description()}</div>+ </div>+ {#if environment.id === '0'}+ <ArcaneTooltip.Root>+ <ArcaneTooltip.Trigger>+ <Switch id="env-enabled" disabled={true} bind:checked={$formInputs.enabled.value} />+ </ArcaneTooltip.Trigger>+ <ArcaneTooltip.Content>+ <p>{m.environments_local_setting_disabled()}</p>+ </ArcaneTooltip.Content>+ </ArcaneTooltip.Root>+ {:else}+ <Switch id="env-enabled" bind:checked={$formInputs.enabled.value} />+ {/if}+ </div>++ <div class="grid grid-cols-2 gap-4 rounded-lg border p-4">+ <div>+ <Label class="text-muted-foreground text-xs font-medium">{m.environments_environment_id_label()}</Label>+ <div class="mt-1 font-mono text-sm">{environment.id}</div>+ </div>+ <div>+ <Label class="text-muted-foreground text-xs font-medium">{m.common_status()}</Label>+ <div class="mt-1">+ <StatusBadge+ text={currentStatus === 'online' ? m.common_online() : m.common_offline()}+ variant={currentStatus === 'online' ? 'green' : 'red'}+ />+ </div>+ </div>+ <div class="col-span-2 border-t pt-4">+ <Label class="text-muted-foreground text-xs font-medium">{m.version_info_version()}</Label>+ <div class="mt-1 flex items-center gap-2">+ {#if environment.id === '0'}+ <span class="font-mono text-sm">{versionInformation?.currentVersion || 'Unknown'}</span>+ {#if versionInformation?.updateAvailable}+ <Badge variant="secondary" class="bg-amber-500/10 text-amber-600 hover:bg-amber-500/20 dark:text-amber-400">+ {m.sidebar_update_available()}: {versionInformation.newestVersion}+ </Badge>+ {/if}+ {:else if isLoadingVersion}+ <Spinner />+ <span class="text-muted-foreground text-sm">{m.common_action_checking()}</span>+ {:else if remoteVersion}+ <span class="font-mono text-sm">{remoteVersion.currentVersion}</span>+ {#if remoteVersion.updateAvailable}+ <Badge variant="secondary" class="bg-amber-500/10 text-amber-600 hover:bg-amber-500/20 dark:text-amber-400">+ {m.sidebar_update_available()}: {remoteVersion.newestVersion}+ </Badge>+ {#if remoteVersion.releaseUrl}+ <a+ href={remoteVersion.releaseUrl}+ target="_blank"+ rel="noopener noreferrer"+ class="text-xs text-blue-500 hover:underline"+ >+ {m.version_info_view_release()}+ </a>+ {/if}+ {/if}+ {:else if currentStatus === 'online'}+ <span class="text-muted-foreground text-sm">Version information unavailable</span>+ {:else}+ <span class="text-muted-foreground text-sm">{m.common_offline()}</span>+ {/if}+ </div>+ </div>+ </div>+ </Card.Content>+</Card.Root>diff --git a/frontend/src/routes/(app)/environments/[id]/components/DockerTab.svelte b/frontend/src/routes/(app)/environments/[id]/components/DockerTab.sveltenew file mode 100644index 000000000..3e3cb1c79--- /dev/null+++ b/frontend/src/routes/(app)/environments/[id]/components/DockerTab.svelte@@ -0,0 +1,76 @@+<script lang="ts">+ import * as Card from '$lib/components/ui/card/index.js';+ import Label from '$lib/components/ui/label/label.svelte';+ import { Switch } from '$lib/components/ui/switch/index.js';+ import SelectWithLabel from '$lib/components/form/select-with-label.svelte';+ import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';+ import { m } from '$lib/paraglide/messages';+ import { DockerBrandIcon } from '$lib/icons';++ let { formInputs, shellSelectValue, handleShellSelectChange, shellOptions, pruneModeDescription, pruneModeOptions } = $props();+</script>++<Card.Root class="flex flex-col">+ <Card.Header icon={DockerBrandIcon}>+ <div class="flex flex-col space-y-1.5">+ <Card.Title>+ <h2>{m.environments_docker_settings_title()}</h2>+ </Card.Title>+ <Card.Description>{m.environments_config_description()}</Card.Description>+ </div>+ </Card.Header>+ <Card.Content class="space-y-6 p-4">+ <div class="grid gap-6 sm:grid-cols-2">+ <!-- Prune Mode -->+ <div class="space-y-2">+ <SelectWithLabel+ id="dockerPruneMode"+ name="pruneMode"+ bind:value={$formInputs.dockerPruneMode.value}+ label={m.docker_prune_action_label()}+ description={pruneModeDescription}+ placeholder={m.docker_prune_placeholder()}+ options={pruneModeOptions}+ onValueChange={(v) => ($formInputs.dockerPruneMode.value = v as 'all' | 'dangling')}+ />+ </div>++ <!-- Default Shell -->+ <div class="space-y-2">+ <SelectWithLabel+ id="shellSelectValue"+ name="shellSelectValue"+ value={shellSelectValue}+ onValueChange={handleShellSelectChange}+ label={m.docker_default_shell_label()}+ description={m.docker_default_shell_description()}+ placeholder={m.docker_default_shell_placeholder()}+ options={[...shellOptions, { value: 'custom', label: m.custom(), description: m.docker_shell_custom_description() }]}+ />++ {#if shellSelectValue === 'custom'}+ <div class="pt-2">+ <TextInputWithLabel+ bind:value={$formInputs.defaultShell.value}+ error={$formInputs.defaultShell.error}+ label={m.custom()}+ placeholder={m.docker_shell_custom_path_placeholder()}+ helpText={m.docker_shell_custom_path_help()}+ type="text"+ />+ </div>+ {/if}+ </div>++ <div class="space-y-4 rounded-lg border p-4">+ <div class="flex items-center justify-between">+ <div class="space-y-0.5">+ <Label for="auto-inject-env" class="text-sm font-medium">{m.docker_auto_inject_env_label()}</Label>+ <div class="text-muted-foreground text-xs">{m.docker_auto_inject_env_description()}</div>+ </div>+ <Switch id="auto-inject-env" bind:checked={$formInputs.autoInjectEnv.value} />+ </div>+ </div>+ </div>+ </Card.Content>+</Card.Root>diff --git a/frontend/src/routes/(app)/environments/[id]/components/GeneralTab.svelte b/frontend/src/routes/(app)/environments/[id]/components/GeneralTab.sveltenew file mode 100644index 000000000..1184635ca--- /dev/null+++ b/frontend/src/routes/(app)/environments/[id]/components/GeneralTab.svelte@@ -0,0 +1,60 @@+<script lang="ts">+ import * as Card from '$lib/components/ui/card/index.js';+ import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';+ import { m } from '$lib/paraglide/messages';+ import { SettingsIcon } from '$lib/icons';++ let { formInputs } = $props();+</script>++<Card.Root class="flex flex-col">+ <Card.Header icon={SettingsIcon}>+ <div class="flex flex-col space-y-1.5">+ <Card.Title>+ <h2>{m.general_title()}</h2>+ </Card.Title>+ <Card.Description>{m.environments_config_description()}</Card.Description>+ </div>+ </Card.Header>+ <Card.Content class="space-y-6 p-4">+ <div class="grid gap-6 sm:grid-cols-2">+ <div class="space-y-2">+ <TextInputWithLabel+ id="projects-directory"+ label={m.general_projects_directory_label()}+ bind:value={$formInputs.projectsDirectory.value}+ error={$formInputs.projectsDirectory.error}+ helpText={m.general_projects_directory_help()}+ />+ </div>+ <div class="space-y-2">+ <TextInputWithLabel+ id="disk-usage-path"+ label={m.disk_usage_settings()}+ bind:value={$formInputs.diskUsagePath.value}+ error={$formInputs.diskUsagePath.error}+ helpText={m.disk_usage_settings_description()}+ />+ </div>+ <div class="space-y-2">+ <TextInputWithLabel+ id="base-server-url"+ label={m.general_base_url_label()}+ bind:value={$formInputs.baseServerUrl.value}+ error={$formInputs.baseServerUrl.error}+ helpText={m.general_base_url_help()}+ />+ </div>+ <div class="space-y-2">+ <TextInputWithLabel+ id="max-upload-size"+ type="number"+ label={m.docker_max_upload_size_label()}+ bind:value={$formInputs.maxImageUploadSize.value}+ error={$formInputs.maxImageUploadSize.error}+ helpText={m.docker_max_upload_size_description()}+ />+ </div>+ </div>+ </Card.Content>+</Card.Root>diff --git a/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte b/frontend/src/routes/(app)/environments/[id]/components/JobsTab.sveltenew file mode 100644index 000000000..688412f39--- /dev/null+++ b/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte@@ -0,0 +1,209 @@+<script lang="ts">+ import { jobScheduleService } from '$lib/services/job-schedule-service';+ import { tryCatch } from '$lib/utils/try-catch';+ import JobCard from '$lib/components/job-card/job-card.svelte';+ import { Spinner } from '$lib/components/ui/spinner';+ import { m } from '$lib/paraglide/messages';+ import * as Card from '$lib/components/ui/card';+ import { Label } from '$lib/components/ui/label';+ import { Switch } from '$lib/components/ui/switch';+ import { JobsIcon, AlertIcon } from '$lib/icons';+ import type { JobListResponse, JobStatus, JobPrerequisite } from '$lib/types/job-schedule.type';++ let { formInputs, environmentId } = $props();++ let jobsResponse = $state<JobListResponse | null>(null);+ let isLoading = $state(true);+ let error = $state<string | null>(null);++ function resolveSettingsUrl(job: JobStatus, prereq: JobPrerequisite): string | undefined {+ if (!prereq.settingsUrl) return undefined;+ if (!environmentId) return prereq.settingsUrl;++ const envBase = `/environments/${environmentId}`;+ switch (prereq.settingKey) {+ case 'pollingEnabled':+ case 'autoUpdate':+ return `${envBase}?tab=docker`;+ case 'gitopsSyncEnabled':+ return `${envBase}?tab=gitops`;+ case 'scheduledPruneEnabled':+ return undefined;+ default:+ return prereq.settingsUrl;+ }+ }++ async function loadJobs() {+ isLoading = true;+ const result = await tryCatch(jobScheduleService.listJobs());+ isLoading = false;++ if (result.error) {+ error = result.error.message;+ return;+ }++ jobsResponse = {+ ...result.data,+ jobs: result.data.jobs.map((job) => ({+ ...job,+ prerequisites: job.prerequisites.map((prereq) => ({+ ...prereq,+ settingsUrl: resolveSettingsUrl(job, prereq)+ }))+ }))+ };+ }++ $effect(() => {+ if (environmentId) {+ loadJobs();+ }+ });++ const categories = [+ { id: 'monitoring', label: m.jobs_monitoring_heading() },+ { id: 'maintenance', label: m.jobs_maintenance_heading() },+ { id: 'updates', label: m.jobs_updates_heading() },+ { id: 'sync', label: m.jobs_sync_heading() },+ { id: 'telemetry', label: m.jobs_telemetry_heading() }+ ];++ const hiddenJobIds = new Set(['gitops-sync', 'filesystem-watcher']);++ function getJobsByCategory(categoryId: string): JobStatus[] {+ if (!jobsResponse) return [];+ return jobsResponse.jobs.filter((j) => {+ if (hiddenJobIds.has(j.id)) return false;+ if (j.category !== categoryId) return false;+ // Only show manager-only jobs on the local environment (ID "0")+ if (j.managerOnly && environmentId !== '0') return false;+ return true;+ });+ }++ function getEnabledOverride(job: JobStatus): boolean | undefined {+ switch (job.id) {+ case 'scheduled-prune':+ return $formInputs.scheduledPruneEnabled.value;+ case 'auto-update':+ return $formInputs.autoUpdate.value;+ case 'image-polling':+ return $formInputs.pollingEnabled.value;+ default:+ return undefined;+ }+ }+</script>++<div class="space-y-6">+ <Card.Root>+ <Card.Header icon={JobsIcon}>+ <div class="flex flex-col space-y-1.5">+ <Card.Title>+ <h2>{m.jobs_title()}</h2>+ </Card.Title>+ <Card.Description>{m.jobs_environment_scope_description()}</Card.Description>+ </div>+ </Card.Header>+ <Card.Content class="p-4 sm:p-6">+ {#if isLoading}+ <div class="flex h-32 items-center justify-center">+ <Spinner class="size-8" />+ </div>+ {:else if error}+ <div class="border-destructive/50 bg-destructive/10 text-destructive rounded-lg border p-4">+ {error}+ </div>+ {:else if jobsResponse}+ <div class="space-y-8">+ {#each categories as category (category.id)}+ {@const categoryJobs = getJobsByCategory(category.id)}+ {#if categoryJobs.length > 0}+ <div class="space-y-4">+ <h3 class="text-muted-foreground text-sm font-semibold tracking-tight uppercase">+ {category.label}+ </h3>+ <div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-2">+ {#each categoryJobs as job (job.id)}+ <JobCard+ {job}+ isAgent={jobsResponse.isAgent}+ onScheduleUpdate={loadJobs}+ enabledOverride={getEnabledOverride(job)}+ >+ {#snippet headerAccessory()}+ {#if job.id === 'image-polling'}+ <Switch bind:checked={$formInputs.pollingEnabled.value} />+ {:else if job.id === 'auto-update'}+ <Switch bind:checked={$formInputs.autoUpdate.value} disabled={!$formInputs.pollingEnabled.value} />+ {:else if job.id === 'scheduled-prune'}+ <Switch bind:checked={$formInputs.scheduledPruneEnabled.value} />+ {/if}+ {/snippet}++ {#if job.id === 'scheduled-prune'}+ {#if $formInputs.scheduledPruneEnabled.value}+ <div class="border-border/20 space-y-4 border-t pt-3">+ <div class="grid gap-3 sm:grid-cols-2">+ <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">+ <div class="space-y-0.5">+ <Label class="text-sm font-medium">{m.scheduled_prune_containers_label()}</Label>+ <p class="text-muted-foreground text-xs">{m.scheduled_prune_containers_description()}</p>+ </div>+ <Switch bind:checked={$formInputs.scheduledPruneContainers.value} />+ </div>+ <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">+ <div class="space-y-0.5">+ <Label class="text-sm font-medium">{m.scheduled_prune_images_label()}</Label>+ <p class="text-muted-foreground text-xs">{m.scheduled_prune_images_description()}</p>+ </div>+ <Switch bind:checked={$formInputs.scheduledPruneImages.value} />+ </div>+ <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">+ <div class="space-y-0.5">+ <Label class="text-sm font-medium">{m.scheduled_prune_volumes_label()}</Label>+ <p class="text-muted-foreground text-xs">{m.scheduled_prune_volumes_description()}</p>+ </div>+ <Switch bind:checked={$formInputs.scheduledPruneVolumes.value} />+ </div>+ <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">+ <div class="space-y-0.5">+ <Label class="text-sm font-medium">{m.scheduled_prune_networks_label()}</Label>+ <p class="text-muted-foreground text-xs">{m.scheduled_prune_networks_description()}</p>+ </div>+ <Switch bind:checked={$formInputs.scheduledPruneNetworks.value} />+ </div>+ <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">+ <div class="space-y-0.5">+ <Label class="text-sm font-medium">{m.scheduled_prune_build_cache_label()}</Label>+ <p class="text-muted-foreground text-xs">{m.scheduled_prune_build_cache_description()}</p>+ </div>+ <Switch bind:checked={$formInputs.scheduledPruneBuildCache.value} />+ </div>+ </div>+ {#if $formInputs.scheduledPruneVolumes.value}+ <div+ class="flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-amber-900 dark:text-amber-200"+ >+ <AlertIcon class="mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400" />+ <div class="space-y-1 text-sm">+ <p class="font-medium">{m.scheduled_prune_volumes_warning()}</p>+ </div>+ </div>+ {/if}+ </div>+ {/if}+ {/if}+ </JobCard>+ {/each}+ </div>+ </div>+ {/if}+ {/each}+ </div>+ {/if}+ </Card.Content>+ </Card.Root>+</div>diff --git a/frontend/src/routes/(app)/settings/jobs/+page.svelte b/frontend/src/routes/(app)/settings/jobs/+page.sveltedeleted file mode 100644index 9f690b821..000000000--- a/frontend/src/routes/(app)/settings/jobs/+page.svelte+++ /dev/null@@ -1,192 +0,0 @@-<script lang="ts">- import { getContext } from 'svelte';- import { untrack } from 'svelte';- import { toast } from 'svelte-sonner';- import { z } from 'zod/v4';- import { m } from '$lib/paraglide/messages';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import settingsStore from '$lib/stores/config-store';- import { JobsIcon } from '$lib/icons';- import { SettingsPageLayout } from '$lib/layouts';- import { Label } from '$lib/components/ui/label';- import { createForm } from '$lib/utils/form.utils';- import { tryCatch } from '$lib/utils/try-catch';- import { jobScheduleService } from '$lib/services/job-schedule-service';- import type { JobSchedules } from '$lib/types/job-schedule.type';-- let { data } = $props();-- const isReadOnly = $derived.by(() => $settingsStore?.uiConfigDisabled);- let isLoading = $state(false);-- // Track the last saved schedules separately so we can compute hasChanges and reset.- let savedSchedules = $state<JobSchedules>(untrack(() => data.jobSchedules));-- const formSchema = z.object({- environmentHealthInterval: z.string().min(1),- eventCleanupInterval: z.string().min(1),- analyticsHeartbeatInterval: z.string().min(1)- });-- const form = createForm(- formSchema,- untrack(() => savedSchedules)- );- const formInputs = form.inputs;-- const hasChanges = $derived.by(() => {- const inputs = $formInputs;- return (- inputs.environmentHealthInterval.value !== savedSchedules.environmentHealthInterval ||- inputs.eventCleanupInterval.value !== savedSchedules.eventCleanupInterval ||- inputs.analyticsHeartbeatInterval.value !== savedSchedules.analyticsHeartbeatInterval- );- });-- // Integrate with Settings layout Save/Reset buttons via context.- type SettingsFormState = {- hasChanges: boolean;- isLoading: boolean;- saveFunction: (() => Promise<void>) | null;- resetFunction: (() => void) | null;- };- let formState: SettingsFormState | null = null;- try {- formState = getContext('settingsFormState') as SettingsFormState;- } catch {- // Context not available (shouldn't happen in settings routes)- }-- function resetForm() {- formInputs.update((inputs) => {- inputs.environmentHealthInterval.value = savedSchedules.environmentHealthInterval;- inputs.environmentHealthInterval.error = null;- inputs.eventCleanupInterval.value = savedSchedules.eventCleanupInterval;- inputs.eventCleanupInterval.error = null;- inputs.analyticsHeartbeatInterval.value = savedSchedules.analyticsHeartbeatInterval;- inputs.analyticsHeartbeatInterval.error = null;- return inputs;- });- }-- async function save() {- if (isReadOnly) {- return;- }-- const values = form.validate();- if (!values) {- toast.error('Please check the form for errors');- return;- }-- isLoading = true;- const result = await tryCatch(jobScheduleService.updateJobSchedules(values));- isLoading = false;-- if (result.error) {- console.error('Failed to update job schedules:', result.error);- toast.error(result.error.message || 'Failed to update job schedules');- return;- }-- savedSchedules = result.data;- resetForm();- toast.success(m.security_settings_saved());- }-- $effect(() => {- if (!formState) return;- formState.hasChanges = hasChanges;- formState.isLoading = isLoading;- formState.saveFunction = save;- formState.resetFunction = resetForm;- });-</script>--<SettingsPageLayout- title={m.jobs_title()}- description={m.jobs_description()}- icon={JobsIcon}- pageType="form"- showReadOnlyTag={isReadOnly}->- {#snippet mainContent()}- <fieldset disabled={isReadOnly || isLoading} class="relative space-y-8">- <!-- Monitoring -->- <div class="space-y-4">- <h3 class="text-lg font-medium">{m.jobs_monitoring_heading()}</h3>- <div class="bg-card rounded-lg border shadow-sm">- <div class="space-y-6 p-6">- <div class="grid gap-4 md:grid-cols-[1fr_1.5fr] md:gap-8">- <div>- <Label class="text-base">{m.environments_health_check_title()}</Label>- <p class="text-muted-foreground mt-1 text-sm">{m.environments_health_check_description()}</p>- </div>- <div class="max-w-xs">- <TextInputWithLabel- bind:value={$formInputs.environmentHealthInterval.value}- error={$formInputs.environmentHealthInterval.error}- label={m.environments_health_check_interval_label()}- placeholder="0 */2 * * * *"- helpText={m.environments_health_check_interval_description()}- type="text"- />- </div>- </div>- </div>- </div>- </div>-- <!-- Maintenance -->- <div class="space-y-4">- <h3 class="text-lg font-medium">{m.jobs_maintenance_heading()}</h3>- <div class="bg-card rounded-lg border shadow-sm">- <div class="space-y-6 p-6">- <div class="grid gap-4 md:grid-cols-[1fr_1.5fr] md:gap-8">- <div>- <Label class="text-base">{m.jobs_event_cleanup_title()}</Label>- <p class="text-muted-foreground mt-1 text-sm">{m.jobs_event_cleanup_description()}</p>- </div>- <div class="max-w-xs">- <TextInputWithLabel- bind:value={$formInputs.eventCleanupInterval.value}- error={$formInputs.eventCleanupInterval.error}- label={m.jobs_event_cleanup_interval_label()}- placeholder="0 0 */6 * * *"- helpText={m.jobs_event_cleanup_interval_help()}- type="text"- />- </div>- </div>- </div>- </div>- </div>-- <!-- Telemetry -->- <div class="space-y-4">- <h3 class="text-lg font-medium">{m.jobs_telemetry_heading()}</h3>- <div class="bg-card rounded-lg border shadow-sm">- <div class="space-y-6 p-6">- <div class="grid gap-4 md:grid-cols-[1fr_1.5fr] md:gap-8">- <div>- <Label class="text-base">{m.jobs_analytics_title()}</Label>- <p class="text-muted-foreground mt-1 text-sm">{m.jobs_analytics_description()}</p>- </div>- <div class="max-w-xs">- <TextInputWithLabel- bind:value={$formInputs.analyticsHeartbeatInterval.value}- error={$formInputs.analyticsHeartbeatInterval.error}- label={m.jobs_analytics_interval_label()}- placeholder="0 0 0 * * *"- helpText={m.jobs_analytics_interval_help()}- type="text"- />- </div>- </div>- </div>- </div>- </div>- </fieldset>- {/snippet}-</SettingsPageLayout>diff --git a/frontend/src/routes/(app)/settings/jobs/+page.ts b/frontend/src/routes/(app)/settings/jobs/+page.tsdeleted file mode 100644index ce7e9c024..000000000--- a/frontend/src/routes/(app)/settings/jobs/+page.ts+++ /dev/null@@ -1,12 +0,0 @@-import type { PageLoad } from './$types';-import { jobScheduleService } from '$lib/services/job-schedule-service';--export const load: PageLoad = async () => {- try {- const jobSchedules = await jobScheduleService.getJobSchedules();- return { jobSchedules };- } catch (error) {- console.error('Failed to load job schedules:', error);- throw error;- }-};diff --git a/frontend/src/routes/(auth)/oidc/callback/+page.svelte b/frontend/src/routes/(auth)/oidc/callback/+page.svelteindex f3b936790..ad3624690 100644--- a/frontend/src/routes/(auth)/oidc/callback/+page.svelte+++ b/frontend/src/routes/(auth)/oidc/callback/+page.svelte@@ -9,6 +9,7 @@import settingsStore from '$lib/stores/config-store';import { settingsService } from '$lib/services/settings-service';import { authService } from '$lib/services/auth-service';+ import { Spinner } from '$lib/components/ui/spinner/index.js';let isProcessing = $state(true);let error = $state('');@@ -116,13 +117,11 @@});</script>-<svelte:head><title>{m.layout_title()}</title></svelte:head>-<div class="bg-background flex min-h-screen items-center justify-center"><div class="w-full max-w-md space-y-8"><div class="text-center">{#if isProcessing}- <div class="border-primary mx-auto h-12 w-12 animate-spin rounded-full border-b-2"></div>+ <Spinner /><h2 class="mt-6 text-2xl font-bold">{m.auth_processing_login()}</h2><p class="text-muted-foreground mt-2 text-sm">{m.auth_processing_login_description()}</p>{:else if error}diff --git a/types/jobschedule/jobschedule.go b/types/jobschedule/jobschedule.goindex 25f5f3e74..931ff3a89 100644--- a/types/jobschedule/jobschedule.go+++ b/types/jobschedule/jobschedule.go@@ -1,5 +1,7 @@package jobschedule+import "time"+// Config represents the configured intervals (in minutes) for Arcane background jobs.//// All fields are in minutes.@@ -18,3 +20,44 @@ type Update struct {EventCleanupInterval *string `json:"eventCleanupInterval,omitempty"`AnalyticsHeartbeatInterval *string `json:"analyticsHeartbeatInterval,omitempty"`}++// JobStatus represents the current status and metadata for a background job.+type JobStatus struct {+ ID string `json:"id"`+ Name string `json:"name"`+ Description string `json:"description"`+ Category string `json:"category"`+ Schedule string `json:"schedule"`+ NextRun *time.Time `json:"nextRun,omitempty"`+ Enabled bool `json:"enabled"`+ ManagerOnly bool `json:"managerOnly"`+ IsContinuous bool `json:"isContinuous"`+ CanRunManually bool `json:"canRunManually"`+ Prerequisites []JobPrerequisite `json:"prerequisites"`+ SettingsKey string `json:"settingsKey,omitempty"`+}++// JobPrerequisite represents a requirement that must be met for a job to run.+type JobPrerequisite struct {+ SettingKey string `json:"settingKey"`+ Label string `json:"label"`+ IsMet bool `json:"isMet"`+ SettingsURL string `json:"settingsUrl,omitempty"`+}++// JobListResponse contains all jobs and system mode information.+type JobListResponse struct {+ Jobs []JobStatus `json:"jobs"`+ IsAgent bool `json:"isAgent"`+}++// JobRunRequest is the request to manually run a job.+type JobRunRequest struct {+ JobID string `json:"jobId" path:"jobId" minLength:"1"`+}++// JobRunResponse is the response after manually triggering a job.+type JobRunResponse struct {+ Success bool `json:"success"`+ Message string `json:"message"`+}diff --git a/types/meta/job_metadata.go b/types/meta/job_metadata.gonew file mode 100644index 000000000..c4672abeb--- /dev/null+++ b/types/meta/job_metadata.go@@ -0,0 +1,182 @@+package meta++import (+ "time"++ "github.com/getarcaneapp/arcane/types/jobschedule"+)++type JobMetadata struct {+ ID string+ Name string+ Description string+ Category string+ SettingsKey string+ EnabledKey string+ ManagerOnly bool+ IsContinuous bool+ CanRunManually bool+ Prerequisites []JobPrerequisiteMetadata+}++type JobPrerequisiteMetadata struct {+ SettingKey string+ Label string+ SettingsURL string+}++var jobMetadataRegistry = map[string]JobMetadata{+ "environment-health": {+ ID: "environment-health",+ Name: "Environment Health",+ Description: "Checks the health and connectivity of all enabled environments",+ Category: "monitoring",+ SettingsKey: "environmentHealthInterval",+ ManagerOnly: true,+ IsContinuous: false,+ CanRunManually: true,+ Prerequisites: []JobPrerequisiteMetadata{},+ },+ "event-cleanup": {+ ID: "event-cleanup",+ Name: "Event Cleanup",+ Description: "Removes old system events to maintain database performance",+ Category: "maintenance",+ SettingsKey: "eventCleanupInterval",+ ManagerOnly: false,+ IsContinuous: false,+ CanRunManually: true,+ Prerequisites: []JobPrerequisiteMetadata{},+ },+ "analytics-heartbeat": {+ ID: "analytics-heartbeat",+ Name: "Analytics Heartbeat",+ Description: "Sends usage statistics and telemetry data",+ Category: "telemetry",+ SettingsKey: "analyticsHeartbeatInterval",+ ManagerOnly: false,+ IsContinuous: false,+ CanRunManually: true,+ Prerequisites: []JobPrerequisiteMetadata{+ {+ SettingKey: "analyticsEnabled",+ Label: "Analytics enabled",+ SettingsURL: "/settings/general",+ },+ },+ },+ "auto-update": {+ ID: "auto-update",+ Name: "Auto Update",+ Description: "Automatically updates containers when new images are available",+ Category: "updates",+ SettingsKey: "autoUpdateInterval",+ EnabledKey: "autoUpdate",+ ManagerOnly: false,+ IsContinuous: false,+ CanRunManually: true,+ Prerequisites: []JobPrerequisiteMetadata{+ {+ SettingKey: "pollingEnabled",+ Label: "Image polling enabled",+ SettingsURL: "/settings/updates",+ },+ {+ SettingKey: "autoUpdate",+ Label: "Auto update enabled",+ SettingsURL: "/settings/updates",+ },+ },+ },+ "image-polling": {+ ID: "image-polling",+ Name: "Image Polling",+ Description: "Checks container registries for new image versions",+ Category: "updates",+ SettingsKey: "pollingInterval",+ EnabledKey: "pollingEnabled",+ ManagerOnly: false,+ IsContinuous: false,+ CanRunManually: true,+ Prerequisites: []JobPrerequisiteMetadata{+ {+ SettingKey: "pollingEnabled",+ Label: "Image polling enabled",+ SettingsURL: "/settings/updates",+ },+ },+ },+ "scheduled-prune": {+ ID: "scheduled-prune",+ Name: "Scheduled Prune",+ Description: "Removes unused containers, images, volumes, and networks",+ Category: "maintenance",+ SettingsKey: "scheduledPruneInterval",+ EnabledKey: "scheduledPruneEnabled",+ ManagerOnly: false,+ IsContinuous: false,+ CanRunManually: true,+ Prerequisites: []JobPrerequisiteMetadata{+ {+ SettingKey: "scheduledPruneEnabled",+ Label: "Scheduled prune enabled",+ SettingsURL: "/settings/general",+ },+ },+ },+ "gitops-sync": {+ ID: "gitops-sync",+ Name: "GitOps Sync",+ Description: "Synchronizes project state with configured git repositories",+ Category: "sync",+ SettingsKey: "gitopsSyncInterval",+ EnabledKey: "gitopsSyncEnabled",+ ManagerOnly: false,+ IsContinuous: false,+ CanRunManually: true,+ Prerequisites: []JobPrerequisiteMetadata{+ {+ SettingKey: "gitopsSyncEnabled",+ Label: "GitOps sync enabled",+ SettingsURL: "/settings/gitops",+ },+ },+ },+ "filesystem-watcher": {+ ID: "filesystem-watcher",+ Name: "Filesystem Watcher",+ Description: "Monitors project directory for changes and syncs automatically",+ Category: "sync",+ SettingsKey: "",+ ManagerOnly: false,+ IsContinuous: true,+ CanRunManually: false,+ Prerequisites: []JobPrerequisiteMetadata{},+ },+}++func GetJobMetadata(jobID string) (JobMetadata, bool) {+ meta, ok := jobMetadataRegistry[jobID]+ return meta, ok+}++func GetAllJobMetadata() map[string]JobMetadata {+ return jobMetadataRegistry+}++func (meta JobMetadata) ToJobStatus(schedule string, nextRun *time.Time, enabled bool, prerequisites []jobschedule.JobPrerequisite) jobschedule.JobStatus {+ return jobschedule.JobStatus{+ ID: meta.ID,+ Name: meta.Name,+ Description: meta.Description,+ Category: meta.Category,+ Schedule: schedule,+ NextRun: nextRun,+ Enabled: enabled,+ ManagerOnly: meta.ManagerOnly,+ IsContinuous: meta.IsContinuous,+ CanRunManually: meta.CanRunManually,+ Prerequisites: prerequisites,+ SettingsKey: meta.SettingsKey,+ }+}