From 33b4794c3c2d30c156400c0c5e21739690430350 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Thu, 16 Mar 2023 19:54:27 +0100 Subject: [PATCH] webapp: Optimize pinview. Build output based on given json data instead of hard coded values --- webapp/src/components/PinInfo.vue | 159 ++++++++++++------------------ 1 file changed, 63 insertions(+), 96 deletions(-) diff --git a/webapp/src/components/PinInfo.vue b/webapp/src/components/PinInfo.vue index de7524b7..0770e3d5 100644 --- a/webapp/src/components/PinInfo.vue +++ b/webapp/src/components/PinInfo.vue @@ -11,102 +11,21 @@ - - NRF24 - MISO - {{ selectedPinAssignment?.nrf24?.miso }} - {{ currentPinAssignment?.nrf24?.miso }} - - - MOSI - {{ selectedPinAssignment?.nrf24?.mosi }} - {{ currentPinAssignment?.nrf24?.mosi }} - - - CLK - {{ selectedPinAssignment?.nrf24?.clk }} - {{ currentPinAssignment?.nrf24?.clk }} - - - IRQ - {{ selectedPinAssignment?.nrf24?.irq }} - {{ currentPinAssignment?.nrf24?.irq }} - - - EN - {{ selectedPinAssignment?.nrf24?.en }} - {{ currentPinAssignment?.nrf24?.en }} - - - CS - {{ selectedPinAssignment?.nrf24?.cs }} - {{ currentPinAssignment?.nrf24?.cs }} - - - - Ethernet - enabled - {{ selectedPinAssignment?.eth?.enabled }} - {{ currentPinAssignment?.eth?.enabled }} - - - phy_addr - {{ selectedPinAssignment?.eth?.phy_addr }} - {{ currentPinAssignment?.eth?.phy_addr }} - - - power - {{ selectedPinAssignment?.eth?.power }} - {{ currentPinAssignment?.eth?.power }} - - - mdc - {{ selectedPinAssignment?.eth?.mdc }} - {{ currentPinAssignment?.eth?.mdc }} - - - mdio - {{ selectedPinAssignment?.eth?.mdio }} - {{ currentPinAssignment?.eth?.mdio }} - - - type - {{ selectedPinAssignment?.eth?.type }} - {{ currentPinAssignment?.eth?.type }} - - - clk_mode - {{ selectedPinAssignment?.eth?.clk_mode }} - {{ currentPinAssignment?.eth?.clk_mode }} - - - - Display - type - {{ selectedPinAssignment?.display?.type }} - {{ currentPinAssignment?.display?.type }} - - - data - {{ selectedPinAssignment?.display?.data }} - {{ currentPinAssignment?.display?.data }} - - - clk - {{ selectedPinAssignment?.display?.clk }} - {{ currentPinAssignment?.display?.clk }} - - - cs - {{ selectedPinAssignment?.display?.cs }} - {{ currentPinAssignment?.display?.cs }} - - - reset - {{ selectedPinAssignment?.display?.reset }} - {{ currentPinAssignment?.display?.reset }} - - + @@ -126,5 +45,53 @@ export default defineComponent({ selectedPinAssignment: { type: Object as PropType, required: true }, currentPinAssignment: { type: Object as PropType, required: true }, }, + computed: { + categories(): string[] { + let curArray: Array = []; + if (this.currentPinAssignment) { + curArray = Object.keys(this.currentPinAssignment as Device); + } + + let selArray: Array = []; + if (this.selectedPinAssignment) { + selArray = Object.keys(this.selectedPinAssignment as Device); + } + + let total: Array = []; + total = total.concat(curArray, selArray); + return Array.from(new Set(total)).filter(cat => cat != 'name').sort(); + }, + }, + methods: { + properties(category: string): string[] { + let curArray: Array = []; + if ((this.currentPinAssignment as Device)[category as keyof Device]) { + curArray = Object.keys((this.currentPinAssignment as Device)[category as keyof Device]); + } + + let selArray: Array = []; + if ((this.selectedPinAssignment as Device)[category as keyof Device]) { + selArray = Object.keys((this.selectedPinAssignment as Device)[category as keyof Device]); + } + + let total: Array = []; + total = total.concat(curArray, selArray); + + return Array.from(new Set(total)).sort(); + }, + isEqual(category: string, prop: string): boolean { + if (!((this.selectedPinAssignment as Device)[category as keyof Device])) { + return false; + } + if (!((this.currentPinAssignment as Device)[category as keyof Device])) { + return false; + } + + return (this.selectedPinAssignment as any)[category][prop] == (this.currentPinAssignment as any)[category][prop]; + }, + capitalizeFirstLetter(value: string): string { + return value.charAt(0).toUpperCase() + value.slice(1); + }, + } });