Skip to content

Commit

Permalink
Feature/reconfigure the new edpoint card (project-chip#1354)
Browse files Browse the repository at this point in the history
* feat: Reconfigure the create new endpoint based on device type

* feat: remove profile id from card in Matter

* fix:modify getCategory func for Matter and Zigbee mode

* fix: add / remove some logics

* fix: modify showProfileId's return

* fix: remove console log
  • Loading branch information
tbrkollar committed Jul 18, 2024
1 parent 5c38c1f commit 17375d6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 18 deletions.
21 changes: 21 additions & 0 deletions src/components/ZclCreateModifyEndpoint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,27 @@ export default {
// New temporary variable
this.deviceTypeTmp = value
// Get first item package reference
const packageRefTmp =
this.zclDeviceTypes[this.deviceTypeTmp[0].deviceTypeRef]?.packageRef
// Get readable device category by packageRef
const categoryTmp = this.getDeviceCategory(packageRefTmp)
// Set / unset multiple device option in mcp
if (this.$store.state.zap.isMultiConfig) {
if (categoryTmp === 'zigbee') {
this.enableMultipleDevice = false
this.enableParentEndpoint = false
this.enablePrimaryDevice = false
this.enableProfileId = true
} else {
this.enableMultipleDevice = true
this.enableParentEndpoint = true
this.enablePrimaryDevice = true
this.enableProfileId = false
}
}
// Create default device version if not exists
for (const dt of value) {
if (dt && dt.deviceVersion === undefined) {
Expand Down
28 changes: 10 additions & 18 deletions src/components/ZclEndpointCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ limitations under the License.
<strong>{{ parentEndpointIdentifier[endpointReference] }}</strong>
</div>
</q-item>
<q-item class="row" v-if="$store.state.zap.isProfileIdShown">
<q-item class="row" v-if="showProfileId">
<div class="col-6">
<strong>Profile ID</strong>
</div>
Expand Down Expand Up @@ -300,23 +300,6 @@ export default {
}
},
methods: {
/**
* Calculate readable category
*
* @param {*} packageRef
* @returns Returns a string value for category
*/
getDeviceCategory(packageRef) {
let category = ''
let zclProperty =
this.$store.state.zap.selectedZapConfig.zclProperties.find(
(item) => item.id === packageRef && item.category
)
if (zclProperty) {
category = zclProperty.category
}
return category
},
openDeviceLibraryDocumentation() {
if (
this.$store.state.zap.genericOptions[
Expand Down Expand Up @@ -504,6 +487,15 @@ export default {
return this.$store.state.zap.endpointView.profileId
},
},
showProfileId: {
get() {
return (
this.getDeviceCategory(this.deviceType[0].packageRef) === 'zigbee' &&
this.$store.state.zap.isProfileIdShown &&
this.enableProfileId
)
},
},
deviceId: {
get() {
return this.$store.state.zap.endpointTypeView.deviceIdentifier
Expand Down
21 changes: 21 additions & 0 deletions src/util/common-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,26 @@ export default {

return logos
},
/**
* Calculate readable category
*
* @param {*} packageRef
* @returns Returns a string value for category
*/
getDeviceCategory(packageRef) {
let zclProperty = ''
if (this.$store.state.zap.isMultiConfig) {
zclProperty =
this.$store.state.zap.selectedZapConfig.zclProperties.find(
(item) => item.id === packageRef && item.category
)
return zclProperty.category
} else {
zclProperty = this.$store.state.zap.packages.find(
(item) => item.pkg.id === packageRef && item.pkg.category
)
return zclProperty.pkg?.category
}
},
},
}

0 comments on commit 17375d6

Please sign in to comment.