From afc1e361fe4fc7c5f94e6d42342cd9f20fdeb805 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 16 Nov 2018 19:02:39 +0000 Subject: [PATCH] --- app/ayanova/src/api/apiutil.js | 11 +++++------ app/ayanova/src/utils/authutil.js | 17 +++++++++++------ app/ayanova/src/utils/initialize.js | 4 ++-- app/ayanova/src/utils/logit.js | 21 --------------------- app/ayanova/src/views/log.vue | 11 +++++------ 5 files changed, 23 insertions(+), 41 deletions(-) delete mode 100644 app/ayanova/src/utils/logit.js diff --git a/app/ayanova/src/api/apiutil.js b/app/ayanova/src/api/apiutil.js index 411e44d8..3f1cd74c 100644 --- a/app/ayanova/src/api/apiutil.js +++ b/app/ayanova/src/api/apiutil.js @@ -1,5 +1,4 @@ /* Xeslint-disable */ -import logger from "../utils/logit"; import store from "../store"; export default { @@ -7,7 +6,7 @@ export default { if (response.status >= 200 && response.status < 300) { return Promise.resolve(response); } else { - logger.log("API error", response.statusText); + store.commit("logItem", "API error: " + response.statusText); return Promise.reject(new Error(response.statusText)); } }, @@ -67,7 +66,7 @@ export default { window.location.hostname == "localhost" && window.location.port == "8080" ) { - logger.log("apiutil::APIUrl -> APIURL empty setting to dev. mode"); + store.commit("logItem", "apiutil::APIUrl -> setting to dev. mode"); store.commit("setAPIURL", "http://localhost:7575/api/v8.0/"); } else { //production location //:/ @@ -75,9 +74,9 @@ export default { "setAPIURL", window.location.protocol + "//" + window.location.host + "/api/v8.0/" ); - logger.log( - "apiutil::APIUrl -> APIURL empty using: ", - store.state.apiUrl + store.commit( + "logItem", + "apiutil::APIUrl -> setting to: " + store.state.apiUrl ); } } diff --git a/app/ayanova/src/utils/authutil.js b/app/ayanova/src/utils/authutil.js index 65c870ff..326dba94 100644 --- a/app/ayanova/src/utils/authutil.js +++ b/app/ayanova/src/utils/authutil.js @@ -1,24 +1,26 @@ /* xeslint-disable */ import decode from "jwt-decode"; -import logger from "./logit"; import store from "../store"; import initialize from "./initialize"; export function processLogin(response) { //is token present? if (!response || !response.data || !response.data.token) { - logger.log("auth::processLogin -> token empty"); + store.commit("logItem", "auth::processLogin -> response empty"); return Promise.reject(); } const token = decode(response.data.token); if (!token || !token.iss) { - logger.log("auth::processLogin -> token empty"); + store.commit("logItem", "auth::processLogin -> response token empty"); return Promise.reject(); } if (token.iss != "ayanova.com") { - logger.log("auth::processLogin -> token invalid (iss)", token.iss); + store.commit( + "logItem", + "auth::processLogin -> token invalid (iss): " + token.iss + ); return Promise.reject(); } @@ -32,12 +34,15 @@ export function processLogin(response) { //Initialize the application initialize(); - logger.log("User " + token.id + " logged in"); + store.commit( + "logItem", + "auth::processLogin -> User " + token.id + " logged in" + ); return Promise.resolve(true); } export function processLogout() { - logger.log("Logout"); + store.commit("logItem", "auth::processLogout -> User logged out"); store.commit("logout"); } diff --git a/app/ayanova/src/utils/initialize.js b/app/ayanova/src/utils/initialize.js index 1e65d421..b1def938 100644 --- a/app/ayanova/src/utils/initialize.js +++ b/app/ayanova/src/utils/initialize.js @@ -1,5 +1,4 @@ /* xeslint-disable */ -import logger from "./logit"; import store from "../store"; import roles from "./roles"; import lt from "../api/locale"; @@ -84,7 +83,8 @@ export default function initialize() { addNavItem(lt.get("Logout"), "sign-out-alt", "/login"); }) .catch(function(error) { - logger.log("Initialize::() -> error", error); + store.commit("logItem", "Initialize::() -> error" + error); + throw error; }); } } diff --git a/app/ayanova/src/utils/logit.js b/app/ayanova/src/utils/logit.js deleted file mode 100644 index ac35b69e..00000000 --- a/app/ayanova/src/utils/logit.js +++ /dev/null @@ -1,21 +0,0 @@ -/* xeslint-disable */ -////////////////////////////////////////////////////// -//in-memory log, keeps up to 100 of the past log items -// -import cbuffer from "./cbuffer"; -import store from "../store"; - -const buffer = new cbuffer(100); -export default { - log(msg, obj) { - if (obj) { - msg = msg + "|[" + JSON.stringify(obj) + "]"; - } - msg = Date.now() + "|" + msg; - buffer.push(msg); - store.commit("setLog", buffer.toArray()); - }, - getLogText() { - //TODO: iterate the array from store, convert timestamps to local date and time and arrange as a block of multiline text to display in the UI - } -}; diff --git a/app/ayanova/src/views/log.vue b/app/ayanova/src/views/log.vue index 3d0e64e0..22641bcd 100644 --- a/app/ayanova/src/views/log.vue +++ b/app/ayanova/src/views/log.vue @@ -1,15 +1,14 @@