Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Commit

Permalink
enhanced dashboard, now contains list of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapinkas committed Aug 13, 2015
1 parent 046dd07 commit 6d02abf
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 41 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
13.8.2015: version 2.2.1
+ enhanced dashboard, now contains list of errors

12.8.2015: version 2.2.0
+ dashboard
+ checks split to multiple pages
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.sf.sitemonitoring</groupId>
<artifactId>sitemonitoring</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
<packaging>war</packaging>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sf.sitemonitoring.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -17,10 +18,25 @@
@ViewScoped
@Data
public class DashboardController {

@Data
public class CheckAndCheckResultDto {
private Check check;
private CheckResultDto checkResultDto;
public CheckAndCheckResultDto(Check check, CheckResultDto checkResultDto) {
this.check = check;
this.checkResultDto = checkResultDto;
}
}

private Map<Integer, CheckResultDto> lastResults;

private List<Check> checks;

/**
* contains only erroneous results
*/
private Map<Integer, CheckAndCheckResultDto> checksWithResults;

@ManagedProperty("#{checkResultService}")
private CheckResultService checkResultService;
Expand All @@ -30,7 +46,14 @@ public class DashboardController {

public void loadChecks() {
checks = checkService.findAll();
checksWithResults = new HashMap<Integer, CheckAndCheckResultDto>();
lastResults = checkResultService.getLastResults(checks);
for (Check check : checks) {
CheckResultDto lastResult = lastResults.get(check.getId());
if(lastResult.getSuccess() != null && lastResult.getSuccess() == false) {
checksWithResults.put(check.getId(), new CheckAndCheckResultDto(check, lastResult));
}
}
}

public int successCount() {
Expand All @@ -52,5 +75,5 @@ public int failureCount() {
}
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CheckResultDto {
private Date finishDate;

private long responseTime;

public String getDateInterval() {
if (startDate == null && finishDate == null) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void init() throws Exception {
}
System.out.println("*** DATABASE INIT STARTED ***");
configuration = new Configuration();
configuration.setMonitoringVersion("2.2.0");
configuration.setMonitoringVersion("2.2.1");
configuration.setEmailSubject("sitemonitoring error");
configuration.setEmailBody("check name:{CHECK-NAME}\n\ncheck url: {CHECK-URL}\n\nerror:\n{ERROR}");
configuration.setDefaultSingleCheckInterval(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public void upgradeDatabase(Configuration configuration) {
configurationService.saveExcludingPassword(configuration);
configuration = configurationService.find();
}
if (configuration.getMonitoringVersion().equals("2.2.0")) {
configuration.setMonitoringVersion("2.2.1");
configurationService.saveExcludingPassword(configuration);
configuration = configurationService.find();
}
}

private void update(String sql) {
Expand Down
5 changes: 1 addition & 4 deletions src/main/webapp/admin/checks.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@
<p:column style="width:250px;vertical-align:top;" styleClass="greyBackground">

<h:panelGroup style="float:left;padding-top:5px">
<h:panelGroup styleClass="fa fa-header" rendered="#{check.type eq 'SINGLE_PAGE'}"></h:panelGroup>
<h:panelGroup styleClass="fa fa-sitemap" rendered="#{check.type eq 'SITEMAP'}"></h:panelGroup>
<h:panelGroup styleClass="fa fa-bug" rendered="#{check.type eq 'SPIDER'}"></h:panelGroup>
<h:panelGroup styleClass="fa fa-code" rendered="#{check.type eq 'XML' or check.type eq 'JSON'}"></h:panelGroup>
<components:check-icon checkType="#{check.type}" />
<strong style="#{check.active eq true ? '' : 'text-decoration:line-through;'}">#{check.name}</strong>
</h:panelGroup>

Expand Down
56 changes: 37 additions & 19 deletions src/main/webapp/admin/dashboard.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:components="http://xmlns.jcp.org/jsf/composite/components">
<ui:composition template="/template.xhtml">

<ui:param name="title" value="dashboard" />
Expand All @@ -13,26 +14,43 @@
<f:viewAction action="#{dashboardController.loadChecks()}" />
</f:metadata>

<div class="center" style="width:3 00px;">
<h1>Quick overview:</h1>

<h1>Quick overview:</h1>

<p:panelGrid columns="2" styleClass="tableNoBorder">
<h:panelGroup>
<i class="fa fa-check fa-green" style="padding-right:5px"></i>
<h:outputText value="Success count:" />
</h:panelGroup>
#{dashboardController.successCount()}

<h:panelGroup>
<i class="fa fa-warning fa-red" style="padding-right:5px"></i>
<h:outputText value="Failure count:" />
</h:panelGroup>
#{dashboardController.failureCount()}
</p:panelGrid>

</div>
<p:panelGrid columns="2" styleClass="tableNoBorder">
<h:panelGroup>
<i class="fa fa-check fa-green" style="padding-right:5px"></i>
<h:outputText value="Success:" />
</h:panelGroup>
#{dashboardController.successCount()}x

<h:panelGroup>
<i class="fa fa-warning fa-red" style="padding-right:5px"></i>
<h:outputText value="Failure:" />
</h:panelGroup>
#{dashboardController.failureCount()}x
</p:panelGrid>


<h:panelGroup rendered="#{dashboardController.failureCount() > 0}">
<h2>All errors:</h2>

<p:dataTable value="#{dashboardController.checksWithResults.values()}" var="checkWithResult">
<p:column headerText="detail">
<components:check-icon checkType="#{checkWithResult.check.type}" />
<strong>
<h:panelGroup rendered="#{checkWithResult.check.page eq null}">
<a href="checks.xhtml">#{checkWithResult.check.name}</a>:
</h:panelGroup>
<h:panelGroup rendered="#{checkWithResult.check.page ne null}">
<a href="checks.xhtml?page=#{checkWithResult.check.page.id}">#{checkWithResult.check.name}</a>:
</h:panelGroup>
</strong>
#{checkWithResult.checkResultDto.result}
<br />
</p:column>
</p:dataTable>
</h:panelGroup>

</ui:define>
</ui:composition>
</html>
22 changes: 22 additions & 0 deletions src/main/webapp/resources/components/check-icon.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:composite="http://xmlns.jcp.org/jsf/composite"
xmlns:components="http://xmlns.jcp.org/jsf/composite/components">

<composite:interface>
<composite:attribute name="checkType" required="true" />
</composite:interface>

<composite:implementation>

<h:panelGroup styleClass="fa fa-header" rendered="#{cc.attrs.checkType eq 'SINGLE_PAGE'}"></h:panelGroup>
<h:panelGroup styleClass="fa fa-sitemap" rendered="#{cc.attrs.checkType eq 'SITEMAP'}"></h:panelGroup>
<h:panelGroup styleClass="fa fa-bug" rendered="#{cc.attrs.checkType eq 'SPIDER'}"></h:panelGroup>
<h:panelGroup styleClass="fa fa-code" rendered="#{cc.attrs.checkType eq 'XML' or cc.attrs.checkType eq 'JSON'}"></h:panelGroup>

</composite:implementation>

</html>
16 changes: 2 additions & 14 deletions src/main/webapp/template.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,9 @@
<div>
<h:form id="menubarForm">
<a href="dashboard.xhtml" style="float:left;padding-left:5px;padding-top:5px;">
<i class="fa fa-clock-o fa-2x" style="color:#00a8ec;margin-top:3px;"></i>
<i class="fa fa-clock-o fa-2x" style="color:#00a8ec;position:absolute;left:18px;top:25px;z-index:100"></i>
</a>
<p:menubar model="#{menubarController.menubar}" style="margin-left:50px">
<!-- <p:menuitem> -->
<!-- <a href="dashboard.xhtml"> -->
<!-- <i class="fa fa-clock-o fa-2x" style="color:#00a8ec;margin-top:3px;"></i> -->
<!-- </a> -->
<!-- </p:menuitem> -->
<!-- <p:menuitem value="Dashboard" url="dashboard.xhtml" styleClass="customMenuItem" /> -->
<!-- <p:submenu label="Checks" styleClass="customSubMenu"> -->
<!-- <p:menuitem value="Uncategorized" url="checks.xhtml" styleClass="customMenuItem" /> -->
<!-- </p:submenu> -->
<!-- <p:menuitem value="Pages" url="pages.xhtml" styleClass="customMenuItem" /> -->
<!-- <p:menuitem value="Configuration" url="configuration.xhtml" styleClass="customMenuItem" /> -->
<!-- <p:menuitem value="Logout" url="/logout" styleClass="customMenuItem" /> -->
<p:menubar model="#{menubarController.menubar}" style="padding-left:40px">
</p:menubar>
</h:form>
</div>
Expand Down

0 comments on commit 6d02abf

Please sign in to comment.