@kando-env/kando-ui 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/.DS_Store +0 -0
  2. package/.babelrc +10 -0
  3. package/.eslintrc.json +25 -0
  4. package/.nvmrc +1 -0
  5. package/.prettierrc.json +6 -0
  6. package/.storybook/main.js +11 -0
  7. package/.storybook/preview-head.html +43 -0
  8. package/.storybook/preview.js +15 -0
  9. package/.storybook/webpack.config.js +48 -0
  10. package/babel.config.js +15 -0
  11. package/demo-server.js +11 -0
  12. package/index.html +14 -0
  13. package/javascript/.DS_Store +0 -0
  14. package/javascript/bundles/.DS_Store +0 -0
  15. package/javascript/bundles/overview/.DS_Store +0 -0
  16. package/javascript/bundles/overview/views/.DS_Store +0 -0
  17. package/package.json +131 -3
  18. package/public/favicon.ico +0 -0
  19. package/public/index.html +43 -0
  20. package/src/bundles/CovidView/views/components/Body.tsx +59 -0
  21. package/src/bundles/CovidView/views/components/Map.tsx +110 -0
  22. package/src/bundles/CovidView/views/components/MapStyle.scss +387 -0
  23. package/src/bundles/CovidView/views/components/Sidebar.tsx +32 -0
  24. package/src/bundles/CovidView/views/components/SidebarStyle.scss +11 -0
  25. package/src/bundles/CovidView/views/components/Summary.tsx +134 -0
  26. package/src/bundles/CovidView/views/components/SummaryStyle.scss +61 -0
  27. package/src/bundles/CovidView/views/components/areas/Area.tsx +130 -0
  28. package/src/bundles/CovidView/views/components/areas/AreaPolygonWBE.tsx +186 -0
  29. package/src/bundles/CovidView/views/components/areas/AreaPolygonsWBE.tsx +71 -0
  30. package/src/bundles/CovidView/views/components/areas/AreasList.tsx +84 -0
  31. package/src/bundles/CovidView/views/components/areas/AreasStyle.scss +237 -0
  32. package/src/bundles/CovidView/views/components/areas/Sort.tsx +40 -0
  33. package/src/bundles/CovidView/views/components/areas/TrendPopupContent/TrendPopupContent.tsx +112 -0
  34. package/src/bundles/CovidView/views/components/areas/TrendPopupContent/index.ts +3 -0
  35. package/src/bundles/CovidView/views/components/areas/TrendPopupContent/styles.scss +30 -0
  36. package/src/bundles/CovidView/views/covidView.tsx +30 -0
  37. package/src/bundles/DashboardV2/AreaDashboard.tsx +59 -0
  38. package/src/bundles/DashboardV2/SiteDashboard.tsx +218 -0
  39. package/src/bundles/DashboardV2/WaterAuthorityDashboard.tsx +33 -0
  40. package/src/bundles/DashboardV2/index.ts +5 -0
  41. package/src/bundles/DashboardV2/styles.scss +126 -0
  42. package/src/bundles/DashboardV2/types/IDashboardData.ts +28 -0
  43. package/src/bundles/EventsView/views/_colors.scss +1 -0
  44. package/src/bundles/EventsView/views/components/Body.tsx +73 -0
  45. package/src/bundles/EventsView/views/components/areas/AreaPolygon.tsx +42 -0
  46. package/src/bundles/EventsView/views/components/areas/AreaPolygons.tsx +43 -0
  47. package/src/bundles/EventsView/views/components/edges/Edge.tsx +60 -0
  48. package/src/bundles/EventsView/views/components/edges/Edges.tsx +41 -0
  49. package/src/bundles/EventsView/views/components/events/EventIndicator.tsx +241 -0
  50. package/src/bundles/EventsView/views/components/events/EventPath.tsx +88 -0
  51. package/src/bundles/EventsView/views/components/events/EventsStyle.scss +725 -0
  52. package/src/bundles/EventsView/views/components/events/MoreInfo.tsx +48 -0
  53. package/src/bundles/EventsView/views/components/events/Sidebar.tsx +49 -0
  54. package/src/bundles/EventsView/views/components/events/event_info/EarlyWarnings.tsx +146 -0
  55. package/src/bundles/EventsView/views/components/events/event_info/EventDetails.tsx +106 -0
  56. package/src/bundles/EventsView/views/components/events/event_info/EventInfo.tsx +102 -0
  57. package/src/bundles/EventsView/views/components/events/event_info/EventInfoStyle.scss +508 -0
  58. package/src/bundles/EventsView/views/components/events/event_info/EventTimeRange.tsx +109 -0
  59. package/src/bundles/EventsView/views/components/events/event_info/HistoricalInformation.tsx +37 -0
  60. package/src/bundles/EventsView/views/components/events/event_info/MiniEventTree.tsx +89 -0
  61. package/src/bundles/EventsView/views/components/events/event_info/MobileEventPath.tsx +29 -0
  62. package/src/bundles/EventsView/views/components/events/event_info/PollutionDischarge.tsx +57 -0
  63. package/src/bundles/EventsView/views/components/events/event_info/charts/EventDetailsLineChart.tsx +61 -0
  64. package/src/bundles/EventsView/views/components/events/event_info/charts/EventDetailsPieChart.tsx +107 -0
  65. package/src/bundles/EventsView/views/components/events/event_info/damage_type/DamageType.tsx +98 -0
  66. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/agriculture.svg +29 -0
  67. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/bacteria-process.svg +90 -0
  68. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/effluent.svg +55 -0
  69. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/energy.svg +42 -0
  70. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/equipment.svg +82 -0
  71. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/extra-biological-sludge.svg +40 -0
  72. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/overflow.svg +26 -0
  73. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/pipes-bluckages.svg +29 -0
  74. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/pipes-infrastructure.svg +31 -0
  75. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/reuse.svg +29 -0
  76. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/sea-rivers.svg +54 -0
  77. package/src/bundles/EventsView/views/components/events/event_info/damage_type/svgs/sludge.svg +37 -0
  78. package/src/bundles/EventsView/views/components/events/event_info/samplings/Sampling.tsx +26 -0
  79. package/src/bundles/EventsView/views/components/events/event_info/samplings/Samplings.tsx +32 -0
  80. package/src/bundles/EventsView/views/components/events/event_info/sources/Source.tsx +120 -0
  81. package/src/bundles/EventsView/views/components/events/event_info/sources/Sources.tsx +35 -0
  82. package/src/bundles/EventsView/views/components/events/events_list/EventItem.tsx +122 -0
  83. package/src/bundles/EventsView/views/components/events/events_list/EventsList.tsx +242 -0
  84. package/src/bundles/EventsView/views/components/events/events_list/Filter/Filter.tsx +91 -0
  85. package/src/bundles/EventsView/views/components/events/events_list/Filter/FilterContainer.tsx +302 -0
  86. package/src/bundles/EventsView/views/components/events/events_list/Filter/FilterItem.tsx +180 -0
  87. package/src/bundles/EventsView/views/components/events/events_list/Filter/FiltersDropDown.tsx +48 -0
  88. package/src/bundles/EventsView/views/components/events/events_list/Filter/OptionsDropDown.tsx +97 -0
  89. package/src/bundles/EventsView/views/components/events/events_list/Sort.tsx +70 -0
  90. package/src/bundles/EventsView/views/components/map/FloatingGraph.tsx +61 -0
  91. package/src/bundles/EventsView/views/components/map/Map.tsx +137 -0
  92. package/src/bundles/EventsView/views/components/map/mapStyle.scss +387 -0
  93. package/src/bundles/EventsView/views/components/points/PointMarker.tsx +447 -0
  94. package/src/bundles/EventsView/views/components/points/PointMarkers.tsx +23 -0
  95. package/src/bundles/EventsView/views/eventsView.tsx +32 -0
  96. package/src/bundles/ProjectManagement/api/index.js +10 -0
  97. package/src/bundles/ProjectManagement/components/kpi-list-item.jsx +57 -0
  98. package/src/bundles/ProjectManagement/components/kpi-percentage-item.jsx +69 -0
  99. package/src/bundles/ProjectManagement/components/kpi.jsx +23 -0
  100. package/src/bundles/ProjectManagement/components/legend-icon.jsx +14 -0
  101. package/src/bundles/ProjectManagement/components/link-to-item.jsx +16 -0
  102. package/src/bundles/ProjectManagement/components/list-of-points.jsx +76 -0
  103. package/src/bundles/ProjectManagement/components/map-view.jsx +95 -0
  104. package/src/bundles/ProjectManagement/components/metrics.jsx +42 -0
  105. package/src/bundles/ProjectManagement/components/node-label.jsx +23 -0
  106. package/src/bundles/ProjectManagement/components/period-selector-button.jsx +23 -0
  107. package/src/bundles/ProjectManagement/components/period-selector.jsx +25 -0
  108. package/src/bundles/ProjectManagement/components/point-preview.jsx +225 -0
  109. package/src/bundles/ProjectManagement/components/project-management.jsx +229 -0
  110. package/src/bundles/ProjectManagement/components/tree-legend.jsx +59 -0
  111. package/src/bundles/ProjectManagement/components/tree-view.jsx +215 -0
  112. package/src/bundles/ProjectManagement/stores/project-management-store.js +16 -0
  113. package/src/bundles/ProjectManagement/util/constants.js +2 -0
  114. package/src/bundles/ProjectManagement/util/treeUtil.js +32 -0
  115. package/src/bundles/ProjectManagement/util/url.js +10 -0
  116. package/src/bundles/Router.tsx +57 -0
  117. package/src/bundles/assets/NVL_trends/down.png +0 -0
  118. package/src/bundles/assets/NVL_trends/same.png +0 -0
  119. package/src/bundles/assets/NVL_trends/up.png +0 -0
  120. package/src/bundles/assets/area_statuses/invalid-sampling.png +0 -0
  121. package/src/bundles/assets/area_statuses/missing-sampling.png +0 -0
  122. package/src/bundles/assets/area_statuses/pending-sampling.png +0 -0
  123. package/src/bundles/assets/area_statuses/valid-sampling.png +0 -0
  124. package/src/bundles/assets/factory-icon.png +0 -0
  125. package/src/bundles/assets/flask.svg +7 -0
  126. package/src/bundles/assets/kando_logo.png +0 -0
  127. package/src/bundles/assets/line-chart.svg +56 -0
  128. package/src/bundles/assets/missing/authority.png +0 -0
  129. package/src/bundles/assets/missing/group.png +0 -0
  130. package/src/bundles/assets/missing/point.png +0 -0
  131. package/src/bundles/assets/no_events.svg +31 -0
  132. package/src/bundles/assets/no_results.svg +327 -0
  133. package/src/bundles/assets/point_icons/WWTP-icon.svg +26 -0
  134. package/src/bundles/assets/point_icons/blue-circle.svg +3 -0
  135. package/src/bundles/assets/point_icons/bright-blue-circle.svg +3 -0
  136. package/src/bundles/assets/point_icons/factory-icon.svg +23 -0
  137. package/src/bundles/assets/point_icons/green-circle.png +0 -0
  138. package/src/bundles/assets/point_icons/green-circle.svg +3 -0
  139. package/src/bundles/assets/point_icons/observation-icon.svg +12 -0
  140. package/src/bundles/assets/point_icons/pink-circle.svg +3 -0
  141. package/src/bundles/assets/point_icons/pump-station-icon.svg +15 -0
  142. package/src/bundles/assets/point_icons/red-pin-red-shadow.png +0 -0
  143. package/src/bundles/assets/point_icons/sampling-icon.svg +9 -0
  144. package/src/bundles/assets/point_icons/white-pin-black-shadow.png +0 -0
  145. package/src/bundles/assets/point_icons/white-pin-red-shadow.png +0 -0
  146. package/src/bundles/assets/point_icons/yellow-circle.svg +3 -0
  147. package/src/bundles/assets/sewer.svg +3 -0
  148. package/src/bundles/assets/user.svg +44 -0
  149. package/src/bundles/assets/white-point.png +0 -0
  150. package/src/bundles/index.js +26 -0
  151. package/src/bundles/shared/TimeRangeSelector/TimeRangeSelector.tsx +79 -0
  152. package/src/bundles/shared/TimeRangeSelector/constants.ts +1 -0
  153. package/src/bundles/shared/TimeRangeSelector/index.ts +3 -0
  154. package/src/bundles/shared/TimeRangeSelector/styles.scss +65 -0
  155. package/src/bundles/shared/components/Breadcrumbs/Breadcrumbs.tsx +34 -0
  156. package/src/bundles/shared/components/Breadcrumbs/index.ts +3 -0
  157. package/src/bundles/shared/components/Breadcrumbs/styles.scss +8 -0
  158. package/src/bundles/shared/components/ContentLoader/ContentLoader.tsx +39 -0
  159. package/src/bundles/shared/components/ContentLoader/index.ts +1 -0
  160. package/src/bundles/shared/components/DamageType/DamageType.tsx +234 -0
  161. package/src/bundles/shared/components/DamageType/index.ts +3 -0
  162. package/src/bundles/shared/components/DamageType/styles.scss +50 -0
  163. package/src/bundles/shared/components/DischargeHeatmap/DischargeHeatmap.tsx +205 -0
  164. package/src/bundles/shared/components/DischargeHeatmap/index.ts +3 -0
  165. package/src/bundles/shared/components/DischargeHeatmap/styles.scss +17 -0
  166. package/src/bundles/shared/components/ErrorBoundary.jsx +40 -0
  167. package/src/bundles/shared/components/Events/Events.tsx +205 -0
  168. package/src/bundles/shared/components/Events/index.ts +3 -0
  169. package/src/bundles/shared/components/Events/styles.scss +131 -0
  170. package/src/bundles/shared/components/Graph/Graph.tsx +156 -0
  171. package/src/bundles/shared/components/Graph/index.ts +3 -0
  172. package/src/bundles/shared/components/KandoModal/KandoModal.tsx +88 -0
  173. package/src/bundles/shared/components/KandoModal/index.ts +3 -0
  174. package/src/bundles/shared/components/KandoModal/styles.scss +19 -0
  175. package/src/bundles/shared/components/KandoNavbar/KandoNavbar.tsx +232 -0
  176. package/src/bundles/shared/components/KandoNavbar/NavbarStyle.scss +238 -0
  177. package/src/bundles/shared/components/KandoNavbar/index.ts +3 -0
  178. package/src/bundles/shared/components/LiveEvents/CarouselSlide.tsx +80 -0
  179. package/src/bundles/shared/components/LiveEvents/LiveEvents.tsx +38 -0
  180. package/src/bundles/shared/components/LiveEvents/index.ts +3 -0
  181. package/src/bundles/shared/components/LiveEvents/styles.scss +80 -0
  182. package/src/bundles/shared/components/Map/Map.tsx +79 -0
  183. package/src/bundles/shared/components/Map/index.ts +3 -0
  184. package/src/bundles/shared/components/Map/styles.scss +7 -0
  185. package/src/bundles/shared/components/NarrowHeader.jsx +18 -0
  186. package/src/bundles/shared/components/PointInfo/PointInfo.tsx +80 -0
  187. package/src/bundles/shared/components/PointInfo/index.ts +3 -0
  188. package/src/bundles/shared/components/PointInfo/styles.scss +48 -0
  189. package/src/bundles/shared/components/Search/Search.tsx +106 -0
  190. package/src/bundles/shared/components/Search/index.ts +3 -0
  191. package/src/bundles/shared/components/Search/styles.scss +27 -0
  192. package/src/bundles/shared/components/Sector/Sector.tsx +156 -0
  193. package/src/bundles/shared/components/Sector/index.ts +3 -0
  194. package/src/bundles/shared/components/Sector/styles.scss +14 -0
  195. package/src/bundles/shared/components/Sector/svgs/Brewing.svg +93 -0
  196. package/src/bundles/shared/components/Sector/svgs/Cowshed.svg +23 -0
  197. package/src/bundles/shared/components/Sector/svgs/Garage.svg +24 -0
  198. package/src/bundles/shared/components/Sector/svgs/Missing.svg +36 -0
  199. package/src/bundles/shared/components/Sector/svgs/barrel.svg +93 -0
  200. package/src/bundles/shared/components/Sector/svgs/beer.svg +13 -0
  201. package/src/bundles/shared/components/Sector/svgs/beverage.svg +13 -0
  202. package/src/bundles/shared/components/Sector/svgs/car-repair.svg +24 -0
  203. package/src/bundles/shared/components/Sector/svgs/car-wash.svg +36 -0
  204. package/src/bundles/shared/components/Sector/svgs/chemistry.svg +30 -0
  205. package/src/bundles/shared/components/Sector/svgs/conductor-manufacturer.svg +17 -0
  206. package/src/bundles/shared/components/Sector/svgs/cosmetic-manufacturer.svg +23 -0
  207. package/src/bundles/shared/components/Sector/svgs/cow.svg +23 -0
  208. package/src/bundles/shared/components/Sector/svgs/cpu.svg +17 -0
  209. package/src/bundles/shared/components/Sector/svgs/dairy.svg +18 -0
  210. package/src/bundles/shared/components/Sector/svgs/dippel-oil.svg +17 -0
  211. package/src/bundles/shared/components/Sector/svgs/food-donation.svg +29 -0
  212. package/src/bundles/shared/components/Sector/svgs/food-factory.svg +17 -0
  213. package/src/bundles/shared/components/Sector/svgs/garbage-truck-1.svg +34 -0
  214. package/src/bundles/shared/components/Sector/svgs/gas-station.svg +26 -0
  215. package/src/bundles/shared/components/Sector/svgs/glass-manufacturer.svg +21 -0
  216. package/src/bundles/shared/components/Sector/svgs/glass.svg +21 -0
  217. package/src/bundles/shared/components/Sector/svgs/hand-washing.svg +17 -0
  218. package/src/bundles/shared/components/Sector/svgs/hospital.svg +28 -0
  219. package/src/bundles/shared/components/Sector/svgs/hotel.svg +24 -0
  220. package/src/bundles/shared/components/Sector/svgs/laundromat.svg +26 -0
  221. package/src/bundles/shared/components/Sector/svgs/leather-factory.svg +23 -0
  222. package/src/bundles/shared/components/Sector/svgs/leather.svg +23 -0
  223. package/src/bundles/shared/components/Sector/svgs/lipstick.svg +23 -0
  224. package/src/bundles/shared/components/Sector/svgs/meat.svg +24 -0
  225. package/src/bundles/shared/components/Sector/svgs/metal-coating-plant.svg +21 -0
  226. package/src/bundles/shared/components/Sector/svgs/metal-facbrication.svg +20 -0
  227. package/src/bundles/shared/components/Sector/svgs/milk.svg +18 -0
  228. package/src/bundles/shared/components/Sector/svgs/oil-rig.svg +17 -0
  229. package/src/bundles/shared/components/Sector/svgs/petrochemical.svg +13 -0
  230. package/src/bundles/shared/components/Sector/svgs/pie.svg +17 -0
  231. package/src/bundles/shared/components/Sector/svgs/pills.svg +22 -0
  232. package/src/bundles/shared/components/Sector/svgs/plant-unkown-3.svg +36 -0
  233. package/src/bundles/shared/components/Sector/svgs/plastic-rubber.svg +43 -0
  234. package/src/bundles/shared/components/Sector/svgs/printer.svg +17 -0
  235. package/src/bundles/shared/components/Sector/svgs/recycling.svg +17 -0
  236. package/src/bundles/shared/components/Sector/svgs/refinery.svg +18 -0
  237. package/src/bundles/shared/components/Sector/svgs/repair.svg +13 -0
  238. package/src/bundles/shared/components/Sector/svgs/sewing-machine.svg +22 -0
  239. package/src/bundles/shared/components/Sector/svgs/shop.svg +24 -0
  240. package/src/bundles/shared/components/Sector/svgs/soda.svg +13 -0
  241. package/src/bundles/shared/components/Sector/svgs/spray-gun.svg +21 -0
  242. package/src/bundles/shared/components/Sector/svgs/washing-machine.svg +26 -0
  243. package/src/bundles/shared/components/Sector/svgs/waste.svg +43 -0
  244. package/src/bundles/shared/components/Sector/svgs/welder-a.svg +20 -0
  245. package/src/bundles/shared/components/Sector/svgs/wine-glass.svg +15 -0
  246. package/src/bundles/shared/components/Toggle/Toggle.tsx +51 -0
  247. package/src/bundles/shared/components/Toggle/index.ts +3 -0
  248. package/src/bundles/shared/components/Toggle/styles.scss +44 -0
  249. package/src/bundles/shared/components/TrendGraph/TrendGraph.tsx +166 -0
  250. package/src/bundles/shared/components/TrendGraph/index.ts +3 -0
  251. package/src/bundles/shared/components/TrendGraph/styles.scss +2 -0
  252. package/src/bundles/shared/components/TrendGraphNVL/TrendGraphNVL.tsx +134 -0
  253. package/src/bundles/shared/components/TrendGraphNVL/index.ts +3 -0
  254. package/src/bundles/shared/components/TrendGraphNVL/styles.scss +16 -0
  255. package/src/bundles/shared/helpers/kql.ts +39 -0
  256. package/src/bundles/shared/helpers/time.ts +12 -0
  257. package/src/bundles/shared/models/IAction.ts +9 -0
  258. package/src/bundles/shared/models/IAppState.ts +18 -0
  259. package/src/bundles/shared/redux/WBE/actionTypes.ts +1 -0
  260. package/src/bundles/shared/redux/WBE/actions.ts +8 -0
  261. package/src/bundles/shared/redux/WBE/models/IAreaWBE.ts +21 -0
  262. package/src/bundles/shared/redux/WBE/models/IWBE.ts +7 -0
  263. package/src/bundles/shared/redux/WBE/models/IWBEState.ts +5 -0
  264. package/src/bundles/shared/redux/WBE/reducer.ts +24 -0
  265. package/src/bundles/shared/redux/areas/actionTypes.ts +3 -0
  266. package/src/bundles/shared/redux/areas/actions.ts +31 -0
  267. package/src/bundles/shared/redux/areas/models/IArea.ts +6 -0
  268. package/src/bundles/shared/redux/areas/models/IAreasState.ts +6 -0
  269. package/src/bundles/shared/redux/areas/reducer.ts +44 -0
  270. package/src/bundles/shared/redux/context/actionTypes.ts +1 -0
  271. package/src/bundles/shared/redux/context/actions.ts +8 -0
  272. package/src/bundles/shared/redux/context/models/INavContext.ts +4 -0
  273. package/src/bundles/shared/redux/context/models/INavContextState.ts +5 -0
  274. package/src/bundles/shared/redux/context/reducer.ts +25 -0
  275. package/src/bundles/shared/redux/edges/actionTypes.ts +4 -0
  276. package/src/bundles/shared/redux/edges/actions.ts +37 -0
  277. package/src/bundles/shared/redux/edges/models/IEdge.ts +9 -0
  278. package/src/bundles/shared/redux/edges/models/IEdgesState.ts +6 -0
  279. package/src/bundles/shared/redux/edges/reducer.ts +59 -0
  280. package/src/bundles/shared/redux/events/actionTypes.ts +11 -0
  281. package/src/bundles/shared/redux/events/actions.ts +100 -0
  282. package/src/bundles/shared/redux/events/models/IEvent.ts +29 -0
  283. package/src/bundles/shared/redux/events/models/IEventsState.ts +9 -0
  284. package/src/bundles/shared/redux/events/models/ISource.ts +6 -0
  285. package/src/bundles/shared/redux/events/reducer.ts +167 -0
  286. package/src/bundles/shared/redux/filters/IFilter.ts +13 -0
  287. package/src/bundles/shared/redux/filters/IFilterItem.ts +9 -0
  288. package/src/bundles/shared/redux/global/actionTypes.ts +9 -0
  289. package/src/bundles/shared/redux/global/actions.ts +76 -0
  290. package/src/bundles/shared/redux/global/models/IGlobalState.ts +16 -0
  291. package/src/bundles/shared/redux/global/reducer.ts +81 -0
  292. package/src/bundles/shared/redux/points/actionTypes.ts +3 -0
  293. package/src/bundles/shared/redux/points/actions.ts +24 -0
  294. package/src/bundles/shared/redux/points/models/IGroup.ts +7 -0
  295. package/src/bundles/shared/redux/points/models/IPoint.ts +16 -0
  296. package/src/bundles/shared/redux/points/models/IPointsState.ts +6 -0
  297. package/src/bundles/shared/redux/points/reducer.ts +26 -0
  298. package/src/bundles/shared/redux/rootActionTypes.ts +1 -0
  299. package/src/bundles/shared/redux/rootActions.ts +7 -0
  300. package/src/bundles/shared/redux/rootReducer.ts +33 -0
  301. package/src/bundles/shared/redux/rootStore.ts +34 -0
  302. package/src/bundles/shared/utilities/ActionUtility.ts +9 -0
  303. package/src/bundles/shared/utilities/ErrorBoundary.tsx +40 -0
  304. package/src/bundles/shared/utilities/KandoDate.ts +11 -0
  305. package/src/bundles/shared/utilities/KandoModal.tsx +40 -0
  306. package/src/bundles/shared/utilities/LocalStorage.tsx +31 -0
  307. package/src/bundles/shared/utilities/TimeFormat.tsx +64 -0
  308. package/src/bundles/shared/utilities/Truncate.tsx +54 -0
  309. package/src/bundles/shared/utilities/custom_hooks/useClickOutside.ts +18 -0
  310. package/src/bundles/shared/utilities/custom_hooks/useKandoFetch.ts +45 -0
  311. package/src/bundles/shared/utilities/custom_hooks/useQueryURL.ts +7 -0
  312. package/src/bundles/shared/utilities/custom_hooks/useRemoveExistingLayers.tsx +24 -0
  313. package/src/bundles/shared/utilities/custom_hooks/useUpdateEventBodyTail.tsx +52 -0
  314. package/src/bundles/shared/utilities/i18n.tsx +9 -0
  315. package/src/index.js +21 -0
  316. package/src/init-api-mock.js +11 -0
  317. package/src/locals.js +12296 -0
  318. package/src/react-app-env.d.ts +1 -0
  319. package/src/stories/examples/Button.stories.tsx +37 -0
  320. package/src/stories/examples/Button.tsx +48 -0
  321. package/src/stories/examples/Header.stories.tsx +19 -0
  322. package/src/stories/examples/Header.tsx +47 -0
  323. package/src/stories/examples/Introduction.stories.mdx +211 -0
  324. package/src/stories/examples/Page.stories.tsx +22 -0
  325. package/src/stories/examples/Page.tsx +67 -0
  326. package/src/stories/examples/assets/code-brackets.svg +1 -0
  327. package/src/stories/examples/assets/colors.svg +1 -0
  328. package/src/stories/examples/assets/comments.svg +1 -0
  329. package/src/stories/examples/assets/direction.svg +1 -0
  330. package/src/stories/examples/assets/flow.svg +1 -0
  331. package/src/stories/examples/assets/plugin.svg +1 -0
  332. package/src/stories/examples/assets/repo.svg +1 -0
  333. package/src/stories/examples/assets/stackalt.svg +1 -0
  334. package/src/stories/examples/button.css +30 -0
  335. package/src/stories/examples/header.css +26 -0
  336. package/src/stories/examples/page.css +69 -0
  337. package/static/fonts/Gilroy-ExtraBold.otf +0 -0
  338. package/static/fonts/Gilroy-Light.otf +0 -0
  339. package/static/fonts/Gilroy-Regular.otf +0 -0
  340. package/static/fonts/Gilroy-SemiBold.otf +0 -0
  341. package/static/fonts/IBMPlexSerif-Italic.ttf +0 -0
  342. package/static/mockServiceWorker.js +323 -0
  343. package/temp-fix-paths/fix-paths.test.js +143 -0
  344. package/temp-fix-paths/lib.js +97 -0
  345. package/temp-fix-paths/run.js +4 -0
  346. package/temp-fix-paths/test-dir/a/a.ts +0 -0
  347. package/temp-fix-paths/test-dir/a/aa/aa.ts +0 -0
  348. package/temp-fix-paths/test-dir/a/aa/aaa/aaa.ts +8 -0
  349. package/temp-fix-paths/test-dir/b/b.ts +0 -0
  350. package/temp-fix-paths/test-dir/b/bb/bb.ts +0 -0
  351. package/temp-fix-paths/test-dir/b/bb/bbb/bbb.ts +1 -0
  352. package/tsconfig.json +39 -0
  353. package/types/global/index.d.ts +28 -0
  354. package/index.js +0 -1
