This commit is contained in:
1
app/ayanova/.eslintignore
Normal file
1
app/ayanova/.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
src/utils/lodash/*.js
|
||||
@@ -8,6 +8,7 @@
|
||||
</v-list-tile-action>
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title>{{ item.title }}</v-list-tile-title>
|
||||
<!-- <v-list-tile-title>{{ item.title }}</v-list-tile-title> -->
|
||||
</v-list-tile-content>
|
||||
</v-list-tile>
|
||||
</v-list>
|
||||
@@ -49,6 +50,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import lt from "./api/locale";
|
||||
|
||||
export default {
|
||||
name: "App",
|
||||
data() {
|
||||
|
||||
56
app/ayanova/src/api/locale.js
Normal file
56
app/ayanova/src/api/locale.js
Normal file
@@ -0,0 +1,56 @@
|
||||
import config from "../utils/config";
|
||||
import api from "./apiutil";
|
||||
import has from "../utils/lodash/map";
|
||||
|
||||
/*
|
||||
Locale:
|
||||
Methods
|
||||
- This module is responsible for handling all localized text operations
|
||||
- It stores a local in memory cache of the keys and returns them from cache whenever possible
|
||||
- Method: Get keys one at a time or in an array
|
||||
- a method that accepts lt keys and returns their text
|
||||
- If a key is not in the cache here then it fetches it from the server
|
||||
- Method: pre-fetch / Cache keys
|
||||
- Used to pre-fetch a bunch of keys at once if necessary
|
||||
- A caller will call this with the list of keys it will need in advance, the ones that are not present in the cache will be fetched from the server and the cache populated
|
||||
- No text is actually returned at this point, it's just a pre-setup kind of thing to ensure better perf later
|
||||
- Method: Clear cache
|
||||
- Clear the local cache entirely
|
||||
|
||||
|
||||
*/
|
||||
|
||||
const lt = {};
|
||||
|
||||
export default {
|
||||
async Get(keys) {},
|
||||
async PreFetch(keys) {},
|
||||
ClearCache() {},
|
||||
async authenticate(login, password) {
|
||||
return fetch(config.apiUrl + "auth", {
|
||||
method: "post",
|
||||
mode: "cors",
|
||||
headers: {
|
||||
Accept: "application/json, text/plain, */*",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
login: login,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
.then(api.status)
|
||||
.then(api.json)
|
||||
.then(processLogin)
|
||||
.then(() => {
|
||||
return Promise.resolve(true);
|
||||
}) //succeeded, nothing to return
|
||||
.catch(function(error) {
|
||||
processLogout();
|
||||
return Promise.reject(error);
|
||||
});
|
||||
},
|
||||
logout() {
|
||||
processLogout();
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import store from "../store";
|
||||
import roles from "./roles";
|
||||
import lt from "../api/locale";
|
||||
|
||||
function addNavItem(title, icon, route) {
|
||||
store.state.navItems.push({
|
||||
@@ -15,11 +16,25 @@ function addNavItem(title, icon, route) {
|
||||
export default function initialize() {
|
||||
//clear the nav items either way
|
||||
store.state.navItems = [];
|
||||
//clear the locale text cache
|
||||
lt.ClearCache();
|
||||
if (store.state.authenticated) {
|
||||
//prefetch the always required localized text keys into the cache
|
||||
lt.PreFetch([
|
||||
"Service",
|
||||
"Dispatch",
|
||||
"Inventory",
|
||||
"Accounting",
|
||||
"Administration",
|
||||
"Operations",
|
||||
"HelpAboutAyaNova",
|
||||
"Logout"
|
||||
]);
|
||||
|
||||
//put nav items into store
|
||||
|
||||
//Everyone has a home
|
||||
addNavItem("Home", "home", "/");
|
||||
addNavItem(lt.Get("Home"), "home", "/");
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.TechLimited) ||
|
||||
@@ -27,44 +42,44 @@ export default function initialize() {
|
||||
roles.hasRole(roles.AuthorizationRoles.SubContractorLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.SubContractorFull)
|
||||
) {
|
||||
addNavItem("Service", "toolbox", "/service");
|
||||
addNavItem(lt.Get("Service"), "toolbox", "/service");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.DispatchLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.DispatchFull)
|
||||
) {
|
||||
addNavItem("Dispatch", "shipping-fast", "/dispatch");
|
||||
addNavItem(lt.Get("Dispatch"), "shipping-fast", "/dispatch");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.InventoryLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.InventoryFull)
|
||||
) {
|
||||
addNavItem("Inventory", "dolly", "/inventory");
|
||||
addNavItem(lt.Get("Inventory"), "dolly", "/inventory");
|
||||
}
|
||||
|
||||
if (roles.hasRole(roles.AuthorizationRoles.AccountingFull)) {
|
||||
addNavItem("Accounting", "file-invoice-dollar", "/accounting");
|
||||
addNavItem(lt.Get("Accounting"), "file-invoice-dollar", "/accounting");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.BizAdminLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.BizAdminFull)
|
||||
) {
|
||||
addNavItem("Administration", "user-tie", "/admin");
|
||||
addNavItem(lt.Get("Administration"), "user-tie", "/admin");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.OpsAdminFull) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.OpsAdminLimited)
|
||||
) {
|
||||
addNavItem("Operations", "cogs", "ops");
|
||||
addNavItem(lt.Get("Operations"), "cogs", "ops");
|
||||
}
|
||||
|
||||
//Everyone can see about and logout
|
||||
addNavItem("About", "info-circle", "/about");
|
||||
addNavItem("Log out", "sign-out-alt", "/login");
|
||||
addNavItem(lt.Get("HelpAboutAyaNova"), "info-circle", "/about");
|
||||
addNavItem(lt.Get("Logout"), "sign-out-alt", "/login");
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -41,8 +41,7 @@ NEXT: Test authorization code to login even if just doing it from code for now t
|
||||
- Test as PWA on all devices
|
||||
|
||||
- Stage 2:
|
||||
- Make it work with the backend:
|
||||
- Login, logout
|
||||
- Make it work with the backend:
|
||||
- Error handling at client (log? display?)
|
||||
- Notification of some kind (bell / toast)
|
||||
- Localized text
|
||||
|
||||
@@ -147,7 +147,10 @@ ICONS = FONTAWESOME 5 (free)
|
||||
https://fontawesome.com/icons?d=gallery&s=regular,solid&m=free
|
||||
|
||||
|
||||
|
||||
UTILITY = LODASH
|
||||
=-=-=-=-=-=-=-=-=-
|
||||
- Using modularized one by one to save build space : https://www.blazemeter.com/blog/the-correct-way-to-import-lodash-libraries-a-benchmark
|
||||
- https://lodash.com/custom-builds
|
||||
|
||||
POTENTIALLY USEFUL VUE / GENERAL COMPONENTS AND PLUGINS
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
|
||||
@@ -1414,5 +1414,8 @@
|
||||
"WorkorderSummaryWorkorderItem": "Workorder Item Info To Display",
|
||||
|
||||
"Modified":"Modified",
|
||||
"Retrieved":"Retrieved"
|
||||
"Retrieved":"Retrieved",
|
||||
"Dispatch":"Dispatch",
|
||||
"Accounting":"Accounting",
|
||||
"Operations":"Ops"
|
||||
}
|
||||
Reference in New Issue
Block a user