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

Silabs #375

Merged
merged 18 commits into from
Jan 21, 2022
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
55 changes: 55 additions & 0 deletions cypress/integration/theme/theme.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/// <reference types="cypress" />

const { find } = require('underscore')
const rendApi = require('../../../src-shared/rend-api.js')

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})
describe('Check theme functionality', () => {
beforeEach(() => {
cy.visit('http://localhost:8080/?restPort=9070#/')
})

it('Setting light theme via Preference / calling rendereApi with boolean arg', () => {
cy.get('#preference').click()
cy.wait(1000)
cy.get('#darkTheme')
// .parent()
// .get('[type="checkbox"]')
.find('input')
.uncheck({ force: true })

cy.get('body').should('have.css', 'background-color', 'rgba(0, 0, 0, 0)')
})

it('Setting dark theme via Preference / calling rendereApi with boolean arg', () => {
cy.get('#preference').click()
cy.wait(1000)
cy.get('#darkTheme')
// .parent()
// .get('[type="checkbox"]')
.find('input')
.check({ force: true })

cy.get('body').should('have.css', 'background-color', 'rgb(39, 40, 33)')
})

it('Setting light theme via rendererApi with string arg', () => {
cy.window().then(function (window) {
window[rendApi.GLOBAL_SYMBOL_EXECUTE](rendApi.id.setDarkTheme, 'false')
})

cy.get('body').should('have.css', 'background-color', 'rgba(0, 0, 0, 0)')
})

it('Setting dark theme via rendererApi with string arg', () => {
cy.window().then(function (window) {
window[rendApi.GLOBAL_SYMBOL_EXECUTE](rendApi.id.setDarkTheme, 'true')
})

cy.get('body').should('have.css', 'background-color', 'rgb(39, 40, 33)')
})
})
4 changes: 2 additions & 2 deletions docs/zap-schema.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "commonjs",
"name": "zap",
"version": "2022.1.10",
"version": "2022.1.20",
"description": "Configuration tool for the Zigbee Cluster Library",
"productName": "zap",
"cordovaId": "",
Expand All @@ -28,7 +28,7 @@
"test:e2e": "npm run zap-devserver | start-test \"quasar dev\" http-get://localhost:8080 \"cypress open\"",
"test:e2e-ci": "npm run zap-devserver | start-test \"quasar dev\" http-get://localhost:8080 \"cypress run\"",
"postinstall": "electron-builder install-app-deps && husky install && npm rebuild canvas --update-binary",
"wpzap": "npm run build-spa && npm run build-backend && npm run dist-mac",
"wpzap": "npm run build-spa && npm run build-backend && npm run dist-mac && npm run apack:mac",
"zap": "node src-script/zap-start.js --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json",
"zap-dev": "npm run build-spa && quasar dev -m electron",
"zap-devserver": "node src-script/zap-start.js server --allowCors --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json --reuseZapInstance",
Expand Down
1 change: 1 addition & 0 deletions quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