@@ -0,0 +1,447 @@
1
+ import React, {useEffect} from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import {IPoint} from '../../../../shared/redux/points/models/IPoint';
4
+ import {connect, ConnectedProps, useDispatch} from "react-redux";
5
+ import useRemoveExistingLayers, {removeFromMap} from '../../../../shared/utilities/custom_hooks/useRemoveExistingLayers';
6
+ import {IAppState} from '../../../../shared/models/IAppState';
7
+ import i18n from '../../../../shared/utilities/i18n';
8
+ import GraphIcon from "../../../../assets/line-chart.svg"
9
+ import $ from 'jquery'
10
+ import {openFloatingGraph} from '../../../../shared/redux/global/actions';
11
+ import whitePoint from "../../../../assets/white-point.png";
12
+
13
+ import whitePinRedShadow from "../../../../assets/point_icons/white-pin-red-shadow.png"
14
+ import whitePinBlackShadow from "../../../../assets/point_icons/white-pin-black-shadow.png"
15
+ import redPinRedShadow from "../../../../assets/point_icons/red-pin-red-shadow.png"
16
+
17
+ import yellowCircleURL from "../../../../assets/point_icons/yellow-circle.svg"
18
+ import brightBlueCircleURL from "../../../../assets/point_icons/bright-blue-circle.svg"
19
+ import greenCircleURL from "../../../../assets/point_icons/green-circle.svg"
20
+ import pinkCircleURL from "../../../../assets/point_icons/pink-circle.svg"
21
+ import blueCircleURL from "../../../../assets/point_icons/blue-circle.svg"
22
+
23
+ import WWTPIconURL from "../../../../assets/point_icons/WWTP-icon.svg"
24
+ import plantIconURL from "../../../../assets/point_icons/factory-icon.svg"
25
+ import pumpStationIconURL from "../../../../assets/point_icons/pump-station-icon.svg"
26
+ import observationIconURL from "../../../../assets/point_icons/observation-icon.svg"
27
+ import samplingIconURL from "../../../../assets/point_icons/sampling-icon.svg"
28
+ import DamageType from "../events/event_info/damage_type/DamageType";
29
+ import TimeFormat from '../../../../shared/utilities/TimeFormat';
30
+ import Sector from '../../../../shared/components/Sector';
31
+
32
+
33
+ function mapStateToProps(state: IAppState) {
34
+ const {events_data: events_data} = state
35
+
36
+ return {
37
+ events_data,
38
+ }
39
+ }
40
+
41
+ type Props = ConnectedProps<typeof connector>& {
42
+ map: any,
43
+ L: any,
44
+ point: IPoint
45
+ };
46
+
47
+ const PointMarker: React.FC<Props> = props => {
48
+ const { L, map, point, events_data } = props
49
+ const {focusedEvent} = events_data
50
+ const dispatch = useDispatch()
51
+
52
+
53
+ // iconSize: [width, height],
54
+ // Icon Anchor: [(-right)(+left), (-down)(+up)]
55
+ const selectedBackground = () => {
56
+ return (L.icon({
57
+ iconUrl: redPinRedShadow,
58
+ iconSize: [67, 70],
59
+ iconAnchor: [32, 54],
60
+ popupAnchor: [0, -30]
61
+ }))
62
+ }
63
+
64
+ const belongsToSourceBackground = () => {
65
+ return (L.icon({
66
+ iconUrl: whitePinRedShadow,
67
+ iconSize: [67, 70],
68
+ iconAnchor: [32, 54],
69
+ popupAnchor: [0, -30]
70
+ }))
71
+ }
72
+
73
+ const standardBackground = (secondary: boolean = false, third: boolean = false) => {
74
+ return (L.icon({
75
+ iconUrl: whitePinBlackShadow,
76
+ iconSize: secondary ? [20,20] : [43, 46],
77
+ iconAnchor: secondary && third ? [-2, 19] : (secondary ? [-2, 44] : [20, 42]),
78
+ popupAnchor: [0, -30]
79
+ }))
80
+ }
81
+
82
+ const combinedFactoryIcon = [
83
+ L.icon({
84
+ iconUrl: yellowCircleURL,
85
+ iconSize: [25, 24],
86
+ iconAnchor: [10.7, 33.7],
87
+ popupAnchor: [0, -30]
88
+ }),
89
+ L.icon({
90
+ iconUrl: plantIconURL,
91
+ iconSize: [15, 15],
92
+ iconAnchor: [5, 30],
93
+ popupAnchor: [0, -30]
94
+ })
95
+ ]
96
+
97
+ const combinedPumpStationIcon = [
98
+ L.icon({
99
+ iconUrl: greenCircleURL,
100
+ iconSize: [25, 24],
101
+ iconAnchor: [10.7, 33.7],
102
+ popupAnchor: [0, -30]
103
+ }),
104
+ L.icon({
105
+ iconUrl: pumpStationIconURL,
106
+ iconSize: [20, 20],
107
+ iconAnchor: [7, 32],
108
+ popupAnchor: [0, -30]
109
+ })
110
+ ]
111
+
112
+ const combinedWWTPIcon = [
113
+ L.icon({
114
+ iconUrl: brightBlueCircleURL,
115
+ iconSize: [25, 25],
116
+ iconAnchor: [10.7, 33.7],
117
+ popupAnchor: [0, -30]
118
+ }),
119
+ L.icon({
120
+ iconUrl: WWTPIconURL,
121
+ iconSize: [20, 20],
122
+ iconAnchor: [8, 31],
123
+ popupAnchor: [0, -30]
124
+ })
125
+ ]
126
+
127
+ const markerBelongsToSelectedSource = () => {
128
+ let source
129
+
130
+ if (events_data.focusedEvent !== null) {
131
+ source = events_data.focusedEvent.sources.filter(source => source.point_id === point.id)[0]
132
+ }
133
+
134
+ return events_data.focusedEvent !== null &&
135
+ source && events_data.focusedEvent.selected_source === source.point_id
136
+ }
137
+
138
+ const markerBelongsToSource = () => {
139
+ return events_data.focusedEvent !== null &&
140
+ events_data.focusedEvent.sources.filter(source => source.point_id === point.id)[0]
141
+ }
142
+
143
+
144
+ const matchIconToPoint = (point: IPoint) => {
145
+ switch (point.group.type) {
146
+ case "Groups::Factory":
147
+ if (combinedFactoryIcon.length === 2) {
148
+ if (markerBelongsToSelectedSource()) {
149
+ combinedFactoryIcon.unshift(selectedBackground())
150
+ } else if (markerBelongsToSource()) {
151
+ combinedFactoryIcon.unshift(belongsToSourceBackground())
152
+ } else {
153
+ combinedFactoryIcon.unshift(standardBackground())
154
+ }
155
+ }
156
+
157
+ return combinedFactoryIcon
158
+ break;
159
+ case "Groups::PumpStation":
160
+ if (combinedPumpStationIcon.length === 2) {
161
+ if (markerBelongsToSelectedSource()) {
162
+ combinedPumpStationIcon.unshift(selectedBackground())
163
+ } else if (markerBelongsToSource()) {
164
+ combinedPumpStationIcon.unshift(belongsToSourceBackground())
165
+ } else {
166
+ combinedPumpStationIcon.unshift(standardBackground())
167
+ }
168
+ }
169
+
170
+ return combinedPumpStationIcon
171
+ break;
172
+ case "Groups::WastewaterTreatmentPlant":
173
+ if (combinedWWTPIcon.length === 2) {
174
+ if (markerBelongsToSelectedSource()) {
175
+ combinedWWTPIcon.unshift(selectedBackground())
176
+ } else if (markerBelongsToSource()) {
177
+ combinedWWTPIcon.unshift(belongsToSourceBackground())
178
+ } else {
179
+ combinedWWTPIcon.unshift(standardBackground())
180
+ }
181
+ }
182
+
183
+ return combinedWWTPIcon
184
+ break;
185
+ default:
186
+ return null
187
+ }
188
+ }
189
+
190
+ const createManholePoint = (markerLocation: object) => {
191
+ let pointIcon = L.icon({
192
+ iconUrl: whitePoint,
193
+ iconSize: [9, 9],
194
+ iconAnchor: [4.5, 4.5],
195
+ })
196
+ let manholeIcon: any = L.marker(markerLocation, {icon: pointIcon, riseOnHover: true}).addTo(map);
197
+ manholeIcon.bindTooltip(`${point.group.name} (${point.id})`)
198
+ manholeIcon["kando_object_id"] = point.id
199
+ manholeIcon["kando_object"] = "Point"
200
+ }
201
+
202
+ const createCustomIconPoint = (markerLocation: object) => {
203
+ // @ts-ignore
204
+ matchIconToPoint(point) !== null && matchIconToPoint(point).map((icon: any) => {
205
+ let pointCustomIcon: any = L.marker(markerLocation, {icon: icon, riseOnHover: false}).addTo(map);
206
+ pointCustomIcon.bindTooltip(`${point.group.name} (${point.id})`)
207
+ pointCustomIcon["kando_object_id"] = point.id
208
+ pointCustomIcon["kando_object"] = "Point"
209
+ })
210
+ }
211
+
212
+ const createSamplingIconPoint = (markerLocation: object, secondaryIcon: boolean) => {
213
+ // iconSize: [width, height],
214
+ // Icon Anchor: [(-right)(+left), (-down)(+up)]
215
+ let samplingIcon = [
216
+ L.icon({
217
+ iconUrl: blueCircleURL,
218
+ iconSize: secondaryIcon ? [10,10] : [25, 24],
219
+ iconAnchor: secondaryIcon ? [-7,15] : [10.7, 33.7],
220
+ popupAnchor: [0, -30]
221
+ }),
222
+ L.icon({
223
+ iconUrl: samplingIconURL,
224
+ iconSize: secondaryIcon ? [7,7] : [13, 15],
225
+ iconAnchor: secondaryIcon ? [-8,13] : [5, 30],
226
+ popupAnchor: [0, -30]
227
+ })
228
+ ]
229
+
230
+ if (markerBelongsToSelectedSource() && !secondaryIcon) {
231
+ samplingIcon.unshift(selectedBackground())
232
+ } else if (markerBelongsToSource() && !secondaryIcon) {
233
+ samplingIcon.unshift(belongsToSourceBackground())
234
+ } else {
235
+ samplingIcon.unshift(standardBackground(secondaryIcon, true))
236
+ }
237
+
238
+ samplingIcon.map((icon) => {
239
+ let pointCustomIcon: any = L.marker(markerLocation, {icon: icon, riseOnHover: false}).addTo(map);
240
+ pointCustomIcon.bindTooltip(`${point.group.name} (${point.id})`)
241
+ pointCustomIcon["kando_object_id"] = point.id
242
+ pointCustomIcon["kando_object"] = "Sampling"
243
+ })
244
+ }
245
+
246
+ const createObservationIconPoint = (markerLocation: object, secondaryIcon: boolean) => {
247
+ // iconSize: [width, height],
248
+ // Icon Anchor: [(-right)(+left), (-down)(+up)]
249
+ let observationIcon = [
250
+ L.icon({
251
+ iconUrl: pinkCircleURL,
252
+ iconSize: secondaryIcon ? [10,10] : [25, 24],
253
+ iconAnchor: secondaryIcon ? [-7,40] : [10.7, 33.7],
254
+ popupAnchor: [0, -30]
255
+ }),
256
+ L.icon({
257
+ iconUrl: observationIconURL,
258
+ iconSize: secondaryIcon ? [7,7] : [13, 15],
259
+ iconAnchor: secondaryIcon ? [-8,38] : [5, 30],
260
+ popupAnchor: [0, -30]
261
+ })
262
+ ]
263
+
264
+ if (markerBelongsToSelectedSource() && !secondaryIcon) {
265
+ observationIcon.unshift(selectedBackground())
266
+ } else if (markerBelongsToSource() && !secondaryIcon) {
267
+ observationIcon.unshift(belongsToSourceBackground())
268
+ } else {
269
+ observationIcon.unshift(standardBackground(secondaryIcon))
270
+ }
271
+
272
+ observationIcon.map((icon) => {
273
+ let pointCustomIcon: any = L.marker(markerLocation, {icon: icon, riseOnHover: false}).addTo(map);
274
+ pointCustomIcon.bindTooltip(`${point.group.name} (${point.id})`)
275
+ pointCustomIcon["kando_object_id"] = point.id
276
+ pointCustomIcon["kando_object"] = "Observation"
277
+ })
278
+ }
279
+
280
+ const popupContent = (obs: any) => {
281
+ if (obs === null) {
282
+ return (
283
+ `
284
+ <div class="event-popup">
285
+ <div class="popup-graph-icon popup-graph-icon-${point.id}">
286
+ <img src="${GraphIcon}"/>
287
+ </div>
288
+ <div class="popup-content">
289
+ <h5 class="popup-content__site-name"><b>${point.group.name}</b></h5>
290
+ <hr/>
291
+
292
+ <div id="sector"></div>
293
+ </div>
294
+ </div>
295
+ `
296
+ )
297
+ } else {
298
+ return (
299
+ `
300
+ <div class="event-popup">
301
+ <div class="popup-graph-icon popup-graph-icon-${obs.id}">
302
+ <img src="${GraphIcon}"/>
303
+ </div>
304
+ <div class="popup-content">
305
+ <h5 class="popup-content__site-name"><b>${point.group.name}</b></h5>
306
+ <div class="popup-content__severity">
307
+ <p>${i18n.t(`events_overview.severity`)}</p>
308
+ <span class="${'popup-content__severity--' + obs.severity}"><b>${i18n.t(`events_overview.severities.${obs.severity}`)}</b></span>
309
+ </div>
310
+
311
+ <hr/>
312
+
313
+ <div class="popup-content__damage-type" id="damage-type-popup">
314
+ <p>${i18n.t(`events_overview.local_damage_type`)}</p>
315
+ </div>
316
+
317
+ <hr/>
318
+
319
+ <div class="popup-content__discharge-time">
320
+ <div>
321
+ <p>${i18n.t(`events_overview.first_seen`)}</p>
322
+ <span><b id="first-seen-popup"></b></span>
323
+ </div>
324
+ <div>
325
+ <p>${i18n.t(`events_overview.last_seen`)}</p>
326
+ <span><b id="last-seen-popup"></b></span>
327
+ </div>
328
+ </div>
329
+ </div>
330
+ </div>
331
+ `
332
+ )
333
+ }
334
+ }
335
+
336
+ useRemoveExistingLayers(map, point, "Point")
337
+ useRemoveExistingLayers(map, point, "Observation")
338
+ useRemoveExistingLayers(map, point, "Sampling")
339
+
340
+ const pointIsObservation = () => {
341
+ return focusedEvent !== null && focusedEvent.observations.filter(obs => obs.point_id === point.id)[0]
342
+ }
343
+
344
+ const pointBelongsToEvent = () => {
345
+ return true
346
+ }
347
+
348
+ const bindPopupToPoint = (obs: any = null) => {
349
+ let layers = map._layers
350
+ for (const property in layers) {
351
+ if ( ["Point", "Observation"].includes(layers[property].kando_object) && layers[property].kando_object_id === point.id) {
352
+ layers[property].bindPopup(popupContent(obs), {minWidth: 200})
353
+ layers[property].on('popupopen', function(e: any) {
354
+ if (focusedEvent !== null) {
355
+ let damages = document.createElement('div')
356
+ let firstSeen = document.createElement('div')
357
+ let lastSeen = document.createElement('div')
358
+ let sector = document.createElement('div')
359
+
360
+ if (obs !== null) {
361
+ ReactDOM.render(<TimeFormat timestamp={obs.start_time} time_zone={obs.time_zone}/>, firstSeen)
362
+ ReactDOM.render(<TimeFormat timestamp={obs.last_seen_time} time_zone={obs.time_zone}/>, lastSeen)
363
+ ReactDOM.render(<DamageType event={focusedEvent} forEvent={false} observation={obs}/>, damages);
364
+ } else {
365
+ ReactDOM.render(<Sector sectorName={point.group.sector_name} sectorIconName={point.group.sector_icon_name} width='37' />, sector)
366
+ }
367
+
368
+ setTimeout(() => {
369
+ $("#damage-type-popup").append(damages)
370
+ $("#first-seen-popup").append(firstSeen)
371
+ $("#last-seen-popup").append(lastSeen)
372
+ $("#sector").append(sector)
373
+ }, 200)
374
+ }
375
+
376
+ let attachClickEvent = (selector: string, observation: any) => {
377
+ $(document.body).on('click', selector, () => {
378
+ dispatch(openFloatingGraph(true, observation, point))
379
+ })
380
+ }
381
+
382
+ if (obs !== null) {
383
+ attachClickEvent(".popup-graph-icon-" + obs.id, obs)
384
+ } else {
385
+ attachClickEvent(".popup-graph-icon-" + point.id, null)
386
+ }
387
+ });
388
+ layers[property].on("click", () => {
389
+ layers[property].openPopup();
390
+ })
391
+ }
392
+ }
393
+ }
394
+
395
+ useEffect(() => {
396
+ let markerLocation = [point['latitude'], point['longitude']]
397
+ if (markerLocation[0] !== null) {
398
+ createManholePoint(markerLocation)
399
+
400
+ if (matchIconToPoint(point) !== null &&
401
+ (focusedEvent === null || (focusedEvent !== null && pointIsObservation() ) ||
402
+ point.group.type === 'Groups::WastewaterTreatmentPlant')) {
403
+ createCustomIconPoint(markerLocation);
404
+ }
405
+
406
+ if (focusedEvent !== null && pointIsObservation()) {
407
+ let hasPrimaryIcon = matchIconToPoint(point) !== null
408
+ createObservationIconPoint(markerLocation, hasPrimaryIcon)
409
+ // @ts-ignore
410
+ if (focusedEvent !== null && focusedEvent.samplings.length !== 0 && focusedEvent.samplings[0].point_id === point.id) {
411
+ createSamplingIconPoint(markerLocation, hasPrimaryIcon)
412
+ }
413
+ }
414
+
415
+ if (focusedEvent !== null && pointBelongsToEvent()) {
416
+ let obs = focusedEvent.observations.filter(obs => obs.point_id === point.id)[0]
417
+ bindPopupToPoint(obs)
418
+ }
419
+ }
420
+
421
+ return function cleanup() {
422
+ // UNBIND POPUP
423
+ removeFromMap(map, point, "Observation")
424
+ removeFromMap(map, point, "Point")
425
+ removeFromMap(map, point, "Sampling")
426
+ }
427
+
428
+ }, [focusedEvent])
429
+
430
+ return (
431
+ <div>
432
+ </div>
433
+ )
434
+ }
435
+
436
+ const connector = connect(mapStateToProps);
437
+ export default connector(React.memo(PointMarker, (prevProps, nextProps)=> {
438
+ let prev_focusedEventId = (((prevProps || {}).events_data || {}).focusedEvent || {}).id;
439
+ let next_focusedEventId = (((nextProps || {}).events_data || {}).focusedEvent || {}).id;
440
+ let prev_selectedSource = (((prevProps || {}).events_data || {}).focusedEvent || {}).selected_source;
441
+ let next_selectedSource = (((nextProps || {}).events_data || {}).focusedEvent || {}).selected_source;
442
+ if (prev_focusedEventId != next_focusedEventId || prev_selectedSource != next_selectedSource){
443
+ return false
444
+ } else {
445
+ return true
446
+ }
447
+ } ));
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import {IPoint} from '../../../../shared/redux/points/models/IPoint'
3
+ import PointMarker from './PointMarker'
4
+
5
+ type Props = {
6
+ map: any,
7
+ L: any,
8
+ points: any
9
+ };
10
+
11
+ export const PointMarkers: React.FC<Props> = props => {
12
+ const { L, points, map} = props
13
+
14
+ return (
15
+ <div>
16
+ {points.length !== 0 && (
17
+ points.filter((point: IPoint) => point.has_device).map((point: IPoint) => (
18
+ <PointMarker map={map} L={L} point={point} key={point.id}/>
19
+ ))
20
+ )}
21
+ </div>
22
+ )
23
+ }
@@ -0,0 +1,32 @@
1
+ import React, {useEffect} from 'react';
2
+ import {useDispatch, useSelector} from 'react-redux';
3
+ import 'bootstrap/dist/css/bootstrap.min.css';
4
+ import Body from './components/Body';
5
+ import {updateNavContext} from '../../shared/redux/context/actions';
6
+ import KandoNavbar from '../../shared/components/KandoNavbar'
7
+ import {appReducer} from '../../shared/redux/rootReducer';
8
+ import {resetStore} from '../../shared/redux/rootActions';
9
+
10
+ const eventsView = () => {
11
+ const dispatch = useDispatch()
12
+
13
+ const waterAuthorityId = useSelector(
14
+ (state: ReturnType<typeof appReducer>) => state.global_data.waterAuthorityId
15
+ )
16
+
17
+ useEffect(() => {
18
+ console.log("HEY")
19
+ dispatch(updateNavContext({name: 'events_view'}))
20
+ }, [dispatch])
21
+
22
+ return (
23
+ <>
24
+ <KandoNavbar waterAuthorityId={waterAuthorityId}/>
25
+ <div className="app-wrapper">
26
+ <Body/>
27
+ </div>
28
+ </>
29
+ );
30
+ }
31
+
32
+ export default eventsView;
@@ -0,0 +1,10 @@
1
+ export function getDataFromServer(period, waterAuthorityId) {
2
+ return fetch("/project_management/points_tree.json?period=" + period + "&water_authority_id=" + waterAuthorityId)
3
+ .then(res => res.json());
4
+ }
5
+
6
+
7
+ export function getDetection(period, waterAuthorityId) {
8
+ return fetch("/project_management/detection.json?period=" + period + "&water_authority_id=" + waterAuthorityId)
9
+ .then(res => res.json());
10
+ }
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import LinkToItem from "./link-to-item";
3
+ import Metrics from "./metrics";
4
+ import { BulletList } from 'react-content-loader';
5
+ import ErrorBoundary from '../../shared/components/ErrorBoundary';
6
+
7
+ function ItemsList(props){
8
+ const items = props.items;
9
+ const listItems = items.map((item) =>
10
+
11
+ <div key={item.id} className="prj-mng-item">
12
+ <div className="item-details">
13
+ <div className="row">
14
+ <div className="col-lg-9">
15
+ <LinkToItem item={item} handleSetSelectedPoint={props.handleSetSelectedPoint}/>
16
+ </div>
17
+ <div className="col-lg-3">
18
+ <Metrics item={item}/>
19
+ </div>
20
+ </div>
21
+
22
+
23
+ </div>
24
+
25
+ </div>
26
+ );
27
+ return (
28
+ <div>{listItems}</div>
29
+ );
30
+
31
+ }
32
+
33
+
34
+ export default class KpiListItem extends React.Component {
35
+
36
+
37
+ render() {
38
+
39
+ return (<div className="col col-lg-3 col-md-6">
40
+ <div className="ibox float-e-margins ibox-sm">
41
+ <div className="ibox-title">
42
+ <h5>{this.props.title}</h5>
43
+ </div>
44
+ <div className="ibox-content">
45
+ <ErrorBoundary>
46
+ {this.props.loading ? <BulletList/> : <ItemsList items={this.props.items}
47
+ handleSetSelectedPoint={this.props.handleSetSelectedPoint}/>}
48
+ </ErrorBoundary>
49
+ </div>
50
+ </div>
51
+
52
+ </div>);
53
+ }
54
+ }
55
+
56
+
57
+
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import {getDetection} from "../api";
3
+ import {getUrlQueryParam} from "../util/url";
4
+ import ErrorBoundary from '../../shared/components/ErrorBoundary';
5
+
6
+
7
+
8
+
9
+ export default class KPIPercentageItem extends React.Component {
10
+
11
+ constructor(props){
12
+ super(props)
13
+ this.state = {
14
+ value: 0,
15
+ total: 0
16
+ }
17
+ }
18
+
19
+
20
+ componentDidMount() {
21
+ this.getDataFromServer();
22
+ }
23
+
24
+ getDataFromServer() {
25
+ const period = this.props.selectedPeriod;
26
+ const waterAuthorityId = getUrlQueryParam('water_authority_id');
27
+ getDetection(period, waterAuthorityId).then(
28
+ (result) => {
29
+ this.setState({
30
+ value: result.value,
31
+ total: result.total
32
+ });
33
+
34
+ });
35
+ }
36
+
37
+ componentDidUpdate(prevProps, prevState) {
38
+ if (prevProps.selectedPeriod != this.props.selectedPeriod) {
39
+ this.getDataFromServer();
40
+ }
41
+ }
42
+
43
+
44
+
45
+
46
+ render() {
47
+
48
+
49
+ return (<div className="col col-lg-3 col-md-6">
50
+ <div className="ibox float-e-margins ibox-sm kpi-percentage-item">
51
+ <div className="ibox-title">
52
+ <h5>{this.props.title}</h5>
53
+ </div>
54
+ <div className="ibox-content">
55
+ <ErrorBoundary>
56
+ <div className="stat-percent font-bold text-primary"></div>
57
+ <h1 className="kpi-number no-margins">{this.state.total > 0 ? Math.round(this.state.value/this.state.total*100) : 0}%</h1>
58
+ <div className="stat-percent font-bold text-success">{this.state.value}/{this.state.total}</div>
59
+ <small>{I18n.t('project_management.kpi.upstream_detection')}</small>
60
+ </ErrorBoundary>
61
+ </div>
62
+ </div>
63
+
64
+ </div>);
65
+ }
66
+ }
67
+
68
+
69
+
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import KpiListItem from "./kpi-list-item";
3
+ import KPIPercentageItem from "./kpi-percentage-item";
4
+
5
+
6
+ export default class KPI extends React.Component {
7
+
8
+
9
+ render() {
10
+ return (<div className="kpi">
11
+ <div className="row">
12
+ <KpiListItem loading={this.props.loading} title={I18n.t('project_management.kpi.most_polluted_collectors')} items={this.props.mostPollutedCollectors} handleSetSelectedPoint={this.props.handleSetSelectedPoint}/>
13
+ <KPIPercentageItem title={I18n.t('project_management.kpi.detection')} selectedPeriod={this.props.selectedPeriod}/>
14
+ <KpiListItem loading={this.props.loading} title={I18n.t('project_management.kpi.lowest_collectors_detection')} items={this.props.collectorsWithLowestDetection} handleSetSelectedPoint={this.props.handleSetSelectedPoint}/>
15
+ <KpiListItem loading={this.props.loading} title={I18n.t('project_management.kpi.most_polluted_factories')} items={this.props.mostPollutedFactories} handleSetSelectedPoint={this.props.handleSetSelectedPoint}/>
16
+ </div>
17
+
18
+ </div>);
19
+ }
20
+ }
21
+
22
+
23
+
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+
3
+
4
+ export default class LegendIcon extends React.PureComponent {
5
+ render() {
6
+ const {path, fill, strokeColor, strokeWidth, iconSize} = this.props
7
+ return (
8
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="-5 -5 30 30" height={iconSize || 40} width={iconSize || 40}>
9
+ <path d={path}
10
+ fill={fill} strokeWidth={strokeWidth} stroke={strokeColor}></path>
11
+ </svg>
12
+ )
13
+ }
14
+ }