Sfoglia il codice sorgente

Show error message instead of pushing to Error view

Bubka 1 anno fa
parent
commit
0451888b84

+ 10 - 3
resources/js_vue3/components/VersionChecker.vue

@@ -4,16 +4,20 @@
 
     const appSettings = useAppSettingsStore()
     const isScanning = ref(false)
-    const isUpToDate = ref(null)
+    const isUpToDate = ref()
 
     async function getLatestRelease() {
         isScanning.value = true;
+        isUpToDate.value = undefined
 
-        await systemService.getLastRelease()
+        await systemService.getLastRelease({returnError: true})
         .then(response => {
             appSettings.latestRelease = response.data.newRelease
             isUpToDate.value = response.data.newRelease === false
         })
+        .catch(() => {
+            isUpToDate.value = null
+        })
 
         isScanning.value = false;
     }
@@ -30,7 +34,10 @@
                 <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>
             </span>
             <span v-if="isUpToDate" class="has-text-grey">
-                {{ $t('commons.you_are_up_to_date') }}
+                <FontAwesomeIcon :icon="['fas', 'check']" class="mr-1 has-text-success" /> {{ $t('commons.you_are_up_to_date') }}
+            </span>
+            <span v-else-if="isUpToDate === null" class="has-text-grey">
+                <FontAwesomeIcon :icon="['fas', 'times']" class="mr-1 has-text-danger" />{{ $t('errors.check_failed_try_later') }}
             </span>
         </div>
     </div>

+ 4 - 4
resources/js_vue3/services/systemService.js

@@ -7,16 +7,16 @@ export default {
      * 
      * @returns Promise
      */
-    getSystemInfos() {
-        return webClient.get('infos')
+    getSystemInfos(config = {}) {
+        return webClient.get('infos', { ...config })
     },
 
     /**
      * 
      * @returns Promise
      */
-    getLastRelease() {
-        return webClient.get('latestRelease')
+    getLastRelease(config = {}) {
+        return webClient.get('latestRelease', { ...config })
     }
     
 }

+ 8 - 2
resources/js_vue3/views/About.vue

@@ -17,7 +17,7 @@
     const listAdminSettings = ref(null)
 
     onMounted(() => {
-        systemService.getSystemInfos().then(response => {
+        systemService.getSystemInfos({returnError: true}).then(response => {
             infos.value = response.data.common
 
             if (response.data.admin_settings) {
@@ -28,6 +28,9 @@
                 userPreferences.value = response.data.user_preferences
             }
         })
+        .catch(() => {
+            infos.value = null
+        })
     })
 
     function copyToClipboard(data) {
@@ -94,7 +97,7 @@
         <h2 class="title is-5 has-text-grey-light">
             {{ $t('commons.environment') }}
         </h2>
-        <div class="about-debug box is-family-monospace is-size-7">
+        <div v-if="infos" class="about-debug box is-family-monospace is-size-7">
             <button id="btnCopyEnvVars" :aria-label="$t('commons.copy_to_clipboard')" class="button is-like-text is-pulled-right is-small is-text" @click.stop="copyToClipboard(listInfos.innerText)">
                 <FontAwesomeIcon :icon="['fas', 'copy']" />
             </button>
@@ -102,6 +105,9 @@
                 <li v-for="(value, key) in infos" :value="value" :key="key"><b>{{key}}</b>: {{value}}</li>
             </ul>
         </div>
+        <div v-else-if="infos === null" class="about-debug box is-family-monospace is-size-7 has-text-warning-dark">
+            {{ $t('errors.error_during_data_fetching') }}
+        </div>
         <h2 v-if="adminSettings" class="title is-5 has-text-grey-light">
             {{ $t('settings.admin_settings') }}
         </h2>

+ 3 - 1
resources/lang/en/errors.php

@@ -56,5 +56,7 @@ return [
     'file_upload_failed' => 'File upload failed',
     'unauthorized' => 'Unauthorized',
     'unauthorized_legend' => 'You do not have permissions to view this resource or to perform this action',
-    'cannot_delete_the_only_admin' => 'Cannot delete the only admin account'
+    'cannot_delete_the_only_admin' => 'Cannot delete the only admin account',
+    'error_during_data_fetching' => '💀 Something went wrong during data fetching',
+    'check_failed_try_later' => 'Check failed, please retry later',
 ];