Skip to content

Commit

Permalink
only show button if conform data exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanzhouyc committed Nov 13, 2024
1 parent 3a7872b commit c5f45e9
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 44 deletions.
27 changes: 14 additions & 13 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3657,7 +3657,7 @@ This module provides queries for features.
* [~getOutdatedElementWarning(featureData, elements, elementMap)](#module_DB API_ feature related queries..getOutdatedElementWarning) ⇒
* [~processElements(elementType)](#module_DB API_ feature related queries..getOutdatedElementWarning..processElements)
* [~filterRequiredElements(elements, elementMap, featureMap)](#module_DB API_ feature related queries..filterRequiredElements) ⇒
* [~checkIfDeviceTypeFeatureDataExist(db)](#module_DB API_ feature related queries..checkIfDeviceTypeFeatureDataExist) ⇒
* [~checkIfConformanceDataExist(db)](#module_DB API_ feature related queries..checkIfConformanceDataExist) ⇒

<a name="module_DB API_ feature related queries..getFeaturesByDeviceTypeRefs"></a>

Expand Down Expand Up @@ -3853,13 +3853,14 @@ An element is unsupported if it conforms to element(s) in elementMap and has 'no
| elementMap | <code>\*</code> |
| featureMap | <code>\*</code> |

<a name="module_DB API_ feature related queries..checkIfDeviceTypeFeatureDataExist"></a>
<a name="module_DB API_ feature related queries..checkIfConformanceDataExist"></a>

### DB API: feature related queries~checkIfDeviceTypeFeatureDataExist(db) ⇒
Check if DEVICE_TYPE_FEATURE table exists and is not empty.
### DB API: feature related queries~checkIfConformanceDataExist(db) ⇒
Check if any non-empty conformance data exist in ATTRIBUTE, COMMAND,
and DEVICE_TYPE_FEATURE table.

**Kind**: inner method of [<code>DB API: feature related queries</code>](#module_DB API_ feature related queries)
**Returns**: true if DEVICE_TYPE_FEATURE table is not empty, false if not
**Returns**: boolean value indicating if conformance data exists

| Param | Type |
| --- | --- |
Expand Down Expand Up @@ -14613,7 +14614,7 @@ This module provides the API to access zcl specific information.
* [~httpPostDuplicateEndpoint(db)](#module_REST API_ user data..httpPostDuplicateEndpoint) ⇒
* [~httpPostDuplicateEndpointType(db)](#module_REST API_ user data..httpPostDuplicateEndpointType) ⇒
* [~httpPatchUpdateBitOfFeatureMapAttribute(db)](#module_REST API_ user data..httpPatchUpdateBitOfFeatureMapAttribute) ⇒
* [~httpGetDeviceTypeFeatureExists(db)](#module_REST API_ user data..httpGetDeviceTypeFeatureExists) ⇒
* [~httpGetConformDataExists(db)](#module_REST API_ user data..httpGetConformDataExists) ⇒
* [~httpPostRequiredElementWarning(db)](#module_REST API_ user data..httpPostRequiredElementWarning) ⇒
* [~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId)](#module_REST API_ user data..duplicateEndpointTypeClusters)

Expand Down Expand Up @@ -15065,10 +15066,10 @@ Update feature map attribute with given new value
| --- | --- |
| db | <code>\*</code> |

<a name="module_REST API_ user data..httpGetDeviceTypeFeatureExists"></a>
<a name="module_REST API_ user data..httpGetConformDataExists"></a>

### REST API: user data~httpGetDeviceTypeFeatureExists(db) ⇒
Check data exsit in DEVICE_TYPE_FEATURE table
### REST API: user data~httpGetConformDataExists(db) ⇒
Check if conformance data exists in the database

**Kind**: inner method of [<code>REST API: user data</code>](#module_REST API_ user data)
**Returns**: boolean value of data exist or not
Expand Down Expand Up @@ -15952,7 +15953,7 @@ This module provides the REST API to the user specific data.
* [~httpPostDuplicateEndpoint(db)](#module_REST API_ user data..httpPostDuplicateEndpoint) ⇒
* [~httpPostDuplicateEndpointType(db)](#module_REST API_ user data..httpPostDuplicateEndpointType) ⇒
* [~httpPatchUpdateBitOfFeatureMapAttribute(db)](#module_REST API_ user data..httpPatchUpdateBitOfFeatureMapAttribute) ⇒
* [~httpGetDeviceTypeFeatureExists(db)](#module_REST API_ user data..httpGetDeviceTypeFeatureExists) ⇒
* [~httpGetConformDataExists(db)](#module_REST API_ user data..httpGetConformDataExists) ⇒
* [~httpPostRequiredElementWarning(db)](#module_REST API_ user data..httpPostRequiredElementWarning) ⇒
* [~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId)](#module_REST API_ user data..duplicateEndpointTypeClusters)

Expand Down Expand Up @@ -16404,10 +16405,10 @@ Update feature map attribute with given new value
| --- | --- |
| db | <code>\*</code> |

<a name="module_REST API_ user data..httpGetDeviceTypeFeatureExists"></a>
<a name="module_REST API_ user data..httpGetConformDataExists"></a>

### REST API: user data~httpGetDeviceTypeFeatureExists(db) ⇒
Check data exsit in DEVICE_TYPE_FEATURE table
### REST API: user data~httpGetConformDataExists(db) ⇒
Check if conformance data exists in the database

**Kind**: inner method of [<code>REST API: user data</code>](#module_REST API_ user data)
**Returns**: boolean value of data exist or not
Expand Down
34 changes: 28 additions & 6 deletions src-electron/db/query-feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ function filterElementsToUpdate(elements, elementMap, featureCode) {

/**
* Get warnings for element requirements that are outdated after a feature update.
*
* @param {*} featureData
* @param {*} elements
* @param {*} elementMap
Expand Down Expand Up @@ -589,16 +590,37 @@ function filterRequiredElements(elements, elementMap, featureMap) {
}

/**
* Check if DEVICE_TYPE_FEATURE table exists and is not empty.
* Check if any non-empty conformance data exist in ATTRIBUTE, COMMAND,
* and DEVICE_TYPE_FEATURE table.
*
* @export
* @param {*} db
* @returns true if DEVICE_TYPE_FEATURE table is not empty, false if not
* @returns boolean value indicating if conformance data exists
*/
async function checkIfDeviceTypeFeatureDataExist(db) {
async function checkIfConformanceDataExist(db) {
try {
let rows = await dbApi.dbAll(db, 'SELECT * FROM DEVICE_TYPE_FEATURE')
return rows.length > 0
let deviceTypeFeatureRows = await dbApi.dbAll(
db,
'SELECT DEVICE_TYPE_CLUSTER_CONFORMANCE FROM DEVICE_TYPE_FEATURE'
)
let hasFeatureConformanceData = deviceTypeFeatureRows.some((row) => {
return (
row.DEVICE_TYPE_CLUSTER_CONFORMANCE &&
row.DEVICE_TYPE_CLUSTER_CONFORMANCE.trim() != ''
)
})
let attributeRows = await dbApi.dbAll(
db,
'SELECT CONFORMANCE FROM ATTRIBUTE'
)
let commandRows = await dbApi.dbAll(db, 'SELECT CONFORMANCE FROM COMMAND')
let hasConformanceData = (rows) =>
rows.some((row) => row.CONFORMANCE && row.CONFORMANCE.trim() != '')
return (
hasConformanceData(attributeRows) &&
hasConformanceData(commandRows) &&
hasFeatureConformanceData
)
} catch (err) {
return false
}
Expand All @@ -609,5 +631,5 @@ exports.checkElementConformance = checkElementConformance
exports.evaluateConformanceExpression = evaluateConformanceExpression
exports.filterElementsContainingDesc = filterElementsContainingDesc
exports.filterRelatedDescElements = filterRelatedDescElements
exports.checkIfDeviceTypeFeatureDataExist = checkIfDeviceTypeFeatureDataExist
exports.checkIfConformanceDataExist = checkIfConformanceDataExist
exports.getOutdatedElementWarning = getOutdatedElementWarning
13 changes: 6 additions & 7 deletions src-electron/rest/user-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -1140,16 +1140,15 @@ function httpPatchUpdateBitOfFeatureMapAttribute(db) {
}

/**
* Check data exsit in DEVICE_TYPE_FEATURE table
* Check if conformance data exists in the database
*
* @param {*} db
* @returns boolean value of data exist or not
*/
function httpGetDeviceTypeFeatureExists(db) {
function httpGetConformDataExists(db) {
return async (request, response) => {
let deviceTypeFeatureExists =
await queryFeature.checkIfDeviceTypeFeatureDataExist(db)
response.status(StatusCodes.OK).json(deviceTypeFeatureExists)
let conformDataExists = await queryFeature.checkIfConformanceDataExist(db)
response.status(StatusCodes.OK).json(conformDataExists)
}
}

Expand Down Expand Up @@ -1346,8 +1345,8 @@ exports.get = [
callback: httpGetAllPackages
},
{
uri: restApi.uri.deviceTypeFeatureExists,
callback: httpGetDeviceTypeFeatureExists
uri: restApi.uri.conformDataExists,
callback: httpGetConformDataExists
}
]

Expand Down
2 changes: 1 addition & 1 deletion src-shared/rest-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const uri = {
packageNotificationById: '/packageNotificationById/:packageId',
updateNotificationToSeen: '/updateNotificationToSeen',
updateBitOfFeatureMapAttribute: '/updateBitOfFeatureMapAttribute',
deviceTypeFeatureExists: '/deviceTypeFeatureExists',
conformDataExists: '/conformDataExists',
requiredElementWarning: '/requiredElementWarning',
deleteSessionNotification: '/deleteSessionNotification',
deletePackageNotification: 'deletePackageNotification',
Expand Down
2 changes: 1 addition & 1 deletion src/components/ZclClusterManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default {
this.scrollToElementById(this.lastSelectedDomain)
}
this.changeDomainFilter(this.filter)
this.$store.dispatch('zap/updateDeviceTypeFeatureExists')
this.$store.dispatch('zap/updateConformDataExists')
},
watch: {
enabledClusters() {
Expand Down
15 changes: 6 additions & 9 deletions src/store/zap/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,17 +989,14 @@ export async function setDeviceTypeFeatures(
}

/**
* Update the deviceTypeFeatureExists state
* Update the conformDataExists state
* to show or hide of the device type features button.
* @param {*} state
* @param {*} value
* @param {*} context
*/
export function updateDeviceTypeFeatureExists(context) {
axiosRequests
.$serverGet(restApi.uri.deviceTypeFeatureExists)
.then((response) => {
context.commit('updateDeviceTypeFeatureExists', response.data)
})
export function updateConformDataExists(context) {
axiosRequests.$serverGet(restApi.uri.conformDataExists).then((response) => {
context.commit('updateConformDataExists', response.data)
})
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/store/zap/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -1163,12 +1163,12 @@ export function updateFeatureMapAttributeOfFeature(
}

/**
* Updates the deviceTypeFeatureExists state to show or hide the device type features button.
* Updates the conformDataExists state to show or hide the device type features button.
* @param {*} state
* @param {*} value
*/
export function updateDeviceTypeFeatureExists(state, value) {
vue3Set(state.featureView, 'deviceTypeFeatureExists', value)
export function updateConformDataExists(state, value) {
vue3Set(state.featureView, 'conformDataExists', value)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/store/zap/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default function () {
featureView: {
deviceTypeFeatures: [],
enabledDeviceTypeFeatures: [],
deviceTypeFeatureExists: false
conformDataExists: false
},
calledArgs: {
defaultUiMode: restApi.uiMode.ZIGBEE
Expand Down
6 changes: 3 additions & 3 deletions src/util/ui-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export default {
return categories
}
},
deviceTypeFeatureDataExists() {
return this.$store.state.zap.featureView.deviceTypeFeatureExists
conformDataExists() {
return this.$store.state.zap.featureView.conformDataExists
},
enableMatterFeatures() {
// Check if cmpEnableMatterFeatures is true
Expand Down Expand Up @@ -106,7 +106,7 @@ export default {
return this.enableMatterFeatures
},
enableFeature() {
return this.enableMatterFeatures && this.deviceTypeFeatureDataExists
return this.enableMatterFeatures && this.conformDataExists
},
enableServerOnly() {
return this.enableMatterFeatures
Expand Down

0 comments on commit c5f45e9

Please sign in to comment.