From c9de558a0666ac836f39a81c52553678da706fc9 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 12 Nov 2018 21:09:42 +0000 Subject: [PATCH] --- app/ayanova/.eslintignore | 2 +- app/ayanova/src/App.vue | 2 +- app/ayanova/src/api/locale.js | 25 +++--- app/ayanova/src/utils/initialize.js | 101 ++++++++++++++----------- app/ayanova/src/utils/libs/core.min.js | 29 +++++++ devdocs/todo.txt | 3 +- server/AyaNova/Startup.cs | 2 +- 7 files changed, 100 insertions(+), 64 deletions(-) create mode 100644 app/ayanova/src/utils/libs/core.min.js diff --git a/app/ayanova/.eslintignore b/app/ayanova/.eslintignore index 0cf38967..2323db60 100644 --- a/app/ayanova/.eslintignore +++ b/app/ayanova/.eslintignore @@ -1 +1 @@ -src/utils/lodash/*.js \ No newline at end of file +src/utils/libs/*.js \ No newline at end of file diff --git a/app/ayanova/src/App.vue b/app/ayanova/src/App.vue index 7096dfd2..18890490 100644 --- a/app/ayanova/src/App.vue +++ b/app/ayanova/src/App.vue @@ -2,7 +2,7 @@ - + {{ "fa-" + item.icon }} diff --git a/app/ayanova/src/api/locale.js b/app/ayanova/src/api/locale.js index 2a023fd2..d3d5e3a3 100644 --- a/app/ayanova/src/api/locale.js +++ b/app/ayanova/src/api/locale.js @@ -1,7 +1,8 @@ import config from "../utils/config"; import api from "./apiutil"; -import has from "../utils/lodash/map"; - +import _ from "../utils/libs/core.min.js"; +import { getToken } from "../utils/authUtil"; +/* eslint-disable */ /* Locale: Methods @@ -30,24 +31,20 @@ export default { async PreFetch(keys) { //step 1: build an array of keys that we don't have already var NeedIt = []; - keys.forEach(key => { - if (!has(lt, key)) { - NeedIt.push(key); + for (var i = 0; i < keys.length; i++) { + if (!_.has(lt, keys[i])) { + NeedIt.push(keys[i]); } - }); - - //todo: make this work with the locale route to get teh batch of keys and store into the lt object - fetch(config.apiUrl + "auth", { + } + fetch(config.apiUrl + "locale/subset", { method: "post", mode: "cors", headers: { Accept: "application/json, text/plain, */*", - "Content-Type": "application/json" + "Content-Type": "application/json", + Authorization: "Bearer " + getToken() }, - body: JSON.stringify({ - login: "", - password: "" - }) + body: JSON.stringify(NeedIt) }) .then(api.status) .then(api.json) diff --git a/app/ayanova/src/utils/initialize.js b/app/ayanova/src/utils/initialize.js index 806de06b..8ecc51cf 100644 --- a/app/ayanova/src/utils/initialize.js +++ b/app/ayanova/src/utils/initialize.js @@ -1,7 +1,7 @@ import store from "../store"; import roles from "./roles"; import lt from "../api/locale"; - +/* eslint-disable */ function addNavItem(title, icon, route) { store.state.navItems.push({ title, @@ -20,6 +20,7 @@ export default function initialize() { lt.ClearCache(); if (store.state.authenticated) { //prefetch the always required localized text keys into the cache + lt.PreFetch([ "Service", "Dispatch", @@ -29,57 +30,67 @@ export default function initialize() { "Operations", "HelpAboutAyaNova", "Logout" - ]); + ]) + .then(() => { + debugger; + //do success + //put nav items into store + //Everyone has a home + addNavItem(lt.Get("Home"), "home", "/"); - //put nav items into store + if ( + roles.hasRole(roles.AuthorizationRoles.TechLimited) || + roles.hasRole(roles.AuthorizationRoles.TechFull) || + roles.hasRole(roles.AuthorizationRoles.SubContractorLimited) || + roles.hasRole(roles.AuthorizationRoles.SubContractorFull) + ) { + addNavItem(lt.Get("Service"), "toolbox", "/service"); + } - //Everyone has a home - addNavItem(lt.Get("Home"), "home", "/"); + if ( + roles.hasRole(roles.AuthorizationRoles.DispatchLimited) || + roles.hasRole(roles.AuthorizationRoles.DispatchFull) + ) { + addNavItem(lt.Get("Dispatch"), "shipping-fast", "/dispatch"); + } - if ( - roles.hasRole(roles.AuthorizationRoles.TechLimited) || - roles.hasRole(roles.AuthorizationRoles.TechFull) || - roles.hasRole(roles.AuthorizationRoles.SubContractorLimited) || - roles.hasRole(roles.AuthorizationRoles.SubContractorFull) - ) { - addNavItem(lt.Get("Service"), "toolbox", "/service"); - } + if ( + roles.hasRole(roles.AuthorizationRoles.InventoryLimited) || + roles.hasRole(roles.AuthorizationRoles.InventoryFull) + ) { + addNavItem(lt.Get("Inventory"), "dolly", "/inventory"); + } - if ( - roles.hasRole(roles.AuthorizationRoles.DispatchLimited) || - roles.hasRole(roles.AuthorizationRoles.DispatchFull) - ) { - addNavItem(lt.Get("Dispatch"), "shipping-fast", "/dispatch"); - } + if (roles.hasRole(roles.AuthorizationRoles.AccountingFull)) { + addNavItem( + lt.Get("Accounting"), + "file-invoice-dollar", + "/accounting" + ); + } - if ( - roles.hasRole(roles.AuthorizationRoles.InventoryLimited) || - roles.hasRole(roles.AuthorizationRoles.InventoryFull) - ) { - addNavItem(lt.Get("Inventory"), "dolly", "/inventory"); - } + if ( + roles.hasRole(roles.AuthorizationRoles.BizAdminLimited) || + roles.hasRole(roles.AuthorizationRoles.BizAdminFull) + ) { + addNavItem(lt.Get("Administration"), "user-tie", "/admin"); + } - if (roles.hasRole(roles.AuthorizationRoles.AccountingFull)) { - addNavItem(lt.Get("Accounting"), "file-invoice-dollar", "/accounting"); - } + if ( + roles.hasRole(roles.AuthorizationRoles.OpsAdminFull) || + roles.hasRole(roles.AuthorizationRoles.OpsAdminLimited) + ) { + addNavItem(lt.Get("Operations"), "cogs", "ops"); + } - if ( - roles.hasRole(roles.AuthorizationRoles.BizAdminLimited) || - roles.hasRole(roles.AuthorizationRoles.BizAdminFull) - ) { - addNavItem(lt.Get("Administration"), "user-tie", "/admin"); - } - - if ( - roles.hasRole(roles.AuthorizationRoles.OpsAdminFull) || - roles.hasRole(roles.AuthorizationRoles.OpsAdminLimited) - ) { - 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"); + //Everyone can see about and logout + addNavItem(lt.Get("HelpAboutAyaNova"), "info-circle", "/about"); + addNavItem(lt.Get("Logout"), "sign-out-alt", "/login"); + }) + .catch(function(error) { + debugger; + alert("initialize::LT->Prefetch failed: " + error); + }); } } /* diff --git a/app/ayanova/src/utils/libs/core.min.js b/app/ayanova/src/utils/libs/core.min.js new file mode 100644 index 00000000..bd1e5453 --- /dev/null +++ b/app/ayanova/src/utils/libs/core.min.js @@ -0,0 +1,29 @@ +/** + * @license + * Lodash (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE + * Build: `lodash core -o ./dist/lodash.core.js` + */ +;(function(){function n(n){return H(n)&&pn.call(n,"callee")&&!yn.call(n,"callee")}function t(n,t){return n.push.apply(n,t),n}function r(n){return function(t){return null==t?Z:t[n]}}function e(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function u(n,t){return j(t,function(t){return n[t]})}function o(n){return n instanceof i?n:new i(n)}function i(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t}function c(n,t,r){if(typeof n!="function")throw new TypeError("Expected a function"); +return setTimeout(function(){n.apply(Z,r)},t)}function f(n,t){var r=true;return mn(n,function(n,e,u){return r=!!t(n,e,u)}),r}function a(n,t,r){for(var e=-1,u=n.length;++et}function b(n,t,r,e,u){return n===t||(null==n||null==t||!H(n)&&!H(t)?n!==n&&t!==t:y(n,t,r,e,b,u))}function y(n,t,r,e,u,o){var i=Nn(n),c=Nn(t),f=i?"[object Array]":hn.call(n),a=c?"[object Array]":hn.call(t),f="[object Arguments]"==f?"[object Object]":f,a="[object Arguments]"==a?"[object Object]":a,l="[object Object]"==f,c="[object Object]"==a,a=f==a;o||(o=[]);var p=An(o,function(t){return t[0]==n}),s=An(o,function(n){ +return n[0]==t});if(p&&s)return p[1]==t;if(o.push([n,t]),o.push([t,n]),a&&!l){if(i)r=T(n,t,r,e,u,o);else n:{switch(f){case"[object Boolean]":case"[object Date]":case"[object Number]":r=J(+n,+t);break n;case"[object Error]":r=n.name==t.name&&n.message==t.message;break n;case"[object RegExp]":case"[object String]":r=n==t+"";break n}r=false}return o.pop(),r}return 1&r||(i=l&&pn.call(n,"__wrapped__"),f=c&&pn.call(t,"__wrapped__"),!i&&!f)?!!a&&(r=B(n,t,r,e,u,o),o.pop(),r):(i=i?n.value():n,f=f?t.value():t, +r=u(i,f,r,e,o),o.pop(),r)}function g(n){return typeof n=="function"?n:null==n?X:(typeof n=="object"?d:r)(n)}function _(n,t){return nt&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++ei))return false;for(var c=-1,f=true,a=2&r?[]:Z;++cr?jn(e+r,0):r:0,r=(r||0)-1;for(var u=t===t;++rarguments.length,mn)}function G(n,t){var r;if(typeof t!="function")throw new TypeError("Expected a function");return n=Fn(n), +function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=Z),r}}function J(n,t){return n===t||n!==n&&t!==t}function M(n){var t;return(t=null!=n)&&(t=n.length,t=typeof t=="number"&&-1=t),t&&!U(n)}function U(n){return!!V(n)&&(n=hn.call(n),"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n)}function V(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}function H(n){return null!=n&&typeof n=="object"}function K(n){ +return typeof n=="number"||H(n)&&"[object Number]"==hn.call(n)}function L(n){return typeof n=="string"||!Nn(n)&&H(n)&&"[object String]"==hn.call(n)}function Q(n){return typeof n=="string"?n:null==n?"":n+""}function W(n){return null==n?[]:u(n,Dn(n))}function X(n){return n}function Y(n,r,e){var u=Dn(r),o=h(r,u);null!=e||V(r)&&(o.length||!u.length)||(e=r,r=n,n=this,o=h(r,Dn(r)));var i=!(V(e)&&"chain"in e&&!e.chain),c=U(n);return mn(o,function(e){var u=r[e];n[e]=u,c&&(n.prototype[e]=function(){var r=this.__chain__; +if(i||r){var e=n(this.__wrapped__);return(e.__actions__=A(this.__actions__)).push({func:u,args:arguments,thisArg:n}),e.__chain__=r,e}return u.apply(n,t([this.value()],arguments))})}),n}var Z,nn=1/0,tn=/[&<>"']/g,rn=RegExp(tn.source),en=/^(?:0|[1-9]\d*)$/,un=typeof self=="object"&&self&&self.Object===Object&&self,on=typeof global=="object"&&global&&global.Object===Object&&global||un||Function("return this")(),cn=(un=typeof exports=="object"&&exports&&!exports.nodeType&&exports)&&typeof module=="object"&&module&&!module.nodeType&&module,fn=function(n){ +return function(t){return null==n?Z:n[t]}}({"&":"&","<":"<",">":">",'"':""","'":"'"}),an=Array.prototype,ln=Object.prototype,pn=ln.hasOwnProperty,sn=0,hn=ln.toString,vn=on._,bn=Object.create,yn=ln.propertyIsEnumerable,gn=on.isFinite,_n=function(n,t){return function(r){return n(t(r))}}(Object.keys,Object),jn=Math.max,dn=function(){function n(){}return function(t){return V(t)?bn?bn(t):(n.prototype=t,t=new n,n.prototype=Z,t):{}}}();i.prototype=dn(o.prototype),i.prototype.constructor=i; +var mn=function(n,t){return function(r,e){if(null==r)return r;if(!M(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++or&&(r=jn(e+r,0));n:{for(t=g(t),e=n.length,r+=-1;++re||o&&c&&a||!u&&a||!i){r=1;break n}if(!o&&r