Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix thing-type retrieval and add-on management #1651

Merged
merged 2 commits into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<f7-link v-if="addon" class="addon-card padding-right-half" :href="addon.id">
<f7-link v-if="addon" class="addon-card padding-right-half" :href="addon.uid">
<div class="addon-card-inner card">
<div class="addon-card-headline">
<div>{{ headline || autoHeadline || "&nbsp;" }}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default {
computed: {
information () {
let info = []
if (!this.addon || !this.addon.id) return info
const source = this.addon.id.indexOf(':') > 0 ? this.addon.id.substring(0, this.addon.id.indexOf(':')) : 'karaf'
if (!this.addon || !this.addon.uid) return info
const source = this.addon.uid.indexOf(':') > 0 ? this.addon.uid.substring(0, this.addon.uid.indexOf(':')) : 'karaf'
let sourceName = 'openHAB Distribution'
if (source === 'marketplace') {
sourceName = 'Community Marketplace'
Expand Down Expand Up @@ -123,7 +123,7 @@ export default {
id: 'documentationLink',
title: 'Documentation',
afterIcon: 'question_circle_fill',
linkUrl: `https://${this.$store.state.runtimeInfo.buildString === 'Release Build' ? 'www' : 'next'}.openhab.org/addons/${this.addon.type.replace('misc', 'integrations').replace('binding', 'bindings').replace('transformation', 'transformations')}/${this.addon.id.split('-')[1]}` // this.addon.link
linkUrl: `https://${this.$store.state.runtimeInfo.buildString === 'Release Build' ? 'www' : 'next'}.openhab.org/addons/${this.addon.type.replace('misc', 'integrations').replace('binding', 'bindings').replace('transformation', 'transformations')}/${this.addon.id}` // this.addon.link
})

let repository
Expand All @@ -138,7 +138,7 @@ export default {
} else {
repository = 'openhab-addons'
}
issueFilter += `+${this.addon.id.split('-')[1]}`
issueFilter += `+${this.addon.id}`
}

info.push({
Expand All @@ -151,7 +151,7 @@ export default {
id: 'discussionsLink',
title: 'Community Discussions',
afterIcon: 'chat_bubble_2_fill',
linkUrl: 'https://community.openhab.org/search?q=' + this.addon.id.split('-')[1]
linkUrl: 'https://community.openhab.org/search?q=' + this.addon.id
})
} else {
info.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
v-if="addon"
class="addon-list-item padding-right-half"
:title="addon.label"
:link="addon.id">
:link="addon.uid">
<div v-if="addon.verifiedAuthor" slot="subtitle">
{{ addon.author }}
<f7-icon v-if="addon.verifiedAuthor" size="15" :color="$f7.data.themeOptions.dark === 'dark' ? 'white' : 'blue'" f7="checkmark_seal_fill" style="margin-top: -3px" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
{{ subtitle }}
</f7-block-footer>
<div class="addons-cards">
<addon-card v-for="addon in featuredAddons" :key="addon.id" :addon="addon" :install-action-text="installActionText" :headline="'Featured'" @addonButtonClick="addonButtonClick" />
<addon-card v-for="addon in featuredAddons" :key="addon.uid" :addon="addon" :install-action-text="installActionText" :headline="'Featured'" @addonButtonClick="addonButtonClick" />
</div>
<div v-if="showAsCards" class="addons-cards">
<addon-card v-for="addon in addonsList" :key="addon.id" :addon="addon" :install-action-text="installActionText" @addonButtonClick="addonButtonClick" />
<addon-card v-for="addon in addonsList" :key="addon.uid" :addon="addon" :install-action-text="installActionText" @addonButtonClick="addonButtonClick" />
</div>
<f7-list v-else media-list ref="addonlist" class="addons-table-list" no-chevron no-hairlines>
<addon-list-item v-for="addon in addonsList" :key="addon.id" :addon="addon" :install-action-text="installActionText" @addonButtonClick="addonButtonClick" />
<addon-list-item v-for="addon in addonsList" :key="addon.uid" :addon="addon" :install-action-text="installActionText" @addonButtonClick="addonButtonClick" />
</f7-list>
<f7-block v-if="canExpand" class="display-flex justify-content-center">
<f7-button class="" outline color="blue" @click="expand" :text="`Show ${addons.length - addonCollapsedLimit} More`" />
Expand Down
5 changes: 0 additions & 5 deletions bundles/org.openhab.ui/web/src/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const ServiceSettingsPage = () => import(/* webpackChunkName: "admin-base" */ '.
const AddonsListPage = () => import(/* webpackChunkName: "admin-base" */ '../pages/settings/addons/addons-list.vue')
const AddonsAddPage = () => import(/* webpackChunkName: "admin-base" */ '../pages/settings/addons/addons-add.vue')
const AddonsConfigureBindingPage = () => import(/* webpackChunkName: "admin-base" */ '../pages/settings/addons/addon-config.vue')
const OldAddonsConfigureBindingPage = () => import(/* webpackChunkName: "admin-base" */ '../pages/settings/addons/binding-config.vue')
const AddonsStorePage = () => import(/* webpackChunkName: "admin-base" */ '../pages/settings/addons/addons-store.vue')
const AddonDetailsPage = () => import(/* webpackChunkName: "admin-base" */ '../pages/settings/addons/addon-details.vue')

Expand Down Expand Up @@ -249,10 +248,6 @@ export default [
}
]
},
{
path: 'bindings/:bindingId/config',
async: loadAsync(OldAddonsConfigureBindingPage)
},
{
path: 'services/:serviceId',
beforeLeave: checkDirtyBeforeLeave,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,11 @@ export default {
this.$oh.api.get('/rest/addons/' + this.addonId + (this.serviceId ? '?serviceId=' + this.serviceId : '')).then(data => {
this.addon = data

if (this.addon.type === 'binding' && this.addon.installed) {
this.$oh.api.get('/rest/addons').then(data2 => {
this.bindingInfo = data2.find(b => b.id === this.addonId.replace('binding-', '')) || {}
self.$f7.preloader.hide()
setTimeout(() => {
if (!this.noDetails) self.$refs.sheet.f7Sheet.setSwipeStep()
self.$refs.sheet.f7Sheet.open()
})
})
} else {
self.$f7.preloader.hide()
setTimeout(() => {
if (!this.noDetails) self.$refs.sheet.f7Sheet.setSwipeStep()
self.$refs.sheet.f7Sheet.open()
})
}
self.$f7.preloader.hide()
setTimeout(() => {
if (!this.noDetails) self.$refs.sheet.f7Sheet.setSwipeStep()
self.$refs.sheet.f7Sheet.open()
})
})
} else {
self.$refs.sheet.f7Sheet.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ export default {
addonIcon: null,
descriptionReady: false,
parsedDescription: '',
descriptionExpanded: false,
bindingInfo: null
descriptionExpanded: false
}
},
computed: {
Expand All @@ -209,11 +208,11 @@ export default {
},
realAddonId () {
if (!this.addon) return null
return (this.addon.id.indexOf(':') > 0) ? this.addon.id.substring(this.addon.id.indexOf(':') + 1) : this.addon.id
return this.addon.uid
},
serviceId () {
if (!this.addon) return null
return (this.addon.id.indexOf(':') > 0) ? this.addon.id.substring(0, this.addon.id.indexOf(':')) : undefined
return (this.addon.uid.indexOf(':') > 0) ? this.addon.uid.substring(0, this.addon.uid.indexOf(':')) : undefined
},
imageUrl () {
if (!this.addon) return null
Expand All @@ -236,13 +235,10 @@ export default {
docLinkUrl () {
if (!this.addon) return ''
if (this.serviceId && this.serviceId !== 'karaf' && this.addon.link) return this.addon.link
if (this.addon.id.indexOf('-') > 0) {
let url = `https://${this.$store.state.runtimeInfo.buildString === 'Release Build' ? 'www' : 'next'}.openhab.org` +
`/addons/${this.addon.type.replace('misc', 'integrations').replace('binding', 'bindings').replace('transformation', 'transformations')}` +
`/${this.addon.id.split('-')[1]}`
return url
}
return ''
let url = `https://${this.$store.state.runtimeInfo.buildString === 'Release Build' ? 'www' : 'next'}.openhab.org` +
`/addons/${this.addon.type.replace('misc', 'integrations').replace('binding', 'bindings').replace('transformation', 'transformations')}` +
`/${this.addon.id}`
return url
}
},
methods: {
Expand All @@ -255,14 +251,11 @@ export default {
},
load () {
this.stopEventSource()
let addonId = this.addonId
let serviceId = null
if (addonId.indexOf(':') > 0) {
serviceId = addonId.substring(0, addonId.indexOf(':'))
addonId = addonId.substring(addonId.indexOf(':') + 1)
if (this.addonId.indexOf(':') > 0) {
serviceId = this.addonId.substring(0, this.addonId.indexOf(':'))
}
this.bindingInfo = null
this.$oh.api.get('/rest/addons/' + addonId + (serviceId ? '?serviceId=' + serviceId : '')).then((data) => {
this.$oh.api.get('/rest/addons/' + this.addonId + (serviceId ? '?serviceId=' + serviceId : '')).then((data) => {
this.resetPending()
this.$set(this, 'addon', data)
this.addonIcon = AddonIcons[this.addon.type]
Expand All @@ -280,12 +273,6 @@ export default {
})
this.$f7.lazy.create('.page-addon-details')
})

if (this.addon.type === 'binding' && this.addonId.indexOf('binding-') === 0 && this.addon.installed) {
this.$oh.api.get('/rest/addons').then(data2 => {
this.bindingInfo = data2.find(b => b.id === this.addonId.replace('binding-', '')) || {}
})
}
})
},
processDescription () {
Expand All @@ -296,10 +283,9 @@ export default {
let addonTypeFolder = '_addons_' + this.addon.type
if (this.addon.type === 'misc') addonTypeFolder = '_addons_io'
if (this.addon.type !== 'automation') addonTypeFolder += 's'
let addonId = this.addon.id.split('-')[1]
let docUrl = (this.$store.state.runtimeInfo.buildString === 'Release Build') ? 'https://www.openhab.org' : 'https://next.openhab.org'
docUrl += `/addons/${this.addon.type}/${addonId}`
let docSrcUrl = `https://raw.githubusercontent.com/openhab/openhab-docs/${docsBranch}/${addonTypeFolder}/${addonId}`
docUrl += `/addons/${this.addon.type}/${this.addon.id}`
let docSrcUrl = `https://raw.githubusercontent.com/openhab/openhab-docs/${docsBranch}/${addonTypeFolder}/${this.addon.id}`

fetch(docSrcUrl + '/readme.md').then((readme) => {
readme.text().then((text) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ export default {
},
installAddon (addon) {
this.addonPopupOpened = false
this.currentlyInstalling.push(addon.id)
this.currentlyInstalling.push(addon.uid)
if (this.currentAddon) this.$set(this.currentAddon, 'pending', 'INSTALL')
},
uninstallAddon (addon) {
this.addonPopupOpened = false
this.currentlyUninstalling.push(addon.id)
this.currentlyUninstalling.push(addon.uid)
if (this.currentAddon) this.$set(this.currentAddon, 'pending', 'UNINSTALL')
},
installableAddon (addon) {
return (addon && (addon.contentType === 'application/vnd.openhab.bundle' || addon.contentType.indexOf('application/vnd.openhab.feature') === 0))
},
isInstalling (addon) {
return this.currentlyInstalling.indexOf(addon.id) >= 0
return this.currentlyInstalling.indexOf(addon.uid) >= 0
},
isUninstalling (addon) {
return this.currentlyUninstalling.indexOf(addon.id) >= 0
return this.currentlyUninstalling.indexOf(addon.uid) >= 0
},
isPending (addon) {
return this.isInstalling(addon) || this.isUninstalling(addon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default {
},
installAddon (addon) {
this.addonPopupOpened = false
this.currentlyInstalling.push(addon.id)
this.currentlyInstalling.push(addon.uid)
},
startEventSource () {
this.eventSource = this.$oh.sse.connect('/rest/events?topics=openhab/addons/*/*', null, (event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
media-item
link="#"
v-for="addon in addons"
:key="addon.id"
@click="openAddonPopup(addon.id)"
:header="addon.id"
:key="addon.uid"
@click="openAddonPopup(addon.uid)"
:header="addon.uid"
:footer="addon.version"
:after="(currentlyUninstalling.indexOf(addon.id) >= 0) ? 'Uninstalling...' : ''"
:after="(currentlyUninstalling.indexOf(addon.uid) >= 0) ? 'Uninstalling...' : ''"
:title="addon.label">
<!-- <f7-swipeout-actions left>
<f7-swipeout-button v-if="addon.link" color="blue">Documentation</f7-swipeout-button>
Expand Down Expand Up @@ -124,7 +124,7 @@ export default {
},
uninstallAddon (addon) {
this.addonPopupOpened = false
this.currentlyUninstalling.push(addon.id)
this.currentlyUninstalling.push(addon.uid)
},
startEventSource () {
this.eventSource = this.$oh.sse.connect('/rest/events?topics=openhab/addons/*/*', null, (event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ export default {
})
},
addonButtonClick (addon) {
const realAddonId = (addon.id.indexOf(':') > 0) ? addon.id.substring(addon.id.indexOf(':') + 1) : addon.id
const serviceId = (addon.id.indexOf(':') > 0) ? addon.id.substring(0, addon.id.indexOf(':')) : undefined
this.openAddonPopup(realAddonId, serviceId, addon)
const serviceId = (addon.uid.indexOf(':') > 0) ? addon.uid.substring(0, addon.uid.indexOf(':')) : undefined
this.openAddonPopup(addon.uid, serviceId, addon)
},
search (searchbar, query, previousQuery) {
let results = []
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
<f7-list-item
v-for="binding in bindings"
media-item
:key="binding.id"
:key="binding.uid"
:link="binding.id"
:title="binding.label"
:header="binding.id"
:header="binding.uid"
:badge="inbox.filter((e) => e.thingTypeUID.split(':')[0] === binding.id && e.flag !== 'IGNORED').length || undefined"
badge-color="red"
:footer="(binding.description && binding.description.indexOf('<br>') >= 0) ?
Expand Down Expand Up @@ -76,7 +76,7 @@ export default {
methods: {
onPageAfterIn () {
this.loading = true
this.$oh.api.get('/rest/addons').then((data) => {
this.$oh.api.get('/rest/addons?serviceId=all').then((data) => {
let installedBindings = data.filter(addon => addon.type === 'binding' && addon.installed === true)
this.bindings = installedBindings.sort((a, b) => a.label.localeCompare(b.label))
this.loading = false
Expand Down
Loading