Files
pulse-signage/src/web/views/data-sources/api-sources/list.hbs
T
2026-07-26 20:26:01 +01:00

83 lines
3.7 KiB
Handlebars

<div class="page-header">
<div>
<h2>API sources</h2>
<p>Store API endpoints, refresh cadence, and the latest JSON response pulled from each endpoint.</p>
</div>
</div>
<div class="card card-outline card-primary" data-table-search-container>
<div class="card-header">
<h3 class="card-title">Saved sources</h3>
<div class="card-tools d-flex flex-nowrap align-items-center gap-2">
<div class="input-group input-group-sm flex-shrink-1" style="width: min(14rem, 100%);">
<span class="input-group-text" aria-hidden="true"><i class="bi bi-search"></i></span>
<input type="search" class="form-control" placeholder="Search API sources" aria-label="Search API sources" data-table-search />
</div>
{{#if (hasPermission currentUser 'api-sources.create')}}
<a class="btn btn-primary btn-sm" href="/data-sources/api-sources/new">Add API source</a>
{{/if}}
</div>
</div>
<div class="card-body table-responsive p-0">
<table class="table table-striped w-100 mb-0" data-table-searchable>
<thead>
<tr>
<th data-table-sort-key="name">Name</th>
<th data-table-sort-key="url">API URL</th>
<th data-table-sort-key="interval">Refresh interval</th>
<th data-table-sort-key="last_pulled">Last pulled</th>
<th data-table-sort-key="last_response">Last response</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#if apiSources.length}}
{{#each apiSources}}
<tr data-table-search-row>
<td data-label="Name">{{name}}</td>
<td data-label="API URL" class="text-break">{{api_url}}</td>
<td data-label="Refresh interval">{{intervalLabel}}</td>
<td data-label="Last pulled">
{{#if lastPulledAtValue}}
<time data-local-datetime datetime="{{lastPulledAtValue}}">{{lastPullLabel}}</time>
{{else}}
{{lastPullLabel}}
{{/if}}
</td>
<td data-label="Last response">
{{#if last_pull_error}}
<span class="text-danger">Failed</span>
{{else if last_response_status}}
<span>{{last_response_status}}</span>
{{#if last_response_content_type}}<span class="text-muted small ms-2">{{last_response_content_type}}</span>{{/if}}
{{else}}
<span class="empty">-</span>
{{/if}}
</td>
<td data-label="Actions">
{{#if (anyPermission ../currentUser 'api-sources.update' 'api-sources.delete')}}
<div class="actions">
{{#if (hasPermission ../currentUser 'api-sources.update')}}
<a class="btn btn-sm btn-primary" href="/data-sources/api-sources/{{id}}/edit">Edit</a>
{{/if}}
{{#if (hasPermission ../currentUser 'api-sources.delete')}}
<form class="inline-form" method="post" action="/data-sources/api-sources/{{id}}/delete" data-confirm-message="Delete this API source?">
<button class="btn btn-sm btn-danger" type="submit">Delete</button>
</form>
{{/if}}
</div>
{{else}}
<span class="empty">-</span>
{{/if}}
</td>
</tr>
{{/each}}
{{else}}
<tr data-table-search-empty-default><td colspan="6" class="empty">No API sources yet.</td></tr>
{{/if}}
</tbody>
</table>
</div>
{{> table-pagination pagination=pagination basePath="/data-sources/api-sources"}}
</div>