This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import logger from "../utils/logit";
|
||||
import { getToken } from "../utils/authUtil";
|
||||
import { getToken } from "../utils/authutil";
|
||||
|
||||
export default {
|
||||
status(response) {
|
||||
|
||||
@@ -24,13 +24,13 @@ Methods
|
||||
var lt = {};
|
||||
|
||||
export default {
|
||||
Get(key) {
|
||||
get(key) {
|
||||
if (!_.has(lt, key)) {
|
||||
return "?" + key + "?";
|
||||
}
|
||||
return lt[key];
|
||||
},
|
||||
Fetch(keys) {
|
||||
fetch(keys) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
//step 1: build an array of keys that we don't have already
|
||||
var NeedIt = [];
|
||||
@@ -67,7 +67,7 @@ export default {
|
||||
});
|
||||
});
|
||||
},
|
||||
ClearCache() {
|
||||
clearCache() {
|
||||
lt = {};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,16 +12,20 @@ export default new Vuex.Store({
|
||||
navItems: []
|
||||
},
|
||||
mutations: {
|
||||
authenticated(state, data) {
|
||||
setAuthentication(state, data) {
|
||||
// mutate state
|
||||
state.authenticated = data.authenticated;
|
||||
state.userId = data.userId;
|
||||
state.roles = data.roles;
|
||||
},
|
||||
notAuthenticated(state) {
|
||||
clearAuthentication(state) {
|
||||
state.authenticated = false;
|
||||
state.userId = 0;
|
||||
state.roles = 0;
|
||||
state.navItems = [];
|
||||
},
|
||||
addNavItem(state, data) {
|
||||
state.navItems.push(data);
|
||||
}
|
||||
},
|
||||
actions: {}
|
||||
|
||||
@@ -32,7 +32,7 @@ export function processLogin(response) {
|
||||
setToken(response.data.token);
|
||||
|
||||
//Put app relevant items into vuex store so app can use them
|
||||
store.commit("authenticated", {
|
||||
store.commit("setAuthentication", {
|
||||
authenticated: true,
|
||||
userId: Number(token.id),
|
||||
roles: token["ayanova/roles"]
|
||||
@@ -47,7 +47,7 @@ export function processLogin(response) {
|
||||
|
||||
export function processLogout() {
|
||||
logger.log("Logout");
|
||||
store.commit("notAuthenticated");
|
||||
store.commit("clearAuthentication");
|
||||
clearToken();
|
||||
//router.go('/');
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import roles from "./roles";
|
||||
import lt from "../api/locale";
|
||||
|
||||
function addNavItem(title, icon, route) {
|
||||
store.state.navItems.push({
|
||||
store.commit("addNavItem", {
|
||||
title,
|
||||
icon,
|
||||
route
|
||||
@@ -16,13 +16,11 @@ function addNavItem(title, icon, route) {
|
||||
// Initialize the app
|
||||
// on change of authentication status
|
||||
export default function initialize() {
|
||||
//clear the nav items either way
|
||||
store.state.navItems = [];
|
||||
//clear the locale text cache
|
||||
lt.ClearCache();
|
||||
lt.clearCache();
|
||||
if (store.state.authenticated) {
|
||||
//fetch the required localized text keys into the cache
|
||||
lt.Fetch([
|
||||
lt.fetch([
|
||||
"Home",
|
||||
"Service",
|
||||
"Dispatch",
|
||||
@@ -36,7 +34,7 @@ export default function initialize() {
|
||||
.then(function() {
|
||||
//put nav items into store
|
||||
//Everyone has a home
|
||||
addNavItem(lt.Get("Home"), "home", "/");
|
||||
addNavItem(lt.get("Home"), "home", "/");
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.TechLimited) ||
|
||||
@@ -44,26 +42,26 @@ export default function initialize() {
|
||||
roles.hasRole(roles.AuthorizationRoles.SubContractorLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.SubContractorFull)
|
||||
) {
|
||||
addNavItem(lt.Get("Service"), "toolbox", "/service");
|
||||
addNavItem(lt.get("Service"), "toolbox", "/service");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.DispatchLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.DispatchFull)
|
||||
) {
|
||||
addNavItem(lt.Get("Dispatch"), "shipping-fast", "/dispatch");
|
||||
addNavItem(lt.get("Dispatch"), "shipping-fast", "/dispatch");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.InventoryLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.InventoryFull)
|
||||
) {
|
||||
addNavItem(lt.Get("Inventory"), "dolly", "/inventory");
|
||||
addNavItem(lt.get("Inventory"), "dolly", "/inventory");
|
||||
}
|
||||
|
||||
if (roles.hasRole(roles.AuthorizationRoles.AccountingFull)) {
|
||||
addNavItem(
|
||||
lt.Get("Accounting"),
|
||||
lt.get("Accounting"),
|
||||
"file-invoice-dollar",
|
||||
"/accounting"
|
||||
);
|
||||
@@ -73,19 +71,19 @@ export default function initialize() {
|
||||
roles.hasRole(roles.AuthorizationRoles.BizAdminLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.BizAdminFull)
|
||||
) {
|
||||
addNavItem(lt.Get("Administration"), "user-tie", "/admin");
|
||||
addNavItem(lt.get("Administration"), "user-tie", "/admin");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.OpsAdminFull) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.OpsAdminLimited)
|
||||
) {
|
||||
addNavItem(lt.Get("Operations"), "cogs", "ops");
|
||||
addNavItem(lt.get("Operations"), "cogs", "ops");
|
||||
}
|
||||
|
||||
//Everyone can see about and logout
|
||||
addNavItem(lt.Get("HelpAboutAyaNova"), "info-circle", "/about");
|
||||
addNavItem(lt.Get("Logout"), "sign-out-alt", "/login");
|
||||
addNavItem(lt.get("HelpAboutAyaNova"), "info-circle", "/about");
|
||||
addNavItem(lt.get("Logout"), "sign-out-alt", "/login");
|
||||
})
|
||||
.catch(function(error) {
|
||||
logger.log("Initialize::() -> error", error);
|
||||
|
||||
@@ -28,8 +28,10 @@ Localized text - All text prsented by the server will be a locale key only and i
|
||||
- Ops logs, Metrics, event logs: these items and any other future pre-generated text items will be localized at the server according to the logged in users' locale
|
||||
|
||||
|
||||
|
||||
|
||||
JAVASCRIPT
|
||||
(mostly using AirBNB standard but using Google standard for naming things)
|
||||
https://google.github.io/styleguide/javascriptguide.xml?showone=Naming#Naming
|
||||
In general, use functionNamesLikeThis, variableNamesLikeThis, ClassNamesLikeThis, EnumNamesLikeThis, methodNamesLikeThis, CONSTANT_VALUES_LIKE_THIS, foo.namespaceNamesLikeThis.bar, and filenameslikethis.js.
|
||||
|
||||
OLDER STUFF
|
||||
=-=-=-=-=-=
|
||||
|
||||
@@ -32,7 +32,6 @@ WEEK OF 2018-11-12 - RAVEN shell start work. YAY!
|
||||
|
||||
NEXT UP / CURRENTLY WORKING ON:
|
||||
|
||||
- Clean up the login form to use graphics and no text
|
||||
- lookup naming guidelines for javascript functions (capitalized?) and fixup the code and stick to it.
|
||||
- Look over the (now two) api calls and look for optimization and code shrinkage / de-duplication
|
||||
- Move on to the next thing (build and post?)
|
||||
|
||||
Reference in New Issue
Block a user