ultimatepos/Modules/IntegrationHub/Resources/views/webhooks/index.blade.php

89 lines
4.4 KiB
PHP

@extends('layouts.app')
@section('title', __('integrationhub::lang.webhooks'))
@section('content')
@include('integrationhub::layouts.nav')
<section class="content no-print mt-page">
<div class="mt-page-header">
<h1><i class="fas fa-broadcast-tower" style="color:#8b5cf6;margin-left:8px;"></i> @lang('integrationhub::lang.webhooks')</h1>
<a href="{{ action([\Modules\IntegrationHub\Http\Controllers\WebhookController::class, 'create']) }}" class="mt-btn-primary btn">
<i class="fa fa-plus"></i> @lang('integrationhub::lang.add')
</a>
</div>
<div class="mt-card">
<div class="mt-card-body">
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>@lang('integrationhub::lang.name')</th>
<th>@lang('integrationhub::lang.url')</th>
<th>@lang('integrationhub::lang.events')</th>
<th>@lang('integrationhub::lang.is_active')</th>
<th>@lang('integrationhub::lang.delivered_at')</th>
<th>@lang('integrationhub::lang.action')</th>
</tr>
</thead>
<tbody>
@forelse($endpoints as $endpoint)
<tr>
<td>{{ $endpoint->name }}</td>
<td><small>{{ \Illuminate\Support\Str::limit($endpoint->url, 60) }}</small></td>
<td>
@foreach($endpoint->events ?? [] as $event)
<span class="label label-default">{{ \Modules\IntegrationHub\Utils\IntegrationHubUtil::eventLabel($event) }}</span>
@endforeach
</td>
<td>
@if($endpoint->is_active)
<span class="label label-success">@lang('integrationhub::lang.yes')</span>
@else
<span class="label label-default">@lang('integrationhub::lang.no')</span>
@endif
</td>
<td>@if($endpoint->last_triggered_at) @format_datetime($endpoint->last_triggered_at) @else @endif</td>
<td>
<a href="{{ action([\Modules\IntegrationHub\Http\Controllers\WebhookController::class, 'edit'], $endpoint->id) }}" class="btn btn-xs btn-primary">
<i class="fa fa-edit"></i>
</a>
<button type="button" class="btn btn-xs btn-info ih-test-webhook" data-href="{{ action([\Modules\IntegrationHub\Http\Controllers\WebhookController::class, 'test'], $endpoint->id) }}">
<i class="fa fa-paper-plane"></i>
</button>
{!! Form::open(['url' => action([\Modules\IntegrationHub\Http\Controllers\WebhookController::class, 'destroy'], $endpoint->id), 'method' => 'delete', 'style' => 'display:inline']) !!}
<button type="submit" class="btn btn-xs btn-danger" onclick="return confirm(LANG.sure)"><i class="fa fa-trash"></i></button>
{!! Form::close() !!}
</td>
</tr>
@empty
<tr><td colspan="6" class="text-center text-muted">@lang('integrationhub::lang.no_records')</td></tr>
@endforelse
</tbody>
</table>
</div>
{{ $endpoints->links() }}
</div>
</div>
</section>
@endsection
@section('javascript')
<script>
$(function() {
$(document).on('click', '.ih-test-webhook', function() {
var url = $(this).data('href');
var btn = $(this);
btn.prop('disabled', true);
$.post(url, { _token: '{{ csrf_token() }}' })
.done(function(r) {
if (r.success) { toastr.success(r.msg); } else { toastr.error(r.msg); }
})
.fail(function() { toastr.error(LANG.something_went_wrong); })
.always(function() { btn.prop('disabled', false); });
});
});
</script>
@endsection