2022-09-12 22:18:21 +00:00
|
|
|
import Vue from 'vue';
|
2022-09-12 22:08:34 +00:00
|
|
|
|
|
|
|
|
class OVDashboardPlugin {
|
2022-09-12 22:18:21 +00:00
|
|
|
public install(vue: typeof Vue) {
|
|
|
|
|
vue.prototype.$ovdashboard = this;
|
2022-09-12 22:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-12 22:22:40 +00:00
|
|
|
public api_url(endpoint?: string): string {
|
2022-09-12 22:08:34 +00:00
|
|
|
if (endpoint === undefined)
|
|
|
|
|
return this.api_baseurl;
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
return this.api_baseurl + "/" + endpoint;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default new OVDashboardPlugin();
|