2021-09-15 05:40:26 -07:00
|
|
|
import axios from "axios";
|
2023-07-16 23:54:40 -07:00
|
|
|
import { getDevContainerServerHostname, isDevContainer } from "../util-frontend";
|
2021-09-15 05:40:26 -07:00
|
|
|
|
|
|
|
const env = process.env.NODE_ENV || "production";
|
|
|
|
|
|
|
|
// change the axios base url for development
|
2023-07-16 23:54:40 -07:00
|
|
|
if (env === "development" && isDevContainer()) {
|
|
|
|
axios.defaults.baseURL = location.protocol + "//" + getDevContainerServerHostname();
|
|
|
|
} else if (env === "development" || localStorage.dev === "dev") {
|
2021-09-15 05:40:26 -07:00
|
|
|
axios.defaults.baseURL = location.protocol + "//" + location.hostname + ":3001";
|
|
|
|
}
|
|
|
|
|
2021-09-13 04:21:39 -07:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
publicGroupList: [],
|
2021-09-19 04:04:51 -07:00
|
|
|
};
|
2021-09-13 23:12:27 -07:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
publicMonitorList() {
|
|
|
|
let result = {};
|
|
|
|
|
|
|
|
for (let group of this.publicGroupList) {
|
|
|
|
for (let monitor of group.monitorList) {
|
|
|
|
result[monitor.id] = monitor;
|
|
|
|
}
|
|
|
|
}
|
2021-09-16 07:48:28 -07:00
|
|
|
return result;
|
|
|
|
},
|
|
|
|
|
|
|
|
publicLastHeartbeatList() {
|
2021-09-19 04:04:51 -07:00
|
|
|
let result = {};
|
2021-09-16 07:48:28 -07:00
|
|
|
|
|
|
|
for (let monitorID in this.publicMonitorList) {
|
|
|
|
if (this.lastHeartbeatList[monitorID]) {
|
|
|
|
result[monitorID] = this.lastHeartbeatList[monitorID];
|
|
|
|
}
|
|
|
|
}
|
2021-09-13 23:12:27 -07:00
|
|
|
|
|
|
|
return result;
|
2021-09-16 07:48:28 -07:00
|
|
|
},
|
2021-09-30 09:09:43 -07:00
|
|
|
|
|
|
|
baseURL() {
|
2021-10-08 05:03:52 -07:00
|
|
|
if (this.$root.info.primaryBaseURL) {
|
|
|
|
return this.$root.info.primaryBaseURL;
|
|
|
|
}
|
|
|
|
|
2021-09-30 09:09:43 -07:00
|
|
|
if (env === "development" || localStorage.dev === "dev") {
|
|
|
|
return axios.defaults.baseURL;
|
|
|
|
} else {
|
|
|
|
return location.protocol + "//" + location.host;
|
|
|
|
}
|
2021-10-08 05:03:52 -07:00
|
|
|
},
|
2021-09-13 04:21:39 -07:00
|
|
|
}
|
2021-09-19 04:04:51 -07:00
|
|
|
};
|