module.exports = function (ctx) {
return {
supportTS: true,
// Source files of application
sourceFiles: {
rootComponent: 'src/App.vue',
Expand Down
6 changes: 5 additions & 1 deletion src-electron/db/db-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

const dbApi = require('./db-api.js')
const dbEnums = require('../../src-shared/db-enum.js')

exports.map = {
package: (x) => {
Expand Down Expand Up @@ -104,7 +105,10 @@ exports.map = {
isNullable: dbApi.fromDbBool(x.IS_NULLABLE),
defaultValue: x.DEFAULT_VALUE,
isOptional: dbApi.fromDbBool(x.IS_OPTIONAL),
isReportable: dbApi.fromDbBool(x.IS_REPORTABLE),
isReportable:
x.REPORTING_POLICY == dbEnums.reportingPolicy.mandatory ||
x.REPORTING_POLICY == dbEnums.reportingPolicy.suggested,
reportingPolicy: x.REPORTING_POLICY,
isSceneRequired: dbApi.fromDbBool(x.IS_SCENE_REQUIRED),
entryType: x.ARRAY_TYPE,
mustUseTimedWrite: dbApi.fromDbBool(x.MUST_USE_TIMED_WRITE),
Expand Down
4 changes: 2 additions & 2 deletions src-electron/db/query-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ SELECT
A.IS_WRITABLE,
A.DEFAULT_VALUE,
A.IS_OPTIONAL,
A.IS_REPORTABLE,
A.REPORTING_POLICY,
A.IS_NULLABLE,
A.IS_SCENE_REQUIRED,
A.ARRAY_TYPE,
Expand Down Expand Up @@ -830,7 +830,7 @@ SELECT
A.IS_WRITABLE,
A.DEFAULT_VALUE,
A.IS_OPTIONAL,
A.IS_REPORTABLE,
A.REPORTING_POLICY,
A.IS_NULLABLE,
A.IS_SCENE_REQUIRED,
A.ARRAY_TYPE,
Expand Down
150 changes: 99 additions & 51 deletions src-electron/db/query-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,41 @@ SELECT
ENDPOINT_TYPE_COMMAND.INCOMING AS INCOMING,
ENDPOINT_TYPE_COMMAND.OUTGOING AS OUTGOING,
COUNT(COMMAND.MANUFACTURER_CODE) OVER () AS MANUFACTURING_SPECIFIC_COMMAND_COUNT
FROM COMMAND
INNER JOIN ENDPOINT_TYPE_COMMAND
ON ENDPOINT_TYPE_COMMAND.COMMAND_REF = COMMAND.COMMAND_ID
INNER JOIN CLUSTER
ON CLUSTER.CLUSTER_ID = COMMAND.CLUSTER_REF
INNER JOIN ENDPOINT_TYPE_CLUSTER
ON ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
WHERE ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_REF IN (${endpointTypeIds})
AND ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_REF = ENDPOINT_TYPE_CLUSTER.ENDPOINT_TYPE_REF
AND ENDPOINT_TYPE_CLUSTER.SIDE IN ("client", "server") AND ENDPOINT_TYPE_CLUSTER.ENABLED=1
AND (
(ENDPOINT_TYPE_COMMAND.INCOMING=1 AND COMMAND.SOURCE!=ENDPOINT_TYPE_CLUSTER.SIDE) OR
(ENDPOINT_TYPE_COMMAND.OUTGOING=1 AND COMMAND.SOURCE=ENDPOINT_TYPE_CLUSTER.SIDE)
)
GROUP BY CLUSTER.MANUFACTURER_CODE, CLUSTER.NAME, COMMAND.MANUFACTURER_CODE, COMMAND.NAME, ENDPOINT_TYPE_CLUSTER.SIDE ) GROUP BY CLUSTER_MANUFACTURER_CODE, CLUSTER_NAME, COMMAND_MANUFACTURER_CODE, COMMAND_NAME ORDER BY CLUSTER_MANUFACTURER_CODE, CLUSTER_CODE, COMMAND_MANUFACTURER_CODE, COMMAND_CODE`
FROM
COMMAND
INNER JOIN
ENDPOINT_TYPE_COMMAND
ON
ENDPOINT_TYPE_COMMAND.COMMAND_REF = COMMAND.COMMAND_ID
INNER JOIN
CLUSTER
ON
CLUSTER.CLUSTER_ID = COMMAND.CLUSTER_REF
INNER JOIN
ENDPOINT_TYPE_CLUSTER
ON
ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
WHERE
ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_REF IN (${endpointTypeIds})
AND ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_REF = ENDPOINT_TYPE_CLUSTER.ENDPOINT_TYPE_REF
AND ENDPOINT_TYPE_CLUSTER.SIDE IN ("client", "server") AND ENDPOINT_TYPE_CLUSTER.ENABLED=1
AND (
(ENDPOINT_TYPE_COMMAND.INCOMING=1 AND COMMAND.SOURCE!=ENDPOINT_TYPE_CLUSTER.SIDE) OR
(ENDPOINT_TYPE_COMMAND.OUTGOING=1 AND COMMAND.SOURCE=ENDPOINT_TYPE_CLUSTER.SIDE)
)
GROUP BY
CLUSTER.MANUFACTURER_CODE,
CLUSTER.NAME,
COMMAND.MANUFACTURER_CODE,
COMMAND.NAME,
ENDPOINT_TYPE_CLUSTER.SIDE )
GROUP BY
CLUSTER_MANUFACTURER_CODE,
CLUSTER_NAME,
COMMAND_MANUFACTURER_CODE,
COMMAND_NAME
ORDER BY
CLUSTER_MANUFACTURER_CODE, CLUSTER_CODE, COMMAND_MANUFACTURER_CODE, COMMAND_CODE`
)
.then((rows) => rows.map(mapFunction))
}
Expand Down Expand Up @@ -313,7 +333,9 @@ WHERE
AND COMMAND.SOURCE != ENDPOINT_TYPE_CLUSTER.SIDE
AND CLUSTER.CODE = ${clusterCode}
GROUP BY
CLUSTER.NAME, ENDPOINT_TYPE_CLUSTER.SIDE ORDER BY CLUSTER.NAME, ENDPOINT_TYPE_CLUSTER.SIDE`
CLUSTER.NAME, ENDPOINT_TYPE_CLUSTER.SIDE
ORDER BY
CLUSTER.NAME, ENDPOINT_TYPE_CLUSTER.SIDE`
)
.then((rows) => rows.map(mapFunction))
}
Expand Down Expand Up @@ -418,6 +440,16 @@ async function selectAllIncomingCommandsForClusterCombined(
)
}

