Canviat mètode per activar Dev Mode a paràmetre GET
Abans per activar el Dev Mode s'havia d'establir `localStorage.devMode =
'true'; localStorage.apiUrl = '{URL}';`.
Amb aquest commit aquest mètode canvia a passar el paràmetre `apiUrl`
que contingui l'URL de l'API a utilitzar (no fa falta demanar d'activar
el Dev Mode explícitament). També es pot passar el paràmetre buit per
utilitzar l'URL per defecte del backend-dev.
Exemple:
https://delefme.github.io/covid-tracability/?apiUrl=https://example.com/api/v1/
(cherry picked from commit cb45ac83b91fde3238e39a346de95b142375a179)
diff --git a/js/build_page.js b/js/build_page.js
index 8178181..76ded35 100644
--- a/js/build_page.js
+++ b/js/build_page.js
@@ -272,16 +272,11 @@
}
function onPageLoad() {
-
- // Check if user is signed in
- if (localStorage.getItem('devMode') == 'true') {
+ var searchParams = new URLSearchParams(location.search);
+ if (searchParams.has('apiUrl')) {
var banner = document.getElementById('dev-mode');
- banner.addEventListener('click', _ => {
- localStorage.devMode = 'false';
- location.reload();
- });
banner.classList.remove('is-hidden');
- api_url = localStorage.getItem('apiUrl') || 'https://covid-tracability-backend-dev.sandbox.avm99963.com/api/v1/'
+ api_url = searchParams.get('apiUrl') || 'https://covid-tracability-backend-dev.sandbox.avm99963.com/api/v1/'
} else {
api_url = "https://covid-tracability-backend-prod.sandbox.avm99963.com/api/v1/";
}
@@ -289,6 +284,7 @@
current_time = getDefaultTime();
buildTimeSelector(current_time);
+ // Check if user is signed in
fetch(api_url + "isSignedIn", {
"mode": "cors",
"credentials": "include"