Added webhook support and webhook display
This commit is contained in:
1 parent
89d246f3f6
commit
88d9188055
13 files changed
+551
-26
No files matched your search
@@ -18,6 +18,7 @@
|
||||
<section class="container">
|
||||
<a class="selected" href="#">Search</a>
|
||||
<a href="/admin/countries">Countries</a>
|
||||
<a href="/admin/webhooks">Webhooks</a>
|
||||
<button data-type="dialog" data-trigger="#create-card" data-url="/admin/dialogs/add-holiday">Add new holiday</button>
|
||||
</section>
|
||||
</nav>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<section class="container">
|
||||
<a href="/admin">Search</a>
|
||||
<a class="selected" href="#">Countries</a>
|
||||
<a href="/admin/webhooks">Webhooks</a>
|
||||
<button data-type="dialog" data-trigger="#create-card" data-url="/admin/dialogs/add-holiday">Add new holiday</button>
|
||||
</section>
|
||||
</nav>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<dialog class="card" id="create-card">
|
||||
<h3 class="card-title">Create webhook</h3>
|
||||
<form method="post" action="/admin/webhooks">
|
||||
<section>
|
||||
<label for="url">Url:</label>
|
||||
<input required id="url" name="url" type="url">
|
||||
</section>
|
||||
<section>
|
||||
<label for="country">Country:</label>
|
||||
<select id="country" required name="country">
|
||||
{{range $entry := .Countries}}
|
||||
<option value="{{$entry.IsoName}}">{{$entry.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</section>
|
||||
<section>
|
||||
<label for="retry_count">Retry count:</label>
|
||||
<input required id="retry_count" name="retry_count" type="number" min="0" max="10">
|
||||
</section>
|
||||
<section>
|
||||
<label class="checkbox"><span>On created</span><input id="on_created" value="true" name="on_created" type="checkbox"></label>
|
||||
</section>
|
||||
<section>
|
||||
<label class="checkbox"><span>On edited</span><input id="on_edited" value="true" name="on_edited" type="checkbox"></label>
|
||||
</section>
|
||||
<section>
|
||||
<label class="checkbox"><span>On deleted</span><input id="on_deleted" value="true" name="on_deleted" type="checkbox"></label>
|
||||
</section>
|
||||
|
||||
<section class="actions">
|
||||
<button type="submit">Create</button>
|
||||
<button type="button" onclick="closeDialog('#create-card')">Cancel</button>
|
||||
</section>
|
||||
</form>
|
||||
</dialog>
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
<dialog class="card" id="delete-card">
|
||||
<h3 class="card-title">Delete webhook</h3>
|
||||
<p>Are you sure you want to delete webhook to <br><b>{{.Webhook.Url}}?</b><br>All jobs for given webhook will be deleted!</p>
|
||||
<form method="post" action="/admin/webhooks/{{.Webhook.Id}}/delete">
|
||||
<section class="actions">
|
||||
<button type="submit">Delete</button>
|
||||
<button type="button" onclick="closeDialog('#delete-card')">Cancel</button>
|
||||
</section>
|
||||
</form>
|
||||
</dialog>
|
||||
@@ -0,0 +1,36 @@
|
||||
<dialog class="card" id="update-card">
|
||||
<h3 class="card-title">Edit webhook</h3>
|
||||
<form method="post" action="/admin/webhooks">
|
||||
<input type="hidden" id="id" name="id" value="{{.Webhook.Id}}">
|
||||
<section>
|
||||
<label for="url">Url:</label>
|
||||
<input required id="url" name="url" type="url" value="{{.Webhook.Url}}">
|
||||
</section>
|
||||
<section>
|
||||
<label for="country">Country:</label>
|
||||
<select id="country" required name="country">
|
||||
{{range $entry := .Countries}}
|
||||
<option {{if eq $.Webhook.Country $entry.IsoName}}selected{{end}} value="{{$entry.IsoName}}">{{$entry.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</section>
|
||||
<section>
|
||||
<label for="retry_count">Retry count:</label>
|
||||
<input required id="retry_count" name="retry_count" type="number" min="0" max="10" value="{{.Webhook.RetryCount}}">
|
||||
</section>
|
||||
<section>
|
||||
<label class="checkbox"><span>On created</span><input id="on_created" value="true" name="on_created" type="checkbox" {{if .Webhook.OnCreated}}checked{{end}}></label>
|
||||
</section>
|
||||
<section>
|
||||
<label class="checkbox"><span>On edited</span><input id="on_edited" value="true" name="on_edited" type="checkbox" {{if .Webhook.OnEdited}}checked{{end}}></label>
|
||||
</section>
|
||||
<section>
|
||||
<label class="checkbox"><span>On deleted</span><input id="on_deleted" value="true" name="on_deleted" type="checkbox" {{if .Webhook.OnDeleted}}checked{{end}}></label>
|
||||
</section>
|
||||
|
||||
<section class="actions">
|
||||
<button type="submit">Update</button>
|
||||
<button type="button" onclick="closeDialog('#update-card')">Cancel</button>
|
||||
</section>
|
||||
</form>
|
||||
</dialog>
|
||||
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Holiday-api | Admin dashboard</title>
|
||||
<link rel="stylesheet" href="/assets/style.css">
|
||||
<script src="/assets/global.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="dialog-container"></div>
|
||||
<header>
|
||||
<section class="container">
|
||||
<h1><a href="/">Holiday-api | Webhooks</a></h1>
|
||||
</section>
|
||||
</header>
|
||||
<nav>
|
||||
<section class="container">
|
||||
<a href="/admin">Search</a>
|
||||
<a href="/admin/countries">Countries</a>
|
||||
<a class="selected" href="#">Webhooks</a>
|
||||
<button data-type="dialog" data-trigger="#create-card" data-url="/admin/dialogs/add-holiday">Add new holiday</button>
|
||||
</section>
|
||||
</nav>
|
||||
<main>
|
||||
<section style="margin: 1em; flex-grow: 1">
|
||||
|
||||
<button data-type="dialog" data-trigger="#create-card" data-url="/admin/dialogs/add-webhook" style="margin-bottom: 1em; float: right">Create webhook</button>
|
||||
|
||||
<table style="width: 100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Country</th>
|
||||
<th>Url</th>
|
||||
<th>Retry count</th>
|
||||
<th>On create</th>
|
||||
<th>On update</th>
|
||||
<th>On delete</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{range $entry := .Webhooks}}
|
||||
<tr>
|
||||
<td>{{$entry.Country}}</td>
|
||||
<td>{{$entry.Url}}</td>
|
||||
<td>{{$entry.RetryCount}}</td>
|
||||
<td><img class="icon" src="{{if $entry.OnCreated}}/assets/images/done-v.svg{{else}}/assets/images/close-x.svg{{end}}"></td>
|
||||
<td><img class="icon" src="{{if $entry.OnEdited}}/assets/images/done-v.svg{{else}}/assets/images/close-x.svg{{end}}"></td>
|
||||
<td><img class="icon" src="{{if $entry.OnDeleted}}/assets/images/done-v.svg{{else}}/assets/images/close-x.svg{{end}}"></td>
|
||||
<td>
|
||||
<button type="button" data-type="dialog" data-trigger="#update-card" data-url="/admin/dialogs/edit-webhook?id={{$entry.Id}}" class="clean icon"><img class="icon" src="/assets/images/edit.svg"></button>
|
||||
<button type="button" data-type="dialog" data-trigger="#delete-card" data-url="/admin/dialogs/delete-webhook?id={{$entry.Id}}" class="clean icon"><img class="icon" src="/assets/images/trash-delete.svg"></button>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user