Refactored property check and alerts page.

This commit is contained in:
Christian P. MOMON 2021-06-16 01:33:43 +02:00
parent 670375a6da
commit a9688259eb
21 changed files with 611 additions and 63 deletions

View file

@ -73,7 +73,7 @@ public class FederationHeaderView
data.setAttribute("subsLink", "href", "index.xhtml"); data.setAttribute("subsLink", "href", "index.xhtml");
data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties"); data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties");
data.setAttribute("rawCheckLink", "href", federation.getTechnicalName() + "-check.xhtml"); data.setAttribute("propertyCheckLink", "href", federation.getTechnicalName() + "-propertycheck.xhtml");
data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml"); data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml");
data.setAttribute("metricsLink", "href", federation.getTechnicalName() + "-metrics-summary-months-last.xhtml"); data.setAttribute("metricsLink", "href", federation.getTechnicalName() + "-metrics-summary-months-last.xhtml");
@ -105,7 +105,7 @@ public class FederationHeaderView
data.setContent("warningCount", checks.getWarningCount()); data.setContent("warningCount", checks.getWarningCount());
data.setContent("voidCount", checks.getVoidCount()); data.setContent("voidCount", checks.getVoidCount());
data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-checkalerts.xhtml"); data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-propertyalerts.xhtml");
} }
if (federation.getLegalURL() != null) if (federation.getLegalURL() != null)

View file

@ -71,10 +71,6 @@ public class FederationPage
String page = htmlize(federation); String page = htmlize(federation);
FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8);
//
page = PropertyFilesCheckPage.htmlize(federation.getName(), federation.getInputChecksAll().getAlertLines());
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8);
// //
logger.info("Htmlize federation metric pages: {}.", federation.getName()); logger.info("Htmlize federation metric pages: {}.", federation.getName());
for (ViewMenu view : ViewMenu.values()) for (ViewMenu view : ViewMenu.values())

View file

