Skip to content

Commit

Permalink
aesthetic changes and connection with backend
Browse files Browse the repository at this point in the history
breadcrums display selcted cluster
breadcums are not connected to anything else
fixed padding in heading 2
commands are now light
connected to backend
JIRA ZAPP-200
JIRA:ZAPP-200
JIRA:ZAPP-201
  • Loading branch information
alexroxy17 authored and thucdtran committed Aug 12, 2020
1 parent e02be95 commit 8029e09
Show file tree
Hide file tree
Showing 3 changed files with 299 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/components/ZclClusterView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
<template>
<div>
<q-page padding>
<div class="row q-mb-none">
<div class="row q-py-none">
<q-btn
flat
dense
Expand All @@ -25,30 +25,30 @@ limitations under the License.
icon="keyboard_arrow_left"
/>
<q-breadcrumbs>
<!-- not sure how this aspect will work so it was left alone -->
<q-breadcrumbs-el
v-for="locationBreadcrum in clusters.locationBreadcrums"
:key="locationBreadcrum"
>
{{ locationBreadcrum }}
</q-breadcrumbs-el>
<!-- this needs to be updated depending on how the pages will work -->
<q-breadcrumbs-el label="Endpoint x0001" to="/"></q-breadcrumbs-el>
<q-breadcrumbs-el label="General Clusters" to="/"></q-breadcrumbs-el>
<q-breadcrumbs-el label="{{ item.label }}" to="/"></q-breadcrumbs-el>
</q-breadcrumbs>
</div>

<h2 class="q-py-none">
<h2 class="q-py-sm">
<b>{{ item.label }}</b>
</h2>

<div class="row q-py-none">
<div class="col">
<p v-if="selectionServer">
Cluster ID: 0x000{{ item.id }}, Enabled for <b>Server</b>
<p v-if="selectionServer && selectionClient">
Cluster ID: 0x000{{ item.id }}, Enabled for <b>Server</b> and
<b>Client</b>
</p>
<p v-else-if="~selectionServer && selectionClient">
Cluster ID: 0x000{{ item.id }}, Enabled for <b>Client</b>
</p>
<p v-else>
Cluster ID: 0x000{{ item.id }}, Disabled for <b>Server</b>
<p v-else-if="selectionServer && ~selectionClient">
Cluster ID: 0x000{{ item.id }}, Enable for <b>Server</b>
</p>
<p v-if="selectionClient">Enabled for <b>Client</b></p>
<p v-else>Disabled for <b>Client</b></p>
<p v-else>Cluster ID: 0x000{{ item.id }}, Disabled for <b>all</b></p>
</div>
<div>
<q-toggle
Expand All @@ -74,7 +74,7 @@ limitations under the License.
<ZclAttributeView />
</div>
<div class="col" v-show="tab == 'commands'">
<ZclCommandView />
<ZclCommandnewView />
</div>
<div class="col" v-show="tab == 'reporting'">
<ZclReportingView />
Expand All @@ -85,7 +85,7 @@ limitations under the License.
</template>
<script>
import ZclAttributeView from './ZclAttributeView.vue'
import ZclCommandView from './ZclCommandView.vue'
import ZclCommandnewView from './ZclCommandnewView.vue'
import ZclClusterInfo from './ZclClusterInfo.vue'
import ZclReportingView from './ZclReportingView.vue'
Expand Down Expand Up @@ -132,7 +132,7 @@ export default {
components: {
ZclAttributeView,
ZclCommandView,
ZclCommandnewView,
ZclReportingView,
},
}
Expand Down
277 changes: 277 additions & 0 deletions src/components/ZclCommandnewView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
<!--
Copyright (c) 2008,2020 Silicon Labs.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<template>
<div v-show="commandData.length > 0">
<q-table
title="Commands"
:data="commandData"
:columns="columns"
row-key="name"
dense
wrap-cells
binary-state-sort
:pagination.sync="pagination"
>
<template v-slot:body="props">
<q-tr :props="props" light>
<q-td key="out" :props="props" auto-width>
<q-checkbox
class="q-mt-xs"
v-model="selectionOut"
:val="hashCommandIdClusterId(props.row.id, selectedCluster.id)"
indeterminate-value="false"
keep-color
:color="
handleColorSelection(
selectionOut,
requiredCommands,
props.row,
selectedCluster.id
)
"
@input="
handleCommandSelection(
selectionOut,
'selectedOut',
props.row,
selectedCluster.id
)
"
/>
</q-td>
<q-td key="in" :props="props" auto-width>
<q-checkbox
class="q-mt-xs"
v-model="selectionIn"
:val="hashCommandIdClusterId(props.row.id, selectedCluster.id)"
indeterminate-value="false"
keep-color
:color="'primary'"
@input="
handleCommandSelection(
selectionIn,
'selectedIn',
props.row,
selectedCluster.id
)
"
/>
</q-td>
<q-td key="direction" :props="props" auto-width>{{
props.row.source === 'client' ? 'C ➞ S' : 'S ➞ C'
}}</q-td>
<q-td key="commandId" :props="props" auto-width>{{
props.row.code
}}</q-td>
<q-td key="commandName" :props="props" auto-width>{{
props.row.label
}}</q-td>
<!-- TODO add required column -->
<q-td key="mfgId" :props="props" auto-width>{{
props.row.manufacturerCode
}}</q-td>
</q-tr>
</template>
</q-table>
</div>
</template>

