From 17d44a4cef2fb3d7684156e6e1ff1000e37c2806 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 4 Jan 2019 00:04:37 +0000 Subject: [PATCH] --- ayanova/src/api/getAPIItem.js | 17 +++++++++++++++++ ayanova/src/utils/initialize.js | 26 +++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 ayanova/src/api/getAPIItem.js diff --git a/ayanova/src/api/getAPIItem.js b/ayanova/src/api/getAPIItem.js new file mode 100644 index 00000000..d5578332 --- /dev/null +++ b/ayanova/src/api/getAPIItem.js @@ -0,0 +1,17 @@ +/* xeslint-disable */ +import apiUtil from "./apiutil"; +export default { + get(route) { + return new Promise(function(resolve, reject) { + fetch(apiUtil.APIUrl(route), apiUtil.fetchGetOptions()) + .then(apiUtil.status) + .then(apiUtil.json) + .then(response => { + resolve(response); + }) + .catch(function(error) { + reject(error); + }); + }); + } +}; diff --git a/ayanova/src/utils/initialize.js b/ayanova/src/utils/initialize.js index b1def938..616b6cb4 100644 --- a/ayanova/src/utils/initialize.js +++ b/ayanova/src/utils/initialize.js @@ -1,7 +1,8 @@ -/* xeslint-disable */ +/* eslint-disable */ import store from "../store"; import roles from "./roles"; import lt from "../api/locale"; +import api from "../api/getAPIItem"; function addNavItem(title, icon, route) { store.commit("addNavItem", { @@ -16,6 +17,29 @@ function addNavItem(title, icon, route) { // on change of authentication status export default function initialize() { if (store.state.authenticated) { + //Fetch the users options for local caching + + //check the timezone offset is still valid, offer to change it if not + + api.get("UserOptions/" + store.state.userId).then(res => { + //debugger; + var localOffset = new Date().getTimezoneOffset(); + if (localOffset != 0) { + localOffset = (localOffset / 60) * -1; //time is in minutes and reversed from what we want or expect + } + + if (res.data.timeZoneOffset != localOffset) { + //todo: timezone doesn't match, offer to fix it + alert( + "Time zone offset for this account is set to " + + res.data.timeZoneOffset + + " which doesn't match the local timezone offset of " + + localOffset + + "." + ); + } + }); + //fetch the required localized text keys into the cache lt.fetch([ "Home",