ovdashboard/ui/src/plugins/ovdashboard.ts

31 lines
696 B
TypeScript
Raw Normal View History

2022-09-12 22:18:21 +00:00
import Vue from 'vue';
class OVDashboardPlugin {
2022-09-12 22:18:21 +00:00
public install(vue: typeof Vue) {
vue.prototype.$ovdashboard = this;
}
private get api_baseurl(): string {
if (process.env.NODE_ENV === "production") {
return "//" + window.location.host + "/api/v1";
} else {
if (process.env.NODE_ENV !== "development") {
console.warn("Unexpected NODE_ENV value");
}
return "//" + window.location.hostname + ":8000/api/v1";
}
}
public api_url(endpoint: string | undefined): string {
if (endpoint === undefined)
return this.api_baseurl;
else
return this.api_baseurl + "/" + endpoint;
}
}
export default new OVDashboardPlugin();