diff --git a/app/ayanova/src/utils/authUtil.js b/app/ayanova/src/utils/authUtil.js
index 8c33bf1a..87a988c5 100644
--- a/app/ayanova/src/utils/authUtil.js
+++ b/app/ayanova/src/utils/authUtil.js
@@ -2,6 +2,8 @@ import decode from "jwt-decode";
import config from "./config";
import logger from "./logit";
import store from "../store";
+import initialize from "./initialize";
+
//import axios from 'axios';
//import auth0 from 'auth0-js';
//import Router from 'vue-router';
@@ -36,14 +38,13 @@ export function processLogin(response) {
roles: token["ayanova/roles"]
});
+ //Initialize the application
+ initialize();
+
logger.log("User " + token.id + " logged in");
return Promise.resolve(true);
}
-// var router = new Router({
-// mode: 'history',
-// });
-
export function processLogout() {
logger.log("Logout");
store.commit("notAuthenticated");
diff --git a/app/ayanova/src/utils/initialize.js b/app/ayanova/src/utils/initialize.js
new file mode 100644
index 00000000..57be7e51
--- /dev/null
+++ b/app/ayanova/src/utils/initialize.js
@@ -0,0 +1,122 @@
+import store from "../store";
+import roles from "./roles";
+
+function addNavItem(title, icon, route) {
+ store.state.navItems.push({
+ title,
+ icon,
+ route
+ });
+}
+
+/////////////////////////////////////
+// Initialize the app
+// on change of authentication status
+export default function initialize() {
+ //clear the nav items either way
+ store.state.navItems = [];
+ if (store.state.authenticated) {
+ //put nav items into store
+
+ //Everyone has a home
+ addNavItem("Home", "home", "/");
+
+ if (
+ roles.hasRole(roles.AuthorizationRoles.TechLimited) ||
+ roles.hasRole(roles.AuthorizationRoles.TechFull) ||
+ roles.hasRole(roles.AuthorizationRoles.SubContractorLimited) ||
+ roles.hasRole(roles.AuthorizationRoles.SubContractorFull)
+ ) {
+ addNavItem("Service", "toolbox", "/service");
+ }
+
+ if (
+ roles.hasRole(roles.AuthorizationRoles.OpsAdminFull) ||
+ roles.hasRole(roles.AuthorizationRoles.OpsAdminLimited)
+ ) {
+ addNavItem("Operations", "cogs", "ops");
+ }
+
+ //Everyone can see about and logout
+ addNavItem("About", "info-circle", "/about");
+ addNavItem("Log out", "sign-out-alt", "/login");
+ }
+}
+/*
+
+
+ fa-home
+
+
+ Home
+
+
+
+
+ fa-toolbox
+
+
+ Service
+
+
+
+
+ fa-shipping-fast
+
+
+ Dispatch
+
+
+
+
+ fa-dolly
+
+
+ Inventory
+
+
+
+
+ fa-file-invoice-dollar
+
+
+ Accounting
+
+
+
+
+ fa-user-tie
+
+
+ Administration
+
+
+
+
+ fa-cogs
+
+
+ Operations
+
+
+
+
+ fa-info-circle
+
+
+ About
+
+
+
+
+ fa-sign-out-alt
+
+
+ Log off
+
+
+*/