From 6770de681fa2f6cce05f709b2fce93a606194faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Thu, 21 Nov 2019 18:42:24 +0100 Subject: Add zone fetch backend for zone prompt --- .../mimuw/cloudatlas/client/ClientController.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/main/java/pl/edu') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java index be853b9..df32f50 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java @@ -200,8 +200,30 @@ public class ClientController { return "home"; } + private String getAvailableZonesString() { + boolean success = true; + Set availableZones; + String availableZonesString = ""; + + try { + availableZones = api.getZoneSet(); + availableZonesString = availableZones.toString().substring(1, availableZones.toString().length() - 1); + } catch (Exception e) { + success = false; + System.err.println("Client exception:"); + e.printStackTrace(); + } + + if (success) { + return "Available zones are: " + availableZonesString; + } else { + return "No zones available, error occured during fetch"; + } + } + @GetMapping("/values") public String valuesPage(Model model) { + model.addAttribute("availableZones", getAvailableZonesString()); model.addAttribute("zoneName", new ContactsString()); return "attribChart"; } @@ -219,6 +241,7 @@ public class ClientController { e.printStackTrace(); } + model.addAttribute("availableZones", getAvailableZonesString()); return "attribChart"; } } -- cgit v1.2.3