Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

🚸 UI shows appropriate messaging when token expired

Alicia Sykeseadd60c9d5e9
diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json
index 4f607886..1ce2fad0 100644
--- a/src/assets/locales/en.json
+++ b/src/assets/locales/en.json
@@ -7,7 +7,10 @@
"home": {
"no-results": "No Search Results",
"no-data": "No Data Configured",
- "no-items-section": "No Items to Show Yet"
+ "no-items-section": "No Items to Show Yet",
+ "session-expired-line1": "Your session has expired",
+ "session-expired-line2": "Re-authenticate to access your dashboard",
+ "sign-in-again": "Sign In Again"
},
"search": {
"search-label": "Search",
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 7e8099e7..361020d9 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -39,7 +39,14 @@
</div>
<!-- Show message when there's no data to show -->
<div v-if="checkIfResults(filteredSections) && !isEditMode" class="no-data">
- {{searchValue ? $t('home.no-results') : $t('home.no-data')}}
+ <template v-if="isBootstrap">
+ {{ $t('home.session-expired-line1') }}
+ <p class="hint">{{ $t('home.session-expired-line2') }}</p>
+ <Button :click="reAuth">{{ $t('home.sign-in-again') }}</Button>
+ </template>
+ <template v-else>
+ {{ searchValue ? $t('home.no-results') : $t('home.no-data') }}
+ </template>
</div>
<!-- Show banner at bottom of screen, for Saving config changes -->
<EditModeSaveMenu v-if="isEditMode" />
@@ -54,6 +61,7 @@ import HomeMixin from '@/mixins/HomeMixin';
import SettingsContainer from '@/components/Settings/SettingsContainer.vue';
import Section from '@/components/LinkItems/Section.vue';
import NotificationThing from '@/components/Settings/LocalConfigWarning.vue';
+import Button from '@/components/FormElements/Button';
import {
makePageName, makeRoutePath, resolveRouteIntent, viewFromPath,
} from '@/utils/config/ConfigHelpers';
@@ -73,6 +81,7 @@ export default {
NotificationThing,
Section,
BackIcon,
+ Button,
},
data: () => ({
layout: '',
@@ -123,8 +132,16 @@ export default {
if (this.colCount) classes += ` col-count-${this.colCount}`;
return classes;
},
+ /* True if the server served a stripped bootstrap config (e.g. expired token) */
+ isBootstrap() {
+ return this.$store.state.rootConfig?._bootstrap?.authenticated === false;
+ },
},
methods: {
+ /* Reload to restart the auth flow (OIDC will see the bootstrap marker and redirect) */
+ reAuth() {
+ window.location.reload();
+ },
/* Clears input field, once a searched item is opened */
finishedSearching() {
if (this.$refs.filterComp) this.$refs.filterComp.clearFilterInput();
@@ -277,13 +294,20 @@ export default {
/* Custom styles only applied when there is no sections in config */
.no-data {
- font-size: 2rem;
- color: var(--background);
- background: #ffffffeb;
+ background: var(--background-darker);
+ color: var(--primary);
width: fit-content;
margin: 2rem auto;
padding: 0.5rem 1rem;
border-radius: var(--curve-factor);
+ border: 1px solid var(--primary);
+ font-size: 1.8rem;
+ text-align: center;
+ .hint {
+ margin: 0.25rem auto;
+ font-size: 1rem;
+ opacity: 0.8;
+ }
}
/* Settings section, includes search, config and user settings */
diff --git a/src/views/Minimal.vue b/src/views/Minimal.vue
index 5ce0d07d..969b1ff9 100644
--- a/src/views/Minimal.vue
+++ b/src/views/Minimal.vue
@@ -56,7 +56,14 @@
{{searchValue ? $t('home.no-results') : $t('home.no-data')}}
</div>
</div>
- <div v-else class="no-data"> {{ $t('home.no-data') }} </div>
+ <div v-else class="no-data">
+ <template v-if="isBootstrap">
+ {{ $t('home.session-expired-line1') }}
+ <p class="hint">{{ $t('home.session-expired-line2') }}</p>
+ <Button :click="reAuth">{{ $t('home.sign-in-again') }}</Button>
+ </template>
+ <template v-else>{{ $t('home.no-data') }}</template>
+ </div>
</div>
<!-- Interactive editor save options bottom banner -->
<EditModeSaveMenu v-if="isEditMode" />
@@ -69,6 +76,7 @@ import MinimalHeading from '@/components/MinimalView/MinimalHeading.vue';
import MinimalSearch from '@/components/MinimalView/MinimalSearch.vue';
import ConfigLauncher from '@/components/Settings/ConfigLauncher';
import EditModeSaveMenu from '@/components/InteractiveEditor/EditModeSaveMenu.vue';
+import Button from '@/components/FormElements/Button';
import { makePageName, resolveRouteIntent } from '@/utils/config/ConfigHelpers';
import ErrorHandler from '@/utils/logging/ErrorHandler';
@@ -81,6 +89,7 @@ export default {
MinimalSearch,
ConfigLauncher,
EditModeSaveMenu,
+ Button,
},
data: () => ({
layout: '',
@@ -102,7 +111,17 @@ export default {
},
sections() { this.syncSelectedFromRoute(); },
},
+ computed: {
+ /* True if the server served a stripped bootstrap config (e.g. expired token) */
+ isBootstrap() {
+ return this.$store.state.rootConfig?._bootstrap?.authenticated === false;
+ },
+ },
methods: {
+ /* Reload to restart the auth flow (OIDC will see the bootstrap marker and redirect) */
+ reAuth() {
+ window.location.reload();
+ },
sectionSelected(index) {
this.selectedSection = index;
},