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

86 lines
4.7 KiB
PHP

@extends('layouts.app')
@section('title', __('integrationhub::lang.edit') . ' — ' . __('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-edit" style="color:#8b5cf6;margin-left:8px;"></i> @lang('integrationhub::lang.edit'): {{ $endpoint->name }}</h1>
<a href="{{ action([\Modules\IntegrationHub\Http\Controllers\WebhookController::class, 'index']) }}" class="btn btn-default">
<i class="fa fa-arrow-right"></i> @lang('integrationhub::lang.cancel')
</a>
</div>
<div class="row">
<div class="col-md-7">
<div class="mt-card">
<div class="mt-card-header"><h3 class="mt-card-title">@lang('integrationhub::lang.endpoint')</h3></div>
<div class="mt-card-body">
{!! Form::open(['url' => action([\Modules\IntegrationHub\Http\Controllers\WebhookController::class, 'update'], $endpoint->id), 'method' => 'put']) !!}
<div class="form-group">
{!! Form::label('name', __('integrationhub::lang.name') . ':') !!}
{!! Form::text('name', $endpoint->name, ['class' => 'form-control', 'required']) !!}
</div>
<div class="form-group">
{!! Form::label('url', __('integrationhub::lang.url') . ':') !!}
{!! Form::url('url', $endpoint->url, ['class' => 'form-control', 'required']) !!}
</div>
<div class="form-group">
{!! Form::label('secret', __('integrationhub::lang.secret') . ':') !!}
{!! Form::text('secret', $endpoint->secret, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('events', __('integrationhub::lang.events') . ':') !!}
{!! Form::select('events[]', $events, $endpoint->events ?? [], ['class' => 'form-control select2', 'multiple' => true, 'style' => 'width:100%']) !!}
</div>
<div class="checkbox">
<label>{!! Form::checkbox('is_active', 1, $endpoint->is_active, ['class' => 'input-icheck']) !!} @lang('integrationhub::lang.is_active')</label>
</div>
<button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> @lang('integrationhub::lang.save')</button>
{!! Form::close() !!}
</div>
</div>
</div>
<div class="col-md-5">
<div class="mt-card">
<div class="mt-card-header"><h3 class="mt-card-title">@lang('integrationhub::lang.recent_deliveries')</h3></div>
<div class="mt-card-body" style="max-height:400px;overflow-y:auto;">
@forelse($deliveries as $delivery)
<div style="margin-bottom:12px;padding-bottom:10px;border-bottom:1px solid #eef2f7;">
<strong>{{ \Modules\IntegrationHub\Utils\IntegrationHubUtil::eventLabel($delivery->event_name) }}</strong>
<span class="label label-{{ $delivery->status === 'delivered' ? 'success' : 'danger' }} pull-left">{{ \Modules\IntegrationHub\Utils\IntegrationHubUtil::statusLabel($delivery->status) }}</span>
<br>
<small class="text-muted">
HTTP {{ $delivery->response_code ?? '—' }}
@if($delivery->delivered_at) · @format_datetime($delivery->delivered_at) @endif
</small>
</div>
@empty
<p class="text-muted">@lang('integrationhub::lang.no_records')</p>
@endforelse
</div>
</div>
<button type="button" class="btn btn-info btn-block ih-test-webhook" data-href="{{ action([\Modules\IntegrationHub\Http\Controllers\WebhookController::class, 'test'], $endpoint->id) }}">
<i class="fa fa-paper-plane"></i> @lang('integrationhub::lang.test_webhook')
</button>
</div>
</div>
</section>
@endsection
@section('javascript')
<script>
$(function(){
$('.select2').select2();
$(document).on('click', '.ih-test-webhook', function() {
var url = $(this).data('href');
$.post(url, { _token: '{{ csrf_token() }}' }).done(function(r) {
if (r.success) { toastr.success(r.msg); } else { toastr.error(r.msg); }
});
});
});
</script>
@endsection