Skip to content

Commit

Permalink
return updated pause job status from db to front end
Browse files Browse the repository at this point in the history
  • Loading branch information
bitkarrot committed Sep 29, 2023
1 parent bc1501a commit 240ccf1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
4 changes: 2 additions & 2 deletions crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ async def pause_scheduler(job_id: str, state: str) -> bool:
""",
(status, job_id)
)

print("Updated database with current status ")
return status
return await get_scheduler_job(job_id)

except Exception as e:
return f"Error pausing job: {e}"

Expand Down
25 changes: 7 additions & 18 deletions templates/scheduler/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ <h5 class="text-subtitle1 q-my-none">Schedule</h5>

<div class="row q-col-gutter-sm">
<div class="col">
<q-label> Job Status</q-label>
<label> Job Status: Is Running?</label>
<q-input
disabled
dense
Expand Down Expand Up @@ -316,12 +316,7 @@ <h5 class="text-subtitle1 q-my-none">Schedule</h5>
{name: 'id', align: 'left', label: 'ID', field: 'id'},
{name: 'name', align: 'left', label: 'Job Name', field: 'name'},
{name: 'status', align: 'left', label: 'Is Running?', field: 'status'},
{
name: 'schedule',
align: 'left',
label: 'Schedule',
field: 'schedule'
},
{name: 'schedule', align: 'left',label: 'Schedule',field: 'schedule'},
],
pagination: {
rowsPerPage: 10
Expand Down Expand Up @@ -510,15 +505,15 @@ <h5 class="text-subtitle1 q-my-none">Schedule</h5>
this.$set(this.jobStates, id, !this.jobStates[id]);
this.pauseJob(id, !this.jobStates[id]);
},
getButtonIcon(id) {
getButtonIcon(id) {
console.log("getButtonIcon: job id: ", id)
console.log("getButtonIcon: button job state:", this.jobStates[id])
return this.jobStates[id] ? 'play_arrow' : 'stop';
},
getButtonText(id) {
return this.jobStates[id] ? 'Play' : 'Stop';
},
getButtonColor(id) {
console.log("job id: ", id)
console.log("button job state:", this.jobStates[id])
return this.jobStates[id] ? 'green' : 'red';
},
pauseJob: function (jobId, status) {
Expand All @@ -538,16 +533,10 @@ <h5 class="text-subtitle1 q-my-none">Schedule</h5>
)
.then(function (response) {
console.log("Pause Response status", response.status);
this.getJobs();
window.location.reload();
// self.jobs[jobId] = mapcrontabs(response.data);

self.jobStates[jobId] = !status
// TODO: fix the status update displayed after post
// update the list of jobs paused or running
// response status for success/failure, we might not need this section?
// in jobStatus.data.id
// self.jobs = _.reject(self.jobs, function (obj) {
// return obj.id == jobId
//})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
Expand Down
2 changes: 1 addition & 1 deletion views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async def api_scheduler_jobs_delete(
)
async def api_scheduler_pause(
job_id, status
) -> bool:
) -> JobDetailed:
return await pause_scheduler(job_id, status)


Expand Down

0 comments on commit 240ccf1

Please sign in to comment.