Skip to content

Commit

Permalink
stop paused campaign + fix disabled action reload
Browse files Browse the repository at this point in the history
remp/remp#308
  • Loading branch information
zoldia committed Oct 16, 2018
1 parent a0af381 commit 5a8c707
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Campaign/app/Http/Controllers/ScheduleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function json(Request $request, Datatables $dataTables, Campaign $campaig
'edit' => !$s->isStopped() ? route('schedule.edit', $s) : null,
'start' => $s->isRunnable() ? route('schedule.start', $s) : null,
'pause' => $s->isRunning() ? route('schedule.pause', $s) : null,
'stop' => $s->isRunning() ? route('schedule.stop', $s) : null,
'stop' => $s->isRunning() || $s->isPaused() ? route('schedule.stop', $s) : null,
'destroy' => $s->isEditable() ? route('schedule.destroy', $s) : null,
];
})
Expand Down Expand Up @@ -259,7 +259,7 @@ public function start(Schedule $schedule)
*/
public function stop(Schedule $schedule)
{
if (!$schedule->isRunning()) {
if (!$schedule->isRunning() && !$schedule->isPaused()) {
return response()->format([
'html' => redirect(route('campaigns.index'))->with('success', sprintf(
"Schedule for campaign %s was not running, stop request ignored",
Expand Down
5 changes: 5 additions & 0 deletions Campaign/app/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public function isStopped()
return $this->status === self::STATUS_STOPPED || ($this->end_time !== null && $this->end_time < Carbon::now());
}

public function isPaused()
{
return $this->status === self::STATUS_PAUSED;
}

public function endsInFuture()
{
return !$this->end_time || $this->end_time > Carbon::now();
Expand Down
2 changes: 1 addition & 1 deletion Package/remp/js/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ $.fn.dataTables = {
var actions = '<span class="actions">';
$.each(actionSettings, function (key, action) {
if (row.actions[action['name']] === null) {
actions += '<a class="btn btn-sm palette-Cyan bg waves-effect" disabled="disabled" title="' + action['title'] + '" href=""><i class="zmdi ' + action['class'] + '"></i></a>\n';
actions += '<a class="btn btn-sm palette-Cyan bg waves-effect" disabled="disabled" title="' + action['title'] + '" href="javascript:void(0)"><i class="zmdi ' + action['class'] + '"></i></a>\n';
return;
}
if (row.action_methods && row.action_methods[action['name']]) {
Expand Down

0 comments on commit 5a8c707

Please sign in to comment.