|
40 | 40 | <tbody> |
41 | 41 | @foreach($tasks as $task) |
42 | 42 | <tr @if($task->active === 0)class="text-disabled"@endif> |
43 | | - <td><a href="{{ route('server.tasks.view', [ $server->uuidShort, $task->id ]) }}">{{ $actions[$task->action] }}</a></td> |
| 43 | + {{-- <td><a href="{{ route('server.tasks.view', [ $server->uuidShort, $task->id ]) }}">{{ $actions[$task->action] }}</a></td> --}} |
| 44 | + <td>{{ $actions[$task->action] }}</td> |
44 | 45 | <td><code>{{ $task->data }}</code></td> |
45 | 46 | <td>{{ Carbon::parse($task->last_run)->toDayDateTimeString() }} <p class="text-muted"><small>({{ Carbon::parse($task->last_run)->diffForHumans() }})</small></p></td> |
46 | 47 | <td> |
|
70 | 71 | $('.server-tasks').addClass('active'); |
71 | 72 | $('[data-toggle="tooltip"]').tooltip(); |
72 | 73 |
|
73 | | - $('[data-action="delete-task"]').click(function (event) { |
74 | | - var self = $(this); |
75 | | - swal({ |
76 | | - type: 'error', |
77 | | - title: 'Delete Task?', |
78 | | - text: 'Are you sure you want to delete this task? There is no undo.', |
79 | | - showCancelButton: true, |
80 | | - allowOutsideClick: true, |
81 | | - closeOnConfirm: false, |
82 | | - confirmButtonText: 'Delete Task', |
83 | | - confirmButtonColor: '#d9534f', |
84 | | - showLoaderOnConfirm: true |
85 | | - }, function () { |
86 | | - $.ajax({ |
87 | | - method: 'DELETE', |
88 | | - url: '{{ route('server.tasks', $server->uuidShort) }}/delete/' + self.data('id'), |
89 | | - headers: { |
90 | | - 'X-CSRF-TOKEN': '{{ csrf_token() }}' |
91 | | - } |
92 | | - }).done(function (data) { |
93 | | - swal({ |
94 | | - type: 'success', |
95 | | - title: '', |
96 | | - text: 'Task has been deleted.' |
97 | | - }); |
98 | | - self.parent().parent().slideUp(); |
99 | | - }).fail(function (jqXHR) { |
100 | | - console.error(jqXHR); |
101 | | - swal({ |
102 | | - type: 'error', |
103 | | - title: 'Whoops!', |
104 | | - text: 'An error occured while attempting to delete this task.' |
| 74 | + @can('delete-task', $server) |
| 75 | + $('[data-action="delete-task"]').click(function (event) { |
| 76 | + var self = $(this); |
| 77 | + swal({ |
| 78 | + type: 'error', |
| 79 | + title: 'Delete Task?', |
| 80 | + text: 'Are you sure you want to delete this task? There is no undo.', |
| 81 | + showCancelButton: true, |
| 82 | + allowOutsideClick: true, |
| 83 | + closeOnConfirm: false, |
| 84 | + confirmButtonText: 'Delete Task', |
| 85 | + confirmButtonColor: '#d9534f', |
| 86 | + showLoaderOnConfirm: true |
| 87 | + }, function () { |
| 88 | + $.ajax({ |
| 89 | + method: 'DELETE', |
| 90 | + url: '{{ route('server.tasks', $server->uuidShort) }}/delete/' + self.data('id'), |
| 91 | + headers: { |
| 92 | + 'X-CSRF-TOKEN': '{{ csrf_token() }}' |
| 93 | + } |
| 94 | + }).done(function (data) { |
| 95 | + swal({ |
| 96 | + type: 'success', |
| 97 | + title: '', |
| 98 | + text: 'Task has been deleted.' |
| 99 | + }); |
| 100 | + self.parent().parent().slideUp(); |
| 101 | + }).fail(function (jqXHR) { |
| 102 | + console.error(jqXHR); |
| 103 | + swal({ |
| 104 | + type: 'error', |
| 105 | + title: 'Whoops!', |
| 106 | + text: 'An error occured while attempting to delete this task.' |
| 107 | + }); |
105 | 108 | }); |
106 | 109 | }); |
107 | 110 | }); |
108 | | - }); |
109 | | -
|
110 | | - $('[data-action="toggle-task"]').click(function (event) { |
111 | | - var self = $(this); |
112 | | - swal({ |
113 | | - type: 'info', |
114 | | - title: 'Toggle Task', |
115 | | - text: 'This will toggle the selected task.', |
116 | | - showCancelButton: true, |
117 | | - allowOutsideClick: true, |
118 | | - closeOnConfirm: false, |
119 | | - confirmButtonText: 'Continue', |
120 | | - showLoaderOnConfirm: true |
121 | | - }, function () { |
122 | | - $.ajax({ |
123 | | - method: 'POST', |
124 | | - url: '{{ route('server.tasks', $server->uuidShort) }}/toggle/' + self.data('id'), |
125 | | - headers: { |
126 | | - 'X-CSRF-TOKEN': '{{ csrf_token() }}' |
127 | | - } |
128 | | - }).done(function (data) { |
129 | | - swal({ |
130 | | - type: 'success', |
131 | | - title: '', |
132 | | - text: 'Task has been toggled.' |
133 | | - }); |
134 | | - if (data.status !== 1) { |
135 | | - self.parent().parent().addClass('text-disabled'); |
136 | | - } else { |
137 | | - self.parent().parent().removeClass('text-disabled'); |
138 | | - } |
139 | | - }).fail(function (jqXHR) { |
140 | | - console.error(jqXHR); |
141 | | - swal({ |
142 | | - type: 'error', |
143 | | - title: 'Whoops!', |
144 | | - text: 'An error occured while attempting to toggle this task.' |
| 111 | + @endcan |
| 112 | + @can('toggle-task', $server) |
| 113 | + $('[data-action="toggle-task"]').click(function (event) { |
| 114 | + var self = $(this); |
| 115 | + swal({ |
| 116 | + type: 'info', |
| 117 | + title: 'Toggle Task', |
| 118 | + text: 'This will toggle the selected task.', |
| 119 | + showCancelButton: true, |
| 120 | + allowOutsideClick: true, |
| 121 | + closeOnConfirm: false, |
| 122 | + confirmButtonText: 'Continue', |
| 123 | + showLoaderOnConfirm: true |
| 124 | + }, function () { |
| 125 | + $.ajax({ |
| 126 | + method: 'POST', |
| 127 | + url: '{{ route('server.tasks', $server->uuidShort) }}/toggle/' + self.data('id'), |
| 128 | + headers: { |
| 129 | + 'X-CSRF-TOKEN': '{{ csrf_token() }}' |
| 130 | + } |
| 131 | + }).done(function (data) { |
| 132 | + swal({ |
| 133 | + type: 'success', |
| 134 | + title: '', |
| 135 | + text: 'Task has been toggled.' |
| 136 | + }); |
| 137 | + if (data.status !== 1) { |
| 138 | + self.parent().parent().addClass('text-disabled'); |
| 139 | + } else { |
| 140 | + self.parent().parent().removeClass('text-disabled'); |
| 141 | + } |
| 142 | + }).fail(function (jqXHR) { |
| 143 | + console.error(jqXHR); |
| 144 | + swal({ |
| 145 | + type: 'error', |
| 146 | + title: 'Whoops!', |
| 147 | + text: 'An error occured while attempting to toggle this task.' |
| 148 | + }); |
145 | 149 | }); |
146 | 150 | }); |
147 | 151 | }); |
148 | | - }); |
| 152 | + @endcan |
149 | 153 |
|
150 | 154 | }); |
151 | 155 | </script> |
|
0 commit comments