Files
hermes-ui/packages/client/src/stores/hermes/jobs.ts
T
toor 1e9ea89d86
Build / build (push) Canceled after 0s
NPM Lockfile Check / npm ci --ignore-scripts (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s
chore: bootstrap hermes-ui skeleton from 0.6.29 snapshot
Import the client, server, skills, tests, and build scripts as the starting
point for the rebuild, then trim the surfaces this project does not ship:
Electron desktop packaging, the marketing website, and the ESP32 firmware
tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows.

Rename the package and CLI entry points to hermes-ui, drop the prepare hook so
npm ci no longer triggers a build, and drop the removed tsconfig and nodemon
references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs
so the documented package map and hard rules match this repository.

reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
2026-10-16 10:34:35 +08:00

73 lines
1.9 KiB
TypeScript

import { defineStore } from 'pinia'
import { ref } from 'vue'
import * as jobsApi from '@/api/hermes/jobs'
import type { Job, CreateJobRequest, UpdateJobRequest } from '@/api/hermes/jobs'
function matchId(job: Job, id: string): boolean {
return job.job_id === id || job.id === id
}
export const useJobsStore = defineStore('jobs', () => {
const jobs = ref<Job[]>([])
const loading = ref(false)
async function fetchJobs() {
loading.value = true
try {
jobs.value = await jobsApi.listJobs()
} catch (err) {
console.error('Failed to fetch jobs:', err)
} finally {
loading.value = false
}
}
async function createJob(data: CreateJobRequest): Promise<Job> {
const job = await jobsApi.createJob(data)
jobs.value.unshift(job)
return job
}
async function updateJob(jobId: string, data: UpdateJobRequest): Promise<Job> {
const job = await jobsApi.updateJob(jobId, data)
const idx = jobs.value.findIndex(j => matchId(j, jobId))
if (idx !== -1) jobs.value[idx] = job
return job
}
async function deleteJob(jobId: string) {
await jobsApi.deleteJob(jobId)
jobs.value = jobs.value.filter(j => !matchId(j, jobId))
}
async function pauseJob(jobId: string) {
const job = await jobsApi.pauseJob(jobId)
const idx = jobs.value.findIndex(j => matchId(j, jobId))
if (idx !== -1) jobs.value[idx] = job
}
async function resumeJob(jobId: string) {
const job = await jobsApi.resumeJob(jobId)
const idx = jobs.value.findIndex(j => matchId(j, jobId))
if (idx !== -1) jobs.value[idx] = job
}
async function runJob(jobId: string) {
const job = await jobsApi.runJob(jobId)
const idx = jobs.value.findIndex(j => matchId(j, jobId))
if (idx !== -1) jobs.value[idx] = job
}
return {
jobs,
loading,
fetchJobs,
createJob,
updateJob,
deleteJob,
pauseJob,
resumeJob,
runJob,
}
})