Skip to content

Commit

Permalink
Semantic model - add search by name and tag
Browse files Browse the repository at this point in the history
Signed-off-by: David Kesl <[email protected]>
  • Loading branch information
Davek145 committed Sep 25, 2023
1 parent 0cc4f27 commit eecf291
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
26 changes: 24 additions & 2 deletions bundles/org.openhab.ui/web/src/components/model/treeview-item.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<f7-treeview-item selectable :label="(model.item.created === false) ? '(New Item)' : (model.item.label || model.item.name)"
<f7-treeview-item selectable :label="(model.item.created === false) ? '(New Item)' : ((model.item.label) ? ((includeItemName) ? model.item.label + ' (' + model.item.name + ')' : model.item.label) : model.item.name)"
:icon-ios="icon('ios')" :icon-aurora="icon('aurora')" :icon-md="icon('md')"
:textColor="iconColor" :color="(model.item.created !== false) ? 'blue' :'orange'"
:selected="selected && selected.item.name === model.item.name"
Expand All @@ -12,9 +12,18 @@
:model="node"
@selected="(event) => $emit('selected', event)"
:selected="selected"
:includeItemName="includeItemName" :includeItemTags="includeItemTags"
@checked="(item, check) => $emit('checked', item, check)" />
<div slot="label" class="semantic-class">
{{ className() }}
<div class="semantic-class chip" v-if="includeItemTags" v-for="tag in getNonSemanticTags(model.item)" :key="tag" style="height: 16px; margin-left: 4px">

Check failure on line 19 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / checks

This 'v-if' should be moved to the wrapper element

Check failure on line 19 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / webpack-stats

This 'v-if' should be moved to the wrapper element
<div class="chip-media bg-color-blue" style="height: 16px; width: 16px">

Check failure on line 20 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / checks

Expected indentation of 8 spaces but found 10 spaces

Check failure on line 20 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / webpack-stats

Expected indentation of 8 spaces but found 10 spaces
<f7-icon slot="media" ios="f7:tag_fill" md="material:label" aurora="f7:tag_fill" style="font-size: 8px; height: 16px; line-height: 16px" />

Check failure on line 21 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / checks

Expected indentation of 10 spaces but found 12 spaces

Check failure on line 21 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / webpack-stats

Expected indentation of 10 spaces but found 12 spaces
</div>

Check failure on line 22 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / checks

Expected indentation of 8 spaces but found 10 spaces

Check failure on line 22 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / webpack-stats

Expected indentation of 8 spaces but found 10 spaces
<div class="chip-label" style="height: 16px; line-height: 16px">

Check failure on line 23 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / checks

Expected indentation of 8 spaces but found 10 spaces

Check failure on line 23 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / webpack-stats

Expected indentation of 8 spaces but found 10 spaces
{{ tag }}

Check failure on line 24 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / checks

Expected indentation of 10 spaces but found 12 spaces

Check failure on line 24 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / webpack-stats

Expected indentation of 10 spaces but found 12 spaces
</div>

Check failure on line 25 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / checks

Expected indentation of 8 spaces but found 10 spaces

Check failure on line 25 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / webpack-stats

Expected indentation of 8 spaces but found 10 spaces
</div>
</div>
<f7-checkbox slot="content-start" v-if="model.checkable"
:checked="model.checked === true" :disabled="model.disabled" @change="check" />
Expand All @@ -23,7 +32,7 @@

