fix: clear UI server cache at simulator stop
[e-mobility-charging-stations-simulator.git] / ui / web / src / views / ChargingStationsView.vue
index 8df77d92429646b638ce576b7e2df4085b22f6db..50851055cf25f924300840e4ebcd6b2ebce23fb9 100644 (file)
         @click="loadChargingStations(() => $router.go(0))"
       />
     </Container>
-    <CSTable :charging-stations="app?.appContext.config.globalProperties.$chargingStations" />
+    <CSTable
+      v-if="
+        Array.isArray(app?.appContext.config.globalProperties.$chargingStations) &&
+        app?.appContext.config.globalProperties.$chargingStations.length > 0
+      "
+      :charging-stations="app?.appContext.config.globalProperties.$chargingStations"
+    />
   </Container>
 </template>
 
@@ -72,6 +78,9 @@ const stopSimulator = (): void => {
   uiClient
     .stopSimulator()
     .then(() => {
+      if (app != null) {
+        app.appContext.config.globalProperties.$chargingStations = []
+      }
       $toast.success('Simulator successfully stopped')
     })
     .catch((error: Error) => {
@@ -85,6 +94,7 @@ const stopSimulator = (): void => {
 #charging-stations-container {
   height: fit-content;
   width: 100%;
+  position: absolute;
   display: flex;
   flex-direction: column;
 }