all over the place with comments and console statements but now properly chains all the calls for login (except translation may have an issue)
This commit is contained in:
@@ -4,24 +4,61 @@ import { processLogin, processLogout } from "./authutil";
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
async authenticate(login, password) {
|
async authenticate(login, password) {
|
||||||
return fetch(
|
return new Promise(async function doAuth(resolve, reject) {
|
||||||
window.$gz.api.APIUrl("auth"),
|
try {
|
||||||
window.$gz.api.fetchPostNoAuthOptions({
|
console.log("AUTH: TOP");
|
||||||
login: login,
|
let fetchData = await fetch(
|
||||||
password: password
|
window.$gz.api.APIUrl("auth"),
|
||||||
})
|
window.$gz.api.fetchPostNoAuthOptions({
|
||||||
)
|
login: login,
|
||||||
.then(window.$gz.api.status)
|
password: password
|
||||||
.then(window.$gz.api.extractBody)
|
})
|
||||||
.then(processLogin)
|
);
|
||||||
.then(() => {
|
console.log("AUTH: status");
|
||||||
return Promise.resolve(true);
|
fetchData = await window.$gz.api.status(fetchData);
|
||||||
}) //succeeded, nothing to return
|
console.log("AUTH: extractBody");
|
||||||
.catch(function handleAuthError(error) {
|
fetchData = await window.$gz.api.extractBody(fetchData);
|
||||||
processLogout();
|
console.log("AUTH: calling processLogin");
|
||||||
return Promise.reject(error);
|
await processLogin(fetchData);
|
||||||
});
|
console.log(
|
||||||
|
"### AUTH:after processlogin completed - resolving done (THIS SHOULD BE LAST)"
|
||||||
|
);
|
||||||
|
resolve();
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
// .catch(function handleAuthError(error) {
|
||||||
|
// processLogout();
|
||||||
|
// return reject(error);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// .then(processLogin)
|
||||||
|
// .then(() => {
|
||||||
|
|
||||||
|
// return resolve(true);
|
||||||
|
// }) //succeeded, nothing to return
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
// async authenticate(login, password) {
|
||||||
|
// return fetch(
|
||||||
|
// window.$gz.api.APIUrl("auth"),
|
||||||
|
// window.$gz.api.fetchPostNoAuthOptions({
|
||||||
|
// login: login,
|
||||||
|
// password: password
|
||||||
|
// })
|
||||||
|
// )
|
||||||
|
// .then(window.$gz.api.status)
|
||||||
|
// .then(window.$gz.api.extractBody)
|
||||||
|
// .then(processLogin)
|
||||||
|
// .then(() => {
|
||||||
|
// console.log("auth:authenticate returning resolved done");
|
||||||
|
// return Promise.resolve(true);
|
||||||
|
// }) //succeeded, nothing to return
|
||||||
|
// .catch(function handleAuthError(error) {
|
||||||
|
// processLogout();
|
||||||
|
// return Promise.reject(error);
|
||||||
|
// });
|
||||||
|
// },
|
||||||
logout() {
|
logout() {
|
||||||
processLogout();
|
processLogout();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,67 +3,101 @@ import decode from "jwt-decode";
|
|||||||
import initialize from "./initialize";
|
import initialize from "./initialize";
|
||||||
|
|
||||||
export function processLogin(response) {
|
export function processLogin(response) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(async function(resolve, reject) {
|
||||||
//check there is a response of some kind
|
try {
|
||||||
if (!response) {
|
console.log("authutil:process login TOP");
|
||||||
window.$gz.store.commit("logItem", "auth::processLogin -> no response");
|
|
||||||
return reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
//is there an error?
|
//check there is a response of some kind
|
||||||
if (response.error) {
|
if (!response) {
|
||||||
return reject(response.error);
|
window.$gz.store.commit("logItem", "auth::processLogin -> no response");
|
||||||
}
|
return reject();
|
||||||
|
}
|
||||||
|
|
||||||
//is token present?
|
//is there an error?
|
||||||
if (!response.data || !response.data.token) {
|
if (response.error) {
|
||||||
window.$gz.store.commit(
|
return reject(response.error);
|
||||||
"logItem",
|
}
|
||||||
"auth::processLogin -> response contains no data"
|
|
||||||
);
|
|
||||||
return reject();
|
|
||||||
}
|
|
||||||
const token = decode(response.data.token);
|
|
||||||
|
|
||||||
if (!token || !token.iss) {
|
//is token present?
|
||||||
window.$gz.store.commit(
|
if (!response.data || !response.data.token) {
|
||||||
"logItem",
|
window.$gz.store.commit(
|
||||||
"auth::processLogin -> response token empty"
|
"logItem",
|
||||||
);
|
"auth::processLogin -> response contains no data"
|
||||||
return reject();
|
);
|
||||||
}
|
return reject();
|
||||||
|
}
|
||||||
|
const token = decode(response.data.token);
|
||||||
|
|
||||||
if (token.iss != "ayanova.com") {
|
if (!token || !token.iss) {
|
||||||
window.$gz.store.commit(
|
window.$gz.store.commit(
|
||||||
"logItem",
|
"logItem",
|
||||||
"auth::processLogin -> token invalid (iss): " + token.iss
|
"auth::processLogin -> response token empty"
|
||||||
);
|
);
|
||||||
return reject();
|
return reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure the store is clean first in case we didn't come here from a clean logout
|
if (token.iss != "ayanova.com") {
|
||||||
window.$gz.store.commit("logout");
|
window.$gz.store.commit(
|
||||||
sessionStorage.clear(); //clear all temporary session storage data
|
"logItem",
|
||||||
|
"auth::processLogin -> token invalid (iss): " + token.iss
|
||||||
|
);
|
||||||
|
return reject();
|
||||||
|
}
|
||||||
|
|
||||||
//Put app relevant items into vuex store so app can use them
|
//ensure the store is clean first in case we didn't come here from a clean logout
|
||||||
window.$gz.store.commit("login", {
|
window.$gz.store.commit("logout");
|
||||||
apiToken: response.data.token,
|
sessionStorage.clear(); //clear all temporary session storage data
|
||||||
authenticated: true,
|
|
||||||
userId: Number(token.id),
|
|
||||||
userName: response.data.name,
|
|
||||||
roles: response.data.roles,
|
|
||||||
userType: response.data.usertype,
|
|
||||||
dlt: response.data.dlt
|
|
||||||
});
|
|
||||||
|
|
||||||
//Initialize the application
|
//Put app relevant items into vuex store so app can use them
|
||||||
initialize().then(() => {
|
window.$gz.store.commit("login", {
|
||||||
|
apiToken: response.data.token,
|
||||||
|
authenticated: true,
|
||||||
|
userId: Number(token.id),
|
||||||
|
userName: response.data.name,
|
||||||
|
roles: response.data.roles,
|
||||||
|
userType: response.data.usertype,
|
||||||
|
dlt: response.data.dlt
|
||||||
|
});
|
||||||
|
//log the login
|
||||||
window.$gz.store.commit(
|
window.$gz.store.commit(
|
||||||
"logItem",
|
"logItem",
|
||||||
"auth::processLogin -> User " + token.id + " logged in"
|
"auth::processLogin -> User " + token.id + " logged in"
|
||||||
);
|
);
|
||||||
resolve(true);
|
|
||||||
});
|
//Get global settings
|
||||||
|
console.log("authutil:calling get blobal settings");
|
||||||
|
let gsets = await window.$gz.api.get("global-biz-setting/client");
|
||||||
|
console.log("authutil:got global settings");
|
||||||
|
|
||||||
|
if (gsets.error) {
|
||||||
|
//In a form this would trigger a bunch of validation or error display code but for here and now:
|
||||||
|
//convert error to human readable string for display and popup a notification to user
|
||||||
|
let msg = window.$gz.api.apiErrorToHumanString(gsets.error);
|
||||||
|
window.$gz.store.commit(
|
||||||
|
"logItem",
|
||||||
|
"Initialize::() fetch global-biz-setting/client -> error" + msg
|
||||||
|
);
|
||||||
|
window.$gz.eventBus.$emit("notify-error", msg);
|
||||||
|
} else {
|
||||||
|
//Check if overrides and use them here
|
||||||
|
//or else use browser defaults
|
||||||
|
window.$gz.store.commit("setGlobalSettings", gsets.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("** authutil calling test delay --->>>>");
|
||||||
|
await window.$gz.api.doDelayAsync();
|
||||||
|
console.log("** authutil back from delay continuing..");
|
||||||
|
|
||||||
|
//INITIALIZE
|
||||||
|
console.log("authutil:calling initialize");
|
||||||
|
await initialize();
|
||||||
|
} catch (err) {
|
||||||
|
console.log("authutil:error in async chain global/init");
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
console.log("authutil:no error resolving async chain global/init");
|
||||||
|
resolve();
|
||||||
|
//-------------------------------------------------
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default {
|
|||||||
if (!window.$gz._.has(window.$gz.store.state.enums, k)) {
|
if (!window.$gz._.has(window.$gz.store.state.enums, k)) {
|
||||||
let that = this;
|
let that = this;
|
||||||
|
|
||||||
await that.fetch(k).then(dat => {
|
await that.fetchEnumKey(k).then(dat => {
|
||||||
//massage the data as necessary
|
//massage the data as necessary
|
||||||
let e = { enumKey: k, items: {} };
|
let e = { enumKey: k, items: {} };
|
||||||
for (let i = 0; i < dat.length; i++) {
|
for (let i = 0; i < dat.length; i++) {
|
||||||
@@ -56,7 +56,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fetch(enumKey) {
|
fetchEnumKey(enumKey) {
|
||||||
return window.$gz.api.get("enum-list/list/" + enumKey).then(res => {
|
return window.$gz.api.get("enum-list/list/" + enumKey).then(res => {
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
throw res.error;
|
throw res.error;
|
||||||
|
|||||||
@@ -150,6 +150,63 @@ export default {
|
|||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
statusEx(response) {
|
||||||
|
//Handle expected api errors
|
||||||
|
if (response.status == 401) {
|
||||||
|
//must reject if not Authenticated
|
||||||
|
throw new Error("[ErrorUserNotAuthenticated]");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.status == 403) {
|
||||||
|
//must reject if not Authorized
|
||||||
|
throw new Error("[ErrorUserNotAuthorized]");
|
||||||
|
}
|
||||||
|
|
||||||
|
//404 not found is an expected status not worth logging allow to bubble up
|
||||||
|
//for client code to deal with
|
||||||
|
if (response.status == 404) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.status == 405) {
|
||||||
|
//Probably a development error
|
||||||
|
|
||||||
|
throw new Error("Method Not Allowed (route issue?) " + response.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.status >= 200 && response.status < 300) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
//log unhandled api error
|
||||||
|
window.$gz.store.commit(
|
||||||
|
"logItem",
|
||||||
|
"API error: status=" +
|
||||||
|
response.status +
|
||||||
|
", statusText=" +
|
||||||
|
response.statusText +
|
||||||
|
", url=" +
|
||||||
|
response.url
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async extractBodyEx(response) {
|
||||||
|
if (response.status == 204) {
|
||||||
|
//no content, nothing to process
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
let contentType = response.headers.get("content-type");
|
||||||
|
if (!contentType) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
//console.log("gzapi::extractBody method, content type is:", contentType);
|
||||||
|
if (contentType.includes("json")) {
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
if (contentType.includes("text/plain")) {
|
||||||
|
return await response.text();
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
},
|
||||||
extractBody(response) {
|
extractBody(response) {
|
||||||
if (response.status == 204) {
|
if (response.status == 204) {
|
||||||
//no content, nothing to process
|
//no content, nothing to process
|
||||||
@@ -372,9 +429,58 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
//////////////////////////////////////
|
||||||
|
// Test delay for troubleshooting
|
||||||
|
//
|
||||||
|
doDelayAsync: () => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(() => resolve("I did something"), 10000);
|
||||||
|
});
|
||||||
|
},
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
// POST / PUT DATA TO API SERVER
|
// POST / PUT DATA TO API SERVER
|
||||||
//
|
//
|
||||||
|
async upsertEx(route, data) {
|
||||||
|
try {
|
||||||
|
console.log("gzapi:upsertEx TOP");
|
||||||
|
let that = this;
|
||||||
|
// return new Promise(function upsertDataToServer(resolve, reject) {
|
||||||
|
//determine if this is a new or existing record
|
||||||
|
let fetchOptions = undefined;
|
||||||
|
if (data.concurrency) {
|
||||||
|
//has concurrency token, so this is a PUT as it's updating an existing record
|
||||||
|
fetchOptions = that.fetchPutOptions(data);
|
||||||
|
} else {
|
||||||
|
//Does not have a concurrency token so this is a POST as it's posting a new record without a concurrency token
|
||||||
|
fetchOptions = that.fetchPostOptions(data);
|
||||||
|
//ensure the route doesn't end in /0 which will happen if it's a new record since the edit forms just send the url here with the ID regardless
|
||||||
|
if (window.$gz._.endsWith(route, "/0")) {
|
||||||
|
route = route.slice(0, -2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// console.log("** gzapi:upsertEx calling test delay");
|
||||||
|
// await this.doDelayAsync();
|
||||||
|
// console.log("** gzapi:upsertEx back from delay continuing..");
|
||||||
|
console.log("gzapi:upsertEx calling fetch");
|
||||||
|
let r = await fetch(that.APIUrl(route), fetchOptions);
|
||||||
|
console.log("gzapi:upsertEx calling statusEx");
|
||||||
|
that.statusEx(r);
|
||||||
|
console.log("gzapi:upsertEx calling extractBodyEx");
|
||||||
|
r = await that.extractBodyEx(r);
|
||||||
|
console.log("gzapi:upsertEx done, returning response");
|
||||||
|
return r;
|
||||||
|
// eslint-disable-next-line
|
||||||
|
// .then((response) => {
|
||||||
|
// //Note: response.error indicates there is an error, however this is not an unusual condition
|
||||||
|
// //it could be validation errors or other general error so we need to treat it here like it's normal
|
||||||
|
// //and let the caller deal with it appropriately
|
||||||
|
// resolve(response);
|
||||||
|
// })
|
||||||
|
} catch (error) {
|
||||||
|
handleError("UPSERT", error, route, reject);
|
||||||
|
}
|
||||||
|
// });
|
||||||
|
},
|
||||||
upsert(route, data) {
|
upsert(route, data) {
|
||||||
let that = this;
|
let that = this;
|
||||||
return new Promise(function upsertDataToServer(resolve, reject) {
|
return new Promise(function upsertDataToServer(resolve, reject) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -11,8 +11,8 @@ export default {
|
|||||||
}
|
}
|
||||||
return window.$gz.store.state.translationText[key];
|
return window.$gz.store.state.translationText[key];
|
||||||
},
|
},
|
||||||
fetch(keys) {
|
async cacheTranslations(keys) {
|
||||||
return new Promise(function fetchTranslationKeysFromServer(resolve) {
|
return new Promise(async function fetchTranslationKeysFromServer(resolve) {
|
||||||
//
|
//
|
||||||
//step 1: build an array of keys that we don't have already
|
//step 1: build an array of keys that we don't have already
|
||||||
//Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen
|
//Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen
|
||||||
@@ -27,29 +27,74 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (needIt.length == 0) {
|
if (needIt.length == 0) {
|
||||||
resolve();
|
return resolve();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//step 2: get it
|
//step 2: get it
|
||||||
fetch(
|
console.log("translation:cacheTranslations calling fetch via API");
|
||||||
|
let testres = await window.$gz.api.upsertEx("translation/subset", needIt);
|
||||||
|
console.log(testres);
|
||||||
|
|
||||||
|
|
||||||
|
console.log("translation:cacheTranslations calling fetch directly");
|
||||||
|
let response = await fetch(
|
||||||
window.$gz.api.APIUrl("translation/subset"),
|
window.$gz.api.APIUrl("translation/subset"),
|
||||||
window.$gz.api.fetchPostOptions(needIt)
|
window.$gz.api.fetchPostOptions(needIt)
|
||||||
)
|
);
|
||||||
.then(window.$gz.api.status)
|
|
||||||
.then(window.$gz.api.extractBody)
|
console.log("translation:fetch calling STATUS");
|
||||||
// eslint-disable-next-line
|
|
||||||
.then((response) => {
|
let data = await window.$gz.api.status(response);
|
||||||
window.$gz._.forEach(
|
console.log("translation:fetch calling extractBody");
|
||||||
response.data,
|
let data2 = await window.$gz.api.extractBody(data);
|
||||||
function commitFetchedLTItemToStore(item) {
|
console.log("translation:fetch calling processing into store");
|
||||||
window.$gz.store.commit("addTranslationText", item);
|
window.$gz._.forEach(data2, function commitFetchedLTItemToStore(item) {
|
||||||
}
|
window.$gz.store.commit("addTranslationText", item);
|
||||||
);
|
});
|
||||||
resolve();
|
console.log("translation:fetch done calling resolve");
|
||||||
});
|
return resolve();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// fetch(keys) {
|
||||||
|
// return new Promise(async function fetchTranslationKeysFromServer(resolve) {
|
||||||
|
// //
|
||||||
|
// //step 1: build an array of keys that we don't have already
|
||||||
|
// //Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen
|
||||||
|
// //for example datatables have dynamic column names so they need to fetch on demand
|
||||||
|
// let needIt = [];
|
||||||
|
// for (let i = 0; i < keys.length; i++) {
|
||||||
|
// if (
|
||||||
|
// !window.$gz._.has(window.$gz.store.state.translationText, keys[i])
|
||||||
|
// ) {
|
||||||
|
// needIt.push(keys[i]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (needIt.length == 0) {
|
||||||
|
// resolve();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //step 2: get it
|
||||||
|
// await fetch(
|
||||||
|
// window.$gz.api.APIUrl("translation/subset"),
|
||||||
|
// window.$gz.api.fetchPostOptions(needIt)
|
||||||
|
// )
|
||||||
|
// .then(window.$gz.api.status)
|
||||||
|
// .then(window.$gz.api.extractBody)
|
||||||
|
// // eslint-disable-next-line
|
||||||
|
// .then((response) => {
|
||||||
|
// window.$gz._.forEach(
|
||||||
|
// response.data,
|
||||||
|
// function commitFetchedLTItemToStore(item) {
|
||||||
|
// window.$gz.store.commit("addTranslationText", item);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// console.log("translation:fetch calling resolve");
|
||||||
|
// resolve();
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// },
|
||||||
//Keys that will always be required for any AyaNova work for any user
|
//Keys that will always be required for any AyaNova work for any user
|
||||||
coreKeys: [
|
coreKeys: [
|
||||||
//main nav options
|
//main nav options
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ async function fetchTranslatedHeaderNames(columnData) {
|
|||||||
headerKeys.push(cm.cm);
|
headerKeys.push(cm.cm);
|
||||||
}
|
}
|
||||||
//Now fetch all the keys and await the response before returning
|
//Now fetch all the keys and await the response before returning
|
||||||
await window.$gz.translation.fetch(headerKeys).then(() => {
|
await window.$gz.translation.cacheTranslations(headerKeys).then(() => {
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,48 +112,48 @@ Vue.config.productionTip = false;
|
|||||||
// AJAX LOADER INDICATOR
|
// AJAX LOADER INDICATOR
|
||||||
//
|
//
|
||||||
// Store a copy of the fetch function
|
// Store a copy of the fetch function
|
||||||
let _oldFetch = fetch;
|
// let _oldFetch = fetch;
|
||||||
|
|
||||||
// Create our new version of the fetch function
|
// // Create our new version of the fetch function
|
||||||
window.fetch = function() {
|
// window.fetch = function() {
|
||||||
// Create hooks
|
// // Create hooks
|
||||||
let fetchStart = new Event("fetchStart", {
|
// let fetchStart = new Event("fetchStart", {
|
||||||
view: document,
|
// view: document,
|
||||||
bubbles: true,
|
// bubbles: true,
|
||||||
cancelable: false
|
// cancelable: false
|
||||||
});
|
// });
|
||||||
let fetchEnd = new Event("fetchEnd", {
|
// let fetchEnd = new Event("fetchEnd", {
|
||||||
view: document,
|
// view: document,
|
||||||
bubbles: true,
|
// bubbles: true,
|
||||||
cancelable: false
|
// cancelable: false
|
||||||
});
|
// });
|
||||||
|
|
||||||
// Pass the supplied arguments to the real fetch function
|
// // Pass the supplied arguments to the real fetch function
|
||||||
let fetchCall = _oldFetch.apply(this, arguments);
|
// let fetchCall = _oldFetch.apply(this, arguments);
|
||||||
|
|
||||||
// Trigger the fetchStart event
|
// // Trigger the fetchStart event
|
||||||
document.dispatchEvent(fetchStart);
|
// document.dispatchEvent(fetchStart);
|
||||||
|
|
||||||
fetchCall
|
// fetchCall
|
||||||
.then(function() {
|
// .then(function() {
|
||||||
// Trigger the fetchEnd event
|
// // Trigger the fetchEnd event
|
||||||
document.dispatchEvent(fetchEnd);
|
// document.dispatchEvent(fetchEnd);
|
||||||
})
|
// })
|
||||||
.catch(function() {
|
// .catch(function() {
|
||||||
// Trigger the fetchEnd event
|
// // Trigger the fetchEnd event
|
||||||
document.dispatchEvent(fetchEnd);
|
// document.dispatchEvent(fetchEnd);
|
||||||
});
|
// });
|
||||||
|
|
||||||
return fetchCall;
|
// return fetchCall;
|
||||||
};
|
// };
|
||||||
|
|
||||||
document.addEventListener("fetchStart", function() {
|
// document.addEventListener("fetchStart", function() {
|
||||||
NProgress.start();
|
// NProgress.start();
|
||||||
});
|
// });
|
||||||
|
|
||||||
document.addEventListener("fetchEnd", function() {
|
// document.addEventListener("fetchEnd", function() {
|
||||||
NProgress.done();
|
// NProgress.done();
|
||||||
});
|
// });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// FILTERS
|
// FILTERS
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ export default {
|
|||||||
for (let i = 0; i < res.data.length; i++) {
|
for (let i = 0; i < res.data.length; i++) {
|
||||||
vm.fieldKeys.push(res.data[i].tKey);
|
vm.fieldKeys.push(res.data[i].tKey);
|
||||||
}
|
}
|
||||||
return window.$gz.translation.fetch(vm.fieldKeys);
|
return window.$gz.translation.cacheTranslations(vm.fieldKeys);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
@@ -460,7 +460,7 @@ function initForm(vm) {
|
|||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
let tKeysRequired = ["Include", "ResetToDefault"];
|
let tKeysRequired = ["Include", "ResetToDefault"];
|
||||||
|
|
||||||
return window.$gz.translation.fetch(tKeysRequired);
|
return window.$gz.translation.cacheTranslations(tKeysRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ function initForm(vm) {
|
|||||||
// Ensures UI translated text is available
|
// Ensures UI translated text is available
|
||||||
//
|
//
|
||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
return window.$gz.translation.fetch([
|
return window.$gz.translation.cacheTranslations([
|
||||||
"UserInterfaceSettings",
|
"UserInterfaceSettings",
|
||||||
"PickListTemplates"
|
"PickListTemplates"
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ function fetchTranslatedText(vm) {
|
|||||||
"CurrencyCode"
|
"CurrencyCode"
|
||||||
];
|
];
|
||||||
|
|
||||||
return window.$gz.translation.fetch(tKeysRequired);
|
return window.$gz.translation.cacheTranslations(tKeysRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ function fetchTranslatedText(vm) {
|
|||||||
"UiFieldDataTypesTrueFalse"
|
"UiFieldDataTypesTrueFalse"
|
||||||
];
|
];
|
||||||
|
|
||||||
return window.$gz.translation.fetch(tKeysRequired);
|
return window.$gz.translation.cacheTranslations(tKeysRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
@@ -1006,7 +1006,7 @@ function fetchTranslatedText(vm) {
|
|||||||
"Name"
|
"Name"
|
||||||
];
|
];
|
||||||
|
|
||||||
return window.$gz.translation.fetch(tKeysRequired);
|
return window.$gz.translation.cacheTranslations(tKeysRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@@ -1182,7 +1182,7 @@ function fetchTranslatedFieldNames(vm) {
|
|||||||
columnKeys.push(cm.tKey);
|
columnKeys.push(cm.tKey);
|
||||||
}
|
}
|
||||||
//Now fetch all the keys and await the response before returning
|
//Now fetch all the keys and await the response before returning
|
||||||
return window.$gz.translation.fetch(columnKeys).then(() => {
|
return window.$gz.translation.cacheTranslations(columnKeys).then(() => {
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ function populateEventTypeList(vm) {
|
|||||||
// Ensures UI translated text is available
|
// Ensures UI translated text is available
|
||||||
//
|
//
|
||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
return window.$gz.translation.fetch([
|
return window.$gz.translation.cacheTranslations([
|
||||||
"EventDeleted",
|
"EventDeleted",
|
||||||
"EventCreated",
|
"EventCreated",
|
||||||
"EventRetrieved",
|
"EventRetrieved",
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ function initForm(vm) {
|
|||||||
// Ensures UI translated text is available
|
// Ensures UI translated text is available
|
||||||
//
|
//
|
||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
return window.$gz.translation.fetch([
|
return window.$gz.translation.cacheTranslations([
|
||||||
"UserLogin",
|
"UserLogin",
|
||||||
"OldPassword",
|
"OldPassword",
|
||||||
"NewPassword",
|
"NewPassword",
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ function initForm(vm) {
|
|||||||
// Ensures UI translated text is available
|
// Ensures UI translated text is available
|
||||||
//
|
//
|
||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
return window.$gz.translation.fetch([
|
return window.$gz.translation.cacheTranslations([
|
||||||
"TooManyResults",
|
"TooManyResults",
|
||||||
"NoResults",
|
"NoResults",
|
||||||
"Object"
|
"Object"
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ function initForm(vm) {
|
|||||||
// Ensures UI translated text is available
|
// Ensures UI translated text is available
|
||||||
//
|
//
|
||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
return window.$gz.translation.fetch([
|
return window.$gz.translation.cacheTranslations([
|
||||||
"CurrencyCode",
|
"CurrencyCode",
|
||||||
"LanguageCode",
|
"LanguageCode",
|
||||||
"TimeZone",
|
"TimeZone",
|
||||||
|
|||||||
@@ -256,14 +256,16 @@ export default {
|
|||||||
let vm = this;
|
let vm = this;
|
||||||
if (vm.input.username != "" && vm.input.password != "") {
|
if (vm.input.username != "" && vm.input.password != "") {
|
||||||
vm.errorBadCreds = false;
|
vm.errorBadCreds = false;
|
||||||
|
|
||||||
auth
|
auth
|
||||||
.authenticate(vm.input.username, vm.input.password)
|
.authenticate(vm.input.username, vm.input.password)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
console.log("LOGIN:BACKFROMAUTHENTICATE");
|
||||||
if (vm.$store.state.openObject != null) {
|
if (vm.$store.state.openObject != null) {
|
||||||
window.$gz.eventBus.$emit("openobject", null);
|
window.$gz.eventBus.$emit("openobject", null);
|
||||||
} else {
|
} else {
|
||||||
vm.$router.push(vm.$store.state.homePage);
|
if (!vm.$store.state.homePage) {
|
||||||
|
console.log("####LOGIN END BUT homePage is empty!");
|
||||||
|
} else vm.$router.push(vm.$store.state.homePage);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function handleCaughtLoginError(error) {
|
.catch(function handleCaughtLoginError(error) {
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ function initForm(vm) {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
return window.$gz.translation.fetch([
|
return window.$gz.translation.cacheTranslations([
|
||||||
"BackupSettings",
|
"BackupSettings",
|
||||||
"BackupTime",
|
"BackupTime",
|
||||||
"BackupLast",
|
"BackupLast",
|
||||||
|
|||||||
@@ -260,6 +260,6 @@ function initForm(vm) {
|
|||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
let tKeysRequired = ["OpsTestJob"];
|
let tKeysRequired = ["OpsTestJob"];
|
||||||
|
|
||||||
return window.$gz.translation.fetch(tKeysRequired);
|
return window.$gz.translation.cacheTranslations(tKeysRequired);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ function initForm(vm) {
|
|||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
let tKeysRequired = ["OpsTestJob", "Log"];
|
let tKeysRequired = ["OpsTestJob", "Log"];
|
||||||
|
|
||||||
return window.$gz.translation.fetch(tKeysRequired);
|
return window.$gz.translation.cacheTranslations(tKeysRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|||||||
@@ -565,6 +565,6 @@ function fetchTranslatedText(vm) {
|
|||||||
"MetricPrivateBytes"
|
"MetricPrivateBytes"
|
||||||
];
|
];
|
||||||
|
|
||||||
return window.$gz.translation.fetch(tKeysRequired);
|
return window.$gz.translation.cacheTranslations(tKeysRequired);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -152,6 +152,6 @@ function initForm(vm) {
|
|||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
let tKeysRequired = ["ServerProfiler"];
|
let tKeysRequired = ["ServerProfiler"];
|
||||||
|
|
||||||
return window.$gz.translation.fetch(tKeysRequired);
|
return window.$gz.translation.cacheTranslations(tKeysRequired);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ function initForm(vm) {
|
|||||||
// Ensures UI translated text is available
|
// Ensures UI translated text is available
|
||||||
//
|
//
|
||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
return window.$gz.translation.fetch([
|
return window.$gz.translation.cacheTranslations([
|
||||||
"ServerStateOpen",
|
"ServerStateOpen",
|
||||||
"ServerStateOps",
|
"ServerStateOps",
|
||||||
"ServerStateReason"
|
"ServerStateReason"
|
||||||
|
|||||||
@@ -756,7 +756,7 @@ function initForm(vm) {
|
|||||||
// Ensures UI translated text is available
|
// Ensures UI translated text is available
|
||||||
//
|
//
|
||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
return window.$gz.translation.fetch([
|
return window.$gz.translation.cacheTranslations([
|
||||||
"Widget",
|
"Widget",
|
||||||
"WidgetName",
|
"WidgetName",
|
||||||
"WidgetSerial",
|
"WidgetSerial",
|
||||||
|
|||||||
Reference in New Issue
Block a user