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 last_api_request_url = url;
14 if (fetch_running || last_updated_date) return;
18 fetch_from_api('status', { format: 'json' }, function (data) {
19 last_updated_date = data.data_updated;
20 fetch_running = false;
38 background-color: #eee;
43 <div id="last-updated" class="container-fluid py-2 px-4 mb-3">
44 <div id="loading" class="py-2 px-4">
45 <div class="spinner-border spinner-border-sm text-primary mr-1" role="status"></div>
46 Loading data from API ...
49 <div class="col-sm-6">
50 {#if last_api_request_url}
51 <div id="api-request">
52 Data from <a href="{last_api_request_url}">API request</a>
53 <span id="api-request-debug">
54 (<a href="{last_api_request_url}&debug=1">debug output</a>)
59 <div class="col-sm-6 text-right">
60 {#if last_updated_date}
62 <abbr id="data-date" title="{last_updated_date} (UTC timezone)">{timeago.format(new Date(last_updated_date))}</abbr>
64 (<PageLink page="status">Details</PageLink>)