Skip to content

Commit

Permalink
Testing feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Jul 26, 2022
1 parent d7229ab commit 8bc4626
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public static function getItemTypes()
$types = DB::table('devices')->whereNotNull('item_type')
->select(['item_type', 'categories.name AS categoryname', 'categories.idcategories', 'categories.powered', DB::raw('COUNT(*) as count')])
->join('categories', 'categories.idcategories', '=', 'devices.category')
->groupBy('item_type')
->groupBy(DB::raw('CONCAT(item_type, categoryname)'))
->orderBy('count', 'desc')
->get()->toArray();

Expand Down
11 changes: 10 additions & 1 deletion resources/js/components/DeviceType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ export default {
},
computed: {
suggestions() {
const ret = this.itemTypes.filter(i => Boolean(i.powered) === Boolean(this.powered)).map(i => i.item_type)
let ret = []
let used = {}
this.itemTypes.filter(i => Boolean(i.powered) === Boolean(this.powered)).forEach(i => {
if (!(i.item_type in used)) {
used[i.item_type] = true
ret.push(i.item_type)
}
})
return ret
},
notASuggestion() {
Expand Down
15 changes: 10 additions & 5 deletions resources/js/components/EventDevice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default {
this.pulsating = true
setTimeout(() => {
this.pulsating = false
}, 2000)
}, 5000)
}
}
},
Expand All @@ -221,8 +221,9 @@ export default {
cluster.categories.forEach((c) => {
const name = this.$lang.get('strings.' + c.name)
if (Boolean(c.powered) === Boolean(this.powered) && name === this.currentDevice.item_type) {
if (Boolean(c.powered) === Boolean(this.powered) && name.toLowerCase().indexOf(this.currentDevice.item_type.toLowerCase()) !== -1) {
ret = {
idcategories: c.idcategories,
categoryname: c.name,
powered: c.powered
}
Expand All @@ -231,11 +232,15 @@ export default {
})
if (!ret) {
// Now check the item types.
this.itemTypes.forEach(t => {
if (Boolean(t.powered) === Boolean(this.powered) && this.currentDevice.item_type === t.item_type) {
// Now check the item types. Stop at the first match, which is the most popular.
this.itemTypes.every(t => {
if (!ret && Boolean(t.powered) === Boolean(this.powered) && this.currentDevice.item_type === t.item_type) {
ret = t
return false
}
return true
})
}
}
Expand Down

0 comments on commit 8bc4626

Please sign in to comment.