-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow model cards and model tabs outside of homepage (#2584)
Fixes #2583. Fixes #1591. This moves model loading code to a new Vuex store module named model. Model loading is now done by app.vue on init and when an Item change event is received through SSE. home.vue and home-edit.vue now get the model from the Vuex store instead of loading it. Add tab components for locations-tab, equipment-tab and properties-tab for easy usage in tabbed pages. Add card components for oh-.location-card, oh-equipment-card and oh-property-card to standard widget list. --------- Also-by: Florian Hotze <florianh_dev@icloud.com> Signed-off-by: Thomas Wunschel <4302898+wuschi@users.noreply.github.com>
- Loading branch information
Showing
24 changed files
with
409 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
bundles/org.openhab.ui/web/src/components/tabs/equipment-tab.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<model-tab type="equipment" :page="context" /> | ||
</template> | ||
|
||
<script> | ||
import ModelTab from '@/pages/home/model-tab.vue' | ||
export default { | ||
props: ['context'], | ||
components: { ModelTab } | ||
} | ||
</script> |
12 changes: 12 additions & 0 deletions
12
bundles/org.openhab.ui/web/src/components/tabs/locations-tab.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<model-tab type="locations" :page="context" /> | ||
</template> | ||
|
||
<script> | ||
import ModelTab from '@/pages/home/model-tab.vue' | ||
export default { | ||
props: ['context'], | ||
components: { ModelTab } | ||
} | ||
</script> |
12 changes: 12 additions & 0 deletions
12
bundles/org.openhab.ui/web/src/components/tabs/properties-tab.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<model-tab type="properties" :page="context" /> | ||
</template> | ||
|
||
<script> | ||
import ModelTab from '@/pages/home/model-tab.vue' | ||
export default { | ||
props: ['context'], | ||
components: { ModelTab } | ||
} | ||
</script> |
3 changes: 3 additions & 0 deletions
3
bundles/org.openhab.ui/web/src/components/widgets/standard/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
bundles/org.openhab.ui/web/src/components/widgets/standard/oh-equipment-card.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<template> | ||
<equipment-card :element="element" :context="context" :tab-context="config" /> | ||
</template> | ||
|
||
<script> | ||
import mixin from '../widget-mixin' | ||
import store from '@/js/store' | ||
import { OhEquipmentCardParameters } from '@/assets/definitions/widgets/home' | ||
import EquipmentCard from '@/components/cards/equipment-card.vue' | ||
export default { | ||
components: { EquipmentCard }, | ||
mixins: [mixin], | ||
computed: { | ||
element () { | ||
return this.$store.getters.semanticModelElement(this.config.item, 'equipment') || | ||
{ defaultTitle: 'Equipment Card', item: { equipment: [], metadata: { semantics: { value: '' } } }, equipment: [], properties: [] } | ||
} | ||
}, | ||
widget: () => { | ||
const widget = OhEquipmentCardParameters() | ||
widget.props.parameters.find(p => p.name === 'item').options = store.state.semantics.Equipment.map(p => { return { name: p, label: store.state.semantics.Labels[p] } }) | ||
return widget | ||
} | ||
} | ||
</script> |
24 changes: 24 additions & 0 deletions
24
bundles/org.openhab.ui/web/src/components/widgets/standard/oh-location-card.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<template> | ||
<location-card :element="element" :context="context" :tab-context="config" :parent-location="parentLocationName" /> | ||
</template> | ||
|
||
<script> | ||
import LocationCard from '@/components/cards/location-card.vue' | ||
import mixin from '../widget-mixin' | ||
import { OhLocationCardParameters } from '@/assets/definitions/widgets/home' | ||
export default { | ||
components: { LocationCard }, | ||
mixins: [mixin], | ||
computed: { | ||
element () { | ||
return this.$store.getters.semanticModelElement(this.config.item, 'location') || | ||
{ defaultTitle: 'Location Card', item: { equipment: [], metadata: { semantics: { value: '' } } }, equipment: [], properties: [] } | ||
}, | ||
parentLocationName () { | ||
return this.element && this.element.parent ? this.element.parent.label || this.element.parent.name : '' | ||
} | ||
}, | ||
widget: OhLocationCardParameters | ||
} | ||
</script> |
26 changes: 26 additions & 0 deletions
26
bundles/org.openhab.ui/web/src/components/widgets/standard/oh-property-card.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<template> | ||
<property-card :element="element" :context="context" :tab-context="config" /> | ||
</template> | ||
|
||
<script> | ||
import mixin from '../widget-mixin' | ||
import store from '@/js/store' | ||
import { OhPropertyCardParameters } from '@/assets/definitions/widgets/home' | ||
import PropertyCard from '@/components/cards/property-card.vue' | ||
export default { | ||
components: { PropertyCard }, | ||
mixins: [mixin], | ||
computed: { | ||
element () { | ||
return this.$store.getters.semanticModelElement(this.config.item, 'property') || | ||
{ defaultTitle: 'Property Card', item: { equipment: [], metadata: { semantics: { value: '' } } }, equipment: [], properties: [], points: [] } | ||
} | ||
}, | ||
widget: () => { | ||
const widget = OhPropertyCardParameters() | ||
widget.props.parameters.find(p => p.name === 'item').options = store.state.semantics.Properties.map(p => { return { name: p, label: store.state.semantics.Labels[p] } }) | ||
return widget | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.