-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
192 additions
and
82 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@extends('mailcoach-api::app.webhooks.layouts.edit', [ | ||
'webhook' => $webhook, | ||
'titlePrefix' => 'Events Log' | ||
]) | ||
|
||
@section('breadcrumbs') | ||
<li> | ||
<a href="{{ route('mailcoach-api.webhooks.event-log', $webhook) }}"> | ||
<span class="breadcrumb">{{ $webhook->name }}</span> | ||
</a> | ||
</li> | ||
<li><span class="breadcrumb">Event Log</span></li> | ||
@endsection | ||
|
||
@section('webhook') | ||
@if($totalEventLogsCount > 0) | ||
{{-- <div class="table-actions">--}} | ||
{{-- <div class="table-filters">--}} | ||
{{-- <x-search placeholder="Filter opens" />--}} | ||
{{-- </div>--}} | ||
{{-- </div>--}} | ||
|
||
<table class="table table-fixed"> | ||
<thead> | ||
<tr> | ||
<x-th sort-by="status" class="">On Event</x-th> | ||
<x-th sort-by="email">Url</x-th> | ||
<x-th sort-by="status" class="w-32 th-numeric">Status</x-th> | ||
<x-th sort-by="attempts" class="w-32 th-numeric">Attempts</x-th> | ||
<x-th sort-by="-created_at" sort-default class="w-48 th-numeric hidden | md:table-cell">Created At</x-th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($eventLogs as $eventLog) | ||
<tr> | ||
<td>{{ $eventLog->payload['event'] }}</td> | ||
<td class="markup-links"> | ||
<div class="break-words"> | ||
{{ $eventLog->url }} | ||
</div> | ||
</td> | ||
<td class="td-numeric">{{ ucfirst($eventLog->status) }}</td> | ||
<td class="td-numeric">{{ $eventLog->attempts }}</td> | ||
<td class="td-numeric hidden | md:table-cell">{{ $eventLog->created_at->toMailcoachFormat() }}</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
|
||
<x-table-status | ||
name="event" | ||
:paginator="$eventLogs" | ||
:total-count="$totalEventLogsCount" | ||
:show-all-url="route('mailcoach-api.webhooks.event-log', $webhook)" | ||
></x-table-status> | ||
@else | ||
<p class="alert alert-info"> | ||
No events for this webhook yet. | ||
</p> | ||
@endif | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
@extends('mailcoach-api::app.webhooks.layouts.edit', [ | ||
'webhook' => $webhook, | ||
'titlePrefix' => 'Settings' | ||
]) | ||
|
||
@section('breadcrumbs') | ||
<li><span class="breadcrumb">{{ $webhook->name }}</span></li> | ||
<li><span class="breadcrumb">Settings</span></li> | ||
@endsection | ||
|
||
@section('webhook') | ||
<form | ||
class="form-grid" | ||
action="{{ route('mailcoach-api.webhooks.edit', [$webhook]) }}" | ||
method="POST" | ||
> | ||
@csrf | ||
@method('PUT') | ||
|
||
<x-text-field label="Name" name="name" :value="$webhook->name" type="name" required/> | ||
|
||
<x-text-field label="Url" name="url" :value="$webhook->url" type="name" required/> | ||
|
||
<hr class="border-t-2 border-gray-200 my-8"> | ||
|
||
<h2 class="markup-h2">Trigger webhook on these triggers:</h2> | ||
|
||
<x-help> | ||
The url you specify above will be hit when the checked event(s) occur. | ||
</x-help> | ||
|
||
@error('triggers') | ||
<p class="form-error">{{ $message }}</p> | ||
@enderror | ||
|
||
<div class="flex w-full"> | ||
|
||
<div class="w-1/2 flex flex-col align-start form-row"> | ||
<label class="label mb-4">When a message is…</label> | ||
<div class="checkbox-group"> | ||
@foreach ($messageTriggers as $trigger) | ||
<x-checkbox-field | ||
:label="$trigger->label" | ||
:name="'triggers['.$trigger->key.']'" | ||
:checked="$webhook->hasTrigger($trigger->key)" | ||
/> | ||
@endforeach | ||
</div> | ||
</div> | ||
|
||
<div class="w-1/2 flex flex-col align-start form-row"> | ||
<label class="label mb-4">When a subscriber…</label> | ||
<div class="checkbox-group"> | ||
@foreach ($subscriberTriggers as $trigger) | ||
<x-checkbox-field | ||
:label="$trigger->label" | ||
:name="'triggers['.$trigger->key.']'" | ||
:checked="$webhook->hasTrigger($trigger->key)" | ||
/> | ||
@endforeach | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="form-buttons"> | ||
<button type="submit" class="button"> | ||
<x-icon-label icon="fas fa-play" text="Save & Activate"/> | ||
</button> | ||
</div> | ||
</form> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Http/App/Controllers/Webhooks/WebhookEventLogController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Leeovery\MailcoachApi\Http\App\Controllers\Webhooks; | ||
|
||
use Leeovery\MailcoachApi\Models\Webhook; | ||
use Leeovery\MailcoachApi\Http\App\Queries\WebhookEventLogQuery; | ||
|
||
class WebhookEventLogController | ||
{ | ||
public function __invoke(Webhook $webhook) | ||
{ | ||
$webhookEventLogQuery = new WebhookEventLogQuery($webhook); | ||
|
||
return view('mailcoach-api::app.webhooks.events-log', [ | ||
'webhook' => $webhook, | ||
'eventLogs' => $webhookEventLogQuery->paginate(), | ||
'totalEventLogsCount' => $webhook->webhookEvents()->count(), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Leeovery\MailcoachApi\Http\App\Queries; | ||
|
||
use Spatie\QueryBuilder\QueryBuilder; | ||
use Leeovery\MailcoachApi\Models\Webhook; | ||
|
||
class WebhookEventLogQuery extends QueryBuilder | ||
{ | ||
public function __construct(Webhook $webhook) | ||
{ | ||
$query = $webhook->webhookEvents()->getQuery(); | ||
|
||
parent::__construct($query); | ||
|
||
$this | ||
->defaultSort('-created_at'); | ||
// ->allowedFilters( | ||
// AllowedFilter::custom('search', new FuzzyFilter('name')) | ||
// ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters