-
Notifications
You must be signed in to change notification settings - Fork 107
Add table view for charge points to Koala web theme #2310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
benderl
merged 9 commits into
openWB:feature-koala-web-theme
from
Brett-S-OWB:koala-web-theme
Apr 9, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c2b240e
Add chargepoint table view
Brett-S-OWB 390fb80
Charge modes migrated to composable
Brett-S-OWB 80eb53b
Add formating for longer text in state message
Brett-S-OWB a8dfa0b
Formatting
Brett-S-OWB 04af9a3
Add display mode to drawer component in mainlayout
Brett-S-OWB 06400b1
Formatting
Brett-S-OWB 82494c9
Quasar table moved into a reuseable component
Brett-S-OWB ef57503
Chargepoint message text format
Brett-S-OWB d6e6c4a
Update packages/modules/web_themes/koala/config.py
benderl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
packages/modules/web_themes/koala/source/src/components/BaseTable.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| <template> | ||
| <div class="q-pa-md"> | ||
| <q-table | ||
| class="sticky-header-table" | ||
| :rows="rows" | ||
| :columns="columns" | ||
| row-key="id" | ||
| :filter="filter" | ||
| :filter-method="customFilterMethod" | ||
| virtual-scroll | ||
| :virtual-scroll-item-size="48" | ||
| :virtual-scroll-sticky-size-start="48" | ||
| :style="{ height: tableHeight }" | ||
| @row-click="onRowClick" | ||
| binary-state-sort | ||
| :pagination="{ rowsPerPage: 0 }" | ||
| hide-bottom | ||
| > | ||
| <template v-slot:top v-if="searchInputVisible"> | ||
| <div class="row full-width items-center q-mb-sm"> | ||
| <div class="col"> | ||
| <q-input | ||
| v-model="filterModel" | ||
| dense | ||
| outlined | ||
| color="white" | ||
| placeholder="Suchen..." | ||
| class="search-field white-outline-input" | ||
| input-class="text-white" | ||
| > | ||
| <template v-slot:append> | ||
| <q-icon name="search" color="white" /> | ||
| </template> | ||
| </q-input> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <!-- Dynamic slot for custom cell rendering --> | ||
| <template | ||
| v-for="(_, name) in $slots" | ||
| :key="name" | ||
| v-slot:[name]="slotData" | ||
| > | ||
| <slot :name="name" v-bind="slotData"></slot> | ||
| </template> | ||
| </q-table> | ||
| </div> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .search-field { | ||
| width: 100%; | ||
| max-width: 18em; | ||
| } | ||
| </style> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed } from 'vue'; | ||
| import { QTableColumn, QTableProps } from 'quasar'; | ||
| import { BaseRow } from 'src/components/models/base-table-models'; | ||
|
|
||
| type FilterFunction = NonNullable<QTableProps['filterMethod']>; | ||
|
|
||
| const props = defineProps<{ | ||
| rows: BaseRow[]; | ||
| columns: QTableColumn[]; | ||
| searchInputVisible?: boolean; | ||
| tableHeight?: string; | ||
| filter?: string; | ||
| columnsToSearch?: string[]; | ||
| }>(); | ||
|
|
||
| const emit = defineEmits<{ | ||
| (e: 'row-click', row: BaseRow): void; | ||
| (e: 'update:filter', value: string): void; | ||
| }>(); | ||
|
|
||
| const filterModel = computed({ | ||
| get: () => props.filter || '', | ||
| set: (value) => { | ||
| emit('update:filter', value); | ||
| }, | ||
| }); | ||
|
|
||
| const customFilterMethod: FilterFunction = (rows, terms, cols) => { | ||
| if (!terms || terms.trim() === '') { | ||
| return rows; | ||
| } | ||
| const lowerTerms = terms.toLowerCase(); | ||
| const columnsToSearch = props.columnsToSearch || | ||
| cols.map(col => typeof col.field === 'string' ? col.field : ''); | ||
| return rows.filter(row => { | ||
| return columnsToSearch.some(field => { | ||
| const val = row[field as keyof typeof row]; | ||
| return val !== null && | ||
| val !== undefined && | ||
| String(val).toLowerCase().includes(lowerTerms); | ||
| }); | ||
| }); | ||
| }; | ||
|
|
||
| const onRowClick = (evt: Event, row: BaseRow) => { | ||
| emit('row-click', row); | ||
| }; | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
229 changes: 221 additions & 8 deletions
229
packages/modules/web_themes/koala/source/src/components/ChargePointInformation.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,232 @@ | ||
| <template> | ||
| <BaseCarousel :items="chargePointIds"> | ||
| <template #item="{ item }"> | ||
| <ChargePointCard :charge-point-id="item" /> | ||
| </template> | ||
| </BaseCarousel> | ||
| <div> | ||
| <BaseCarousel | ||
| v-if="chargePointIds.length <= cardViewBreakpoint" | ||
| :items="chargePointIds" | ||
| > | ||
| <template #item="{ item }"> | ||
| <ChargePointCard :charge-point-id="item" /> | ||
| </template> | ||
| </BaseCarousel> | ||
|
|
||
| <BaseTable | ||
| v-else | ||
| :rows="rows" | ||
| :columns="mobile ? columnsMobile : columns" | ||
| :search-input-visible="searchInputVisible" | ||
| :table-height="mobile ? '35vh' : '40vh'" | ||
| v-model:filter="filter" | ||
| :columns-to-search="['vehicle', 'name']" | ||
| @row-click="onRowClick($event as ChargePointRow)" | ||
| > | ||
| <template v-slot:body-cell-plugged="props"> | ||
| <q-td :props="props"> | ||
| <ChargePointStateIcon :charge-point-id="props.row.id" /> | ||
| </q-td> | ||
| </template> | ||
| </BaseTable> | ||
|
|
||
| <!-- ChargePointCard Dialog --> | ||
| <q-dialog | ||
| v-model="modalChargePointCardVisible" | ||
| transition-show="fade" | ||
| transition-hide="fade" | ||
| :backdrop-filter="$q.screen.width < 385 ? '' : 'blur(4px)'" | ||
| > | ||
| <div class="dialog-content"> | ||
| <ChargePointCard | ||
| v-if="selectedChargePointId !== null" | ||
| :charge-point-id="selectedChargePointId" | ||
| > | ||
| <template #card-footer> | ||
| <div class="card-footer"> | ||
| <q-btn | ||
| color="primary" | ||
| flat | ||
| no-caps | ||
| v-close-popup | ||
| class="close-button" | ||
| size="md" | ||
| >Schließen</q-btn | ||
| > | ||
| </div> | ||
| </template> | ||
| </ChargePointCard> | ||
| </div> | ||
| </q-dialog> | ||
| </div> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .dialog-content { | ||
| width: auto; | ||
| max-width: 24em; | ||
| } | ||
|
|
||
| .close-button { | ||
| position: absolute; | ||
| bottom: 0.4em; | ||
| right: 0.4em; | ||
| z-index: 1; | ||
| background: transparent; | ||
| } | ||
|
|
||
| .card-footer { | ||
| height: 1.9em; | ||
| } | ||
| </style> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed } from 'vue'; | ||
| import { computed, ref } from 'vue'; | ||
| import { useQuasar, Platform, QTableColumn } from 'quasar'; | ||
| import { useMqttStore } from 'src/stores/mqtt-store'; | ||
|
|
||
| import BaseCarousel from 'src/components/BaseCarousel.vue'; | ||
| import BaseTable from 'src/components/BaseTable.vue'; | ||
| import ChargePointCard from 'src/components/ChargePointCard.vue'; | ||
| import ChargePointStateIcon from 'src/components/ChargePointStateIcon.vue'; | ||
| import { useChargeModes } from 'src/composables/useChargeModes'; | ||
| import { ChargePointRow } from 'src/components/models/chargepoint-information-models'; | ||
|
|
||
| const $q = useQuasar(); | ||
| const mobile = computed(() => Platform.is.mobile); | ||
| const mqttStore = useMqttStore(); | ||
|
|
||
| const selectedChargePointId = ref<number | null>(null); | ||
| const modalChargePointCardVisible = ref(false); | ||
| const filter = ref(''); | ||
| const chargePointIds = computed(() => mqttStore.chargePointIds); | ||
| const cardViewBreakpoint = computed( | ||
| () => mqttStore.themeConfiguration?.card_view_breakpoint || 4, | ||
| ); | ||
| const searchInputVisible = computed( | ||
| () => mqttStore.themeConfiguration?.table_search_input_field, | ||
| ); | ||
| const { chargeModes } = useChargeModes(); | ||
|
|
||
| const rows = computed<ChargePointRow[]>(() => { | ||
| return chargePointIds.value.map((id) => { | ||
| const chargePointName = mqttStore.chargePointName(id); | ||
| const vehicleName = | ||
| mqttStore.chargePointConnectedVehicleInfo(id).value?.name || | ||
| 'Kein Fahrzeug'; | ||
| const plugState = mqttStore.chargePointPlugState(id) ? 'Ja' : 'Nein'; | ||
| const chargeModeValue = | ||
| mqttStore.chargePointConnectedVehicleChargeMode(id).value; | ||
| const chargeModeObj = chargeModes.find( | ||
| (mode) => mode.value === chargeModeValue, | ||
| ); | ||
| const chargeMode = chargeModeObj ? chargeModeObj.label : chargeModeValue; | ||
| const soc = Math.round( | ||
| mqttStore.chargePointConnectedVehicleSoc(id).value?.soc || 0, | ||
| ); | ||
| const socDisplay = `${soc}%`; | ||
| const power = mqttStore.chargePointPower(id, 'textValue'); | ||
| const energyCharged = mqttStore.chargePointEnergyChargedPlugged( | ||
| id, | ||
| 'textValue', | ||
| ); | ||
| return { | ||
| id: id, | ||
| name: chargePointName, | ||
| vehicle: vehicleName, | ||
| plugged: plugState, | ||
| mode: chargeMode, | ||
| soc: socDisplay, | ||
| power: power, | ||
| charged: energyCharged, | ||
| }; | ||
| }); | ||
| }); | ||
|
|
||
| const columns: QTableColumn[] = [ | ||
| { | ||
| name: 'name', | ||
| label: 'Ladepunkt', | ||
| field: 'name', | ||
| sortable: true, | ||
| align: 'left', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| { | ||
| name: 'vehicle', | ||
| label: 'Fahrzeug', | ||
| field: 'vehicle', | ||
| sortable: true, | ||
| align: 'left', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| { | ||
| name: 'plugged', | ||
| label: 'Status', | ||
| field: 'plugged', | ||
| sortable: true, | ||
| align: 'center', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| { | ||
| name: 'mode', | ||
| label: 'Mode', | ||
| field: 'mode', | ||
| sortable: true, | ||
| align: 'left', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| { | ||
| name: 'soc', | ||
| label: 'Ladestand', | ||
| field: 'soc', | ||
| sortable: true, | ||
| align: 'left', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| { | ||
| name: 'power', | ||
| label: 'Leistung', | ||
| field: 'power', | ||
| sortable: true, | ||
| align: 'left', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| { | ||
| name: 'charged', | ||
| label: 'Geladen', | ||
| field: 'charged', | ||
| sortable: true, | ||
| align: 'left', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| ]; | ||
|
|
||
| const columnsMobile = computed((): QTableColumn[] => { | ||
| return [ | ||
| { | ||
| name: 'name', | ||
| label: 'Ladepunkt', | ||
| field: 'name', | ||
| sortable: true, | ||
| align: 'left', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| { | ||
| name: 'vehicle', | ||
| label: 'Fahrzeug', | ||
| field: 'vehicle', | ||
| sortable: true, | ||
| align: 'left', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| { | ||
| name: 'plugged', | ||
| label: 'Status', | ||
| field: 'plugged', | ||
| sortable: true, | ||
| align: 'center', | ||
| headerStyle: 'font-weight: bold', | ||
| }, | ||
| ]; | ||
| }); | ||
|
|
||
| const onRowClick = (row: ChargePointRow) => { | ||
| selectedChargePointId.value = row.id; | ||
| modalChargePointCardVisible.value = true; | ||
| }; | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.