From 7f25f8d9279c5c9d0f457132ff35563fe39b36ec Mon Sep 17 00:00:00 2001
From: zdenevuk <zdenko.vuk@ijs.si>
Date: Thu, 1 Dec 2022 16:17:13 +0100
Subject: [PATCH]  This is a combination of 3 commits.

added getKpiVisInfo

also some css improvements

small update, added some info to user
---
 .../results-map/results-map.component.scss    |   2 +-
 .../results-map/results-map.component.ts      | 122 ++----------------
 .../utils/services/network.service.ts         |  10 ++
 3 files changed, 21 insertions(+), 113 deletions(-)

diff --git a/src/app/pages/simulation-wizard/results-map/results-map.component.scss b/src/app/pages/simulation-wizard/results-map/results-map.component.scss
index 44a89677..e4d50741 100644
--- a/src/app/pages/simulation-wizard/results-map/results-map.component.scss
+++ b/src/app/pages/simulation-wizard/results-map/results-map.component.scss
@@ -28,7 +28,7 @@
     padding: 4px 3px 0 3px;
   }
   #loadGeojsonButtonsContainer {
-    z-index: 1003;
+    z-index: 997;
     position: absolute;
     top: 5px;
     left: 57px;
diff --git a/src/app/pages/simulation-wizard/results-map/results-map.component.ts b/src/app/pages/simulation-wizard/results-map/results-map.component.ts
index 2dda41ac..68ac09b1 100644
--- a/src/app/pages/simulation-wizard/results-map/results-map.component.ts
+++ b/src/app/pages/simulation-wizard/results-map/results-map.component.ts
@@ -127,7 +127,7 @@ export class ResultsMapComponent implements OnChanges {
 
     if (res["message"] == "Calculating...") {
       this.toastrService.show(
-        "Server says: Calculating the KPI visualization. GEOJSON loading will not be completed.",
+        "Server says: Calculating the KPI visualization. GEOJSON loading will not be completed. When it will be ready, you will need to refresh the page.",
         "Geojson not ready",
         {
           status: "danger",
@@ -622,118 +622,16 @@ export class ResultsMapComponent implements OnChanges {
   }
 
   setLoadGeojsons() {
-    if (this.selectedSimulation != undefined) {
-      if (this.selectedSimulation["city"]["cityId"] == "amsterdam") {
-        this.loadGeojsons = [
-          {
-            response: undefined,
-            buttonValue: "bikeability",
-            buttonLabel: "bikeability",
-          },
-          {
-            response: undefined,
-            buttonValue: "bikeIntensity",
-            buttonLabel: "bike Intensity",
-          },
-          {
-            response: undefined,
-            buttonValue: "bikeSafety",
-            buttonLabel: "bike Safety",
-          },
-          {
-            response: undefined,
-            buttonValue: "pollution",
-            buttonLabel: "pollution",
-          },
-        ];
-      } else if (this.selectedSimulation["city"]["cityId"] == "bilbao") {
-        console.log(
-          "%c buttons set might not be the right ones for bilbao",
-          "background: indianred; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
-        );
-        this.loadGeojsons = [
-          {
-            response: undefined,
-            buttonValue: "bikeability",
-            buttonLabel: "bikeability",
-          },
-          {
-            response: undefined,
-            buttonValue: "bikeIntensity",
-            buttonLabel: "bike Intensity",
-          },
-          {
-            response: undefined,
-            buttonValue: "bikeSafety",
-            buttonLabel: "bike Safety",
-          },
-          {
-            response: undefined,
-            buttonValue: "pollution",
-            buttonLabel: "pollution",
-          },
-        ];
-      } else if (this.selectedSimulation["city"]["cityId"] == "helsinki") {
-        this.loadGeojsons = [
-          {
-            response: undefined,
-            buttonValue: "congestionsAndBottlenecks",
-            buttonLabel: "congestions And Bottlenecks",
-          },
-          {
-            response: undefined,
-            buttonValue: "harbourAreaTrafficFlow",
-            buttonLabel: "harbour Area Traffic Flow",
-          },
-          {
-            response: undefined,
-            buttonValue: "accousticPollution",
-            buttonLabel: "accoustic Pollution",
-          },
-          {
-            response: undefined,
-            buttonValue: "pollution",
-            buttonLabel: "pollution",
-          },
-        ];
-      } else if (this.selectedSimulation["city"]["cityId"] == "messina") {
-        console.log(
-          "%c buttons set might not be the right ones for messina",
-          "background: magenta; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
-        );
-        this.loadGeojsons = [
-          {
-            response: undefined,
-            buttonValue: "bikeability",
-            buttonLabel: "bikeability",
-          },
-          {
-            response: undefined,
-            buttonValue: "bikeIntensity",
-            buttonLabel: "bike Intensity",
-          },
-          {
-            response: undefined,
-            buttonValue: "bikeSafety",
-            buttonLabel: "bike Safety",
-          },
-          {
-            response: undefined,
-            buttonValue: "pollution",
-            buttonLabel: "pollution",
-          },
-          {
-            response: undefined,
-            buttonValue: "publicTransportUse",
-            buttonLabel: "public transport use",
-          },
-        ];
-      } else {
-        this.toastrService.show("Unexpected value for city name.", "Error", {
-          status: "danger",
+    this.networkService.getKpiVisInfo().subscribe((res) => {
+      this.loadGeojsons = [];
+      res.forEach((but) => {
+        this.loadGeojsons.push({
+          response: undefined,
+          buttonValue: but["buttonValue"],
+          buttonLabel: but["buttonLabel"],
         });
-      }
-    }
+      });
+    });
   }
 
   openOverviewOfIndicators(dialog: TemplateRef<any>) {
diff --git a/src/app/pages/simulation-wizard/utils/services/network.service.ts b/src/app/pages/simulation-wizard/utils/services/network.service.ts
index 649eab47..a338ac93 100644
--- a/src/app/pages/simulation-wizard/utils/services/network.service.ts
+++ b/src/app/pages/simulation-wizard/utils/services/network.service.ts
@@ -91,4 +91,14 @@ export class NetworkService {
       catchError(this.handleError)
     );
   }
+
+  getKpiVisInfo(): Observable<any> {
+    return this.httpClient.get(`${this.dssUrl}/kpi-vis-info`).pipe(
+      map((res) => {
+        return res;
+      }),
+      tapDebugApi,
+      catchError(this.handleError)
+    );
+  }
 }
-- 
GitLab