docs: add Pause/Resume UI implementation guide for Studio team
- API endpoint documentation (pause, resume, list paused) - Vue component examples for Pause/Resume buttons - Paused Jobs management page template - Navigation update suggestions - State flow diagram
This commit is contained in:
@@ -0,0 +1,324 @@
|
||||
# Pause/Resume Job Feature - UI Implementation Guide
|
||||
|
||||
**Date**: 2026-10-18
|
||||
**From**: Core Team
|
||||
**To**: Studio Team
|
||||
**Priority**: Medium
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
The Core team has implemented a Pause/Resume feature for job management. This allows users to pause stuck jobs so the worker can process other pending jobs.
|
||||
|
||||
---
|
||||
|
||||
## New API Endpoints
|
||||
|
||||
### 1. POST `/api/v1/jobs/:uuid/pause`
|
||||
|
||||
**Purpose**: Pause a job so the worker skips it during polling.
|
||||
|
||||
**Request**:
|
||||
```http
|
||||
POST /api/v1/jobs/7a1523df54e2161a54e4577d1835acfd/pause
|
||||
X-API-Key: muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Job 7a1523df54e2161a54e4577d1835acfd paused",
|
||||
"uuid": "7a1523df54e2161a54e4577d1835acfd"
|
||||
}
|
||||
```
|
||||
|
||||
**Error Responses**:
|
||||
- `404`: Job not found
|
||||
- `400`: Cannot pause completed/failed job
|
||||
- `500`: Internal server error
|
||||
|
||||
---
|
||||
|
||||
### 2. POST `/api/v1/jobs/:uuid/resume`
|
||||
|
||||
**Purpose**: Resume a paused job.
|
||||
|
||||
**Request**:
|
||||
```http
|
||||
POST /api/v1/jobs/7a1523df54e2161a54e4577d1835acfd/resume
|
||||
X-API-Key: muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Job 7a1523df54e2161a54e4577d1835acfd resumed",
|
||||
"uuid": "7a1523df54e2161a54e4577d1835acfd"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. GET `/api/v1/jobs/paused`
|
||||
|
||||
**Purpose**: List all paused jobs.
|
||||
|
||||
**Request**:
|
||||
```http
|
||||
GET /api/v1/jobs/paused
|
||||
X-API-Key: muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"uuid": "7a1523df54e2161a54e4577d1835acfd",
|
||||
"file_name": "Accusys-WD_FilmRiot_test.mp4",
|
||||
"status": "paused",
|
||||
"paused_at": "2026-10-18T12:00:00Z"
|
||||
}
|
||||
],
|
||||
"total": 1
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## UI Implementation Recommendations
|
||||
|
||||
### 1. Job List Page - Pause/Resume Buttons
|
||||
|
||||
**Add action buttons to each job card**:
|
||||
|
||||
```vue
|
||||
<!-- JobCard.vue -->
|
||||
<template>
|
||||
<div class="job-card" :class="job.status">
|
||||
<div class="job-info">
|
||||
<h3>{{ job.file_name }}</h3>
|
||||
<span class="uuid">{{ job.uuid.slice(0, 12) }}...</span>
|
||||
<span class="status-badge" :class="job.status">
|
||||
{{ statusText(job.status) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="job-actions">
|
||||
<!-- Pause button (for pending/running jobs) -->
|
||||
<button
|
||||
v-if="job.status === 'pending' || job.status === 'running'"
|
||||
@click="pauseJob(job.uuid)"
|
||||
class="btn-pause"
|
||||
title="Pause this job">
|
||||
⏸️ Pause
|
||||
</button>
|
||||
|
||||
<!-- Resume button (for paused jobs) -->
|
||||
<button
|
||||
v-if="job.status === 'paused'"
|
||||
@click="resumeJob(job.uuid)"
|
||||
class="btn-resume"
|
||||
title="Resume this job">
|
||||
▶️ Resume
|
||||
</button>
|
||||
|
||||
<!-- Unregister button (always available) -->
|
||||
<button
|
||||
@click="unregisterJob(job.uuid)"
|
||||
class="btn-unregister"
|
||||
title="Unregister this file">
|
||||
🗑️ Unregister
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
job: Object
|
||||
})
|
||||
|
||||
const emit = defineEmits(['pause', 'resume', 'unregister'])
|
||||
|
||||
const pauseJob = async (uuid) => {
|
||||
try {
|
||||
await api.post(`/api/v1/jobs/${uuid}/pause`)
|
||||
emit('pause', uuid)
|
||||
} catch (e) {
|
||||
showError(e.response?.data?.error || 'Failed to pause job')
|
||||
}
|
||||
}
|
||||
|
||||
const resumeJob = async (uuid) => {
|
||||
try {
|
||||
await api.post(`/api/v1/jobs/${uuid}/resume`)
|
||||
emit('resume', uuid)
|
||||
} catch (e) {
|
||||
showError(e.response?.data?.error || 'Failed to resume job')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.btn-pause {
|
||||
background: #f59e0b;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 4px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-resume {
|
||||
background: #22c55e;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 4px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-pause:hover {
|
||||
background: #d97706;
|
||||
}
|
||||
|
||||
.btn-resume:hover {
|
||||
background: #16a34a;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 2. Paused Jobs Management Page
|
||||
|
||||
**Create a new page or tab for managing paused jobs**:
|
||||
|
||||
```vue
|
||||
<!-- PausedJobsView.vue -->
|
||||
<template>
|
||||
<div class="paused-jobs-page">
|
||||
<h2>Paused Jobs ({{ pausedJobs.length }})</h2>
|
||||
|
||||
<div v-if="pausedJobs.length === 0" class="empty-state">
|
||||
<p>No paused jobs</p>
|
||||
</div>
|
||||
|
||||
<table v-else class="jobs-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>File Name</th>
|
||||
<th>UUID</th>
|
||||
<th>Paused At</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="job in pausedJobs" :key="job.uuid">
|
||||
<td>{{ job.file_name }}</td>
|
||||
<td class="uuid">{{ job.uuid.slice(0, 12) }}...</td>
|
||||
<td>{{ formatDate(job.paused_at) }}</td>
|
||||
<td class="actions">
|
||||
<button @click="resumeJob(job.uuid)" class="btn-resume">
|
||||
▶️ Resume
|
||||
</button>
|
||||
<button @click="unregisterJob(job.uuid)" class="btn-unregister">
|
||||
🗑️ Unregister
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import api from '@/api'
|
||||
|
||||
const pausedJobs = ref([])
|
||||
|
||||
const loadPausedJobs = async () => {
|
||||
try {
|
||||
const res = await api.get('/api/v1/jobs/paused')
|
||||
pausedJobs.value = res.data.jobs
|
||||
} catch (e) {
|
||||
console.error('Failed to load paused jobs:', e)
|
||||
}
|
||||
}
|
||||
|
||||
const resumeJob = async (uuid) => {
|
||||
try {
|
||||
await api.post(`/api/v1/jobs/${uuid}/resume`)
|
||||
await loadPausedJobs()
|
||||
} catch (e) {
|
||||
showError(e.response?.data?.error || 'Failed to resume job')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadPausedJobs()
|
||||
// Refresh every 30 seconds
|
||||
setInterval(loadPausedJobs, 30000)
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. Navigation Update
|
||||
|
||||
**Add a link to the Paused Jobs page in the navigation**:
|
||||
|
||||
```vue
|
||||
<!-- Navigation.vue -->
|
||||
<nav>
|
||||
<router-link to="/jobs">Jobs</router-link>
|
||||
<router-link to="/jobs/paused">
|
||||
Paused
|
||||
<span v-if="pausedCount > 0" class="badge">{{ pausedCount }}</span>
|
||||
</router-link>
|
||||
</nav>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Files to Modify
|
||||
|
||||
| File | Changes |
|
||||
|------|---------|
|
||||
| `src/api/jobs.ts` | Add pause/resume/listPaused methods |
|
||||
| `src/components/JobCard.vue` | Add Pause/Resume buttons |
|
||||
| `src/views/PausedJobsView.vue` | New component |
|
||||
| `src/router/index.ts` | Add route for /jobs/paused |
|
||||
| `src/stores/jobs.ts` | Add paused jobs state management |
|
||||
|
||||
---
|
||||
|
||||
## State Flow
|
||||
|
||||
```
|
||||
┌─────────────┐ POST /pause ┌─────────────┐
|
||||
│ Pending │ ───────────────────▶ │ Paused │
|
||||
│ Running │ │ │
|
||||
└─────────────┘ ◀─────────────────── └─────────────┘
|
||||
POST /resume
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Priority
|
||||
|
||||
| Feature | Priority | Effort |
|
||||
|---------|----------|--------|
|
||||
| Pause/Resume buttons | 🔴 High | Low |
|
||||
| Paused Jobs list | 🟡 Medium | Medium |
|
||||
| Navigation badge | 🟢 Low | Low |
|
||||
|
||||
---
|
||||
|
||||
**Contact**: Core Team for API questions.
|
||||
Reference in New Issue
Block a user