Add last sync info

This commit is contained in:
ostertun
2020-10-06 00:21:23 +02:00
parent 01d0ae96f9
commit 3fd9beae1e
2 changed files with 29 additions and 28 deletions

View File

@@ -417,29 +417,31 @@ function dbSettingsSet(key, value) {
} }
} }
async function updateSyncStatus() { // TODO async function updateSyncStatus() {
// var syncStatus = document.getElementById('syncstatus'); var lastSync = await dbGetData('update_times', 'last_sync');
// var lastSync = await dbGetData('update_times', 'last_sync'); lastSync = new Date(lastSync.time * 1000);
// lastSync = new Date(lastSync.time * 1000); if (lastSync > 0) {
// var now = new Date(); var now = new Date();
// var diff = Math.round((now - lastSync) / 1000); var diff = Math.round((now - lastSync) / 1000);
// var txt = ''; var txt = '';
//
// if (diff < 30) { // 30 sec if (diff < 30) { // 30 sec
// txt = 'jetzt'; txt = 'jetzt';
// } else if (diff < 3600) { // 60 min } else if (diff < 3600) { // 60 min
// diff = Math.round(diff / 60); diff = Math.round(diff / 60);
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Minute' : 'Minuten'); txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Minute' : 'Minuten');
// } else if (diff < 86400) { // 24 std } else if (diff < 86400) { // 24 std
// diff = Math.round(diff / 3600); diff = Math.round(diff / 3600);
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Stunde' : 'Stunden'); txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Stunde' : 'Stunden');
// } else { } else {
// diff = Math.round(diff / 86400); diff = Math.round(diff / 86400);
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Tag' : 'Tagen'); txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Tag' : 'Tagen');
// } }
// } else {
// var btn = '<a href="#" onclick="setLoading(true); sync(); return false;"><i class="fas fa-sync"></i> Sync</a>'; var txt = 'nie';
// syncStatus.innerHTML = 'Zuletzt aktualisiert: ' + txt + btn; }
$('#syncstatus').html('Zuletzt aktualisiert: ' + txt);
} }
async function runPageScript() { async function runPageScript() {
@@ -460,16 +462,14 @@ async function runPageScript() {
dbSettingsSet('myregattas_' + BOATCLASS, plannings); dbSettingsSet('myregattas_' + BOATCLASS, plannings);
} }
} }
if (typeof updateSyncStatusTimer == 'undefined') { // TODO if (typeof updateSyncStatusTimer == 'undefined') {
// var syncStatus = document.getElementById('syncstatus');
if (canUseLocalDB) { if (canUseLocalDB) {
updateSyncStatusTimer = window.setInterval(updateSyncStatus, 10000); updateSyncStatusTimer = window.setInterval(updateSyncStatus, 10000);
} else { } else {
// syncStatus.innerHTML = 'Keine Offline-Nutzung möglich.'; $('#syncstatus').html('Keine Offline-Nutzung möglich.');
$('#i-sync').parent().hide(); $('#i-sync').parent().hide();
updateSyncStatusTimer = null; updateSyncStatusTimer = null;
} }
// syncStatus.style.display = 'block';
} }
if (typeof siteScript === 'function') { if (typeof siteScript === 'function') {

View File

@@ -27,7 +27,8 @@
<?php include(__DIR__ . '/headerfooter.php'); ?> <?php include(__DIR__ . '/headerfooter.php'); ?>
<!--start of page content, add your stuff here--> <!--start of page content, add your stuff here-->
<div class="page-content header-clear-medium"> <div class="page-content header-clear">
<div id="syncstatus" class="text-right mr-2 mb-1">Zuletzt aktualisiert: nie</div>
<?php echo $sp['output']; ?> <?php echo $sp['output']; ?>
</div> </div>
<!--end of page content, off canvas elements here--> <!--end of page content, off canvas elements here-->