From 8c3e72fe7bdb85035d47612870c8370f62d834c0 Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 12 May 2020 06:28:14 +0900 Subject: [PATCH] fix wizard route and config load error --- ...nfig.example.json => config.template.json} | 0 src/scripts/routes.js | 64 ++++++++++--------- src/scripts/settings/webSettings.js | 12 +++- 3 files changed, 44 insertions(+), 32 deletions(-) rename src/{config.example.json => config.template.json} (100%) diff --git a/src/config.example.json b/src/config.template.json similarity index 100% rename from src/config.example.json rename to src/config.template.json diff --git a/src/scripts/routes.js b/src/scripts/routes.js index 31530705c..a5ed0a00a 100644 --- a/src/scripts/routes.js +++ b/src/scripts/routes.js @@ -38,6 +38,14 @@ define([ controller: 'auth/selectserver', type: 'selectserver' }); + defineRoute({ + path: '/login.html', + autoFocus: false, + anonymous: true, + startup: true, + controller: 'auth/login', + type: 'login' + }); defineRoute({ path: '/forgotpassword.html', anonymous: true, @@ -52,12 +60,6 @@ define([ controller: 'auth/forgotpasswordpin' }); - defineRoute({ - path: '/addplugin.html', - autoFocus: false, - roles: 'admin', - controller: 'dashboard/plugins/add' - }); defineRoute({ path: '/mypreferencesmenu.html', autoFocus: false, @@ -137,6 +139,24 @@ define([ roles: 'admin', controller: 'dashboard/dlna/dlnaprofiles' }); + defineRoute({ + path: '/addplugin.html', + autoFocus: false, + roles: 'admin', + controller: 'dashboard/plugins/add' + }); + defineRoute({ + path: '/library.html', + autoFocus: false, + roles: 'admin', + controller: 'dashboard/medialibrarypage' + }); + defineRoute({ + path: '/librarydisplay.html', + autoFocus: false, + roles: 'admin', + controller: 'dashboard/librarydisplay' + }); defineRoute({ path: '/dlnasettings.html', autoFocus: false, @@ -154,6 +174,7 @@ define([ roles: 'admin', controller: 'dashboard/encodingsettings' }); + defineRoute({ path: '/home.html', autoFocus: false, @@ -161,6 +182,10 @@ define([ transition: 'fade', type: 'home' }); + defineRoute({ + path: '/search.html', + controller: 'searchpage' + }); defineRoute({ path: '/list.html', autoFocus: false, @@ -173,18 +198,6 @@ define([ autoFocus: false, transition: 'fade' }); - defineRoute({ - path: '/library.html', - autoFocus: false, - roles: 'admin', - controller: 'dashboard/medialibrarypage' - }); - defineRoute({ - path: '/librarydisplay.html', - autoFocus: false, - roles: 'admin', - controller: 'dashboard/librarydisplay' - }); defineRoute({ path: '/livetv.html', controller: 'livetv/livetvsuggested', @@ -219,14 +232,6 @@ define([ roles: 'admin', controller: 'dashboard/logs' }); - defineRoute({ - path: '/login.html', - autoFocus: false, - anonymous: true, - startup: true, - controller: 'auth/login', - type: 'login' - }); defineRoute({ path: '/metadataimages.html', autoFocus: false, @@ -293,10 +298,6 @@ define([ roles: 'admin', controller: 'dashboard/scheduledtasks/scheduledtasks' }); - defineRoute({ - path: '/search.html', - controller: 'searchpage' - }); defineRoute({ path: '/serveractivity.html', autoFocus: false, @@ -321,6 +322,7 @@ define([ controller: 'shows/tvrecommended', transition: 'fade' }); + defineRoute({ path: '/useredit.html', autoFocus: false, @@ -373,7 +375,7 @@ define([ path: '/wizardlibrary.html', autoFocus: false, anonymous: true, - controller: 'medialibrarypage' + controller: 'dashboard/medialibrarypage' }); defineRoute({ path: '/wizardsettings.html', diff --git a/src/scripts/settings/webSettings.js b/src/scripts/settings/webSettings.js index 92093dfbe..14825e2aa 100644 --- a/src/scripts/settings/webSettings.js +++ b/src/scripts/settings/webSettings.js @@ -2,7 +2,17 @@ let data; function getConfig() { if (data) return Promise.resolve(data); - return fetch('/config.json?nocache=' + new Date().getUTCMilliseconds()).then(function (response) { + return fetch('/config.json?nocache=' + new Date().getUTCMilliseconds()).then(response => { + data = response.json(); + return data; + }).catch(error => { + return getDefaultConfig(); + }); +} + +function getDefaultConfig() { + console.warn('web config file is missing so the template will be used') + return fetch('/config.template.json').then(function (response) { data = response.json(); return data; });