@ -0,0 +1,154 @@
/*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
* StatoolInfos is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* StatoolInfos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.htmlize;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.checker.PropertyChecks;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationPropertyCheckAlertPage.
*/
public class FederationPropertyAlertPage
{
private static Logger logger = LoggerFactory.getLogger(FederationPropertyAlertPage.class);
public enum PropertyAlertScope
{
ALL,
FEDERATION,
ORGANIZATIONS,
SERVICES,
METRICS
}
/**
* Builds the all.
*
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static void buildAll() throws IOException, StatoolInfosException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
String page = htmlize(PropertyAlertScope.ALL);
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8);
page = htmlize(PropertyAlertScope.FEDERATION);
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-propertyalerts-federation.xhtml"), page, StandardCharsets.UTF_8);
page = htmlize(PropertyAlertScope.ORGANIZATIONS);
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-propertyalerts-organizations.xhtml"), page, StandardCharsets.UTF_8);
page = htmlize(PropertyAlertScope.SERVICES);
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-propertyalerts-services.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Htmlize.
*
* @param federation
* the federation
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final PropertyAlertScope scope) throws StatoolInfosException
{
String result;
try
{
Federation federation = HtmlizerContext.instance().getFederation();
TagDataManager data = new TagDataManager();
data.setContent("headerView", FederationHeaderView.htmlize(federation));
// TODO submenu
data.setAttribute("allButton", "href", federation.getLocalFileBaseName() + "-propertyalerts.xhtml");
data.setAttribute("federationButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-federation.xhtml");
data.setAttribute("organizationButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-organizations.xhtml");
data.setAttribute("serviceButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-services.xhtml");
data.setAttribute("metricsButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-metrics.xhtml");
PropertyChecks checks;
if (scope == PropertyAlertScope.ALL)
{
checks = federation.getInputChecksAll().getAlertLines();
}
else if (scope == PropertyAlertScope.FEDERATION)
{
checks = federation.getInputChecks().getAlertLines();
}
else if (scope == PropertyAlertScope.ORGANIZATIONS)
{
checks = new PropertyChecks();
for (Organization organization : federation.getOrganizations())
{
checks.addAll(organization.getInputChecks().getAlertLines());
}
}
else if (scope == PropertyAlertScope.SERVICES)
{
checks = new PropertyChecks();
for (Service service : federation.getServicesAll())
{
checks.addAll(service.getInputChecksAll().getAlertLines());
}
}
else
{
checks = new PropertyChecks();
}
data.setContent("contentView", PropertyAlertView.htmlize(checks));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Propriétés en alertes", federation.getLocalFileBaseName() + "-propertyalerts.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation property file check alert page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -36,9 +36,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils;
/** /**
* The Class PropertyFileCheckPage. * The Class PropertyFileCheckPage.
*/ */
public class FederationPropertyFileCheckPage public class FederationPropertyCheckPage
{ {
private static Logger logger = LoggerFactory.getLogger(FederationPropertyFileCheckPage.class); private static Logger logger = LoggerFactory.getLogger(FederationPropertyCheckPage.class);
/** /**
* Builds the. * Builds the.
@ -54,7 +54,7 @@ public class FederationPropertyFileCheckPage
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
String page = htmlize(federation); String page = htmlize(federation);
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8);
} }
/** /**
@ -75,12 +75,12 @@ public class FederationPropertyFileCheckPage
TagDataManager data = new TagDataManager(); TagDataManager data = new TagDataManager();
data.setContent("headerView", FederationHeaderView.htmlize(federation)); data.setContent("headerView", FederationHeaderView.htmlize(federation));
data.setContent("contentView", PropertyFileCheckView.htmlize(federation.getInputChecks())); data.setContent("contentView", PropertyCheckView.htmlize(federation.getInputChecks()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail(); BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Propriétés", federation.getLocalFileBaseName() + "-check.xhtml"); trail.add("Propriétés", federation.getLocalFileBaseName() + "-propertycheck.xhtml");
result = WebCharterView.build(content, trail); result = WebCharterView.build(content, trail);
} }
catch (XidynException exception) catch (XidynException exception)

View file

@ -163,24 +163,27 @@ public class Htmlizer
EditoPage.build(); EditoPage.build();
ExportsPage.build(); ExportsPage.build();
FederationPage.build(); FederationPage.build();
FederationStatsPage.build();
FederationCrawlJournalPage.build(); FederationCrawlJournalPage.build();
FederationPropertyCheckPage.build();
FederationPropertyAlertPage.buildAll();
FederationStatsPage.build();
FederationUptimePage.build(); FederationUptimePage.build();
FederationPropertyFileCheckPage.build();
OrganizationPage.buildAll(); OrganizationPage.buildAll();
OrganizationCrawlJournalPage.buildAll(); OrganizationCrawlJournalPage.buildAll();
OrganizationUptimePage.buildAll(); OrganizationUptimePage.buildAll();
OrganizationPropertyFileCheckPage.buildAll(); OrganizationPropertyCheckPage.buildAll();
OrganizationPropertyAlertPage.buildAll();
PropertiesFilesPage.build(); PropertiesFilesPage.build();
PropertyStatsPage.buildAll(); PropertyStatsPage.buildAll();
ServicePage.buildAll(); ServicePage.buildAll();
ServiceCrawlJournalPage.buildAll(); ServiceCrawlJournalPage.buildAll();
ServicePropertyCheckPage.buildAll();
ServicePropertyAlertPage.buildAll();
ServiceUptimePage.buildAll(); ServiceUptimePage.buildAll();
ServicePropertyFileCheckPage.buildAll();
ServicesPage.build(); ServicesPage.build();
SoftwaresPage.build(); SoftwaresPage.build();
SoftwarePage.buildAll(); SoftwarePage.buildAll();
SocialNetworksPage.buildAll(); SocialNetworksPage.buildAll();
PropertyFileCheckView.buildAll(); // PropertyCheckView.buildAll();
} }
} }

View file

@ -98,7 +98,7 @@ public class OrganizationHeaderView
data.setAttribute("subsLink", "href", organization.getTechnicalName() + ".xhtml"); data.setAttribute("subsLink", "href", organization.getTechnicalName() + ".xhtml");
data.setAttribute("rawLink", "href", organization.getTechnicalName() + ".properties"); data.setAttribute("rawLink", "href", organization.getTechnicalName() + ".properties");
data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-check.xhtml"); data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-propertycheck.xhtml");
data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml"); data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml");
data.setAttribute("metricsLink", "href", organization.getTechnicalName() + "-metrics-summary-months-last.xhtml"); data.setAttribute("metricsLink", "href", organization.getTechnicalName() + "-metrics-summary-months-last.xhtml");
@ -130,7 +130,7 @@ public class OrganizationHeaderView
data.setContent("warningCount", checks.getWarningCount()); data.setContent("warningCount", checks.getWarningCount());
data.setContent("voidCount", checks.getVoidCount()); data.setContent("voidCount", checks.getVoidCount());
data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-checkalerts.xhtml"); data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-propertyalerts.xhtml");
} }
if (organization.getLegalURL() != null) if (organization.getLegalURL() != null)

View file

@ -71,8 +71,7 @@ public class OrganizationPage
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
// //
page = PropertyFilesCheckPage.htmlize(organization.getName(), organization.getInputChecksAll().getAlertLines()); OrganizationPropertyAlertPage.buildAll();
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8);
// //
logger.info("Htmlize organization general stats page: {}.", organization.getName()); logger.info("Htmlize organization general stats page: {}.", organization.getName());

View file

@ -0,0 +1,99 @@
/*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
* StatoolInfos is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* StatoolInfos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.htmlize;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationPropertyFileAlertPage.
*/
public class OrganizationPropertyAlertPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyAlertPage.class);
/**
* Builds the all 1.
*
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static void buildAll() throws IOException, StatoolInfosException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
for (Organization organization : federation.getOrganizations())
{
String page = htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8);
}
}
/**
* Htmlize.
*
* @param organization
* the organization
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Organization organization) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
data.setContent("contentView", PropertyAlertView.htmlize(organization.getInputChecksAll().getAlertLines()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml");
trail.add("Propriétés en alertes", organization.getLocalFileBaseName() + "-propertyalerts.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organization property check alert page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -37,9 +37,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils;
/** /**
* The Class OrganizationPropertyFileCheckView. * The Class OrganizationPropertyFileCheckView.
*/ */
public class OrganizationPropertyFileCheckPage public class OrganizationPropertyCheckPage
{ {
private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyFileCheckPage.class); private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyCheckPage.class);
/** /**
* Builds the all 1. * Builds the all 1.
@ -57,7 +57,7 @@ public class OrganizationPropertyFileCheckPage
for (Organization organization : federation.getOrganizations()) for (Organization organization : federation.getOrganizations())
{ {
String page = htmlize(organization); String page = htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8);
} }
} }
@ -79,13 +79,13 @@ public class OrganizationPropertyFileCheckPage
TagDataManager data = new TagDataManager(); TagDataManager data = new TagDataManager();
data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
data.setContent("contentView", PropertyFileCheckView.htmlize(organization.getInputChecks())); data.setContent("contentView", PropertyCheckView.htmlize(organization.getInputChecks()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail(); BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml");
trail.add("Propriétés", organization.getLocalFileBaseName() + "-check.xhtml"); trail.add("Propriétés", organization.getLocalFileBaseName() + "-propertycheck.xhtml");
result = WebCharterView.build(content, trail); result = WebCharterView.build(content, trail);
} }
catch (XidynException exception) catch (XidynException exception)

View file

@ -111,7 +111,7 @@ public class PropertiesFilesPage
if (stat.getWarningCount() > 0) if (stat.getWarningCount() > 0)
{ {
data.setAttribute("fileListLine", index, "fileListLineWarningCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); data.setAttribute("fileListLine", index, "fileListLineWarningCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml"));
data.setContent("fileListLine", index, "fileListLineWarningCountLink", stat.getWarningCount()); data.setContent("fileListLine", index, "fileListLineWarningCountLink", stat.getWarningCount());
data.setAttribute("fileListLine", index, "fileListLineWarningCount", "style", "background-color: yellow;"); data.setAttribute("fileListLine", index, "fileListLineWarningCount", "style", "background-color: yellow;");
} }
@ -122,7 +122,7 @@ public class PropertiesFilesPage
if (stat.getErrorCount() > 0) if (stat.getErrorCount() > 0)
{ {
data.setAttribute("fileListLine", index, "fileListLineErrorCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); data.setAttribute("fileListLine", index, "fileListLineErrorCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml"));
data.setContent("fileListLine", index, "fileListLineErrorCountLink", stat.getErrorCount()); data.setContent("fileListLine", index, "fileListLineErrorCountLink", stat.getErrorCount());
data.setAttribute("fileListLine", index, "fileListLineErrorCount", "style", "background-color: red;"); data.setAttribute("fileListLine", index, "fileListLineErrorCount", "style", "background-color: red;");
} }
@ -133,7 +133,7 @@ public class PropertiesFilesPage
if (stat.getVoidCount() > 0) if (stat.getVoidCount() > 0)
{ {
data.setAttribute("fileListLine", index, "fileListLineVoidCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); data.setAttribute("fileListLine", index, "fileListLineVoidCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml"));
data.setContent("fileListLine", index, "fileListLineVoidCountLink", stat.getVoidCount()); data.setContent("fileListLine", index, "fileListLineVoidCountLink", stat.getVoidCount());
data.setAttribute("fileListLine", index, "fileListLineVoidCount", "style", "background-color: rgb(54, 162, 235, 0.2);"); data.setAttribute("fileListLine", index, "fileListLineVoidCount", "style", "background-color: rgb(54, 162, 235, 0.2);");
} }

View file

@ -32,9 +32,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils;
/** /**
* The Class PropertyFileCheckPage. * The Class PropertyFileCheckPage.
*/ */
public class PropertyFilesCheckPage public class PropertyAlertPage
{ {
private static Logger logger = LoggerFactory.getLogger(PropertyFilesCheckPage.class); private static Logger logger = LoggerFactory.getLogger(PropertyAlertPage.class);
/** /**
* Builds the. * Builds the.
@ -87,7 +87,7 @@ public class PropertyFilesCheckPage
} }
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyCheck.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail(); BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Propriétés", "propertyStats.xhtml"); trail.add("Propriétés", "propertyStats.xhtml");

View file

@ -0,0 +1,139 @@
/*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
* StatoolInfos is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* StatoolInfos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.htmlize;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.checker.PropertyCheck;
import fr.devinsy.statoolinfos.checker.PropertyChecks;
import fr.devinsy.statoolinfos.core.Service.Status;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class PropertyFileAlertView.
*/
public class PropertyAlertView
{
private static Logger logger = LoggerFactory.getLogger(PropertyAlertView.class);
/**
* Builds the.
*
* @param title
* the title
* @param checks
* the checks
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final PropertyChecks checks) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setContent("lineCount", checks.size());
data.setContent("errorCount", checks.getErrorCount());
data.setContent("warningCount", checks.getWarningCount());
data.setContent("voidCount", checks.getVoidCount());
//
int index = 0;
if (checks.isEmpty())
{
data.setAttribute("blockTable", "class", "xid:nodisplay");
}
else
{
for (PropertyCheck check : checks)
{
//
data.setEscapedContent("line", index, "lineFileName", check.getFileName());
data.setContent("line", index, "lineIndex", check.getIndex());
data.setEscapedContent("line", index, "lineComment", check.getComment());
data.setEscapedContent("line", index, "lineContent", check.getLine());
data.setAttribute("line", index, "lineContent", "class", statusToCSS(check.getStatus()));
index += 1;
}
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyAlertView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building property file alert view: " + exception.getMessage(), exception);
}
//
return result;
}
/**
* Status to CSS.
*
* @param status
* the status
* @return the string
*/
public static String statusToCSS(final Status status)
{
String result;
switch (status)
{
case OK:
result = "bg_ok";
break;
case WARNING:
result = "bg_warning";
break;
case ALERT:
result = "bg_alert";
break;
case ERROR:
result = "bg_error";
break;
case OVER:
result = "bg_over";
break;
case VOID:
default:
result = "bg_void";
}
//
return result;
}
}

View file

@ -43,9 +43,9 @@ import fr.devinsy.xidyn.utils.XidynUtils;
/** /**
* The Class PropertyFileCheckView. * The Class PropertyFileCheckView.
*/ */
public class PropertyFileCheckView public class PropertyCheckView
{ {
private static Logger logger = LoggerFactory.getLogger(PropertyFileCheckView.class); private static Logger logger = LoggerFactory.getLogger(PropertyCheckView.class);
/** /**
* Builds the all. * Builds the all.
@ -99,16 +99,16 @@ public class PropertyFileCheckView
} }
// //
String page = PropertyFilesCheckPage.htmlize("Tous", allAlertChecks); String page = PropertyAlertPage.htmlize("Tous", allAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, "alertChecks.xhtml"), page, StandardCharsets.UTF_8);
page = PropertyFilesCheckPage.htmlize("Fédération", federationAlertChecks); page = PropertyAlertPage.htmlize("Fédération", federationAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks-federation.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, "alertChecks-federation.xhtml"), page, StandardCharsets.UTF_8);
page = PropertyFilesCheckPage.htmlize("Membres", organizationAlertChecks); page = PropertyAlertPage.htmlize("Membres", organizationAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks-organizations.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, "alertChecks-organizations.xhtml"), page, StandardCharsets.UTF_8);
page = PropertyFilesCheckPage.htmlize("Services", serviceAlertChecks); page = PropertyAlertPage.htmlize("Services", serviceAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks-services.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, "alertChecks-services.xhtml"), page, StandardCharsets.UTF_8);
} }
@ -197,7 +197,7 @@ public class PropertyFileCheckView
} }
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyCheckView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content); result = XidynUtils.extractBodyContent(content);
} }
catch (XidynException exception) catch (XidynException exception)

View file

@ -55,8 +55,6 @@ public class ServiceHeaderView
try try
{ {
logger.debug("htmlizing service header page {}…", service.get("service.name"));
TagDataManager data = new TagDataManager(); TagDataManager data = new TagDataManager();
data.setAttribute("serviceLogo", "src", service.getLogoFileName()); data.setAttribute("serviceLogo", "src", service.getLogoFileName());
@ -87,7 +85,7 @@ public class ServiceHeaderView
data.setAttribute("serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString())); data.setAttribute("serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString()));
data.setAttribute("rawLink", "href", service.getLocalFileBaseName() + ".properties"); data.setAttribute("rawLink", "href", service.getLocalFileBaseName() + ".properties");
data.setAttribute("rawCheckLink", "href", service.getLocalFileBaseName() + "-check.xhtml"); data.setAttribute("rawCheckLink", "href", service.getLocalFileBaseName() + "-propertycheck.xhtml");
data.setAttribute("statsLink", "href", service.getLocalFileBaseName() + ".xhtml"); data.setAttribute("statsLink", "href", service.getLocalFileBaseName() + ".xhtml");
data.setAttribute("metricsLink", "href", service.getLocalFileBaseName() + "-metrics-summary-months-last.xhtml"); data.setAttribute("metricsLink", "href", service.getLocalFileBaseName() + "-metrics-summary-months-last.xhtml");
@ -201,12 +199,11 @@ public class ServiceHeaderView
data.setContent("warningCount", checks.getWarningCount()); data.setContent("warningCount", checks.getWarningCount());
data.setContent("voidCount", checks.getVoidCount()); data.setContent("voidCount", checks.getVoidCount());
data.setAttribute("alertLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-check.xhtml#alerts"); data.setAttribute("alertLink", "href", service.getLocalFileBaseName() + "-propertyalerts.xhtml");
} }
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content); result = XidynUtils.extractBodyContent(content);
} }
catch (XidynException exception) catch (XidynException exception)

View file

@ -167,8 +167,6 @@ public class ServicePage
*/ */
private static void htmlizeServiceLogo(final Service service, final CrawlCache cache, final File htmlizeDirectory) throws IOException private static void htmlizeServiceLogo(final Service service, final CrawlCache cache, final File htmlizeDirectory) throws IOException
{ {
logger.info("Htmlize organization logo.");
File target = new File(htmlizeDirectory, service.getLogoFileName()); File target = new File(htmlizeDirectory, service.getLogoFileName());
File logoFile = cache.restoreFile(service.getLogoURL()); File logoFile = cache.restoreFile(service.getLogoURL());

View file

@ -0,0 +1,146 @@
/*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
* StatoolInfos is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* StatoolInfos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.htmlize;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Metrics;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ServicePropertyCheckAlertPage.
*/
public class ServicePropertyAlertPage
{
private static Logger logger = LoggerFactory.getLogger(ServicePropertyAlertPage.class);
/**
* Builds the all.
*
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static void buildAll() throws IOException, StatoolInfosException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
for (Service service : federation.getServicesAll())
{
String page = htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8);
for (Metrics metrics : service.getMetrics())
{
page = htmlize(service, metrics);
FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8);
}
}
}
/**
* Htmlize.
*
* @param service
* the service
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Service service) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("contentView", PropertyAlertView.htmlize(service.getInputChecksAll().getAlertLines()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml");
trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml");
trail.add("Propriétés en alertes", service.getLocalFileBaseName() + "-propertyalerts.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service property file alert page: " + exception.getMessage(), exception);
}
//
return result;
}
/**
* Htmlize.
*
* @param service
* the service
* @param metrics
* the metrics
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Service service, final Metrics metrics) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("contentView", PropertyAlertView.htmlize(metrics.getInputChecks().getAlertLines()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml");
trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml");
trail.add("Propriétés en alertes", service.getLocalFileBaseName() + "-propertyalerts.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building metrics property file check alert page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -38,9 +38,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils;
/** /**
* The Class ServicePropertyFileCheckView. * The Class ServicePropertyFileCheckView.
*/ */
public class ServicePropertyFileCheckPage public class ServicePropertyCheckPage
{ {
private static Logger logger = LoggerFactory.getLogger(ServicePropertyFileCheckPage.class); private static Logger logger = LoggerFactory.getLogger(ServicePropertyCheckPage.class);
/** /**
* Builds the all. * Builds the all.
@ -58,12 +58,12 @@ public class ServicePropertyFileCheckPage
for (Service service : federation.getServicesAll()) for (Service service : federation.getServicesAll())
{ {
String page = htmlize(service); String page = htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8);
for (Metrics metrics : service.getMetrics()) for (Metrics metrics : service.getMetrics())
{ {
page = htmlize(service, metrics); page = htmlize(service, metrics);
FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8);
} }
} }
} }
@ -86,14 +86,14 @@ public class ServicePropertyFileCheckPage
TagDataManager data = new TagDataManager(); TagDataManager data = new TagDataManager();
data.setContent("headerView", ServiceHeaderView.htmlize(service)); data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("contentView", PropertyFileCheckView.htmlize(service.getInputChecks())); data.setContent("contentView", PropertyCheckView.htmlize(service.getInputChecks()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail(); BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml");
trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml");
trail.add("Propriétés", service.getLocalFileBaseName() + "-check.xhtml"); trail.add("Propriétés", service.getLocalFileBaseName() + "-propertycheck.xhtml");
result = WebCharterView.build(content, trail); result = WebCharterView.build(content, trail);
} }
catch (XidynException exception) catch (XidynException exception)
@ -125,15 +125,15 @@ public class ServicePropertyFileCheckPage
TagDataManager data = new TagDataManager(); TagDataManager data = new TagDataManager();
data.setContent("headerView", ServiceHeaderView.htmlize(service)); data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("contentView", PropertyFileCheckView.htmlize(metrics.getInputChecks())); data.setContent("contentView", PropertyCheckView.htmlize(metrics.getInputChecks()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail(); BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml");
trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml");
trail.add("Propriétés", service.getLocalFileBaseName() + "-check.xhtml"); trail.add("Propriétés", service.getLocalFileBaseName() + "-propertycheck.xhtml");
trail.add("Propriétés", metrics.getLocalFileBaseName() + "-check.xhtml"); trail.add("Propriétés", metrics.getLocalFileBaseName() + "-propertycheck.xhtml");
result = WebCharterView.build(content, trail); result = WebCharterView.build(content, trail);
} }
catch (XidynException exception) catch (XidynException exception)

View file

@ -29,7 +29,7 @@
<a id="userDocLink" href="#"><img id="userDocLinkImg" src="circle-icons/bookshelf.svg" class="disabled" title="Documentation"/></a> <a id="userDocLink" href="#"><img id="userDocLinkImg" src="circle-icons/bookshelf.svg" class="disabled" title="Documentation"/></a>
<a id="technicalDocLink" href="#"><img id="technicalDocLinkImg" src="circle-icons/tools.svg" class="disabled" title="Documentation technique"/></a> <a id="technicalDocLink" href="#"><img id="technicalDocLinkImg" src="circle-icons/tools.svg" class="disabled" title="Documentation technique"/></a>
<a id="subsLink" href="#"><img id="subsLinkImg" src="circle-icons/frames-mono.svg" title="Liste des organisations"/></a> <a id="subsLink" href="#"><img id="subsLinkImg" src="circle-icons/frames-mono.svg" title="Liste des organisations"/></a>
<a id="rawCheckLink" href="#"><img id="rawCheckLinkImg" src="circle-icons/clipboard-mono.svg" title="Propriétés"/></a> <a id="propertyCheckLink" href="#"><img id="rawCheckLinkImg" src="circle-icons/clipboard-mono.svg" title="Propriétés"/></a>
<a id="rawLink" href="#"><img id="rawLinkImg" src="circle-icons/document-mono.svg" title="Propriétés brutes"/></a> <a id="rawLink" href="#"><img id="rawLinkImg" src="circle-icons/document-mono.svg" title="Propriétés brutes"/></a>
<a id="crawlLink" href="#"><img id="crawlLinkImg" src="circle-icons/download-mono.svg" title="Statut des téléchargements"/></a> <a id="crawlLink" href="#"><img id="crawlLinkImg" src="circle-icons/download-mono.svg" title="Statut des téléchargements"/></a>
<a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/piechart-mono.svg" title="Statistiques"/></a> <a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/piechart-mono.svg" title="Statistiques"/></a>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>StatoolInfos</title>
<meta charset="UTF-8" />
<meta name="keywords" content="statoolinfos,devinsy,federation" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="statoolinfos.css" />
<script src="sorttable.js" />
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div id="headerView" />
<div style="margin-left: 0px; margin-bottom: 10px;">
<a id="allButton" href="alertChecks.xhtml" class="button">Tous</a>
<a id="federationButton" href="#" class="button">Fédération</a>
<a id="organizationButton" href="#" class="button">Organisations</a>
<a id="serviceButton" href="#" class="button">Services</a>
<a id="metricButton" href="#" class="button">Metrics</a>
</div>
<div id="contentView" />
</body>
</html>

View file

@ -12,15 +12,8 @@
</head> </head>
<body> <body>
<div class="row center_table" style="width: 1400px;"> <div class="row center_table" style="width: 1400px;">
<div style="margin-left: 0px; margin-bottom: 10px;">
<a id="filesButton" href="propertiesFiles.xhtml" class="button">Statistiques</a>
<a id="allButton" href="alertChecks.xhtml" class="button">Tous</a>
<a id="federationButton" href="alertChecks-federation.xhtml" class="button">Fédération</a>
<a id="organizationButton" href="alertChecks-organizations.xhtml" class="button">Membres</a>
<a id="serviceButton" href="alertChecks-services.xhtml" class="button">Services</a>
</div>
<div class="center"> <div class="center">
<h2 id="statsTitle">n/a</h2> <h2 id="statsTitle">Propriétés en alertes</h2>
</div> </div>
<div style="margin-left: 0px; margin-bottom: 10px;"> <div style="margin-left: 0px; margin-bottom: 10px;">
<span style="margin-left: 150px;">Statistiques : </span> <span style="margin-left: 150px;">Statistiques : </span>