Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
afourmy committed Apr 12, 2020
1 parent 8d95aa4 commit 687b166
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion eNMS/models/scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import relationship

from eNMS import app
from eNMS.database import db
from eNMS.models.base import AbstractBase
from eNMS.setup import scheduler
Expand Down
3 changes: 1 addition & 2 deletions eNMS/static/js/automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,11 @@ function exportService(id) {
}

function taskAction(mode, id) {

call({
url: `/task_action/${mode}/${id}`,
callback: function (result) {
const inverseAction = mode == "resume" ? "pause" : "resume";
const action = `eNMS.automation.${inverseAction}Task('${id}')`
const action = `eNMS.automation.${inverseAction}Task('${id}')`;
$(`#pause-resume-${id}`).attr("onclick", action);
notify(result.response, "success", 5);
},
Expand Down
8 changes: 6 additions & 2 deletions eNMS/static/js/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,13 +903,17 @@ tables.task = class TaskTable extends Table {
</li>
<li>
<button type="button" class="btn btn-sm btn-success ${state[0]}" ${state[0]}
onclick="eNMS.automation.taskAction('resume', '${row.id}')" data-tooltip="Play"
onclick="eNMS.automation.taskAction('resume', '${
row.id
}')" data-tooltip="Play"
><span class="glyphicon glyphicon-play"></span
></button>
</li>
<li>
<button type="button" class="btn btn-sm btn-danger ${state[1]}" ${state[1]}
onclick="eNMS.automation.taskAction('pause', '${row.id}')" data-tooltip="Pause"
onclick="eNMS.automation.taskAction('pause', '${
row.id
}')" data-tooltip="Pause"
><span class="glyphicon glyphicon-pause"></span
></button>
</li>
Expand Down
7 changes: 3 additions & 4 deletions scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ async def schedule(request):
if data["mode"] in ("resume", "schedule"):
result = self.schedule_task(data["task"])
if not result:
return JSONResponse({"alert": f"Cannot schedule in the past."})
return JSONResponse({"alert": "Cannot schedule in the past."})
else:
response = f"Task {data['mode']}d."
return JSONResponse({"response": response, "active": True})
return JSONResponse({"response": "Task resumed.", "active": True})
else:
try:
self.scheduler.pause_job(data["task"]["id"])
return JSONResponse({"response": f"Task {data['mode']}d.",})
return JSONResponse({"response": "Task paused."})
except JobLookupError:
return JSONResponse({"alert": "There is no such job scheduled."})

Expand Down

0 comments on commit 687b166

Please sign in to comment.