/**
* Returns all incoming per cluster commands.
*
* @param {*} db
* @param {*} endpointTypes
* @param {*} clName
* @param {*} clSide
* @param {*} isMfgSpecific
* @returns promise of incoming per-cluster commands.
*/
async function selectAllIncomingCommandsForCluster(
db,
endpointTypes,
Expand Down Expand Up @@ -476,23 +508,39 @@ SELECT
ENDPOINT_TYPE_COMMAND.INCOMING AS INCOMING,
ENDPOINT_TYPE_COMMAND.OUTGOING AS OUTGOING,
COUNT(COMMAND.MANUFACTURER_CODE) OVER () AS MANUFACTURING_SPECIFIC_COMMAND_COUNT
FROM COMMAND
INNER JOIN ENDPOINT_TYPE_COMMAND
ON ENDPOINT_TYPE_COMMAND.COMMAND_REF = COMMAND.COMMAND_ID
INNER JOIN CLUSTER
ON CLUSTER.CLUSTER_ID = COMMAND.CLUSTER_REF
INNER JOIN ENDPOINT_TYPE_CLUSTER
ON ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
WHERE ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_REF IN (${endpointTypeIds})
AND ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_REF = ENDPOINT_TYPE_CLUSTER.ENDPOINT_TYPE_REF
AND ENDPOINT_TYPE_CLUSTER.SIDE IN ("client", "server") AND ENDPOINT_TYPE_CLUSTER.ENABLED=1
AND ENDPOINT_TYPE_COMMAND.INCOMING=1 AND COMMAND.SOURCE!=ENDPOINT_TYPE_CLUSTER.SIDE
AND CLUSTER.NAME = "${clName}" AND ENDPOINT_TYPE_CLUSTER.SIDE = "${clSide}"
${mfgSpecificString} GROUP BY COMMAND.NAME`
FROM
COMMAND
INNER JOIN
ENDPOINT_TYPE_COMMAND
ON
ENDPOINT_TYPE_COMMAND.COMMAND_REF = COMMAND.COMMAND_ID
INNER JOIN
CLUSTER
ON
CLUSTER.CLUSTER_ID = COMMAND.CLUSTER_REF
INNER JOIN
ENDPOINT_TYPE_CLUSTER
ON
ENDPOINT_TYPE_CLUSTER.CLUSTER_REF = CLUSTER.CLUSTER_ID
WHERE
ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_REF IN (${endpointTypeIds})
AND ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_REF = ENDPOINT_TYPE_CLUSTER.ENDPOINT_TYPE_REF
AND ENDPOINT_TYPE_CLUSTER.SIDE IN ("client", "server") AND ENDPOINT_TYPE_CLUSTER.ENABLED=1
AND ENDPOINT_TYPE_COMMAND.INCOMING=1 AND COMMAND.SOURCE!=ENDPOINT_TYPE_CLUSTER.SIDE
AND CLUSTER.NAME = "${clName}" AND ENDPOINT_TYPE_CLUSTER.SIDE = "${clSide}"
${mfgSpecificString}
GROUP BY COMMAND.NAME`
)
.then((rows) => rows.map(mapFunction))
}

