Skip to content

Commit e0d9365

Browse files
authored
🔀 Merge pull request #238 from Lissy93/FEATURE/improved-loading
[FEATURE] Improved Loading
2 parents cf5f723 + 3a301af commit e0d9365

File tree

10 files changed

+73
-19
lines changed

10 files changed

+73
-19
lines changed

.github/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## ⚡️ 1.8.3 - Improved UX for Initial Load [PR #238](https://github.com/Lissy93/dashy/pull/238)
4+
- Removes the old splash screen
5+
- Adds placeholder in the HTML index, which will usually be visible on initial load
6+
- Show progress bar on route switcher
7+
38
## ✨ 1.8.2 - Serverless Functions for Netlify Instances [PR #235](https://github.com/Lissy93/dashy/pull/235)
49
- Previously when Dashy was deployed as a static site to Netlify, it was not possible to use several features, which required server-side code
510
- This PR adds serverless cloud functions to provide most of this functionality

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Dashy",
3-
"version": "1.8.2",
3+
"version": "1.8.3",
44
"license": "MIT",
55
"main": "server",
66
"scripts": {

public/index.html

+41-8
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,60 @@
11
<!DOCTYPE html>
2-
<!-- Do not modify this file directly -->
3-
42
<html lang="en">
5-
63
<head>
4+
<!-- Encoding and Viewport -->
75
<meta charset="utf-8">
86
<meta http-equiv="X-UA-Compatible" content="IE=edge">
97
<meta name="viewport" content="width=device-width,initial-scale=1.0">
8+
<!-- Favicon + App Icon -->
109
<link rel="icon" type="image/png" sizes="64x64" href="<%= BASE_URL %>/web-icons/favicon-64x64.png">
1110
<link rel="icon" type="image/png" sizes="32x32" href="web-icons/favicon-32x32.png">
1211
<link rel="icon" href="/favicon.ico" />
1312
<link rel="icon" type="image/png" href="<%= BASE_URL %>favicon.ico" />
13+
<!-- Default Page Title -->
1414
<title>Dashy</title>
1515
</head>
1616

1717
<body>
18+
<!-- built files will be auto injected -->
19+
<div id="app">
20+
<!-- Loading screen, will be replaced when app loaded -->
21+
<div class="loading-placeholder" id="loader"><h1>Dashy</h1><p>Loading...</p></div>
22+
</div>
1823
<!-- Devices without JS enabled -->
1924
<noscript>
20-
<strong>Sorry, JavaScript is required to run this app 😥</strong>
25+
<strong>Sorry, JavaScript needs to be enabled to run Dashy 😥</strong>
2126
</noscript>
22-
23-
<!-- built files will be auto injected -->
24-
<div id="app"></div>
27+
<!-- Styles for loading screen -->
28+
<style type="text/css">
29+
body { margin: 0; }
30+
#app .loading-placeholder {
31+
position: absolute;
32+
margin: 0;
33+
padding: 0;
34+
width: 100%;
35+
height: 100%;
36+
display: flex;
37+
flex-direction: column;
38+
justify-content: center;
39+
align-items: center;
40+
cursor: progress;
41+
background: #121212;
42+
}
43+
#app .loading-placeholder h1 {
44+
font-size: 20vh;
45+
font-family: Tahoma, monospace;
46+
cursor: progress;
47+
color: #0c0c0c;
48+
text-shadow: 0px 4px 4px #090909, 0 0 0 #000, 0px 2px 2px #000000;
49+
}
50+
#app .loading-placeholder p {
51+
font-size: 2rem;
52+
font-family: monospace;
53+
cursor: progress;
54+
color: #0c0c0c;
55+
text-shadow: 0 1px 1px #090909, 0 0 0 #000, 0 1px 1px #000000;
56+
}
57+
::selection { background-color: #db78fc; color: #121212; }
58+
</style>
2559
</body>
26-
2760
</html>

src/App.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ export default {
5353
},
5454
/* Determine if splash screen should be shown */
5555
shouldShowSplash() {
56-
return (this.visibleComponents || defaultVisibleComponents).splashScreen
57-
|| !localStorage[localStorageKeys.HIDE_WELCOME_BANNER];
56+
return (this.visibleComponents || defaultVisibleComponents).splashScreen;
5857
},
5958
},
6059
methods: {
@@ -107,6 +106,10 @@ export default {
107106
this.$i18n.locale = language;
108107
document.getElementsByTagName('html')[0].setAttribute('lang', language);
109108
},
109+
hideLoader() {
110+
const loader = document.getElementById('loader');
111+
if (loader) loader.style.display = 'none';
112+
},
110113
},
111114
/* When component mounted, hide splash and initiate the injection of custom styles */
112115
mounted() {
@@ -115,6 +118,7 @@ export default {
115118
if (this.appConfig.customCss) {
116119
const cleanedCss = this.appConfig.customCss.replace(/<\/?[^>]+(>|$)/g, '');
117120
this.injectCustomStyles(cleanedCss);
121+
this.hideLoader();
118122
}
119123
welcomeMsg();
120124
},

src/components/Configuration/CloudBackupRestore.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import IconBackup from '@/assets/interface-icons/config-backup.svg';
6666
import IconRestore from '@/assets/interface-icons/config-restore.svg';
6767
import { backup, update, restore } from '@/utils/CloudBackup';
6868
import { localStorageKeys } from '@/utils/defaults';
69-
import ErrorHandler, { InfoHandler } from '@/utils/ErrorHandler';
69+
import { InfoHandler, WarningInfoHandler } from '@/utils/ErrorHandler';
7070
7171
export default {
7272
name: 'CloudBackupRestore',
@@ -161,7 +161,7 @@ export default {
161161
this.backupPassword = '';
162162
},
163163
showErrorMsg(errorMsg) {
164-
ErrorHandler(errorMsg);
164+
WarningInfoHandler(errorMsg, 'Cloud Backup');
165165
this.$toasted.show(errorMsg, { className: 'toast-error' });
166166
},
167167
showSuccessMsg(msg) {

src/router.js

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// Import Vue.js and vue router
88
import Vue from 'vue';
99
import Router from 'vue-router';
10+
import ProgressBar from 'rsup-progress';
1011

1112
// Import views
1213
import Home from '@/views/Home.vue';
@@ -21,6 +22,7 @@ import { config } from '@/utils/ConfigHelpers';
2122
import { metaTagData, startingView, routePaths } from '@/utils/defaults';
2223

2324
Vue.use(Router);
25+
const progress = new ProgressBar({ color: 'var(--progress-bar)' });
2426

2527
/* Returns true if user is already authenticated, or if auth is not enabled */
2628
const isAuthenticated = () => {
@@ -119,12 +121,14 @@ const router = new Router({
119121
* If not logged in, prevent all access and redirect them to login page
120122
* */
121123
router.beforeEach((to, from, next) => {
124+
progress.start();
122125
if (to.name !== 'login' && !isAuthenticated()) next({ name: 'login' });
123126
else next();
124127
});
125128

126129
/* If title is missing, then apply default page title */
127130
router.afterEach((to) => {
131+
progress.end();
128132
Vue.nextTick(() => {
129133
document.title = to.meta.title || 'Dashy';
130134
});

src/utils/CoolConsole.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const statusMsg = (title, msg) => {
2828
/* Prints status message, with a stack trace */
2929
export const statusErrorMsg = (title, msg, errorLog) => {
3030
console.log(
31-
`%c${title || ''}\n%c${msg} \n%c${errorLog}`,
31+
`%c${title || ''}\n%c${msg} \n%c${errorLog || ''}`,
3232
'font-weight: bold; color: #0dd8d8; text-decoration: underline;',
3333
'color: #ff025a',
3434
'color: #ff025a80;',

src/utils/ErrorHandler.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Sentry from '@sentry/vue';
2-
import { warningMsg, statusMsg } from '@/utils/CoolConsole';
2+
import { warningMsg, statusMsg, statusErrorMsg } from '@/utils/CoolConsole';
33
import { sessionStorageKeys } from '@/utils/defaults';
44

55
/* Makes the current time, like hh:mm:ss */
@@ -33,4 +33,9 @@ export const InfoHandler = (msg, title) => {
3333
statusMsg(title || 'Info', msg);
3434
};
3535

36+
/* Outputs warnings caused by the user, such as missing field */
37+
export const WarningInfoHandler = (msg, title, log) => {
38+
statusErrorMsg(title || 'Warning', msg, log);
39+
};
40+
3641
export default ErrorHandler;

src/utils/defaults.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ module.exports = {
7171
],
7272
/* Which structural components should be visible by default */
7373
visibleComponents: {
74-
pageTitle: true,
74+
splashScreen: false,
7575
navigation: true,
76+
pageTitle: true,
7677
searchBar: true,
7778
settings: true,
7879
footer: true,

src/views/Login.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ import router from '@/router';
7676
import Button from '@/components/FormElements/Button';
7777
import Input from '@/components/FormElements/Input';
7878
import Defaults, { localStorageKeys } from '@/utils/defaults';
79-
import { InfoHandler } from '@/utils/ErrorHandler';
79+
import { InfoHandler, WarningInfoHandler } from '@/utils/ErrorHandler';
8080
import {
8181
checkCredentials,
8282
login,
@@ -160,17 +160,19 @@ export default {
160160
this.goHome();
161161
InfoHandler(`Succesfully signed in as ${this.username}`, 'Authentication');
162162
} else {
163-
InfoHandler(`Unable to Sign In - ${this.message}`, 'Authentication');
163+
WarningInfoHandler('Unable to Sign In', 'Authentication', this.message);
164164
}
165165
},
166166
/* Calls function to double-check guest access enabled, then log in as guest */
167167
guestLogin() {
168168
const isAllowed = this.isGuestAccessEnabled;
169169
if (isAllowed) {
170170
this.$toasted.show('Logged in as Guest, Redirecting...', { className: 'toast-success' });
171+
InfoHandler('Logged in as Guest', 'Authentication');
171172
this.goHome();
172173
} else {
173-
this.$toasted.show('Guest access not allowed', { className: 'toast-error' });
174+
this.$toasted.show('Guest Access Not Allowed', { className: 'toast-error' });
175+
WarningInfoHandler('Guest Access Not Allowed', 'Authentication');
174176
}
175177
},
176178
/* Calls logout, shows status message, and refreshed page */

0 commit comments

Comments
 (0)