forked from openWB/openwb-ui-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenwbConfigProxy.vue
54 lines (52 loc) · 1.32 KB
/
OpenwbConfigProxy.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<template>
<component
:is="myComponent"
:configuration="configuration"
:deviceId="deviceId"
:deviceType="deviceType"
:componentId="componentId"
:componentType="componentType"
@update:configuration="updateConfiguration($event)"
/>
</template>
<script>
import { defineAsyncComponent } from "vue";
import OpenwbDeviceConfigFallback from "./OpenwbDeviceConfigFallback.vue";
export default {
name: "OpenwbConfigProxy",
emits: ["update:configuration"],
props: {
deviceId: { required: true },
deviceType: { type: String, required: true },
componentId: { default: undefined },
componentType: { type: String, default: undefined },
configuration: { type: Object, required: true },
},
computed: {
myComponent() {
console.debug(
`loading component: ${this.deviceType} / ${this.componentType}`,
);
if (this.componentType !== undefined) {
return defineAsyncComponent({
loader: () =>
import(
`./${this.deviceType}/${this.componentType}.vue`
),
errorComponent: OpenwbDeviceConfigFallback,
});
} else {
return defineAsyncComponent({
loader: () => import(`./${this.deviceType}/device.vue`),
errorComponent: OpenwbDeviceConfigFallback,
});
}
},
},
methods: {
updateConfiguration(event) {
this.$emit("update:configuration", event);
},
},
};
</script>