<script>
export default {
props: ['model', 'selected'],
props: ['model', 'selected', 'includeItemName', 'includeItemTags'],
computed: {
children () {
return [this.model.children.locations,
Expand Down Expand Up @@ -68,6 +77,19 @@ export default {
if (this.model.disabled) return
this.model.checked = event.target.checked
this.$emit('checked', this.model, event.target.checked)
},
getNonSemanticTags (item) {
let tagsNonS = []
if (item.tags) {
tagsNonS = item.tags
if (item.metadata && item.metadata.semantics) {
tagsNonS = item.tags.filter((t) =>
t !== item.metadata.semantics.value.split('_').pop() &&
t !== ((item.metadata.semantics.config && item.metadata.semantics.config.relatesTo) ? item.metadata.semantics.config.relatesTo.split('_').pop() : '')
)

Check failure on line 89 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / checks

Expected indentation of 10 spaces but found 12

Check failure on line 89 in bundles/org.openhab.ui/web/src/components/model/treeview-item.vue

View workflow job for this annotation

GitHub Actions / webpack-stats

Expected indentation of 10 spaces but found 12
}
}
return tagsNonS
}
}
}
Expand Down
37 changes: 35 additions & 2 deletions bundles/org.openhab.ui/web/src/pages/settings/model/model.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,35 @@
:disable-button="!$theme.aurora" />
</f7-subnavbar>
</f7-navbar>
<f7-toolbar bottom class="toolbar-details">
<f7-toolbar bottom class="toolbar-details" v-if="!(this.$theme.ios || this.$theme.md)">
<f7-link :disabled="selectedItem != null" class="left" @click="selectedItem = null">
Clear
</f7-link>
<div class="padding-right text-align-right">
<f7-checkbox :checked="includeNonSemantic" @change="toggleNonSemantic" />
<label @click="toggleNonSemantic" class="advanced-label">Show non-semantic</label>
<f7-checkbox style="margin-left: 5px" :checked="includeItemName" @change="toggleItemName" />
<label @click="toggleItemName" class="advanced-label">Show name</label>
<f7-checkbox style="margin-left: 5px" :checked="includeItemTags" @change="toggleItemTags" />
<label @click="toggleItemTags" class="advanced-label">Show tags</label>
</div>
<f7-link class="right details-link padding-right" ref="detailsLink" @click="detailsOpened = true" icon-f7="chevron_up" />
</f7-toolbar>
<f7-toolbar bottom class="toolbar-details" v-if="this.$theme.ios || this.$theme.md" style="height: 50px">
<f7-link :disabled="selectedItem != null" class="left" @click="selectedItem = null">
Clear
</f7-link>
<div class="padding-right text-align-center" style="font-size: 12px">
<div>
<f7-checkbox :checked="includeNonSemantic" @change="toggleNonSemantic" />
<label @click="toggleNonSemantic" class="advanced-label">Show non-semantic</label>
</div>
<div>
<f7-checkbox :checked="includeItemName" @change="toggleItemName" />
<label @click="toggleItemName" class="advanced-label">Show name</label>
<f7-checkbox style="margin-left: 5px" :checked="includeItemTags" @change="toggleItemTags" />
<label @click="toggleItemTags" class="advanced-label">Show tags</label>
</div>
</div>
<f7-link class="right details-link padding-right" ref="detailsLink" @click="detailsOpened = true" icon-f7="chevron_up" />
</f7-toolbar>
Expand All @@ -35,7 +57,8 @@
<f7-treeview>
<model-treeview-item v-for="node in [rootLocations, rootEquipment, rootPoints, rootGroups, rootItems].flat()"
:key="node.item.name" :model="node"
@selected="selectItem" :selected="selectedItem" />
@selected="selectItem" :selected="selectedItem"
:includeItemName="includeItemName" :includeItemTags="includeItemTags"/>

Check failure on line 61 in bundles/org.openhab.ui/web/src/pages/settings/model/model.vue

View workflow job for this annotation

GitHub Actions / checks

Expected a space before '/>', but not found

Check failure on line 61 in bundles/org.openhab.ui/web/src/pages/settings/model/model.vue

View workflow job for this annotation

GitHub Actions / webpack-stats

Expected a space before '/>', but not found
</f7-treeview>
</f7-block>
</f7-col>
Expand Down Expand Up @@ -213,6 +236,8 @@ export default {
ready: false,
loading: false,
includeNonSemantic: false,
includeItemName: false,
includeItemTags: false,
items: [],
links: [],
locations: [],
Expand Down Expand Up @@ -435,6 +460,14 @@ export default {
this.includeNonSemantic = !this.includeNonSemantic
this.load()
},
toggleItemName () {
this.includeItemName = !this.includeItemName
this.load()
},
toggleItemTags () {
this.includeItemTags = !this.includeItemTags
this.load()
},
addSemanticItem (semanticType) {
this.newItem = {
type: (semanticType === 'Point') ? 'Switch' : 'Group',
Expand Down

0 comments on commit eecf291

Please sign in to comment.