Commit e75cd782 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '634-drop-kpi-mvc' into 'main'

Resolve "Drop KPI MVC"

Closes #634

See merge request genesys-pgr/genesys-server!694
parents 78295f4e 2b2e50fc
package org.genesys2.server.mvc.admin;
import java.util.Map;
import org.genesys2.server.model.kpi.Execution;
import org.genesys2.server.model.kpi.ExecutionRun;
import org.genesys2.server.service.KPIService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@Controller("kpiAdminController")
@RequestMapping(value = "/admin/kpi")
public class KPIController {
@Autowired
private KPIService kpiService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(ModelMap model) {
model.addAttribute("executions", kpiService.listExecutions(PageRequest.of(0, 100)).getContent());
return "/admin/kpi/index";
}
@RequestMapping(value = "/exec/{executionName:.+}", method = RequestMethod.GET)
public String execution(ModelMap model, @PathVariable("executionName") String executionName,
@RequestParam(value = "page", required = false, defaultValue = "1") int page) {
Execution execution = kpiService.loadExecution(executionName);
model.addAttribute("execution", execution);
model.addAttribute("executionRuns", kpiService.listExecutionRuns(execution, PageRequest.of(page - 1, 20)));
return "/admin/kpi/execution";
}
@RequestMapping(value = "/exec/{executionName:.+}", method = RequestMethod.GET, params={"dk"})
public String execution(ModelMap model, @PathVariable("executionName") String executionName,
@RequestParam(value = "dk", required = true) long dimensionKeyId) {
Execution execution = kpiService.loadExecution(executionName);
model.addAttribute("execution", execution);
model.addAttribute("observations", kpiService.listObservations(execution, dimensionKeyId, PageRequest.of(0, 20)));
return "/admin/kpi/execution";
}
@RequestMapping(value = "/exec/{executionName}/run/{runId}", method = RequestMethod.GET)
public String executionRun(ModelMap model, @PathVariable("executionName") String executionName, @PathVariable("runId") long runId,
@RequestParam(value = "page", required = false, defaultValue = "1") int page) {
Execution execution = kpiService.loadExecution(executionName);
ExecutionRun executionRun = kpiService.getExecutionRun(runId);
model.addAttribute("execution", execution);
model.addAttribute("executionRun", executionRun);
Map<String, String> dimensionFilters = null;
model.addAttribute("observations", kpiService.listObservations(executionRun, dimensionFilters, PageRequest.of(page - 1, 500)));
return "/admin/kpi/run";
}
}
......@@ -144,26 +144,6 @@
</ul>
</li>
<li class="dropdown" id="cluster-menu-item">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Data
<span class="caret"></span>
</a>
<ul class="dropdown-menu pull-left">
<li id="ds2-menu-item">
<a class="" href="<c:url value='/admin/ds2/' />">
<spring:message code="menu.admin.ds2"/>
</a>
</li>
<li id="kpi-menu-item">
<a class="" href="<c:url value='/admin/kpi/' />">
<spring:message code="menu.admin.kpi"/>
</a>
</li>
</ul>
</li>
<li id="kpi-menu-item">
<a class="" href="<c:url value='/admin/bsh' />">
<spring:message code="menu.admin.beanshell"/>
......
<!DOCTYPE html>
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<html>
<head>
<title><spring:message code="admin.kpi.execution.page" /></title>
</head>
<body>
<c:if test="${executionRuns ne null}">
<div class="crop-details">
<c:forEach items="${executionRuns}" var="executionRun">
<div class="row">
<div class="col-xs-3">
<local:prettyTime date="${executionRun.timestamp}" locale="${pageContext.response.locale}" />
</div>
<div class="col-xs-5">
<a href="<c:url value="/admin/kpi/exec/${execution.name}/run/${executionRun.id}" />"><c:out
value="${timestamp}"
/> <local:prettyTime date="${executionRun.timestamp}" locale="${pageContext.response.locale}" /> </a>
</div>
</div>
</c:forEach>
</div>
</c:if>
<c:if test="${observations ne null}">
<div class="crop-details">
<c:forEach items="${observations.content}" var="obs">
<div class="row">
<div class="col-xs-4 col-sm-2 text-right">
<local:prettyTime date="${obs.executionRun.timestamp}" locale="${pageContext.response.locale}" />
</div>
<div class="col-xs-4 col-sm-2 text-right">
<c:out value="${obs.value}" />
</div>
<div class="col-xs-4 col-sm-8">
<c:forEach items="${obs.dimensions}" var="dim">
<div>
<a href="<c:url value="/admin/kpi/exec/${executionRun.execution.name}?dk=${dim.id}" />"> <c:out
value="${dim.value}"
/>
</a>
</div>
</c:forEach>
</div>
</div>
</c:forEach>
</div>
</c:if>
</body>
</html>
<!DOCTYPE html>
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<html>
<head>
<title><spring:message code="admin.kpi.index.page" /></title>
</head>
<body>
<div class="crop-details">
<c:forEach items="${executions}" var="execution">
<div class="row">
<div class="col-xs-3">
<c:out value="${execution.name}" />
</div>
<div class="col-xs-5">
<a href="<c:url value="/admin/kpi/exec/${execution.name}" />"><c:out value="${execution.title}" /></a>
</div>
<div class="col-xs-4">
<c:out value="${execution.parameter.title}" />
<small><b><c:out value="${execution.parameter.entity}" /></b> <c:out
value="${execution.parameter.condition}"
/></small>
</div>
<div class="col-xs-12">
<c:forEach items="${execution.executionDimensions}" var="dimension">
<div class="col-xs-6">
<c:out value="${dimension.dimension.title}" />
<c:out value="${dimension.dimension.condition}" />
</div>
<div class="col-xs-6">
<c:out value="${dimension.field}" />
<c:out value="${dimension.link}" />
</div>
</c:forEach>
</div>
</div>
</c:forEach>
</div>
<content tag="javascript">
<script type="text/javascript">
$(document).ready(function() {
$('#kpi-menu-item').addClass('active');
$('#kpi-menu-item').find("a").first().addClass('active');
});
</script>
</content>
</body>
</html>
<!DOCTYPE html>
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<html>
<head>
<title><spring:message code="admin.kpi.execution.page" /></title>
</head>
<body>
<h2>
<local:prettyTime date="${executionRun.timestamp}" locale="${pageContext.response.locale}" />
</h2>
<div class="crop-details">
<c:forEach items="${observations.content}" var="obs">
<div class="row">
<div class="col-xs-4 col-sm-2 text-right">
<c:out value="${obs.value}" />
</div>
<div class="col-xs-8 col-sm-10">
<c:forEach items="${obs.dimensions}" var="dim">
<div>
<a href="<c:url value="/admin/kpi/exec/${executionRun.execution.name}" />?dk=${dim.id}">
<c:out value="${dim.value}" />
</a>
</div>
</c:forEach>
</div>
</div>
</c:forEach>
</div>
</body>
</html>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment