Skip to content

Commit

Permalink
Merge pull request OpenDominion#615 from internetfett/feature/recent-…
Browse files Browse the repository at this point in the history
…news

Permanent notifications
  • Loading branch information
WaveHack committed Jul 31, 2019
2 parents 60e3ad4 + 21d789a commit cb0697e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
42 changes: 42 additions & 0 deletions app/resources/views/pages/dominion/status.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,47 @@
@endif
</div>

<div class="col-sm-12 col-md-9">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title"><i class="fa fa-newspaper-o"></i> Recent News</h3>
</div>
<div class="box-body">
<table class="table table-condensed no-border">
@foreach ($notifications as $notification)
@php
$route = array_get($notificationHelper->getNotificationCategories(), "{$notification->data['category']}.{$notification->data['type']}.route", '#');
if (is_callable($route)) {
if (isset($notification->data['data']['_routeParams'])) {
$route = $route($notification->data['data']['_routeParams']);
} else {
// fallback
$route = '#';
}
}
@endphp
<tr>
<td>
<span class="text-muted">{{ $notification->created_at }}</span>
</td>
<td>
@if ($route !== '#')<a href="{{ $route }}">@endif
<i class="{{ array_get($notificationHelper->getNotificationCategories(), "{$notification->data['category']}.{$notification->data['type']}.iconClass", 'fa fa-question') }}"></i>
{{ $notification->data['message'] }}
@if ($route !== '#')</a>@endif
</td>
</tr>
@endforeach
</table>
</div>
<div class="box-footer">
<div class="pull-right">
{{ $notifications->links() }}
</div>
</div>
</div>
</div>

</div>
@endsection
2 changes: 1 addition & 1 deletion src/Http/Controllers/Dominion/MiscController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MiscController extends AbstractDominionController
{
public function postClearNotifications()
{
$this->getSelectedDominion()->notifications()->delete();
$this->getSelectedDominion()->notifications->markAsRead();
return redirect()->back();
}

Expand Down
10 changes: 9 additions & 1 deletion src/Http/Controllers/Dominion/StatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,28 @@
use OpenDominion\Calculators\Dominion\MilitaryCalculator;
use OpenDominion\Calculators\Dominion\PopulationCalculator;
use OpenDominion\Calculators\NetworthCalculator;
use OpenDominion\Helpers\NotificationHelper;
use OpenDominion\Services\Dominion\ProtectionService;
use OpenDominion\Services\Dominion\QueueService;

class StatusController extends AbstractDominionController
{
public function getStatus()
{
$resultsPerPage = 25;
$selectedDominion = $this->getSelectedDominion();

$notifications = $selectedDominion->notifications()->paginate($resultsPerPage);

return view('pages.dominion.status', [
'dominionProtectionService' => app(ProtectionService::class),
'landCalculator' => app(LandCalculator::class),
'militaryCalculator' => app(MilitaryCalculator::class),
'networthCalculator' => app(NetworthCalculator::class),
'notificationHelper' => app(NotificationHelper::class),
'populationCalculator' => app(PopulationCalculator::class),
'queueService' => app(QueueService::class)
'queueService' => app(QueueService::class),
'notifications' => $notifications
]);
}
}

0 comments on commit cb0697e

Please sign in to comment.