Skip to content

Commit df5455f

Browse files
author
Roshan
committed
wip
1 parent 3a6ea5b commit df5455f

File tree

13 files changed

+92
-285
lines changed

13 files changed

+92
-285
lines changed

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Once `Laravel Totem` is installed , publish `Totem` assets to your public folder
3333

3434
This package assumes that you have a good understanding of [Laravel's Task Scheduling](https://laravel.com/docs/5.4/scheduling) and [Laravel Console Commands](https://laravel.com/docs/5.4/artisan#writing-commands). Before any of this works please make sure you have a cron running as follows:
3535

36-
* * * * * php /path-to-your-project/artisan totem:run >> /dev/null 2>&1
36+
* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
3737

3838
##### Web Dashboard
3939

@@ -50,19 +50,12 @@ By default Totem's dashboard only works in local environment. To view the dashbo
5050

5151
#### Making Commands available in `Laravel Totem`
5252

53-
To be able to view and schedule your console commands in Totem's dashboard you are required to extend your command from `Studio\Totem\Console\Commands\Command` . For e.g.
53+
All available commands can be scheduled. If you want to hide a command from Totem make sure you have the `hidden` attribute set to true in your command. For e.g.
5454

5555
```
56-
use Studio\Totem\Console\Commands\Command
57-
58-
class BackupCommand extends Command
59-
{
60-
// your regular Laravel command stuff
61-
}
56+
protected $hidden = true;
6257
```
6358

64-
I have converted [Spatie's](https://docs.spatie.be/laravel-backup/v4/introduction) backup and cleanup command and included them in the package. To be able to use these commands make sure you follow their documentation and publish and configure laravel-backup.php file to your config directory properly.
65-
6659
#### Current limitations
6760

6861
Currently tasks can only be scheduled with a cron expression. Stay tuned for more Laravel Schedule like fluent configurations.

resources/views/tasks/form.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<div class="blk6">
2727
<select id="command" name="command" class="form-control" placeholder="Click here to select one of the available commands">
2828
@foreach ($commands as $key => $command)
29-
<option value="{{$key}}" {{old('command', $task->command) == $command ? 'selected' : ''}}>{{$command}}</option>
29+
<option value="{{$key}}" {{old('command', $task->command) == $key ? 'selected' : ''}}>{{$command}}</option>
3030
@endforeach
3131
</select>
3232

resources/views/tasks/index.blade.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@
3333
</a>
3434
</td>
3535
<td class="ph2">{{$task->cron ? 'Cron' : 'Frequency'}}</td>
36-
<td class="ph2">N/A</td>
37-
<td class="ph2">N/A</td>
36+
<td class="ph2">{{ $task->results->count() > 0 ? number_format( $task->results->sum('duration') / (1000 * $task->results->count()) , 2) : '0' }} seconds</td>
37+
@if($last = $task->results->last())
38+
<td class="ph2">{{$last->ran_at->toDateTimeString()}}</td>
39+
@else
40+
<td class="ph2">N/A</td>
41+
@endif
3842
<td class="ph2">
3943
<a href="{{ route('totem.task.run', $task) }}">
4044
<i class="ico ico20 ico-baseline">

resources/views/tasks/view.blade.php

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@
1717
<div class="blk2 ft15 lh2 tcg9 tar">
1818
Description<br>
1919
Command<br>
20-
Type<br>
20+
Cron Expression<br>
2121
Created @<br>
2222
Updated @<br>
23-
Notify @
23+
Notify @<br>
24+
Average Run Time
2425
</div>
2526
<div class="blk9 ft15 lh2 basic-text">
2627
{{$task->description}}<br>
2728
{{$task->command}}<br>
28-
{{$task->cron ? 'Cron ( ' . $task->cron . ' )': 'Frequency'}}<br>
29+
{{$task->cron ? $task->cron : 'Frequency'}}<br>
2930
{{$task->created_at->toDateTimeString()}}<br>
3031
{{$task->updated_at->toDateTimeString()}}<br>
31-
{{$task->notification_email_address}}
32+
{{$task->notification_email_address}}<br>
33+
{{$task->results->count() > 0 ? number_format( $task->results->sum('duration') / (1000 * $task->results->count()) , 2) : '0'}} seconds
3234
</div>
3335
</div>
3436
</div>
@@ -48,11 +50,31 @@
4850
@section('additional-panels')
4951
<div class="panel panel-default">
5052
<div class="panel-heading">
51-
Task Stats
53+
Execution Results
5254
</div>
5355
<div class="panel-content">
54-
55-
56+
<table class="table" cellpadding="0" cellspacing="0" class="mb1">
57+
<thead>
58+
<tr>
59+
<th class="pl2">Duration</th>
60+
<th class="pl2">Executed At</th>
61+
</tr>
62+
</thead>
63+
<tbody>
64+
@forelse($task->results as $result)
65+
<tr>
66+
<td class="ph2">{{ number_format($result->duration / 1000 , 2)}} seconds</td>
67+
<td class="ph2">{{$result->ran_at->toDateTimeString()}}</td>
68+
</tr>
69+
@empty
70+
<tr>
71+
<td class="tac" colspan="5">
72+
<p class="pa2">No Results Found.</p>
73+
</td>
74+
</tr>
75+
@endforelse
76+
</tbody>
77+
</table>
5678
</div>
5779
</div>
5880
@stop

src/Console/Command.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/Console/Commands/BackupCommand.php

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/Console/Commands/CleanupCommand.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/Console/Commands/RunSchedule.php

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)