2 import PageLink from './PageLink.svelte';
3 import * as timeago from 'timeago.js';
4 import { last_api_request_url_store } from '../lib/stores.js';
5 import { fetch_from_api } from '../lib/api_utils.js';
8 let last_api_request_url;
9 let fetch_running = false; // prevent multiple parallel fetch runs
11 last_api_request_url_store.subscribe(url => {
12 if (fetch_running || last_updated_date) return;
16 last_api_request_url = url;
17 fetch_from_api('status', { format: 'json' }, function (data) {
18 last_updated_date = data.data_updated;
19 fetch_running = false;
37 background-color: #eee;
42 <div id="last-updated" class="container-fluid py-2 px-4 mb-3">
43 <div id="loading" class="py-2 px-4">
44 <div class="spinner-border spinner-border-sm text-primary mr-1" role="status"></div>
45 Loading data from API ...
48 <div class="col-sm-6">
49 {#if last_api_request_url}
50 <div id="api-request">
51 Data from <a href="{last_api_request_url}">API request</a>
52 <span id="api-request-debug">
53 (<a href="{last_api_request_url}&debug=1">debug output</a>)
58 <div class="col-sm-6 text-right">
59 {#if last_updated_date}
61 <abbr id="data-date" title="{last_updated_date} (UTC timezone)">{timeago.format(new Date(last_updated_date))}</abbr>
63 (<PageLink page="status">Details</PageLink>)