Skip to content

Commit

Permalink
feat: active status and disable non requested security classes in pro…
Browse files Browse the repository at this point in the history
…visioning entities (#2410)
  • Loading branch information
robertsLando committed May 5, 2022
1 parent 30c28e0 commit 11dd784
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 12 deletions.
4 changes: 3 additions & 1 deletion lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,9 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
/**
* Start exclusion
*/
async startExclusion(unprovision = true): Promise<boolean> {
async startExclusion(
unprovision: boolean | 'inactive' = 'inactive'
): Promise<boolean> {
if (this.driverReady) {
if (this.commandsTimeout) {
clearTimeout(this.commandsTimeout)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"vuetify": "^2.5.9",
"vuex": "^3.6.2",
"winston": "^3.3.3",
"zwave-js": "^9.2.0"
"zwave-js": "^9.2.1"
},
"devDependencies": {
"@babel/cli": "^7.15.7",
Expand Down
7 changes: 7 additions & 0 deletions src/components/Confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
:rules="input.rules || []"
:required="input.required"
:min="input.min"
:disabled="input.disabled"
:persistent-hint="!!input.hint"
:max="input.max"
></v-text-field>
Expand All @@ -53,6 +54,7 @@
:required="input.required"
:min="input.min"
:max="input.max"
:disabled="input.disabled"
></v-text-field>
<v-switch
v-if="input.type === 'boolean'"
Expand All @@ -62,6 +64,7 @@
:hint="input.hint"
:persistent-hint="!!input.hint"
:required="input.required"
:disabled="input.disabled"
></v-switch>
<v-checkbox
v-if="input.type === 'checkbox'"
Expand All @@ -71,6 +74,7 @@
:hint="input.hint"
:persistent-hint="!!input.hint"
:required="input.required"
:disabled="input.disabled"
></v-checkbox>
<v-select
v-if="
Expand All @@ -87,6 +91,7 @@
:multiple="!!input.multiple"
:hint="input.hint"
:required="input.required"
:disabled="input.disabled"
></v-select>
<v-combobox
v-if="
Expand All @@ -105,6 +110,7 @@
:hint="input.hint"
:return-object="false"
:required="input.required"
:disabled="input.disabled"
>
</v-combobox>
<v-container v-if="input.type === 'code'">
Expand All @@ -115,6 +121,7 @@
v-model="values[input.key]"
language="js"
:highlight="highlighter"
:disabled="input.disabled"
></prism-editor>
</v-container>
</v-col>
Expand Down
39 changes: 39 additions & 0 deletions src/components/SmartStart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
<h1 class="display-1 my-4">Provisioning Entities</h1>

<v-data-table :headers="headers" :items="items" class="elevation-1">
<template v-slot:[`item.status`]="{ item }">
<v-switch
v-model="item.status"
@change="onChange(item)"
dense
></v-switch>
</template>

<template
v-slot:[`item.securityClasses.s2AccessControl`]="{ item }"
>
<v-checkbox
v-model="item.securityClasses.s2AccessControl"
@change="onChange(item)"
:disabled="!item.requestedSecurityClasses.s2AccessControl"
hide-details
dense
></v-checkbox>
Expand All @@ -19,6 +28,7 @@
<v-checkbox
v-model="item.securityClasses.s2Authenticated"
@change="onChange(item)"
:disabled="!item.requestedSecurityClasses.s2Authenticated"
hide-details
dense
></v-checkbox>
Expand All @@ -28,6 +38,7 @@
>
<v-checkbox
v-model="item.securityClasses.s2Unauthenticated"
:disabled="!item.requestedSecurityClasses.s2Unauthenticated"
@change="onChange(item)"
hide-details
dense
Expand All @@ -36,6 +47,7 @@
<template v-slot:[`item.securityClasses.s0Legacy`]="{ item }">
<v-checkbox
v-model="item.securityClasses.s0Legacy"
:disabled="!item.requestedSecurityClasses.s0Legacy"
@change="onChange(item)"
hide-details
dense
Expand Down Expand Up @@ -139,6 +151,7 @@ import {
validDsk,
securityClassesToArray,
} from '../lib/utils.js'
// import { ProvisioningEntryStatus } from 'zwave-js/safe'
export default {
name: 'SmartStart',
Expand All @@ -157,6 +170,7 @@ export default {
{ text: 'ID', value: 'nodeId' },
{ text: 'Name', value: 'name' },
{ text: 'Location', value: 'location' },
{ text: 'Active', value: 'status' },
{ text: 'DSK', value: 'dsk' },
{
text: 'S2 Access Control',
Expand Down Expand Up @@ -253,6 +267,10 @@ export default {
type: 'checkbox',
label: 'S2 Access Control',
key: 's2AccessControl',
disabled: existingItem
? !existingItem.requestedSecurityClasses
.s2AccessControl
: false,
default: existingItem
? existingItem.securityClasses.s2AccessControl
: false,
Expand All @@ -261,6 +279,10 @@ export default {
type: 'checkbox',
label: 'S2 Authenticated',
key: 's2Authenticated',
disabled: existingItem
? !existingItem.requestedSecurityClasses
.s2Authenticated
: false,
default: existingItem
? existingItem.securityClasses.s2Authenticated
: false,
Expand All @@ -269,6 +291,10 @@ export default {
type: 'checkbox',
label: 'S2 Unauthenticated',
key: 's2Unauthenticated',
disabled: existingItem
? !existingItem.requestedSecurityClasses
.s2Unauthenticated
: false,
default: existingItem
? existingItem.securityClasses.s2Unauthenticated
: false,
Expand All @@ -277,6 +303,10 @@ export default {
type: 'checkbox',
label: 'S0 Legacy',
key: 's0Legacy',
disabled: existingItem
? !existingItem.requestedSecurityClasses
.s0Legacy
: false,
default: existingItem
? existingItem.securityClasses.s0Legacy
: false,
Expand Down Expand Up @@ -324,17 +354,26 @@ export default {
return items.map((item) => {
return {
...item,
status: !item.status,
securityClasses: parseSecurityClasses(
item.securityClasses,
false
),
requestedSecurityClasses: parseSecurityClasses(
item.requestedSecurityClasses,
item.requestedSecurityClasses ? false : true
),
}
})
},
convertItem(item) {
item = {
...item,
status: item.status ? 0 : 1,
securityClasses: securityClassesToArray(item.securityClasses),
requestedSecurityClasses: securityClassesToArray(
item.requestedSecurityClasses
),
}
return item
Expand Down
2 changes: 2 additions & 0 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export function wait(ms) {
}

export function parseSecurityClasses(securityClasses, defaultVal) {
securityClasses = Array.isArray(securityClasses) ? securityClasses : []
const classes = {
s2AccessControl: defaultVal,
s2Authenticated: defaultVal,
Expand Down Expand Up @@ -38,6 +39,7 @@ export function parseSecurityClasses(securityClasses, defaultVal) {

export function securityClassesToArray(securityClasses) {
const classes = []
securityClasses = securityClasses || {}
for (const c in securityClasses) {
if (securityClasses[c] === true) {
switch (c) {
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3030,9 +3030,9 @@ __metadata:
languageName: node
linkType: hard

"@zwave-js/config@npm:9.2.0":
version: 9.2.0
resolution: "@zwave-js/config@npm:9.2.0"
"@zwave-js/config@npm:9.2.1":
version: 9.2.1
resolution: "@zwave-js/config@npm:9.2.1"
dependencies:
"@zwave-js/core": 9.2.0
"@zwave-js/shared": 9.1.0
Expand All @@ -3043,7 +3043,7 @@ __metadata:
json5: ^2.2.1
semver: ^7.3.7
winston: ^3.7.2
checksum: 58a6b02a619736be186e3be3278e1114edc84a9c704aea223c211234064bf3dd068ab708a27c73363adcbeb37667424959e9514664dd73013e129bb28eed5515
checksum: 859c20b7f4a3293787435ee6f703af55628cb3181bd7841354d37f819713fc9cab70e4ea939bd35d645a800c59f897880d855cafd235c0759f6c0d4b49f26987
languageName: node
linkType: hard

Expand Down Expand Up @@ -15801,15 +15801,15 @@ __metadata:
languageName: node
linkType: hard

"zwave-js@npm:^9.2.0":
version: 9.2.0
resolution: "zwave-js@npm:9.2.0"
"zwave-js@npm:^9.2.1":
version: 9.2.1
resolution: "zwave-js@npm:9.2.1"
dependencies:
"@alcalzone/jsonl-db": ^2.5.2
"@alcalzone/pak": ^0.8.1
"@sentry/integrations": ^6.19.7
"@sentry/node": ^6.19.7
"@zwave-js/config": 9.2.0
"@zwave-js/config": 9.2.1
"@zwave-js/core": 9.2.0
"@zwave-js/nvmedit": 9.2.0
"@zwave-js/serial": 9.2.0
Expand All @@ -15826,7 +15826,7 @@ __metadata:
source-map-support: ^0.5.21
winston: ^3.7.2
xstate: ^4.29.0
checksum: 2d20a59a2eef7ecdd05916a2f0a39a9a495fda1137a3a0f2fe0889add3b776c1f328b11dc5c3d84b688d920071850ae084c99bcb7c489cf29a5d00e77079f971
checksum: 3ef9e6730c0f2af1714f069f6deb2e2d5f9ab081ac8b51aeaeea232fcca52b5cea7e978ff8a34eb1dbe0db03775c5653395381c2642cf3a60b862b2d50bc88b5
languageName: node
linkType: hard

Expand Down Expand Up @@ -15984,7 +15984,7 @@ __metadata:
webpack-dev-server: ^4.3.1
webpack-merge: ^5.8.0
winston: ^3.3.3
zwave-js: ^9.2.0
zwave-js: ^9.2.1
dependenciesMeta:
"@release-it/conventional-changelog":
optional: true
Expand Down

0 comments on commit 11dd784

Please sign in to comment.