<script>
import * as Util from '../util/util.js'
import * as RestApi from '../../src-shared/rest-api'
export default {
name: 'ZclCommandnewView',
mounted() {
this.$serverOn('zcl-item', (event, arg) => {
if (arg.type === 'cluster') {
this.$store.dispatch('zap/updateCommands', arg.commandData || [])
}
if (arg.type === 'endpointTypeCommands') {
this.$store.dispatch('zap/setCommandStateLists', arg.data)
}
if (arg.type === 'deviceTypeCommands') {
this.$store.dispatch('zap/setRequiredCommands', arg.data)
}
})
this.$serverOn(RestApi.replyId.singleCommandState, (event, arg) => {
if (arg.action === 'boolean') {
this.$store.dispatch('zap/updateSelectedCommands', {
id: this.hashCommandIdClusterId(arg.id, arg.clusterRef),
added: arg.added,
listType: arg.listType,
view: 'commandView',
})
}
})
},
computed: {
commandData: {
get() {
return this.$store.state.zap.commands
},
},
selectionIn: {
get() {
return this.$store.state.zap.commandView.selectedIn
},
},
selectionOut: {
get() {
return this.$store.state.zap.commandView.selectedOut
},
},
selectedEndpointId: {
get() {
return this.$store.state.zap.endpointTypeView.selectedEndpointType
},
},
requiredCommands: {
get() {
return this.$store.state.zap.commandView.requiredCommands
},
},
selectionClusterClient: {
get() {
return this.$store.state.zap.clustersView.selectedClients
},
},
selectionClusterServer: {
get() {
return this.$store.state.zap.clustersView.selectedServers
},
},
selectedCluster: {
get() {
return this.$store.state.zap.clustersView.selected[0] || {}
},
},
},
methods: {
handleCommandSelection(list, listType, commandData, clusterId) {
// We determine the ID that we need to toggle within the list.
// This ID comes from hashing the base Command ID and cluster data.
var indexOfValue = list.indexOf(
this.hashCommandIdClusterId(commandData.id, clusterId)
)
var addedValue = false
if (indexOfValue === -1) {
addedValue = true
} else {
addedValue = false
}
this.$serverPost(`/command/update`, {
action: 'boolean',
endpointTypeId: this.selectedEndpointId,
id: commandData.id,
value: addedValue,
listType: listType,
clusterRef: clusterId,
commandSide: commandData.source,
})
},
handleColorSelection(selectedList, recommendedList, command, clusterId) {
let relevantClusterList =
command.source === 'client'
? this.selectionClusterClient
: this.selectionClusterServer
let isClusterIncluded = relevantClusterList.includes(clusterId)
let isCommandRecommended =
recommendedList.includes(command.id) || !command.isOptional
let isCommandIncluded = selectedList.includes(
this.hashCommandIdClusterId(command.id, clusterId)
)
if (isCommandRecommended && isCommandIncluded && isClusterIncluded) {
return 'green'
} else if (
isCommandRecommended &&
!isCommandIncluded &&
isClusterIncluded
) {
return 'red'
} else if (
isCommandRecommended &&
isCommandIncluded &&
!isClusterIncluded
) {
return 'orange'
} else {
return 'primary'
}
},
hashCommandIdClusterId(commandId, clusterId) {
return Util.cantorPair(commandId, clusterId)
},
},
data() {
return {
pagination: {
rowsPerPage: 0,
},
columns: [
{
name: 'out',
label: 'Out',
field: 'out',
align: 'left',
sortable: true,
},
{
name: 'in',
label: 'In',
field: 'in',
align: 'left',
sortable: true,
},
{
name: 'direction',
label: 'Direction',
field: 'direction',
align: 'left',
sortable: true,
},
{
name: 'commandId',
align: 'left',
label: 'Command ID',
field: 'commandId',
sortable: true,
},
// TODO add required column
{
name: 'commandName',
align: 'left',
label: 'Command Name',
field: 'commandName',
sortable: true,
},
{
name: 'mfgId',
align: 'left',
label: 'Manufacturing Id',
field: 'mfgId',
sortable: true,
},
],
}
},
}
</script>
4 changes: 4 additions & 0 deletions src/css/quasar.variables.sass
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ $positive : #21BA45
$negative : #C10015
$info : #31CCEC
$warning : #F2C037

h2
padding: 0px
margin: 0px

0 comments on commit 8029e09

Please sign in to comment.