Skip to content

Commit

Permalink
Merge pull request #4148 from FlowFuse/use-arrays-instead-of-maps-for…
Browse files Browse the repository at this point in the history
…-application-devices-and-instances

Swap maps with arrays on the applications page
  • Loading branch information
joepavitt authored Jul 10, 2024
2 parents 7064937 + 9432591 commit 3dc892a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</label>
<div class="items-wrapper" :class="{one: singleDevice, two: twoDevices, three: threeDevices}">
<div
v-for="device in Array.from(application.devices.values())"
v-for="device in devices"
:key="device.id"
class="item-wrapper"
@click.stop="openDevice(device)"
Expand Down Expand Up @@ -91,14 +91,14 @@ export default {
emits: ['delete-device'],
computed: {
hasMoreDevices () {
return this.application.deviceCount > this.application.devices.size
return this.application.deviceCount > this.application.devices.length
},
hasNoDevices () {
return this.application.devices.size === 0
return this.application.devices.length === 0
},
remainingDevices () {
if (this.hasNoDevices || this.hasMoreDevices) {
return this.application.deviceCount - this.application.devices.size
return this.application.deviceCount - this.application.devices.length
} else return 0
},
singleDevice () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ export default {
emits: ['delete-instance'],
computed: {
instances () {
return Array.from(this.application.instances.values())
return this.application.instances
},
hasMoreInstances () {
return this.application.instanceCount > this.application.instances.size
return this.application.instanceCount > this.application.instances.length
},
hasNoInstances () {
return this.application.instances.size === 0
return this.application.instances.length === 0
},
remainingInstances () {
if (this.hasNoInstances || this.hasMoreInstances) {
return this.application.instanceCount - this.application.instances.size
return this.application.instanceCount - this.application.instances.length
} else return 0
},
singleInstance () {
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/pages/team/Applications/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ export default {
},
computed: {
applicationsList () {
return Array.from(this.applications.values())
return Array.from(this.applications.values()).map(app => {
return {
...app,
instances: Array.from(app.instances.values()),
devices: Array.from(app.devices.values())
}
})
},
filteredApplications () {
if (this.filterTerm) {
Expand Down

0 comments on commit 3dc892a

Please sign in to comment.