ovdashboard/ui/src/plugins/ovdashboard.ts

31 lines
698 B
TypeScript
Raw Normal View History

import _Vue from 'vue';
class OVDashboardPlugin {
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();