diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index efbc88b8..369c3ee0 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -9,6 +9,10 @@ todo: can I receive an email link to an AyaNova object that opens the AyaNova ap - a link to localhost:8080?go=2,1 - http://localhost:7575?go=2,1 + +todo: persisted state: https://github.com/robinvdvleuten/vuex-persistedstate + - I can control which paths are persisted, maybe there is shit in there that doesn't need to be persisted or shouldn't be + todo: remember scroll position in lists when returning, make sure it is working, will be a pain if not todo: OPS routes (SERVER AND CLIENT) diff --git a/ayanova/src/App.vue b/ayanova/src/App.vue index 3bfa937c..bbb99ee8 100644 --- a/ayanova/src/App.vue +++ b/ayanova/src/App.vue @@ -276,22 +276,6 @@ export default { window.$gz.eventBus.$off(); }, mounted() { - //Open object after login? - if (window.location.search) { - //https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams - var searchParams = new URLSearchParams(window.location.search); - var openObject = {}; - //data should be format for open-object-handler - // { type: [AYATYPE], id: [RECORDID] } - if (searchParams.has("type")) { - openObject.type = searchParams.get("type"); - if (searchParams.has("id")) { - openObject.type = searchParams.get("id"); - } - window.$gz.store.commit("setOpenObject", openObject); - } - } - this.$root.$gzconfirm = this.$refs.gzconfirm.open; this.$root.$gznotify = this.$refs.gznotify.addNotification; @@ -300,6 +284,24 @@ export default { //this smells bad but it works this.$root.$gz = window.$gz; + //Capture open object type and id if present + //localhost:8080/login?type=2&id=22 + + if (window.location.search) { + //https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams + var searchParams = new URLSearchParams(window.location.search); + var openObject = {}; + //data should be format for open-object-handler + // { type: [AYATYPE], id: [RECORDID] } + if (searchParams.has("type")) { + openObject.type = Number(searchParams.get("type")); + if (searchParams.has("id")) { + openObject.id = Number(searchParams.get("id")); + } + window.$gz.store.commit("setOpenObject", openObject); + } + } + //redirect to login if not authenticated if (!this.$store.state.authenticated) { this.$router.push("login"); diff --git a/ayanova/src/api/authutil.js b/ayanova/src/api/authutil.js index f7f6ac41..a56e9036 100644 --- a/ayanova/src/api/authutil.js +++ b/ayanova/src/api/authutil.js @@ -41,6 +41,11 @@ export function processLogin(response) { return reject(); } + + //ensure the store is clean first in case we didn't come here from a clean logout + window.$gz.store.commit("logout"); + sessionStorage.clear(); //clear all temporary session storage data + //Put app relevant items into vuex store so app can use them window.$gz.store.commit("login", { apiToken: response.data.token, diff --git a/ayanova/src/main.js b/ayanova/src/main.js index 0d3ebc8e..92e9d72b 100644 --- a/ayanova/src/main.js +++ b/ayanova/src/main.js @@ -1,5 +1,4 @@ /* Xeslint-disable */ - import "@fortawesome/fontawesome-free/css/all.css"; import "typeface-roboto/index.css"; import "github-markdown-css"; @@ -55,7 +54,7 @@ import attachmentControl from "./components/attachment-control.vue"; //DEVELOPMENT MODE //THIS SHOULD BE FALSE IN RELEASE //************************************************************ -const DEV_MODE = false; +const DEV_MODE = true; //************************************************************ //************************************************************** //************************************************************** diff --git a/ayanova/src/store.js b/ayanova/src/store.js index 25232cc6..4d8c4e83 100644 --- a/ayanova/src/store.js +++ b/ayanova/src/store.js @@ -7,8 +7,17 @@ const MaxLogLength = 100; Vue.use(Vuex); +//reset all local settings via url in case of fucked up situation +if (window.location.search) { + var searchParams = new URLSearchParams(window.location.search); + if (searchParams.has("reset")) { + localStorage.removeItem("AyaNova"); + console.log("RESET LOCAL SETTINGS"); + } +} + export default new Vuex.Store({ - plugins: [createPersistedState()], + plugins: [createPersistedState({ key: "AyaNova" })], state: { openObject: null, lastClientVersion: "", diff --git a/ayanova/src/views/login.vue b/ayanova/src/views/login.vue index 8cf32a31..f2713390 100644 --- a/ayanova/src/views/login.vue +++ b/ayanova/src/views/login.vue @@ -260,7 +260,7 @@ export default { auth .authenticate(vm.input.username, vm.input.password) .then(() => { - if (vm.$store.state.openObject) { + if (vm.$store.state.openObject != null) { window.$gz.eventBus.$emit("openobject", null); } else { vm.$router.push(vm.$store.state.homePage);