Splitted federation header view.

This commit is contained in:
Christian P. MOMON 2021-06-03 03:05:12 +02:00
parent 920709bd66
commit 82c7d3f3ed
4 changed files with 192 additions and 104 deletions

View file

@ -0,0 +1,138 @@
/*
* 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.IOException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.checker.PropertyChecks;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.DisplayMode;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class FederationHeaderView.
*/
public class FederationHeaderView
{
private static Logger logger = LoggerFactory.getLogger(FederationHeaderView.class);
/**
* Builds the.
*
* @param federation
* the organization
* @return the string
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
*/
public static String htmlize(final Federation federation) throws StatoolInfosException, IOException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setAttribute("federationRawButton", "href", federation.getTechnicalName() + ".properties");
data.setAttribute("federationLogo", "src", federation.getLogoFileName());
data.setEscapedContent("federationName", federation.getName());
data.setEscapedContent("federationDescription", federation.getDescription());
data.setEscapedContent("federationURL", federation.getWebsite());
data.setEscapedAttribute("federationURL", "href", federation.getWebsite());
data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDate(), "n/a"));
data.setAttribute("subsLink", "href", "index.xhtml");
data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties");
data.setAttribute("rawCheckLink", "href", federation.getTechnicalName() + "-check.xhtml");
data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml");
data.setAttribute("crawlLink", "href", federation.getTechnicalName() + "-crawl.xhtml");
if (federation.getCrawlJournal().getErrors().isEmpty())
{
data.setAttribute("crawlLinkImg", "src", "circle-icons/download-mono.svg");
}
else
{
data.setAttribute("crawlLinkImg", "src", "circle-icons/download.svg");
}
{
PropertyChecks checks = federation.getInputChecksAll();
data.setContent("errorCount", checks.getErrorCount());
data.setContent("warningCount", checks.getWarningCount());
data.setContent("voidCount", checks.getVoidCount());
data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-checkalerts.xhtml");
}
if (StringUtils.isNotBlank(federation.getLegalWebsite()))
{
data.setEscapedAttribute("legalLink", "href", federation.getLegalWebsite());
data.setAttribute("legalLinkImg", "class", "");
data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(federation.getContactWebsite()))
{
data.setEscapedAttribute("contactLink", "href", federation.getContactWebsite());
data.setAttribute("contactLinkImg", "class", "");
data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(federation.getContactEmail()))
{
data.setEscapedAttribute("emailLink", "href", "mailto:" + federation.getContactEmail());
data.setAttribute("emailLinkImg", "class", "");
data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(federation.getUserDocWebsite()))
{
data.setEscapedAttribute("userDocLink", "href", federation.getUserDocWebsite());
data.setAttribute("userDocLinkImg", "class", "");
data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(federation.getTechnicalDocWebsite()))
{
data.setEscapedAttribute("technicalDocLink", "href", federation.getTechnicalDocWebsite());
data.setAttribute("technicalDocLinkImg", "class", "");
data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation header view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -24,19 +24,16 @@ import java.nio.charset.StandardCharsets;
import java.time.format.DateTimeFormatter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.catgenerator.core.CatGenerator;
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.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.DisplayMode;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
@ -97,70 +94,7 @@ public class FederationPage
TagDataManager data = new TagDataManager();
data.setAttribute("federationRawButton", "href", federation.getTechnicalName() + ".properties");
data.setAttribute("federationLogo", "src", federation.getLogoFileName());
data.setEscapedContent("federationName", federation.getName());
data.setEscapedContent("federationDescription", federation.getDescription());
data.setEscapedContent("federationURL", federation.getWebsite());
data.setEscapedAttribute("federationURL", "href", federation.getWebsite());
data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDate(), "n/a"));
data.setAttribute("subsLink", "href", "index.xhtml");
data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties");
data.setAttribute("rawCheckLink", "href", federation.getTechnicalName() + "-check.xhtml");
data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml");
data.setAttribute("crawlLink", "href", federation.getTechnicalName() + "-crawl.xhtml");
if (federation.getCrawlJournal().getErrors().isEmpty())
{
data.setAttribute("crawlLinkImg", "src", "circle-icons/download-mono.svg");
}
else
{
data.setAttribute("crawlLinkImg", "src", "circle-icons/download.svg");
}
{
PropertyChecks checks = federation.getInputChecksAll();
data.setContent("errorCount", checks.getErrorCount());
data.setContent("warningCount", checks.getWarningCount());
data.setContent("voidCount", checks.getVoidCount());
data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-checkalerts.xhtml");
}
if (StringUtils.isNotBlank(federation.getLegalWebsite()))
{
data.setEscapedAttribute("legalLink", "href", federation.getLegalWebsite());
data.setAttribute("legalLinkImg", "class", "");
data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(federation.getContactWebsite()))
{
data.setEscapedAttribute("contactLink", "href", federation.getContactWebsite());
data.setAttribute("contactLinkImg", "class", "");
data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(federation.getContactEmail()))
{
data.setEscapedAttribute("emailLink", "href", "mailto:" + federation.getContactEmail());
data.setAttribute("emailLinkImg", "class", "");
data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(federation.getUserDocWebsite()))
{
data.setEscapedAttribute("userDocLink", "href", federation.getUserDocWebsite());
data.setAttribute("userDocLinkImg", "class", "");
data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(federation.getTechnicalDocWebsite()))
{
data.setEscapedAttribute("technicalDocLink", "href", federation.getTechnicalDocWebsite());
data.setAttribute("technicalDocLinkImg", "class", "");
data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation));
data.setContent("organizationCount", federation.getOrganizations().size());
data.setContent("serviceCount", federation.getServiceCount());

