VersionChecker.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <script setup>
  2. import systemService from '@/services/systemService'
  3. import { useAppSettingsStore } from '@/stores/appSettings'
  4. const appSettings = useAppSettingsStore()
  5. const isScanning = ref(false)
  6. const isUpToDate = ref()
  7. async function getLatestRelease() {
  8. isScanning.value = true;
  9. isUpToDate.value = undefined
  10. await systemService.getLastRelease({returnError: true})
  11. .then(response => {
  12. appSettings.latestRelease = response.data.newRelease
  13. isUpToDate.value = response.data.newRelease === false
  14. })
  15. .catch(() => {
  16. isUpToDate.value = null
  17. })
  18. isScanning.value = false;
  19. }
  20. </script>
  21. <template>
  22. <div class="columns is-mobile is-vcentered">
  23. <div class="column is-narrow">
  24. <button type="button" :class="isScanning ? 'is-loading' : ''" class="button is-link is-rounded is-small" @click="getLatestRelease">Check now</button>
  25. </div>
  26. <div class="column">
  27. <span v-if="appSettings.latestRelease" class="mt-2 has-text-warning">
  28. <span class="release-flag"></span>{{ appSettings.latestRelease }} is available <a class="is-size-7" href="https://github.com/Bubka/2FAuth/releases">View on Github</a>
  29. </span>
  30. <span v-if="isUpToDate" class="has-text-grey">
  31. <FontAwesomeIcon :icon="['fas', 'check']" class="mr-1 has-text-success" /> {{ $t('commons.you_are_up_to_date') }}
  32. </span>
  33. <span v-else-if="isUpToDate === null" class="has-text-grey">
  34. <FontAwesomeIcon :icon="['fas', 'times']" class="mr-1 has-text-danger" />{{ $t('errors.check_failed_try_later') }}
  35. </span>
  36. </div>
  37. </div>
  38. </template>