feat: add currently running status
This commit is contained in:
parent
8915825e97
commit
7835fe469c
1 changed files with 35 additions and 1 deletions
|
|
@ -58,10 +58,44 @@ export class BackupController extends Controller {
|
|||
});
|
||||
}
|
||||
|
||||
@Get("backup-running-list")
|
||||
async runningBackupStatus() {
|
||||
return await fetch(
|
||||
`${WINDMILL_URL}/api/w/${WINDMILL_WORKSPACE}/jobs/list?running=true&script_path_exact=${WINDMILL_BACKUP_SCRIPT_PATH}`,
|
||||
{
|
||||
headers: { Authorization: `Bearer ${WINDMILL_API_KEY}` },
|
||||
},
|
||||
).then(async (r) => {
|
||||
const data = await r.json();
|
||||
if (typeof data === "object" && "error" in data) {
|
||||
console.error(data);
|
||||
throw new Error("Backup Error");
|
||||
}
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
@Get("restore-running-list")
|
||||
async runningRestoreStatus() {
|
||||
return await fetch(
|
||||
`${WINDMILL_URL}/api/w/${WINDMILL_WORKSPACE}/jobs/list?running=true&script_path_exact=${WINDMILL_RESTORE_SCRIPT_PATH}`,
|
||||
{
|
||||
headers: { Authorization: `Bearer ${WINDMILL_API_KEY}` },
|
||||
},
|
||||
).then(async (r) => {
|
||||
const data = await r.json();
|
||||
if (typeof data === "object" && "error" in data) {
|
||||
console.error(data);
|
||||
throw new Error("Backup Error");
|
||||
}
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
@Post("create")
|
||||
async runBackup() {
|
||||
return await fetch(
|
||||
`${WINDMILL_URL}/api/w/${WINDMILL_WORKSPACE}/jobs/run_wait_result/p/${WINDMILL_BACKUP_SCRIPT_PATH}`,
|
||||
`${WINDMILL_URL}/api/w/${WINDMILL_WORKSPACE}/jobs/run/p/${WINDMILL_BACKUP_SCRIPT_PATH}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue