mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Refactor global schedules with mobile-responsive UI and backend optimizations (#167)
* ralph: ralph-global-schedules-dashboard completed after 2 iterations * Refactor global schedules with mobile-responsive UI and backend optimizations
This commit is contained in:
1 parent
ba15fb31e4
commit
f18bcbbf3e
10 files changed
+721
-1
No files matched your search
@@ -373,3 +373,40 @@ export function listScheduleRunsByJob(db: Database, repoId: number, jobId: numbe
|
||||
const rows = stmt.all(repoId, jobId, limit) as ScheduleRunRow[]
|
||||
return rows.map(rowToScheduleRun)
|
||||
}
|
||||
|
||||
export interface ScheduleJobWithRepo extends ScheduleJob {
|
||||
repoName: string
|
||||
repoPath: string
|
||||
repoUrl: string
|
||||
}
|
||||
|
||||
interface ScheduleJobWithRepoRow extends ScheduleJobRow {
|
||||
repo_url: string
|
||||
repo_path: string
|
||||
}
|
||||
|
||||
function repoNameFromPath(repoPath: string): string {
|
||||
if (!repoPath || repoPath === '/') return 'Unknown'
|
||||
return repoPath.split(/[\\/]/).pop() ?? repoPath
|
||||
}
|
||||
|
||||
function rowToScheduleJobWithRepo(row: ScheduleJobWithRepoRow): ScheduleJobWithRepo {
|
||||
const job = rowToScheduleJob(row)
|
||||
return {
|
||||
...job,
|
||||
repoName: repoNameFromPath(row.repo_path),
|
||||
repoPath: row.repo_path,
|
||||
repoUrl: row.repo_url,
|
||||
}
|
||||
}
|
||||
|
||||
export function listAllScheduleJobsWithRepos(db: Database): ScheduleJobWithRepo[] {
|
||||
const stmt = db.prepare(`
|
||||
SELECT sj.*, r.repo_url, r.local_path as repo_path
|
||||
FROM schedule_jobs sj
|
||||
JOIN repos r ON sj.repo_id = r.id
|
||||
ORDER BY r.local_path, sj.name
|
||||
`)
|
||||
const rows = stmt.all() as ScheduleJobWithRepoRow[]
|
||||
return rows.map(rowToScheduleJobWithRepo)
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import { createHealthRoutes } from './routes/health'
|
||||
import { createTTSRoutes, cleanupExpiredCache } from './routes/tts';
|
||||
import { createSTTRoutes } from './routes/stt'
|
||||
import { createFileRoutes } from './routes/files'
|
||||
import { createScheduleRoutes } from './routes/schedules'
|
||||
|
||||
async function getAppVersion(): Promise<string> {
|
||||
try {
|
||||
@@ -370,6 +371,7 @@ protectedApi.route('/ssh', createSSHRoutes(gitAuthService))
|
||||
protectedApi.route('/notifications', createNotificationRoutes(notificationService))
|
||||
protectedApi.route('/memory', createMemoryRoutes(db))
|
||||
protectedApi.route('/prompt-templates', createPromptTemplateRoutes(db))
|
||||
protectedApi.route('/schedules', createScheduleRoutes(scheduleService))
|
||||
|
||||
app.route('/api', protectedApi)
|
||||
|
||||
|
||||
@@ -35,6 +35,15 @@ function parseRunListLimit(value: string | undefined): number {
|
||||
export function createScheduleRoutes(scheduleService: ScheduleService) {
|
||||
const app = new Hono()
|
||||
|
||||
app.get('/all', (c) => {
|
||||
try {
|
||||
const jobs = scheduleService.listAllJobsWithRepos()
|
||||
return c.json({ jobs })
|
||||
} catch (error) {
|
||||
return handleScheduleError(c, error, 'Failed to list all schedules')
|
||||
}
|
||||
})
|
||||
|
||||
app.get('/', (c) => {
|
||||
try {
|
||||
const repoId = parseId(c.req.param('id'), 'repo id')
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
type UpdateScheduleJobRequest,
|
||||
} from '@opencode-manager/shared/types'
|
||||
import { getRepoById } from '../db/queries'
|
||||
import type { ScheduleJobWithRepo } from '../db/schedules'
|
||||
import {
|
||||
createScheduleJob,
|
||||
createScheduleRun,
|
||||
@@ -15,6 +16,7 @@ import {
|
||||
getScheduleJobById,
|
||||
getRunningScheduleRunByJob,
|
||||
getScheduleRunById,
|
||||
listAllScheduleJobsWithRepos,
|
||||
listEnabledScheduleJobs,
|
||||
listScheduleJobsByRepo,
|
||||
listRunningScheduleRuns,
|
||||
@@ -359,6 +361,10 @@ export class ScheduleService {
|
||||
return listEnabledScheduleJobs(this.db)
|
||||
}
|
||||
|
||||
listAllJobsWithRepos(): ScheduleJobWithRepo[] {
|
||||
return listAllScheduleJobsWithRepos(this.db)
|
||||
}
|
||||
|
||||
async recoverRunningRuns(): Promise<void> {
|
||||
const runningRuns = listRunningScheduleRuns(this.db)
|
||||
|
||||
|
||||
Reference in new issue
Block a user