Permalink
Browse files

add pagination to scheduler history

  • Loading branch information...
laurencei committed May 12, 2018
1 parent 282e66a commit 57b1e05ceecb79cad9a002fa7e2c8803db53991b
@@ -25,6 +25,7 @@ public function show($id)
return view('eyewitness::scheduler.show')->withEye(app(Eye::class))
->withScheduler($scheduler)
->withHistories($scheduler->history()->simplePaginate(config('eyewitness.pagination_size', 50)))
->withTransformer(new ChartTransformer);
}

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 32" xml:space="preserve" width="32" height="32"><g class="nc-icon-wrapper" fill="#fb503b"><path fill="#fb503b" d="M19.707,15.293L5,0.586L3.586,2l14,14l-14,14L5,31.414l14.707-14.707 C20.098,16.316,20.098,15.684,19.707,15.293z"></path> <path data-color="color-2" fill="#555555" d="M13,0.586L11.586,2l14,14l-14,14L13,31.414l14.707-14.707c0.391-0.391,0.391-1.023,0-1.414 L13,0.586z"></path></g></svg>
@@ -1,5 +1,5 @@
<template>
<a :href="btnLink" class="text-white font-bold pr-4 py-2 rounded inline-flex items-center no-underline shadow-md cursor-pointer" :class="buttonStatus" @click="pressButton" :disabled="loadingStatus">
<a :href="btnLink" class="text-white font-bold pr-4 py-2 rounded inline-flex items-center no-underline shadow-md cursor-pointer" :class="buttonStatus" @click="pressButton" :disabled="disabledStatus">
<span v-show="!loadingStatus" class="pl-3 mr-2 flex items-center" v-html="icon"></span>
<transition enter-active-class="animated zoomIn" leave-active-class="animated zoomOut">
<span v-show="loadingStatus" class="pl-2 mr-1 flex items-center">
@@ -15,39 +15,50 @@
<script>
export default {
props: [
'icon',
'color',
'link'
],
props: {
icon: String,
color: String,
link: String,
disabled: {
default: false,
type: Boolean
}
},
data: function() {
return {
'isDisabled': this.disabled,
'isLoading': false,
'btnColor': this.color,
'btnLink': this.link
};
},
computed: {
disabledStatus() {
return this.isLoading || this.isDisabled;
},
loadingStatus() {
return this.isLoading;
},
buttonStatus() {
return [{
'opacity-50': this.loadingStatus,
'cursor-not-allowed': this.loadingStatus,
'hover:bg-brand-light' : !this.loadingStatus,
'hover:shadow-lg': !this.loadingStatus,
'btn-pop': !this.loadingStatus,
'opacity-50': this.disabledStatus,
'cursor-not-allowed': this.disabledStatus,
'hover:bg-brand-light' : !this.disabledStatus,
'hover:shadow-lg': !this.disabledStatus,
'btn-pop': !this.disabledStatus,
}, this.btnColor];
},
},
methods: {
pressButton() {
this.isLoading = true;
if (! this.disabledStatus) {
this.isLoading = true;
}
},
}
}
@@ -0,0 +1,18 @@
@if ($paginator->hasPages())
<div class="flex mt-8 border-t pt-4">
<div class="flex-1 text-left">
@if ($paginator->onFirstPage())
<eye-btn-link link="#" :disabled=true color="bg-brand" icon='@eyewitness_svg('double-left', 'svgcolor-white h-4 w-4')'>Previous</eye-btn-link>
@else
<eye-btn-link link="{{ $paginator->previousPageUrl() }}" :disabled=false color="bg-brand" icon='@eyewitness_svg('double-left', 'svgcolor-white h-4 w-4')'>Previous</eye-btn-link>
@endif
</div>
<div class="flex-1 text-right">
@if ($paginator->hasMorePages())
<eye-btn-link link="{{ $paginator->nextPageUrl() }}" :disabled=false color="bg-brand" icon='@eyewitness_svg('double-right', 'svgcolor-white h-4 w-4')'>Load More</eye-btn-link>
@else
<eye-btn-link link="#" :disabled=true color="bg-brand" icon='@eyewitness_svg('double-right', 'svgcolor-white h-4 w-4')'>Load More</eye-btn-link>
@endif
</div>
</div>
@endif
@@ -10,7 +10,7 @@
<div class="text-center px-6 pb-8">
@eyewitness_tutorial('Here is the history of this scheduled command. Each time the schedule runs, the results are captured below. Any output by the cron is also stored (although you can disable this in the config file if needed).')
@if (count($scheduler->history))
@if (count($histories))
<table class="w-full" cellspacing="0" cellpadding="0">
<thead>
<tr>
@@ -21,7 +21,7 @@
</tr>
</thead>
<tbody>
@foreach($scheduler->history as $history)
@foreach($histories as $history)
<tr>
<td class="text-center text-sm py-3 text-grey-darker font-hairline">{{ $history->created_at->format('Y-m-d H:i:s') }} <span class="text-grey italic">({{ $history->created_at->diffForHumans() }})</span></td>
<td class="text-center text-sm py-3 text-grey-darker font-hairlinel">{{ round($history->time_to_run, 1) }}s</td>
@@ -51,6 +51,7 @@
@endforeach
</tbody>
</table>
{{ $histories->fragment('history')->links('eyewitness::pagination') }}
@else
<div class="py-8">
<div class="mb-4">
@@ -15,7 +15,7 @@ public function setUp()
$this->artisan('migrate', ['--database' => 'testbench']);
}
public function test_show_scheduler_page_loads()
public function test_show_scheduler_page_loads_with_no_pagination()
{
$scheduler = factory(Scheduler::class)->create();
$history1 = factory(History::class)->create(['scheduler_id' => $scheduler->id, 'time_to_run' => '0.845']);
@@ -31,6 +31,28 @@ public function test_show_scheduler_page_loads()
$response->assertSee((string) round($history2->time_to_run, 1));
$response->assertSee($history1->output);
$response->assertSee($history2->output);
$response->assertDontSee('Load More');
}
public function test_show_scheduler_page_loads_with_pagination()
{
config(['eyewitness.pagination_size' => 4]);
$scheduler = factory(Scheduler::class)->create();
$history1 = factory(History::class)->create(['scheduler_id' => $scheduler->id, 'time_to_run' => '0.845']);
$history2 = factory(History::class)->create(['scheduler_id' => $scheduler->id, 'time_to_run' => '0.234']);
$history3 = factory(History::class)->create(['scheduler_id' => $scheduler->id, 'time_to_run' => '0.234']);
$history4 = factory(History::class)->create(['scheduler_id' => $scheduler->id, 'time_to_run' => '0.234']);
$history5 = factory(History::class)->create(['scheduler_id' => $scheduler->id, 'time_to_run' => '0.987']);
$response = $this->withSession(['eyewitness:auth' => 1])
->get(route('eyewitness.schedulers.show', $scheduler));
$response->assertStatus(200);
$response->assertSee($history1->output);
$response->assertSee($history2->output);
$response->assertSee('Load More');
$response->assertDontSee('0.987');
}
public function test_update_scheduler_validation()

0 comments on commit 57b1e05

Please sign in to comment.