View file

@ -11,43 +11,11 @@
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div class="center">
<div class="row center" style="border: 0px solid yellow;">
<div class="column" style="border: 0px solid red;">
<img id="federationLogo" src="#" style="width: 100px; heigth: 100px; vertical-align: middle;"/>
</div>
<div class="column" style="border: 0px solid red; max-width: 500px;">
<div class="content_title"><a id="federationName" href="#">n/a</a></div>
<div class="content_subtitle"><a id="federationURL" href="#" style="text-decoration: none;">n/a</a></div>
</div>
<p id="federationDescription">Description absente…</p>
<div>Depuis <span id="federationStartDate">n/a</span></div>
<div class="content_infos" style="margin: 5px;">
Liens :
<a id="legalLink" href="#"><img id="legalLinkImg" src="circle-icons/ribbon.svg" class="disabled" title="Mentions légales"/></a>
<a id="contactLink" href="#"><img id="contactLinkImg" src="circle-icons/contacts.svg" class="disabled" title="Page web de contact"/></a>
<a id="emailLink" href="#"><img id="emailLinkImg" src="circle-icons/mail.svg" class="disabled" title="Courriel de contact/support"/></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="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="Fichier propriétés analysé"/></a>
<a id="rawLink" href="#"><img id="rawLinkImg" src="circle-icons/document-mono.svg" title="Fichier propriétés"/></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/barchart-mono.svg" title="Statistiques"/></a>
<div style="display: inline-block; vertical-align: middle; font-size: smaller; margin-left: 2px; width: 35px;">
<a id="alertLink" href="#" style="text-decoration: none;">
<div id="errorCount" class="bg_error center" title="Propriétés en erreurs">n/a</div>
<div id="warningCount" class="bg_warning cener" title="Propriétés attendues">n/a</div>
<div id="voidCount" class="bg_void center" title="Propriétés Inconnues">n/a</div>
</a>
</div>
</div>
<br/>
</div>
<div>Nombre de membres : <span id="organizationCount">n/a</span></div>
<div>Nombre de services : <span id="serviceCount">n/a</span></div>
</div>
<div id="federationHeaderView" />
<div class="center_table" style="width: 900px;">
<br/>
<div class="center">Nombre de membres : <span id="organizationCount">n/a</span></div>
<div class="center">Nombre de services : <span id="serviceCount">n/a</span></div>
<table id="organizations" class="table_classic left">
<thead>
<tr>

View file

@ -0,0 +1,48 @@
<?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 class="center">
<div class="row center" style="border: 0px solid yellow;">
<div class="column" style="border: 0px solid red;">
<img id="federationLogo" src="#" style="width: 100px; heigth: 100px; vertical-align: middle;"/>
</div>
<div class="column" style="border: 0px solid red; max-width: 500px;">
<div class="content_title"><a id="federationName" href="#">n/a</a></div>
<div class="content_subtitle"><a id="federationURL" href="#" style="text-decoration: none;">n/a</a></div>
</div>
<p id="federationDescription">Description absente…</p>
<div>Depuis <span id="federationStartDate">n/a</span></div>
<div class="content_infos" style="margin: 5px;">
Liens :
<a id="legalLink" href="#"><img id="legalLinkImg" src="circle-icons/ribbon.svg" class="disabled" title="Mentions légales"/></a>
<a id="contactLink" href="#"><img id="contactLinkImg" src="circle-icons/contacts.svg" class="disabled" title="Page web de contact"/></a>
<a id="emailLink" href="#"><img id="emailLinkImg" src="circle-icons/mail.svg" class="disabled" title="Courriel de contact/support"/></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="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="Fichier propriétés analysé"/></a>
<a id="rawLink" href="#"><img id="rawLinkImg" src="circle-icons/document-mono.svg" title="Fichier propriétés"/></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/barchart-mono.svg" title="Statistiques"/></a>
<div style="display: inline-block; vertical-align: middle; font-size: smaller; margin-left: 2px; width: 35px;">
<a id="alertLink" href="#" style="text-decoration: none;">
<div id="errorCount" class="bg_error center" title="Propriétés en erreurs">n/a</div>
<div id="warningCount" class="bg_warning cener" title="Propriétés attendues">n/a</div>
<div id="voidCount" class="bg_void center" title="Propriétés Inconnues">n/a</div>
</a>
</div>
</div>
</div>
</div>
</body>
</html>