<h1 id="action">Action</h1>
<h2>Add Charging Stations</h2>
<p>Template:</p>
- <select
- v-show="
- Array.isArray(app?.appContext.config.globalProperties.$templates) &&
- app?.appContext.config.globalProperties.$templates.length > 0
- "
- v-model="state.template"
- >
+ <select v-model="state.template">
<option disabled value="">Please select a template</option>
- <option v-for="template in app?.appContext.config.globalProperties.$templates">
+ <option
+ v-for="template in app?.appContext.config.globalProperties.$templates"
+ v-show="
+ Array.isArray(app?.appContext.config.globalProperties.$templates) &&
+ app?.appContext.config.globalProperties.$templates.length > 0
+ "
+ >
{{ template }}
</option>
</select>
>
Add Charging Stations
</Button>
- <Button id="action-button" @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
</template>
<script setup lang="ts">
>
Set Supervision Url
</Button>
- <Button id="action-button" @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
</template>
<script setup lang="ts">
>
Start Transaction
</Button>
- <Button id="action-button" @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
</template>
<script setup lang="ts">
--- /dev/null
+<template>
+ <Button :class="{ on: state.status }" @click="click()">
+ <slot></slot>
+ </Button>
+</template>
+
+<script setup lang="ts">
+import { ref } from 'vue'
+import Button from '@/components/buttons/Button.vue'
+import { getFromLocalStorage, setToLocalStorage } from '@/composables'
+
+const props = defineProps<{
+ id: string
+ status?: boolean
+ shared?: boolean
+ on?: () => void
+ off?: () => void
+}>()
+
+const id = props.shared === true ? `shared-toggle-button-${props.id}` : `toggle-button-${props.id}`
+
+const state = ref({
+ status: getFromLocalStorage<boolean>(id, props.status ?? false)
+})
+
+const click = (): void => {
+ if (props.shared) {
+ for (const key in localStorage) {
+ if (key !== id && key.startsWith('shared-toggle-button-')) {
+ setToLocalStorage<boolean>(key, false)
+ state.value.status = getFromLocalStorage<boolean>(key, false)
+ }
+ }
+ }
+ setToLocalStorage<boolean>(id, !getFromLocalStorage<boolean>(id, props.status ?? false))
+ state.value.status = getFromLocalStorage<boolean>(id, props.status ?? false)
+ // console.log(`----begin----`)
+ // for (const key in localStorage) {
+ // if (key.startsWith('shared-toggle-button-')) {
+ // console.log(key, getFromLocalStorage<boolean>(key, props.status ?? false))
+ // }
+ // }
+ // console.log(`----end----`)
+ if (getFromLocalStorage<boolean>(id, props.status ?? false)) {
+ props.on?.()
+ } else {
+ props.off?.()
+ }
+}
+</script>
+
+<style>
+.on {
+ background-color: lightgrey;
+}
+</style>
{{ atgStatus?.start === true ? 'Yes' : 'No' }}
</td>
<td class="connectors-table__column">
- <Button
- @click="
- $router.push({
- name: 'start-transaction',
- params: { hashId, chargingStationId, connectorId }
- })
+ <ToggleButton
+ :id="`${hashId}-start-transaction`"
+ :shared="true"
+ :on="
+ () => {
+ $router.push({
+ name: 'start-transaction',
+ params: { hashId, chargingStationId, connectorId }
+ })
+ }
+ "
+ :off="
+ () => {
+ $router.push({ name: 'charging-stations' })
+ }
"
>
Start Transaction
- </Button>
+ </ToggleButton>
<Button @click="stopTransaction()">Stop Transaction</Button>
<Button @click="startAutomaticTransactionGenerator()">Start ATG</Button>
<Button @click="stopAutomaticTransactionGenerator()">Stop ATG</Button>
import { useToast } from 'vue-toast-notification'
import Button from '@/components/buttons/Button.vue'
import type { ConnectorStatus, Status } from '@/types'
+import ToggleButton from '@/components/buttons/ToggleButton.vue'
const props = defineProps<{
hashId: string
<template>
<tr class="cs-table__row">
<td class="cs-table__column">
- {{ props.chargingStation.stationInfo.chargingStationId }}
+ {{ chargingStation.stationInfo.chargingStationId }}
</td>
- <td class="cs-table__column">{{ props.chargingStation.started === true ? 'Yes' : 'No' }}</td>
+ <td class="cs-table__column">{{ chargingStation.started === true ? 'Yes' : 'No' }}</td>
<td class="cs-table__column">
{{ getSupervisionUrl() }}
</td>
<td class="cs-table__column">{{ getWSState() }}</td>
<td class="cs-table__column">
- {{ props.chargingStation?.bootNotificationResponse?.status ?? 'Ø' }}
+ {{ chargingStation?.bootNotificationResponse?.status ?? 'Ø' }}
</td>
<td class="cs-table__column">
- {{ props.chargingStation.stationInfo.templateName }}
+ {{ chargingStation.stationInfo.templateName }}
</td>
- <td class="cs-table__column">{{ props.chargingStation.stationInfo.chargePointVendor }}</td>
- <td class="cs-table__column">{{ props.chargingStation.stationInfo.chargePointModel }}</td>
+ <td class="cs-table__column">{{ chargingStation.stationInfo.chargePointVendor }}</td>
+ <td class="cs-table__column">{{ chargingStation.stationInfo.chargePointModel }}</td>
<td class="cs-table__column">
- {{ props.chargingStation.stationInfo.firmwareVersion ?? 'Ø' }}
+ {{ chargingStation.stationInfo.firmwareVersion ?? 'Ø' }}
</td>
<td class="cs-table__column">
<Button @click="startChargingStation()">Start Charging Station</Button>
<Button @click="stopChargingStation()">Stop Charging Station</Button>
- <Button
- @click="
- $router.push({
- name: 'set-supervision-url',
- params: {
- hashId: props.chargingStation.stationInfo.hashId,
- chargingStationId: props.chargingStation.stationInfo.chargingStationId
- }
- })
+ <ToggleButton
+ :id="`${chargingStation.stationInfo.hashId}-set-supervision-url`"
+ :shared="true"
+ :on="
+ () => {
+ $router.push({
+ name: 'set-supervision-url',
+ params: {
+ hashId: chargingStation.stationInfo.hashId,
+ chargingStationId: chargingStation.stationInfo.chargingStationId
+ }
+ })
+ }
+ "
+ :off="
+ () => {
+ $router.push({ name: 'charging-stations' })
+ }
"
>
Set Supervision Url
- </Button>
+ </ToggleButton>
<Button @click="openConnection()">Open Connection</Button>
<Button @click="closeConnection()">Close Connection</Button>
<Button @click="deleteChargingStation()">Delete Charging Station</Button>
<!-- eslint-disable-next-line vue/valid-v-for -->
<CSConnector
v-for="(connector, index) in getConnectorStatuses()"
- :hash-id="props.chargingStation.stationInfo.hashId"
- :charging-station-id="props.chargingStation.stationInfo.chargingStationId"
+ :hash-id="chargingStation.stationInfo.hashId"
+ :charging-station-id="chargingStation.stationInfo.chargingStationId"
:connector-id="index + 1"
:connector="connector"
:atg-status="getATGStatus(index + 1)"
import CSConnector from '@/components/charging-stations/CSConnector.vue'
import Button from '@/components/buttons/Button.vue'
import type { ChargingStationData, ConnectorStatus, Status } from '@/types'
+import ToggleButton from '@/components/buttons/ToggleButton.vue'
const props = defineProps<{
chargingStation: ChargingStationData
<tbody id="cs-table__body">
<CSData
v-for="chargingStation in chargingStations"
- :key="chargingStation.stationInfo?.chargingStationId"
+ :key="chargingStation.stationInfo.hashId"
:charging-station="chargingStation"
/>
</tbody>
ResponseStatus,
type UIServerConfigurationSection
} from '@/types'
+import { randomUUID } from '@/composables'
type ResponseHandler = {
procedureName: ProcedureName
): Promise<ResponsePayload> {
return new Promise<ResponsePayload>((resolve, reject) => {
if (this.ws?.readyState === WebSocket.OPEN) {
- const uuid = crypto.randomUUID()
+ const uuid = randomUUID()
const msg = JSON.stringify([uuid, procedureName, payload])
const sendTimeout = setTimeout(() => {
this.responseHandlers.delete(uuid)
const item = localStorage.getItem(key)
return item != null ? (JSON.parse(item) as T) : defaultValue
}
+
+export const removeFromLocalStorage = (key: string): void => {
+ localStorage.removeItem(key)
+}
+
+export const getLocalStorage = (): Storage => {
+ return localStorage
+}
+
+export const randomUUID = (): `${string}-${string}-${string}-${string}-${string}` => {
+ return crypto.randomUUID()
+}
export { UIClient } from './UIClient'
-export { convertToBoolean, convertToInt, getFromLocalStorage, setToLocalStorage } from './Utils'
+export {
+ convertToBoolean,
+ convertToInt,
+ getFromLocalStorage,
+ getLocalStorage,
+ randomUUID,
+ removeFromLocalStorage,
+ setToLocalStorage
+} from './Utils'
'open',
() => {
setToLocalStorage<number>('uiServerConfigurationIndex', state.uiServerIndex)
+ for (const key in getLocalStorage()) {
+ if (key.includes('toggle-button')) {
+ removeFromLocalStorage(key)
+ }
+ }
$router.currentRoute.value.name !== 'charging-stations' &&
$router.push({ name: 'charging-stations' })
},
<Container id="buttons-container">
<Button @click="startSimulator()">Start Simulator</Button>
<Button @click="stopSimulator()">Stop Simulator</Button>
- <Button @click="$router.push({ name: 'add-charging-stations' })">
+ <ToggleButton
+ :id="'add-charging-stations'"
+ :shared="true"
+ :on="
+ () => {
+ $router.push({ name: 'add-charging-stations' })
+ }
+ "
+ :off="
+ () => {
+ $router.push({ name: 'charging-stations' })
+ }
+ "
+ >
Add Charging Stations
- </Button>
+ </ToggleButton>
<ReloadButton
id="reload-button"
:loading="state.loading"
import Container from '@/components/Container.vue'
import ReloadButton from '@/components/buttons/ReloadButton.vue'
import Button from '@/components/buttons/Button.vue'
-import { getFromLocalStorage, setToLocalStorage } from '@/composables'
-
-const randomUUID = (): `${string}-${string}-${string}-${string}-${string}` => {
- return crypto.randomUUID()
-}
+import {
+ getFromLocalStorage,
+ getLocalStorage,
+ randomUUID,
+ removeFromLocalStorage,
+ setToLocalStorage
+} from '@/composables'
+import ToggleButton from '@/components/buttons/ToggleButton.vue'
const app = getCurrentInstance()