Skip to content

Commit

Permalink
Merge branch 'master' into fetaure/support_webos5_buildin_browser
Browse files Browse the repository at this point in the history
* master:
  Inbox: Fix error when deleting, add ability to set custom ID (openhab#775)
  Show correct alexa metadata categories for group items (openhab#767)
  Don't show edit/save buttons in model if item is not editable (openhab#774)
  Only show list indexes on mobile devices (openhab#773)
  Consider alarms part of equipment in location glance badges (openhab#772)
  Consider blinds open when state is ON or 0 in blinds glance (openhab#771)
  Fix measurement badges display condition (openhab#770)
  Fallback to UIDs if things have no label during sorting (openhab#769)
  Fix personal widgets ordering (openhab#768)
  • Loading branch information
crnjan committed Jan 9, 2021
2 parents 91597d0 + 874af99 commit c10994c
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ const categories = [
'WEARABLE'
]

// Group endpoints are generated from the display categories. Example from the docs: SECURITY_PANEL => Endpoint.SecurityPanel.
const groupEndpoints = categories
.map(category => {
const convertedChars = []
let capitalizeNext = false
for (var i = 0; i < category.length; i++) {
const currentChar = category.charAt(i)
if (i === 0) {
convertedChars.push(currentChar.toUpperCase())
} else if (currentChar === '_') {
capitalizeNext = true
} else if (capitalizeNext) {
convertedChars.push(currentChar.toUpperCase())
capitalizeNext = false
} else {
convertedChars.push(currentChar.toLocaleLowerCase())
}
}
return 'Endpoint.' + convertedChars.join('')
}).reduce((endpoints, endpointName) => {
endpoints[endpointName] = []
return endpoints
}, {})

const labels = {
'Switchable': [],
'Lighting': [],
Expand Down Expand Up @@ -234,6 +258,11 @@ for (let l in labels) {
classes['label:' + l] = labels[l]
}

for (let l in groupEndpoints) {
groupEndpoints[l].unshift(categoryParameter)
classes['endpoint:' + l] = groupEndpoints[l]
}

for (let c in capabilities) {
capabilities[c].unshift(categoryParameter)
classes[c] = capabilities[c]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<span class="padding-right location-status-badge" v-show="reduce" :class="{ invert: invertColor }">
<span class="padding-right location-status-badge" v-show="map.length" :class="{ invert: invertColor }">
<oh-icon v-if="config.icon.indexOf('oh:') === 0" :icon="config.icon.replace('oh:', '')" :state="config.state" class="oh-icon-badge" width="20" height="20" />
<f7-icon v-else-if="config.icon.indexOf('f7:') === 0" :f7="config.icon.replace('f7:', '')" :color="invertColor ? 'black' : 'white'" class="f7-icon-badge" size="20" />
<!-- <oh-icon v-if="config.icon.indexOf('oh:') === 0 && config.stateOff" v-show="!reduce" icon="config.icon.replace('oh:', '')" :state="config.stateOff" class="oh-icon-badge" width="20" height="20" /> -->
<span class="glance-label" v-show="reduce">{{reduce}} {{config.unit}}</span>
<span class="glance-label" v-show="reduceAux" style="opacity: 0.7">({{reduceAux}} {{config.unit}})</span>
<span class="glance-label">{{reduce}} {{config.unit}}</span>
<span class="glance-label" v-show="mapAux.length" style="opacity: 0.7">({{reduceAux}} {{config.unit}})</span>
</span>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export default {
equipment = [
...findEquipment(this.element.equipment, 'Equipment_Door', false),
...findEquipment(this.element.equipment, 'Equipment_Door_FrontDoor', false),
...findEquipment(this.element.equipment, 'Equipment_Door_BackDoor', false),
...findEquipment(this.element.equipment, 'Equipment_Door_InnerDoor', false),
...findEquipment(this.element.equipment, 'Equipment_Door_CellarDoor', false),
...findEquipment(this.element.equipment, 'Equipment_Door_SideDoor', false)
...findEquipment(this.element.equipment, 'Equipment_Door_BackDoor', false),
...findEquipment(this.element.equipment, 'Equipment_Door_InnerDoor', false),
...findEquipment(this.element.equipment, 'Equipment_Door_CellarDoor', false),
...findEquipment(this.element.equipment, 'Equipment_Door_SideDoor', false)
]
if (!equipment.length) return []
allPoints = allEquipmentPoints(equipment)
Expand Down Expand Up @@ -158,7 +158,9 @@ export default {
if (points.length) return points
return equipment.filter((e) => e.points.length === 0).map((e) => e.item)
case 'alarms':
return findPoints(this.element.properties, 'Point_Alarm', true)
direct = findPoints(this.element.properties, 'Point_Alarm', true)
if (direct.length) return direct
return findPoints(allEquipmentPoints(this.element.equipment), 'Point_Alarm', true)
default:
return []
}
Expand All @@ -171,7 +173,7 @@ export default {
case 'lights':
return this.map.filter((state) => state === 'ON' || (state.split(',').length === 3 && state.split(',')[2] !== '0') || (state.indexOf(',') < 0 && Number.parseInt(state) > 0)).length
case 'blinds':
return this.map.filter((state) => state === 'OPEN' || Number.parseInt(state) > 0).length
return this.map.filter((state) => state === 'OPEN' || state === 'ON' || Number.parseInt(state) === 0).length
default:
return this.map.filter((state) => state === 'ON' || state === 'OPEN').length
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<template>
<div>
<div style="text-align:right" class="padding-right">
<div style="text-align:right" class="padding-right" v-if="itemType !== 'Group'">
<label @click="toggleMultiple" style="cursor:pointer">Multiple</label> <f7-checkbox :checked="multiple" @change="toggleMultiple"></f7-checkbox>
</div>
<f7-list>
<f7-list-item :key="classSelectKey"
:title="(multiple) ? 'Alexa Classes' : 'Alexa Class'" smart-select :smart-select-params="{ openIn: 'popup', searchbar: true, closeOnSelect: !multiple, scrollToSelectedItem: true }" ref="classes">
<select name="parameters" @change="updateClasses" :multiple="multiple">
<option v-if="!multiple" value=""></option>
<optgroup label="Labels" v-if="!multiple">
<optgroup label="Labels" v-if="!multiple && itemType !== 'Group'">
<option v-for="cl in orderedClasses.filter((c) => c.indexOf('label:') === 0)"
:value="cl.replace('label:', '')" :key="cl"
:selected="isSelected(cl.replace('label:', ''))">
{{cl.replace('label:', '')}}
</option>
</optgroup>
<optgroup label="Capabilities">
<option v-for="cl in orderedClasses.filter((c) => c.indexOf('label:') !== 0)"
:value="cl" :key="cl"
:selected="isSelected(cl)">
{{cl}}
<option v-for="cl in orderedClasses.filter((c) => c.indexOf('label:') !== 0 && c.indexOf('endpoint:') === (itemType === 'Group'? 0 : -1))"
:value="cl.replace('endpoint:', '')" :key="cl"
:selected="isSelected(cl.replace('endpoint:', ''))">
{{cl.replace('endpoint:', '')}}
</option>
</optgroup>
</select>
Expand All @@ -39,14 +39,15 @@ import AlexaDefinitions from '@/assets/definitions/metadata/alexa'
import ConfigSheet from '@/components/config/config-sheet.vue'
export default {
props: ['itemName', 'metadata', 'namespace'],
props: ['item', 'metadata', 'namespace'],
components: {
ConfigSheet
},
data () {
return {
itemType: this.item.type,
classesDefs: Object.keys(AlexaDefinitions),
multiple: !!this.metadata.value && this.metadata.value.indexOf(',') > 0,
multiple: this.item.type !== 'Group' && !!this.metadata.value && this.metadata.value.indexOf(',') > 0,
classSelectKey: this.$f7.utils.id()
}
},
Expand All @@ -57,13 +58,13 @@ export default {
},
orderedClasses () {
return [...this.classesDefs].sort((a, b) => {
return a.localeCompare(b);
return a.localeCompare(b)
})
},
parameters () {
if (!this.classes) return []
if (!this.multiple) {
return AlexaDefinitions['label:' + this.classes] || [...AlexaDefinitions[this.classes]]
return AlexaDefinitions['label:' + this.classes] || AlexaDefinitions['endpoint:' + this.classes] || [...AlexaDefinitions[this.classes]]
}
const params = []
this.classes.forEach((c) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
},
orderedClasses () {
return [...this.classesDefs].sort((a, b) => {
return a.localeCompare(b);
return a.localeCompare(b)
})
},
parameters () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default {
},
orderedClasses () {
return [...this.classesDefs].sort((a, b) => {
return a.localeCompare(b);
return a.localeCompare(b)
})
},
parameters () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,27 @@ export default {
computed: {
orderedStandardWidgets () {
return [...this.standardWidgets].sort((a, b) => {
return a.name.localeCompare(b.name);
return a.name.localeCompare(b.name)
})
},
orderedStandardListWidgets () {
return [...this.standardListWidgets].sort((a, b) => {
return a.name.localeCompare(b.name);
return a.name.localeCompare(b.name)
})
},
orderedStandardCellWidgets () {
return [...this.standardCellWidgets].sort((a, b) => {
return a.name.localeCompare(b.name);
return a.name.localeCompare(b.name)
})
},
orderedSystemWidgets () {
return [...this.systemWidgets].sort((a, b) => {
return a.name.localeCompare(b.name);
return a.name.localeCompare(b.name)
})
},
orderedPersonalWidgets () {
return [...$store.getters.widgets].sort((a, b) => {
return a.name.localeCompare(b.name);
return [...this.$store.getters.widgets].sort((a, b) => {
return a.name.localeCompare(b.name)
})
},
configDescriptions () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,25 @@
</f7-card-content>
<f7-card-footer v-if="createMode || editMode" key="item-card-buttons">
<f7-button v-if="createMode" color="blue" fill raised @click="create">Create</f7-button>
<f7-button v-else color="blue" fill raised @click="save">Save</f7-button>
<f7-button v-else color="blue" fill raised @click="save" v-show="model.item.editable">Save</f7-button>
<f7-button v-if="createMode || editMode" color="blue" @click="cancel">Cancel</f7-button>
</f7-card-footer>
<f7-card-footer v-else key="item-card-buttons-edit-mode">
<f7-button v-if="!editMode && !createMode" color="blue" @click="editMode = true" icon-ios="material:expand_more" icon-md="material:expand_more" icon-aurora="material:expand_more">Edit</f7-button>
<f7-button v-if="!editMode && !createMode" color="red" @click="remove">Remove</f7-button>
<f7-button v-if="!editMode && !createMode && model.item.editable" color="red" @click="remove">Remove</f7-button>
</f7-card-footer>
</f7-card>
</template>

<script>
import Item from '@/components/item/item.vue'
import ItemForm from '@/components/item/item-form.vue'
import MetadataMenu from '@/components/item/metadata/item-metadata-menu.vue'
export default {
props: ['model', 'links'],
components: {
Item,
ItemForm,
MetadataMenu
ItemForm
},
data () {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ export default {
computed: {
orderedLocations () {
return [...this.semanticClasses.Locations].sort((a, b) => {
return a.localeCompare(b);
return a.localeCompare(b)
})
},
orderedEquipment () {
return [...this.semanticClasses.Equipment].sort((a, b) => {
return a.localeCompare(b);
return a.localeCompare(b)
})
},
orderedPoints () {
return [...this.semanticClasses.Points].sort((a, b) => {
return a.localeCompare(b);
return a.localeCompare(b)
})
},
orderedProperties () {
return [...this.semanticClasses.Properties].sort((a, b) => {
return a.localeCompare(b);
return a.localeCompare(b)
})
},
currentSemanticType () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

<f7-list-index
ref="listIndex"
v-show="!$device.desktop"
list-el=".items-list"
:scroll-list="true"
:label="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<f7-list-index
v-if="ready"
ref="listIndex" :key="'pages-index'"
v-show="groupBy === 'alphabetical'"
v-show="groupBy === 'alphabetical' && !$device.desktop"
list-el=".pages-list"
:scroll-list="true"
:label="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<f7-list-index
ref="listIndex"
v-if="$refs.rulesList"
v-show="!$device.desktop"
:listEl="$refs.rulesList ? $$($refs.rulesList.$el) : undefined"
:scroll-list="true"
:label="true"
Expand Down Expand Up @@ -168,7 +169,7 @@ export default {
this.ready = true
setTimeout(() => {
this.initSearchbar = true
this.$refs.listIndex.update()
if (this.$refs.listIndex) this.$refs.listIndex.update()
})
if (!this.eventSource) this.startEventSource()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
</f7-subnavbar>
</f7-navbar>

<f7-list-index
ref="listIndex"
list-el=".binding-list"
:scroll-list="true"
:label="true"
></f7-list-index>

<empty-state-placeholder v-if="ready && !bindings.length" icon="circle_grid_hex" title="things.nobindings.title" text="things.nobindings.text" />

<f7-block class="block-narrow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<f7-list-index
ref="listIndex"
v-show="groupBy === 'alphabetical'"
v-show="groupBy === 'alphabetical' && !$device.desktop"
list-el=".inbox-list"
:scroll-list="true"
:label="true"
Expand Down Expand Up @@ -235,6 +235,26 @@ export default {
entry.label)
}
},
{
text: 'Add as Thing (with custom ID)',
color: 'blue',
bold: true,
onClick: () => {
this.$f7.dialog.prompt(`This will create a new Thing of type ${entry.thingTypeUID}. You can change the suggested thing ID below:`,
'Add as Thing',
(newThingId) => {
this.$f7.dialog.prompt(`Enter the desired name of the new Thing:`,
'Add as Thing',
(name) => {
this.approveEntry(entry, name, newThingId)
},
null,
entry.label)
},
null,
entry.thingUID.substring(entry.thingUID.indexOf(':', entry.thingUID.indexOf(':') + 1) + 1))
}
},
{
text: (!ignored) ? 'Ignore' : 'Unignore',
color: (!ignored) ? 'orange' : 'blue',
Expand Down Expand Up @@ -263,8 +283,8 @@ export default {
actions.open()
},
approveEntry (entry, name) {
this.$oh.api.postPlain(`/rest/inbox/${entry.thingUID}/approve`, name).then((res) => {
approveEntry (entry, name, newThingId) {
this.$oh.api.postPlain(`/rest/inbox/${entry.thingUID}/approve${newThingId ? '?newThingId=' + newThingId : ''}`, name).then((res) => {
this.$f7.toast.create({
text: 'Entry approved',
destroyOnClose: true,
Expand Down Expand Up @@ -321,14 +341,14 @@ export default {
destroyOnClose: true,
closeTimeout: 2000
}).open()
self.load()
this.load()
}).catch((err) => {
this.$f7.toast.create({
text: 'Error while removing entry: ' + err,
destroyOnClose: true,
closeTimeout: 2000
}).open()
self.load()
this.load()
})
},
toggleIgnored () {
Expand Down
Loading

0 comments on commit c10994c

Please sign in to comment.