Skip to content
Snippets Groups Projects
Select Git revision
  • aa275fc4792ca811bc736b50dc19cfaa39702922
  • master default protected
  • djmdev
  • dev
  • cloud_water_contents
  • 1-download-era5
  • sysinstall
  • origin/task/language-editing
  • task/language-editing
  • feature/makefiles
  • v7.1.2
  • v7.1.1
  • v7.1
  • v7.0.4.1
  • 7.0.4
15 results

CONTROL_OD

Blame
  • TimeDrift.vue 909 B
    <template>
      <v-alert
        v-cloak
        v-if="timestamp && offSeconds > 3"
        class="banner"
        border="start"
        tile
        type="warning">
        {{ $t('error.data.drift') + ' ' + offSeconds + 's' }}
      </v-alert>
    </template>
    
    <script>
    import { formatTimestamp, timestampsToHumanDifference } from '@/utils'
    
    export default {
      data () {
        return {
          timestamp: null
        }
      },
      computed: {
        drift () {
          return this.timestampsToHumanDifference(Date.now(), this.timestamp)
        },
        offSeconds () {
          if (!this.timestamp) {
            return null
          }
          return (Date.now().valueOf() - Date.parse(this.timestamp)) / 1000
        }
      },
      mounted() {
        const databaseService = useDatabaseService()
        databaseService.getServerTime()
          .then((timestamp) => {
            this.timestamp = timestamp
          })
      },
      methods: {
        formatTimestamp,
        timestampsToHumanDifference
      }
    }
    </script>