This commit is contained in:
2018-11-14 23:13:22 +00:00
parent 105c8c9a78
commit 84e776f66e
6 changed files with 34 additions and 6 deletions

View File

@@ -61,6 +61,8 @@ export default {
},
mounted() {
if (!this.$store.state.authenticated) {
// eslint-disable-next-line
console.log("App.vue::page url is:" + this.$route.query.page);
this.$router.replace({ name: "login" });
}
},

View File

@@ -52,6 +52,27 @@ export default {
};
},
APIUrl(apiPath) {
if ("" == store.state.apiUrl) {
//construct the api url and store it
//development location?
if (
window.location.host == "localhost" &&
window.location.port == "8080"
) {
store.commit("setAPIURL", "http://localhost:7575/api/v8.0/");
} else {
//production location <protocol>//<hostname>:<port>/
store.commit(
"setAPIURL",
window.location.protocol +
"//" +
window.location.hostname +
":" +
window.location.port +
"/api/v8.0/"
);
}
}
return store.state.apiUrl + apiPath;
}
};

View File

@@ -1,4 +1,4 @@
/* xeslint-disable */
/* eslint-disable */
import apiUtil from "./apiutil";
import { processLogin, processLogout } from "../utils/authutil";

View File

@@ -8,7 +8,7 @@ export default new Vuex.Store({
plugins: [createPersistedState()],
state: {
authenticated: false,
apiUrl: "http://localhost:7575/api/v8.0/",
apiUrl: "", //http://localhost:7575/api/v8.0/
apiToken: "-",
userId: 0,
roles: 0,
@@ -30,12 +30,16 @@ export default new Vuex.Store({
state.roles = 0;
state.navItems = [];
state.localeText = {};
state.apiUrl = "";
},
addNavItem(state, data) {
state.navItems.push(data);
},
addLocaleText(state, data) {
state.localeText[data.key] = data.value;
},
setAPIURL(state, data) {
state.apiUrl = data;
}
},
actions: {}

View File

@@ -52,6 +52,9 @@ export default {
},
methods: {
login() {
// eslint-disable-next-line
debugger;
//console.log("Login.vue::page url is:" + this.$route.query.page);
if (this.input.username != "" && this.input.password != "") {
auth
.authenticate(this.input.username, this.input.password)

View File

@@ -28,12 +28,10 @@ refs:
WEEK OF 2018-11-12 - RAVEN shell start work. YAY!
// eslint-disable-next-line
NEXT UP / CURRENTLY WORKING ON:
- Look over the (now two) api calls and look for optimization and code shrinkage / de-duplication
- apiurl handling (really only matters for development, there is no scenario yet where it would matter in release)
- if teh current page was loaded from http://localhost:8080/login then apiurl is automatically set to apiUrl:"http://localhost:7575/api/v8.0/"
- otherwise it just uses the current page url fixed up with the api path instead