Skip to content

Commit

Permalink
server-demo: In CompositeObjectView use nodes as Object instead of Array
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Dec 23, 2021
1 parent acdcbaa commit d4d5523
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions leshan-server-demo/webapp/src/views/CompositeObjectView.vue
Expand Up @@ -36,9 +36,9 @@
</div>
<v-divider></v-divider>
<div v-for="node in lwm2mNodes" :key="node.path.toString()">
<div v-for="(node, path) in lwm2mNodes" :key="path">
<h4 class="pa-1">
{{ node.path }}
{{ path }}
<span
v-if="node.instanceNotAvailable"
class="subtitle-2 grey--text text--darken-1"
Expand Down Expand Up @@ -177,13 +177,13 @@ export default {
state() {
return this.$store.state[this.endpoint];
},
compositeObservationKey(){
compositeObservationKey() {
return this.$store.compositeObjectToKey(this.compositeObject);
},
lwm2mNodes() {
if (!this.objectdefs || this.objectdefs.length == 0) return [];
if (!this.objectdefs || this.objectdefs.length == 0) return {};
let nodes = this.compositeObject.paths.map((p) => {
let nodesArray = this.compositeObject.paths.map((p) => {
let path = new LwM2mPath(p);
// handle invalid path
if (path.type == "invalid") {
Expand Down Expand Up @@ -267,7 +267,11 @@ export default {
return { path: path };
}
});
return nodes;
return nodesArray.reduce((NodesObject, node) => {
NodesObject[node.path.toString()] = node;
return NodesObject;
}, {});
},
},
};
Expand Down

0 comments on commit d4d5523

Please sign in to comment.