/**
* Returns all incoming commands.
* @param {*} db
* @param {*} endpointTypes
* @param {*} isMfgSpecific
* @returns promise of all incoming commands.
*/
async function selectAllIncomingCommands(db, endpointTypes, isMfgSpecific) {
let endpointTypeIds = endpointTypes.map((ep) => ep.endpointTypeId).toString()
let mfgSpecificString =
Expand Down Expand Up @@ -1342,40 +1390,40 @@ async function selectCommandDetailsFromAllEndpointTypesAndClusters(
.toString()
let query = `
SELECT
COMMAND.COMMAND_ID,
COMMAND.NAME,
COMMAND.CODE,
COMMAND.SOURCE,
COMMAND.MANUFACTURER_CODE,
ENDPOINT_TYPE_COMMAND.INCOMING,
ENDPOINT_TYPE_COMMAND.OUTGOING,
COMMAND.DESCRIPTION,
COMMAND.RESPONSE_REF,
COMMAND.MUST_USE_TIMED_INVOKE,
ENDPOINT_TYPE_CLUSTER.SIDE,
CLUSTER.NAME AS CLUSTER_NAME,
ENDPOINT_TYPE_CLUSTER.ENABLED
C.COMMAND_ID,
C.NAME,
C.CODE,
C.SOURCE,
C.MANUFACTURER_CODE,
C.DESCRIPTION,
C.RESPONSE_REF,
C.MUST_USE_TIMED_INVOKE,
ETC.INCOMING,
ETC.OUTGOING,
ETCL.SIDE,
ETCL.ENABLED,
CLUSTER.NAME AS CLUSTER_NAME
FROM
COMMAND
COMMAND AS C
INNER JOIN
ENDPOINT_TYPE_COMMAND
ENDPOINT_TYPE_COMMAND AS ETC
ON
COMMAND.COMMAND_ID = ENDPOINT_TYPE_COMMAND.COMMAND_REF
C.COMMAND_ID = ETC.COMMAND_REF
INNER JOIN
ENDPOINT_TYPE_CLUSTER
ENDPOINT_TYPE_CLUSTER AS ETCL
ON
ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_CLUSTER_REF = ENDPOINT_TYPE_CLUSTER.ENDPOINT_TYPE_CLUSTER_ID
ETC.ENDPOINT_TYPE_CLUSTER_REF = ETCL.ENDPOINT_TYPE_CLUSTER_ID
INNER JOIN
CLUSTER
ON
COMMAND.CLUSTER_REF = CLUSTER.CLUSTER_ID
C.CLUSTER_REF = CLUSTER.CLUSTER_ID
WHERE
ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_REF IN (${endpointTypeIds})
AND ENDPOINT_TYPE_COMMAND.ENDPOINT_TYPE_CLUSTER_REF in (${endpointClusterIds}) `
ETC.ENDPOINT_TYPE_REF IN (${endpointTypeIds})
AND ETC.ENDPOINT_TYPE_CLUSTER_REF in (${endpointClusterIds}) `

if (doGroupBy) {
// See: https://github.com/project-chip/zap/issues/192
query = query + ` GROUP BY COMMAND.NAME, COMMAND.COMMAND_ID`
query = query + ` GROUP BY C.NAME, C.COMMAND_ID`
}

return dbApi.dbAll(db, query).then((rows) => rows.map(commandMapFunction))
Expand Down
11 changes: 9 additions & 2 deletions src-electron/db/query-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,11 @@ async function resolveDefaultDeviceTypeAttributes(
},
{
key: restApi.updateKey.attributeReporting,
value: deviceAttribute.isReportable == true,
value:
deviceAttribute.reportingPolicy ==
dbEnum.reportingPolicy.mandatory ||
deviceAttribute.reportingPolicy ==
dbEnum.reportingPolicy.suggested,
},
],
attribute.reportMinInterval,
Expand Down Expand Up @@ -832,7 +836,10 @@ async function resolveNonOptionalAndReportableAttributes(
) {
let promises = attributes.map((attribute) => {
let settings = []
if (attribute.isReportable)
if (
attribute.reportingPolicy == dbEnum.reportingPolicy.mandatory ||
attribute.reportingPolicy == dbEnum.reportingPolicy.suggested
)
settings.push({
key: restApi.updateKey.attributeReporting,
value: true,
Expand Down
Loading