Skip to content

Commit

Permalink
Solve #59
Browse files Browse the repository at this point in the history
  • Loading branch information
ylvion committed Apr 7, 2022
1 parent 186a24b commit 67a1f83
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ public void checkDashboardConfiguration(DaveDashboard dashboard) {
}
}

/**
* Check if corresponding DAVE-Connector for the LRS use in the given Dashboard description is initialised
*
* @param dashboard Entity to use
* @return true, if the initialisation is completed
*/
public Boolean checkConnectorInitialisation(DaveDashboard dashboard) {
return this.daveConnectorLifecycleManager.getConnector(dashboard.getLrsConnection()).getHealth() != null;
}

/**
* Schedule to clean the cache for LRS' activities every ten minutes
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.tudresden.inf.verdatas.xapitools.dave.dashboards.controllers;

import de.tudresden.inf.verdatas.xapitools.dave.connector.DaveConnectorLifecycleManager;
import de.tudresden.inf.verdatas.xapitools.dave.dashboards.DaveDashboardService;
import de.tudresden.inf.verdatas.xapitools.dave.persistence.DaveDashboard;
import de.tudresden.inf.verdatas.xapitools.ui.BasepageMavController;
Expand Down Expand Up @@ -32,9 +33,9 @@
@Order(3)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class DaveDashboardMavController implements IUIFlow {

static final String BASE_URL = "/ui/dave/dashboards";
private final DaveDashboardService daveDashboardService;
private final DaveConnectorLifecycleManager daveConnectorLifecycleManager;
private final List<DashboardStep> children;

/**
Expand Down Expand Up @@ -112,6 +113,9 @@ public ModelAndView showDetails(@RequestParam(name = "flow") Optional<UUID> dash
@PostMapping(BASE_URL + "/show")
public RedirectView executeDashboard(@RequestParam(name = "flow") UUID dashboardId, RedirectAttributes attributes) {
attributes.addAttribute("flow", dashboardId.toString());
if (!this.daveDashboardService.checkConnectorInitialisation(this.daveDashboardService.getDashboard(dashboardId))) {
return new RedirectView("../error");
}
return new RedirectView("./execute");
}

Expand Down Expand Up @@ -162,6 +166,18 @@ public RedirectView deleteDashboard(@RequestParam(name = "flow") UUID dashboardI
return new RedirectView("../dashboards/show");
}

@GetMapping(BASE_URL + "/error")
public ModelAndView showErrorMessage(@RequestParam(name = "flow") UUID dashboardId) {
DaveDashboard dashboard = this.daveDashboardService.getDashboard(dashboardId);
ModelAndView mav = new ModelAndView("bootstrap/dave/dashboard/error");
mav.addObject("title", "Unsuccessful interaction with DAVE-Connector.");
mav.addObject("message", "The DAVE-Connector "
+ this.daveConnectorLifecycleManager.getConnector(dashboard.getLrsConnection()).getName()
+ " is not ready for interaction. \n"
+ "Please wait, until its initialisation is completed.");
return mav;
}

/**
* UI helper enum, controls button states
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public RedirectView selectLRS(@RequestParam(name = "flow") UUID dashboardId, @Re
this.daveDashboardService.setDashboardSource(dashboard, lrsConnection);
this.daveDashboardService.checkDashboardConfiguration(dashboard);
attributes.addAttribute("flow", dashboardId.toString());
if (!this.daveDashboardService.checkConnectorInitialisation(dashboard)) {
return new RedirectView("../error");
}
return new RedirectView(DaveDashboardMavController.Mode.CREATING.equals(mode) ? "./visualisations" : "../show");
}
}
27 changes: 27 additions & 0 deletions src/main/resources/templates/bootstrap/dave/dashboard/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="bootstrap/header.html :: scripted_head ('Error')"></head>
<body class="bg-dark">
<div class="container">
<div class="row row-cols-1">
<div class="col d-flex">
<div class="card flex-fill">
<h2 class="card-header">
<span th:text="${title}"></span>
</h2>
<div class="card-body">
<div class="mb-2">
Reason:&nbsp;<span th:text="${message}"></span>
</div>
</div>
<div class="card-footer">
<div class="mb-2 d-flex">
<button class="btn btn-outline-success flex-fill" type="button" onclick="history.go(-1);">Go Back</button>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

0 comments on commit 67a1f83

Please sign in to comment.