diff --git a/bundles/org.openhab.ui/web/src/components/addons/addons-section.vue b/bundles/org.openhab.ui/web/src/components/addons/addons-section.vue index 6401162fda..32104f88c3 100644 --- a/bundles/org.openhab.ui/web/src/components/addons/addons-section.vue +++ b/bundles/org.openhab.ui/web/src/components/addons/addons-section.vue @@ -12,7 +12,10 @@
-
+
+ +
+
@@ -95,7 +98,7 @@ import AddonCard from './addon-card.vue' import { compareAddons } from '@/assets/addon-store' export default { - props: ['addons', 'title', 'subtitle', 'showAll', 'featured', 'showAsCards', 'installActionText'], + props: ['addons', 'title', 'subtitle', 'showAll', 'featured', 'showAsCards', 'suggested', 'installActionText'], components: { AddonListItem, AddonCard diff --git a/bundles/org.openhab.ui/web/src/pages/addons/addons-store.vue b/bundles/org.openhab.ui/web/src/pages/addons/addons-store.vue index f55f9491a0..41617c0c5c 100644 --- a/bundles/org.openhab.ui/web/src/pages/addons/addons-store.vue +++ b/bundles/org.openhab.ui/web/src/pages/addons/addons-store.vue @@ -49,6 +49,13 @@ + + @@ -181,6 +195,7 @@ export default { return { currentTab: this.initialTab || 'bindings', services: null, + suggestions: [], ready: false, searchResults: [] } @@ -189,11 +204,20 @@ export default { allAddons () { return Object.keys(this.addons).flatMap((k) => this.addons[k]) }, + suggestedAddons () { + return Object.keys(this.addons).flatMap((k) => this.addons[k]).filter((a) => this.suggestions.some((s) => s.id === a.id)) + }, + unsuggestedAddons () { + return Object.keys(this.addons).flatMap((k) => this.addons[k]).filter((a) => !this.suggestedAddons.includes(a)) + }, officialAddons () { - return Object.keys(this.addons).filter((k) => k === 'eclipse' || k === 'karaf').flatMap((k) => this.addons[k]) + return Object.keys(this.addons).filter((k) => k === 'eclipse' || k === 'karaf').flatMap((k) => this.addons[k]).filter((a) => !this.suggestedAddons.includes(a)) + }, + marketplaceAddons () { + return this.addons.marketplace.filter((a) => !this.suggestedAddons.includes(a)) }, otherAddons () { - return Object.keys(this.addons).filter((k) => k !== 'eclipse' && k !== 'karaf' && k !== 'marketplace').flatMap((k) => this.addons[k]) + return Object.keys(this.addons).filter((k) => k !== 'eclipse' && k !== 'karaf' && k !== 'marketplace').flatMap((k) => this.addons[k]).filter((a) => !this.suggestedAddons.includes(a)) } }, methods: { @@ -206,6 +230,9 @@ export default { }, load () { this.stopEventSource() + this.$oh.api.get('/rest/addons/suggestions').then((data) => { + this.$set(this, 'suggestions', data) + }) this.$oh.api.get('/rest/addons/services').then((data) => { this.services = data Promise.all(this.services.map((s) => this.$oh.api.get('/rest/addons?serviceId=' + s.id))).then((data2) => { diff --git a/bundles/org.openhab.ui/web/src/pages/wizards/setup-wizard.vue b/bundles/org.openhab.ui/web/src/pages/wizards/setup-wizard.vue index 404d8548ab..ffae1fdfde 100644 --- a/bundles/org.openhab.ui/web/src/pages/wizards/setup-wizard.vue +++ b/bundles/org.openhab.ui/web/src/pages/wizards/setup-wizard.vue @@ -415,31 +415,35 @@ export default { this.i18nReady = true } }) - this.$oh.api.get('/rest/addons').then((data) => { - this.addons = data.sort((a, b) => a.label.toUpperCase().localeCompare(b.label.toUpperCase())) - this.selectedAddons = this.addons.filter((a) => this.recommendedAddons.includes(a.uid) && !a.installed) - const self = this - this.autocompleteAddons = this.$f7.autocomplete.create({ - openIn: 'popup', - pageTitle: this.$t('setupwizard.addons.selectAddons'), - searchbarPlaceholder: this.$t('setupwizard.addons.selectAddons.placeholder'), - openerEl: this.$refs.selectAddons, - multiple: true, - requestSourceOnOpen: true, - source: (query, render) => { - if (query.length === 0) { - render(self.addons.filter((a) => !a.installed).map((a) => a.label)) - } else { - render(self.addons.filter((a) => !a.installed && (a.label.toLowerCase().indexOf(query.toLowerCase()) >= 0 || a.uid.toLowerCase().indexOf(query.toLowerCase()) >= 0)).map((a) => a.label)) - } - }, - on: { - change (value) { - const selected = value.map((label) => self.addons.find((a) => a.label === label)) - self.$set(self, 'selectedAddons', selected) - } - }, - value: this.addons.filter((a) => this.recommendedAddons.includes(a.uid)).map((a) => a.label) + this.$oh.api.get('/rest/addons/suggestions').then((suggestedAddons) => { + let suggestions = suggestedAddons.flatMap((s) => s.id) + this.$oh.api.get('/rest/addons').then((data) => { + this.addons = data.sort((a, b) => a.label.toUpperCase().localeCompare(b.label.toUpperCase())) + this.selectedAddons = this.addons.filter((a) => (this.recommendedAddons.includes(a.uid) || suggestions.includes(a.id)) && !a.installed).sort((a, b) => a.label.toUpperCase().localeCompare(b.label.toUpperCase())) + const sortedAddons = this.selectedAddons.concat(this.addons.filter((a) => (!this.selectedAddons.includes(a)))) + const self = this + this.autocompleteAddons = this.$f7.autocomplete.create({ + openIn: 'popup', + pageTitle: this.$t('setupwizard.addons.selectAddons'), + searchbarPlaceholder: this.$t('setupwizard.addons.selectAddons.placeholder'), + openerEl: this.$refs.selectAddons, + multiple: true, + requestSourceOnOpen: true, + source: (query, render) => { + if (query.length === 0) { + render(sortedAddons.filter((a) => !a.installed).map((a) => a.label)) + } else { + render(sortedAddons.filter((a) => !a.installed && (a.label.toLowerCase().indexOf(query.toLowerCase()) >= 0 || a.uid.toLowerCase().indexOf(query.toLowerCase()) >= 0)).map((a) => a.label)) + } + }, + on: { + change (value) { + const selected = value.map((label) => self.addons.find((a) => a.label === label)) + self.$set(self, 'selectedAddons', selected) + } + }, + value: this.addons.filter((a) => this.recommendedAddons.includes(a.uid) || suggestions.includes(a.id)).map((a) => a.label) + }) }) }) }