Split htmlize command code to statoolinfosweb project.

This commit is contained in:
Christian P. MOMON 2024-07-26 02:32:50 +02:00
parent 9227238b25
commit be08c8c7e4
242 changed files with 10 additions and 24992 deletions

View file

@ -83,7 +83,7 @@ Usage:
statoolinfos clear <configurationfile> remove property files from conf
statoolinfos crawl <configurationfile> crawl all file from conf and input
statoolinfos format <fileordirectory> format property files in tiny way
statoolinfos htmlize <configurationfile> generate web pages from conf
s̶t̶a̶t̶o̶o̶l̶i̶n̶f̶o̶s̶ ̶h̶t̶m̶l̶i̶z̶e̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶<̶c̶o̶n̶f̶i̶g̶u̶r̶a̶t̶i̶o̶n̶f̶i̶l̶e̶>̶ ̶ ̶ ̶ ̶ ̶g̶e̶n̶e̶r̶a̶t̶e̶ ̶w̶e̶b̶ ̶p̶a̶g̶e̶s̶ ̶f̶r̶o̶m̶ ̶c̶o̶n̶f̶ REMOVED since splitweb
statoolinfos probe OPTION [<directory>|<configurationfile>] generate metrics files from conf
OPTION = [-full|-today|-previousday|-NN] with NN a day count
statoolinfos tagdate <fileordirectory> update the file.datetime file
@ -101,6 +101,14 @@ Usage:
statoolinfos list errlog <logfilesorconfigfile> display http error log lines
```
### htmlize removed
The htmlize command is removed since 2024-07.
As a reminder, the htmlize command generated absolutely all the pages needed for a static site.
As the number of pages generated became too large (> 10000 with 100 organizations), the decision was made to separate the html valuation into a separate project, StatoolInfosWeb.
A dynamic web site allows to generate page only when it is necessary.
## Generate metrics files

View file

@ -110,7 +110,7 @@ public final class StatoolInfosCLI
message.appendln(" statoolinfos clear <configurationfile> remove property files from conf");
message.appendln(" statoolinfos crawl <configurationfile> crawl all file from conf and input");
message.appendln(" statoolinfos format <fileordirectory> format property files in tiny way");
message.appendln(" statoolinfos htmlize <configurationfile> generate web pages from conf");
message.appendln(" s̶t̶a̶t̶o̶o̶l̶i̶n̶f̶o̶s̶ ̶h̶t̶m̶l̶i̶z̶e̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶<̶c̶o̶n̶f̶i̶g̶u̶r̶a̶t̶i̶o̶n̶f̶i̶l̶e̶> REMOVED since splitweb");
message.appendln(" statoolinfos probe OPTION [<directory>|<configurationfile>] generate metrics files from conf");
message.appendln(" OPTION = [-full|-today|-previousday|-NN] with NN a day count");
message.appendln(" statoolinfos tagdate <fileordirectory> update the file.datetime file");
@ -300,21 +300,6 @@ public final class StatoolInfosCLI
}
}
}
else if (CLIUtils.isMatching(args, "htmlize", ".+\\.conf"))
{
Chrono chrono = new Chrono().start();
File configurationFile = new File(StringUtils.trim(args[1]));
try
{
StatoolInfos.htmlize(configurationFile);
}
catch (Exception exception)
{
logger.error("Error with [{}]: {}", configurationFile.getAbsoluteFile(), exception.getMessage());
exception.printStackTrace();
}
System.out.println(chrono.format());
}
else if (CLIUtils.isMatching(args, "list", "ip", "(-all|-bot|-nobot)", ".+\\.conf*"))
{
BotFilter filter = parseLogFilterOption(args[2]);

View file

@ -31,7 +31,6 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.build.Builder;
import fr.devinsy.statoolinfos.crawl.Crawler;
import fr.devinsy.statoolinfos.htmlize.Htmlizer;
import fr.devinsy.statoolinfos.metrics.Prober;
import fr.devinsy.statoolinfos.metrics.httpaccess.HttpAccessLog;
import fr.devinsy.statoolinfos.metrics.httpaccess.HttpAccessLogs;
@ -92,7 +91,6 @@ public class StatoolInfos
Builder.clear(configuration);
new Crawler(configuration.getCrawlCacheDirectory()).clear();
Htmlizer.clear(configuration);
}
/**
@ -150,21 +148,6 @@ public class StatoolInfos
}
}
/**
* Htmlize.
*
* @param configurationFile
* the input
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void htmlize(final File configurationFile) throws StatoolInfosException, IOException
{
Htmlizer.htmlize(configurationFile);
}
/**
* List files.
*

View file

@ -1,95 +0,0 @@
/*
* Copyright (C) 2020 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.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class AboutPage.
*/
public class AboutPage
{
private static Logger logger = LoggerFactory.getLogger(AboutPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build() throws StatoolInfosException, IOException
{
logger.info("Htmlize about page.");
Federation federation = HtmlizerContext.instance().getFederation();
CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
String page = htmlize();
FileUtils.write(new File(htmlizeDirectory, "about.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize() throws StatoolInfosException
{
String result;
try
{
logger.debug("Building about page {}.");
TagDataManager data = new TagDataManager();
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/about.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("À propos", "about.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building about page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,92 +0,0 @@
/*
* Copyright (C) 2020 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;
/**
* The Class Breadcrumb.
*/
public class Breadcrumb
{
private String label;
private String link;
/**
* Instantiates a new breadcrumb.
*/
public Breadcrumb()
{
}
/**
* Instantiates a new breadcrumb.
*
* @param label
* the label
* @param link
* the link
*/
public Breadcrumb(final String label, final String link)
{
this.label = label;
this.link = link;
}
/**
* Gets the label.
*
* @return the label
*/
public String getLabel()
{
return this.label;
}
/**
* Gets the link.
*
* @return the link
*/
public String getLink()
{
return this.link;
}
/**
* Sets the label.
*
* @param label
* the new label
*/
public void setLabel(final String label)
{
this.label = label;
}
/**
* Sets the link.
*
* @param link
* the new link
*/
public void setLink(final String link)
{
this.link = link;
}
}

View file

@ -1,133 +0,0 @@
/*
* Copyright (C) 2020-2023 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.util.ArrayList;
import fr.devinsy.strings.StringList;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class BreadcrumbTrail.
*/
public class BreadcrumbTrail extends ArrayList<Breadcrumb>
{
private static final long serialVersionUID = -2688444486042912675L;
/**
* Instantiates a new breadcrumb trail.
*/
public BreadcrumbTrail()
{
this("🏡", "index.xhtml");
}
/**
* Instantiates a new breadcrumb trail.
*
* @param label
* the label
* @param link
* the link
*/
public BreadcrumbTrail(final String label, final String link)
{
super();
add(label, link);
}
/**
* Adds the.
*
* @param label
* the label
* @return the breadcrumb trail
*/
public BreadcrumbTrail add(final String label)
{
BreadcrumbTrail result;
Breadcrumb crumb = new Breadcrumb(label, null);
add(crumb);
result = this;
//
return result;
}
/**
* Adds the.
*
* @param label
* the label
* @param link
* the link
* @return the breadcrumb trail
*/
public BreadcrumbTrail add(final String label, final String link)
{
BreadcrumbTrail result;
Breadcrumb crumb = new Breadcrumb(label, link);
add(crumb);
result = this;
//
return result;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString()
{
String result;
StringList buffer = new StringList();
for (Breadcrumb crumb : this)
{
if (crumb.getLink() == null)
{
buffer.append(XidynUtils.escapeXmlBlank(crumb.getLabel()));
}
else
{
buffer.append(String.format("<a href=\"%s\" style=\"text-decoration: none; padding: 5px;\">%s</a>", crumb.getLink(), XidynUtils.escapeXmlBlank(crumb.getLabel())));
}
buffer.append(" > ");
}
if (buffer.size() > 2)
{
buffer.removeLast();
}
result = buffer.toString();
//
return result;
}
}

View file

@ -1,120 +0,0 @@
/*
* Copyright (C) 2020-2023 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.Categories;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.categories.CategoryStat;
import fr.devinsy.statoolinfos.stats.categories.CategoryStats;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class CategoriesPage.
*/
public class CategoriesPage
{
private static Logger logger = LoggerFactory.getLogger(CategoriesPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
Categories categories = HtmlizerContext.instance().getCategories();
logger.info("Htmlize categories page.");
CategoryStats stats = StatAgent.statAllCategories(federation, categories);
String page = CategoriesPage.htmlize(stats);
FileUtils.write(new File(htmlizeDirectory, "categories.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
* @param stats
* the stats
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final CategoryStats stats) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building categories page.");
TagDataManager data = new TagDataManager();
data.setContent("categoryCount", stats.size());
int index = 0;
for (CategoryStat stat : stats)
{
data.setEscapedContent("categoryListLine", index, "categoryListLineNameValue", stat.getCategory().getName());
data.setAttribute("categoryListLine", index, "categoryListLineNameLink", "href", "category-" + stat.getCategory().getTechnicalName() + ".xhtml");
data.setAttribute("categoryListLine", index, "categoryListLineNameLink", "title", stat.getCategory().getDescription());
data.setAttribute("categoryListLine", index, "categoryListLineNameLogo", "src", stat.getCategory().getLogoPath());
data.setEscapedContent("categoryListLine", index, "categoryListLineSoftwares", stat.getCategory().getSoftwares().sort().toStringWithFrenchCommas());
data.setContent("categoryListLine", index, "categoryListLineOrganizationCount", stat.getOrganizationCount());
data.setContent("categoryListLine", index, "categoryListLineServiceCount", StatoolInfosUtils.defaultIfZero(stat.getServiceCount(), "😿"));
data.setContent("categoryListLine", index, "categoryListLineUserCount", StatoolInfosUtils.defaultIfZero(stat.getUserCount(), "😢"));
data.setContent("categoryListLine", index, "categoryListLineVisitCount", StatoolInfosUtils.defaultIfZero(stat.getVisitCount(), "😞"));
index += 1;
}
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/categories.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Catégories", "categories.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building categories page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,105 +0,0 @@
/*
* Copyright (C) 2020 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.core.Categories;
import fr.devinsy.statoolinfos.core.Category;
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 CategoriesView.
*/
public class CategoriesView
{
private static Logger logger = LoggerFactory.getLogger(CategoriesView.class);
public enum Mode
{
ALL,
ICONS_ONLY,
LABELS_ONLY
}
/**
* Builds the.
*
* @param categories
* the categories
* @param mode
* the mode
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final Categories categories, final Mode mode) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building categories view.");
TagDataManager data = new TagDataManager();
int index = 0;
for (Category category : categories)
{
data.setAttribute("category", index, "categoryLink", "href", "category-" + category.getTechnicalName() + ".xhtml");
if (mode == Mode.ALL)
{
data.setAttribute("category", index, "categoryLink", "title", category.getDescription());
data.setAttribute("category", index, "categoryLogo", "src", category.getLogoPath());
data.setEscapedContent("category", index, "categoryName", category.getName());
}
else if (mode == Mode.ICONS_ONLY)
{
data.setAttribute("category", index, "categoryLink", "title", category.getName());
data.setAttribute("category", index, "categoryLogo", "src", category.getLogoPath());
data.setAttribute("category", index, "categoryName", "class", "xid:nodisplay");
}
else if (mode == Mode.LABELS_ONLY)
{
data.setAttribute("category", index, "categoryLink", "title", category.getDescription());
data.setAttribute("category", index, "categoryLogo", "class", "xid:nodisplay");
data.setEscapedContent("category", index, "categoryName", category.getName());
}
index += 1;
}
String page = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/categoriesView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(page.replaceAll("id=\"[^\"]*\"", ""));
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building categories view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,112 +0,0 @@
/*
* Copyright (C) 2020-2022 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.Categories;
import fr.devinsy.statoolinfos.core.Category;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ServicesPage.
*/
public class CategoryPage
{
private static Logger logger = LoggerFactory.getLogger(CategoryPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* @throws IOException
*/
public static void buildAll() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
Categories categories = HtmlizerContext.instance().getCategories();
logger.info("Htmlize category pages.");
for (Category category : categories)
{
Services services = federation.getServices().getBy(category);
String page = CategoryPage.htmlize(category, services);
FileUtils.write(new File(htmlizeDirectory, "category-" + category.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
}
}
/**
* Builds the.
*
* @param category
* the category
* @param services
* the services
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Category category, final Services services) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building category page.");
TagDataManager data = new TagDataManager();
data.setAttribute("categoryLogo", "src", category.getLogoPath());
data.setEscapedContent("categoryName", category.getName());
data.setEscapedContent("categoryDescription", category.getDescription());
data.setEscapedContent("categorySoftwares", category.getSoftwares().sort().toStringWithFrenchCommas());
data.setContent("serviceCount", services.size());
data.setContent("serviceListView", ServiceListView.htmlize(services.sortByName()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/category.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Catégories", "categories.xhtml");
trail.add(category.getName(), "category-" + category.getTechnicalName() + ".xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building category page: " + exception.getMessage(), exception);
}
//
return result;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,99 +0,0 @@
/*
* Copyright (C) 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.time.format.DateTimeFormatter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlJournal;
import fr.devinsy.statoolinfos.crawl.CrawlLog;
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 CrawlJournalPage.
*/
public class CrawlJournalView
{
private static Logger logger = LoggerFactory.getLogger(CrawlJournalView.class);
/**
* Htmlize.
*
* @param journal
* the journal
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final CrawlJournal journal) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setEscapedContent("title", "Journal des téléchargements");
data.setContent("date", journal.getDatetime().format(DateTimeFormatter.ofPattern("dd/MM/YYYY HH:mm")));
data.setContent("totalCount", journal.size());
data.setContent("errorCount", journal.getErrors().size());
int index = 0;
for (CrawlLog log : journal)
{
data.setEscapedContent("crawlLogLine", index, "crawlLogLineParentUrlLink", StringUtils.abbreviate(log.getParentUrlValue(), 35));
data.setEscapedAttribute("crawlLogLine", index, "crawlLogLineParentUrlLink", "href", StringUtils.defaultString(log.getParentUrlValue(), "#"));
data.setEscapedAttribute("crawlLogLine", index, "crawlLogLineParentUrlLink", "title", StringUtils.defaultString(log.getParentUrlValue(), "#"));
data.setEscapedContent("crawlLogLine", index, "crawlLogLineUrlLink", log.getUrl().toString());
data.setEscapedAttribute("crawlLogLine", index, "crawlLogLineUrlLink", "href", log.getUrl().toString());
data.setContent("crawlLogLine", index, "crawlLogLineStatus", log.getStatus().toString());
if (log.getStatus().isError())
{
data.setAttribute("crawlLogLine", index, "crawlLogLineStatus", "style", "background-color: red;");
}
else
{
data.setAttribute("crawlLogLine", index, "crawlLogLineStatus", "style", "background-color: lime;");
}
index += 1;
}
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/crawlJournalView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building crawl journal page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,127 +0,0 @@
/*
* Copyright (C) 2020 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.Configuration;
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 EditoPage.
*/
public class EditoPage
{
private static Logger logger = LoggerFactory.getLogger(EditoPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build() throws StatoolInfosException, IOException
{
logger.info("Htmlize edito page.");
Configuration configuration = HtmlizerContext.instance().getConfiguration();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
String edito;
File editoDirectory = configuration.getEditoDirectory();
if ((editoDirectory != null) && (editoDirectory.exists()))
{
File editoFile = new File(editoDirectory, "edito.xhtml");
if (editoFile.exists())
{
logger.info("EDITO: found data.");
// Copy files.
FileUtils.copyDirectory(editoDirectory, htmlizeDirectory);
// Load body edito xhtml file.
edito = FileUtils.readFileToString(editoFile, StandardCharsets.UTF_8);
edito = XidynUtils.extractBodyContent(edito);
}
else
{
logger.info("EDITO: not found data.");
edito = null;
}
}
else
{
logger.info("EDITO: not found configuration.");
edito = null;
}
String page = htmlize(edito);
FileUtils.write(new File(htmlizeDirectory, "edito.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final String edito) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building edito page {}.");
TagDataManager data = new TagDataManager();
if (edito != null)
{
data.setContent("edito", edito);
}
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/edito.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Édito", "edito.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building edito page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,145 +0,0 @@
/*
* Copyright (C) 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.StatoolInfosException;
import fr.devinsy.statoolinfos.io.CSVFile;
import fr.devinsy.statoolinfos.io.JSONFile;
import fr.devinsy.statoolinfos.io.ODSFile;
import fr.devinsy.statoolinfos.uptime.ServiceUptimes;
import fr.devinsy.statoolinfos.uptime.ServiceUptimesFile;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ExportsPage.
*/
public class ExportsPage
{
private static Logger logger = LoggerFactory.getLogger(ExportsPage.class);
/**
* Builds the.
*/
public static void build()
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
//
try
{
logger.info("EXPORTS CSV.");
CSVFile.save(new File(htmlizeDirectory, "organizations.csv"), federation.getOrganizations());
CSVFile.save(new File(htmlizeDirectory, "services.csv"), federation.getServicesAll());
}
catch (IOException exception)
{
logger.error("Error during CSV export: " + exception.getMessage(), exception);
}
//
try
{
logger.info("EXPORTS JSON.");
JSONFile.save(new File(htmlizeDirectory, "federation.json"), federation);
JSONFile.save(new File(htmlizeDirectory, "organizations.json"), federation.getOrganizations());
JSONFile.save(new File(htmlizeDirectory, "services.json"), federation.getServicesAll());
}
catch (IOException exception)
{
logger.error("Error during JSON export: " + exception.getMessage(), exception);
}
//
try
{
logger.info("EXPORTS ODS.");
ODSFile.save(new File(htmlizeDirectory, "organizations.ods"), federation.getOrganizations());
ODSFile.save(new File(htmlizeDirectory, "services.ods"), federation.getServicesAll());
}
catch (Exception exception)
{
logger.error("Error during ODS export: " + exception.getMessage(), exception);
}
//
try
{
logger.info("EXPORTS SERVICE UPTIME JOURNAL.");
ServiceUptimes uptimes = ServiceUptimes.of(federation.getServicesAll(), HtmlizerContext.instance().getUptimeJournal());
ServiceUptimesFile.saveCSV(new File(htmlizeDirectory, "serviceUptimeJournal.csv"), uptimes);
ServiceUptimesFile.saveODS(new File(htmlizeDirectory, "serviceUptimeJournal.ods"), uptimes);
}
catch (Exception exception)
{
logger.error("Error during Uptime export: " + exception.getMessage(), exception);
}
//
try
{
String page = htmlize();
FileUtils.write(new File(htmlizeDirectory, "exports.xhtml"), page, StandardCharsets.UTF_8);
}
catch (StatoolInfosException | IOException exception)
{
logger.error("Error building export page: " + exception.getMessage(), exception);
}
}
/**
* Htmlize.
*
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize() throws StatoolInfosException
{
String result;
try
{
logger.info("PAGE EXPORTS.");
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/exports.xhtml", null).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,74 +0,0 @@
/*
* Copyright (C) 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.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class CrawlJournalFederationPage.
*/
public class FederationCrawlJournalPage
{
private static Logger logger = LoggerFactory.getLogger(FederationCrawlJournalPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build() throws StatoolInfosException, IOException
{
try
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
TagDataManager data = new TagDataManager();
data.setContent("headerView", FederationHeaderView.htmlize(federation));
data.setContent("contentView", CrawlJournalView.htmlize(federation.getCrawlJournal()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
String page = WebCharterView.build(content, trail);
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-crawl.xhtml"), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation crawl journal page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,153 +0,0 @@
/*
* Copyright (C) 2020-2023 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.apache.commons.lang3.StringUtils;
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.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);
/**
* Htmlize.
*
* @param federation
* the federation
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Federation federation) throws StatoolInfosException
{
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());
if (federation.getWebsiteURL() != null)
{
data.setEscapedContent("federationURL", federation.getWebsiteURL().toString());
data.setEscapedAttribute("federationURL", "href", federation.getWebsiteURL().toString());
}
data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDateValue(), "n/a"));
data.setAttribute("organizationsLink", "href", federation.getTechnicalName() + "-organizations.xhtml");
data.setAttribute("servicesLink", "href", federation.getTechnicalName() + "-services.xhtml");
data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties");
data.setAttribute("propertyCheckLink", "href", federation.getTechnicalName() + "-propertycheck.xhtml");
data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml");
data.setAttribute("metricsLink", "href", federation.getTechnicalName() + "-metrics-summary-months-last.xhtml");
data.setAttribute("figuresLink", "href", federation.getTechnicalName() + "-services-figures.xhtml");
data.setAttribute("crawlLink", "href", federation.getTechnicalName() + "-crawl.xhtml");
data.setAttribute("uptimeLink", "href", federation.getLocalFileBaseName() + "-uptimes.xhtml");
if (HtmlizerContext.instance().getUptimeJournal().hasRecentError(federation.getActiveServices()))
{
data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ko-mono.svg");
}
else
{
data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ok-mono.svg");
}
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() + "-propertyalerts.xhtml");
}
if (federation.getLegalURL() != null)
{
data.setEscapedAttribute("legalLink", "href", federation.getLegalURL().toString());
data.setAttribute("legalLinkImg", "class", "");
data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (federation.getContactURL() != null)
{
data.setEscapedAttribute("contactLink", "href", federation.getContactURL().toString());
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 (federation.getUserGuideURL() != null)
{
data.setEscapedAttribute("userDocLink", "href", federation.getUserGuideURL().toString());
data.setAttribute("userDocLinkImg", "class", "");
data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (federation.getTechnicalGuideURL() != null)
{
data.setEscapedAttribute("technicalDocLink", "href", federation.getTechnicalGuideURL().toString());
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,101 +0,0 @@
/*
* 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.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationMetricsPage.
*/
public class FederationMetricGenericPage
{
private static Logger logger = LoggerFactory.getLogger(FederationMetricGenericPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param federation
* the federation
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", FederationHeaderView.htmlize(federation));
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.GENERIC, view, period));
//
FederationMetricHtmlizer.htmlize(data, "graphic.users", federation, view, period, "metrics.service.users", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.users.ipv4-ipv6", federation, view, period, "service.users (ipv4 + ipv6)", "metrics.service.users.ipv4", ChartColor.YELLOW,
"metrics.service.users.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.users.ipv4", federation, view, period, "metrics.service.users.ipv4", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "graphic.users.ipv6", federation, view, period, "metrics.service.users.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.accounts", federation, view, period, "metrics.service.accounts", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.accounts.active", federation, view, period, "metrics.service.accounts.active", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.database.bytes", federation, view, period, "metrics.service.database.bytes", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", federation, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();
//
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Metrics génériques");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-generic-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,192 +0,0 @@
/*
* Copyright (C) 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.time.YearMonth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.threeten.extra.YearWeek;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.statoolinfos.properties.MonthValues;
import fr.devinsy.statoolinfos.properties.WeekValues;
import fr.devinsy.statoolinfos.properties.YearValues;
import fr.devinsy.xidyn.data.TagDataManager;
/**
* The Class MetricHtmlizeDataUtils.
*/
public class FederationMetricHtmlizer
{
private static Logger logger = LoggerFactory.getLogger(FederationMetricHtmlizer.class);
/**
* Htmlize data.
*
* @param data
* the data
* @param metricId
* the metric id
* @param federation
* the federation
* @param view
* the view
* @param period
* the period
* @param metricPath
* the metric path
* @param color
* the color
* @throws StatoolInfosException
* the statool infos exception
*/
public static void htmlize(final TagDataManager data, final String metricId, final Federation federation, final ViewMenu view, final PeriodMenu period, final String metricPath,
final ChartColor color) throws StatoolInfosException
{
if (view == ViewMenu.YEARS)
{
YearValues yearMetric = federation.getMetricYearValuesAll(metricPath);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color));
}
}
else if (view == ViewMenu.MONTHS)
{
MonthValues monthMetric = federation.getMetricMonthValuesAll(metricPath);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(year, 01), YearMonth.of(year, 12), monthMetric, color));
}
}
else if (view == ViewMenu.WEEKS)
{
WeekValues weekMetric = federation.getMetricWeekValuesAll(metricPath);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(year, 01), YearWeek.of(year, 53), weekMetric, color));
}
}
}
/**
* Htmlize.
*
* @param data
* the data
* @param metricId
* the metric id
* @param federation
* the federation
* @param view
* the view
* @param period
* the period
* @param metricLabel
* the metric label
* @param metricPath1
* the metric path 1
* @param color1
* the color 1
* @param metricPath2
* the metric path 2
* @param color2
* the color 2
* @throws StatoolInfosException
* the statool infos exception
*/
public static void htmlize(final TagDataManager data, final String metricId, final Federation federation, final ViewMenu view, final PeriodMenu period, final String metricLabel,
final String metricPath1, final ChartColor color1, final String metricPath2, final ChartColor color2) throws StatoolInfosException
{
if (view == ViewMenu.YEARS)
{
YearValues yearMetric1 = federation.getMetricYearValuesAll(metricPath1);
YearValues yearMetric2 = federation.getMetricYearValuesAll(metricPath2);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2));
}
}
else if (view == ViewMenu.MONTHS)
{
//
MonthValues monthMetric1 = federation.getMetricMonthValuesAll(metricPath1);
MonthValues monthMetric2 = federation.getMetricMonthValuesAll(metricPath2);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId,
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId,
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(year, 01), YearMonth.of(year, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
}
}
else if (view == ViewMenu.WEEKS)
{
WeekValues weekMetric1 = federation.getMetricWeekValuesAll(metricPath1);
WeekValues weekMetric2 = federation.getMetricWeekValuesAll(metricPath2);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(year, 01), YearWeek.of(year, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
}
}
}
}

View file

@ -1,264 +0,0 @@
/*
* Copyright (C) 2021-2023 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.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Federation;
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 OrganizationMetricMenuView.
*/
public class FederationMetricMenuView
{
private static Logger logger = LoggerFactory.getLogger(FederationMetricMenuView.class);
public enum PeriodMenu
{
FULL,
LAST,
Y2021,
Y2022;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
if (this.name().startsWith("Y"))
{
result = this.name().substring(1);
}
else
{
result = this.name().toLowerCase();
}
//
return result;
}
/**
* Gets the years.
*
* @return the years
*/
public static PeriodMenu[] getYears()
{
PeriodMenu[] result;
ArrayList<PeriodMenu> list = new ArrayList<PeriodMenu>();
for (PeriodMenu item : values())
{
if (item.name().startsWith("Y"))
{
list.add(item);
}
}
result = list.toArray(new PeriodMenu[0]);
//
return result;
}
}
public enum TypeMenu
{
SUMMARY,
WEB,
GENERIC,
SPECIFIC;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
result = this.name().toLowerCase();
//
return result;
}
}
public enum ViewMenu
{
YEARS,
MONTHS,
WEEKS,
DAYS;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
result = this.name().toLowerCase();
//
return result;
}
}
/**
* Htmlize.
*
* @param federation
* the service
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Federation federation, final TypeMenu type, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
//
String filename = String.format("%s-metrics-summary-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("summaryTypeButton", "href", filename);
filename = String.format("%s-metrics-generic-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("genericTypeButton", "href", filename);
filename = String.format("%s-metrics-specific-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("specificTypeButton", "href", filename);
filename = String.format("%s-metrics-web-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("webTypeButton", "href", filename);
//
filename = String.format("%s-metrics-%s-years-%s.xhtml", federation.getLocalFileBaseName(), type.getName(), PeriodMenu.FULL.getName());
data.setAttribute("yearsViewButton", "href", filename);
filename = String.format("%s-metrics-%s-months-%s.xhtml", federation.getLocalFileBaseName(), type.getName(), period.getName());
data.setAttribute("monthsViewButton", "href", filename);
filename = String.format("%s-metrics-%s-weeks-%s.xhtml", federation.getLocalFileBaseName(), type.getName(), period.getName());
data.setAttribute("weeksViewButton", "href", filename);
data.setAttribute("daysViewButton", "href", "#");
//
filename = String.format("%s-metrics-%s-%s-full.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("fullPeriodButton", "href", filename);
if (view != ViewMenu.YEARS)
{
filename = String.format("%s-metrics-%s-%s-last.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("lastPeriodButton", "href", filename);
filename = String.format("%s-metrics-%s-%s-2021.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("2021PeriodButton", "href", filename);
filename = String.format("%s-metrics-%s-%s-2022.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("2022PeriodButton", "href", filename);
}
//
if ((type == null) || (type == TypeMenu.SUMMARY))
{
data.appendAttribute("summaryTypeButton", "class", "button selected");
}
else if (type == TypeMenu.GENERIC)
{
data.appendAttribute("genericTypeButton", "class", "button selected");
}
else if (type == TypeMenu.WEB)
{
data.appendAttribute("webTypeButton", "class", "button selected");
}
else if (type == TypeMenu.SPECIFIC)
{
data.appendAttribute("specificTypeButton", "class", "button selected");
}
//
if ((view == null) || (view == ViewMenu.YEARS))
{
data.appendAttribute("yearsViewButton", "class", "button selected");
}
else if (view == ViewMenu.MONTHS)
{
data.appendAttribute("monthsViewButton", "class", "button selected");
}
else if (view == ViewMenu.WEEKS)
{
data.appendAttribute("weeksViewButton", "class", "button selected");
}
else if (view == ViewMenu.DAYS)
{
data.appendAttribute("daysViewButton", "class", "button selected");
}
//
if ((period == null) || (period == PeriodMenu.FULL))
{
data.appendAttribute("fullPeriodButton", "class", "button selected");
}
else if (period == PeriodMenu.LAST)
{
data.appendAttribute("lastPeriodButton", "class", "button selected");
}
else if (period == PeriodMenu.Y2021)
{
data.appendAttribute("2021PeriodButton", "class", "button selected");
}
else if (period == PeriodMenu.Y2022)
{
data.appendAttribute("2022PeriodButton", "class", "button selected");
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building metric menu view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,78 +0,0 @@
/*
* 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.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationMetricsPage.
*/
public class FederationMetricSpecificPage
{
private static Logger logger = LoggerFactory.getLogger(FederationMetricSpecificPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", FederationHeaderView.htmlize(federation));
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.SPECIFIC, view, period));
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
//
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Metrics spécifiques");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-specific-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,90 +0,0 @@
/*
* 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.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationMetricsPage.
*/
public class FederationMetricSummaryPage
{
private static Logger logger = LoggerFactory.getLogger(FederationMetricSummaryPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param federation
* the federation
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", FederationHeaderView.htmlize(federation));
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.SUMMARY, view, period));
FederationMetricHtmlizer.htmlize(data, "http.hits.humans", federation, view, period, "metrics.http.hits.humans", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.visitors", federation, view, period, "metrics.http.visitors", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.visits", federation, view, period, "metrics.http.visits", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Metrics résumé");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-summary-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,141 +0,0 @@
/*
* 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.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationMetricWebPage.
*/
public class FederationMetricWebPage
{
private static Logger logger = LoggerFactory.getLogger(FederationMetricWebPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", FederationHeaderView.htmlize(federation));
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.WEB, view, period));
//
FederationMetricHtmlizer.htmlize(data, "http.hits", federation, view, period, "metrics.http.hits", ChartColor.BLUE);
FederationMetricHtmlizer.htmlize(data, "http.hits-ipv4ipv6", federation, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6",
ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.hits.ipv4", federation, view, period, "metrics.http.hits.ipv4", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.hits.ipv6", federation, view, period, "metrics.http.hits.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.hits-humansbots", federation, view, period, "http.hits (humans + bots)", "metrics.http.hits.humans", ChartColor.GREEN,
"metrics.http.hits.bots",
ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.hits.humans", federation, view, period, "metrics.http.hits.humans", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.hits.bots", federation, view, period, "metrics.http.hits.bots", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.hits.humans-ipv4ipv6", federation, view, period, "http.hits.humans (ipv4 + ipv6)", "metrics.http.hits.humans.ipv4", ChartColor.YELLOW,
"metrics.http.hits.humans.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv4", federation, view, period, "metrics.http.hits.humans.ipv4", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv6", federation, view, period, "metrics.http.hits.humans.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.errors", federation, view, period, "metrics.http.errors", ChartColor.RED);
FederationMetricHtmlizer.htmlize(data, "http.errors.php", federation, view, period, "metrics.http.errors.php", ChartColor.RED);
FederationMetricHtmlizer.htmlize(data, "http.files", federation, view, period, "metrics.http.files", ChartColor.BLUE);
FederationMetricHtmlizer.htmlize(data, "http.pages", federation, view, period, "metrics.http.pages", ChartColor.BLUE);
FederationMetricHtmlizer.htmlize(data, "http.bytes", federation, view, period, "metrics.http.bytes", ChartColor.BLUE);
FederationMetricHtmlizer.htmlize(data, "http.ip", federation, view, period, "metrics.http.ip", ChartColor.BLUE);
FederationMetricHtmlizer.htmlize(data, "http.ip-humansbots", federation, view, period, "http.ip (humans + bots)", "metrics.http.ip.humans", ChartColor.GREEN, "metrics.http.ip.bots",
ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.ip.humans", federation, view, period, "metrics.http.ip.humans", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.ip.bots", federation, view, period, "metrics.http.ip.bots", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.ip-ipv4ipv6", federation, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6",
ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.ip.ipv4", federation, view, period, "metrics.http.ip.ipv4", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.ip.ipv6", federation, view, period, "metrics.http.ip.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.requesters", federation, view, period, "metrics.http.requesters", ChartColor.BLUE);
FederationMetricHtmlizer.htmlize(data, "http.requesters-humansbots", federation, view, period, "http.requesters (humans + bots)", "metrics.http.requesters.humans", ChartColor.GREEN,
"metrics.http.requesters.bots", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.requesters.humans", federation, view, period, "metrics.http.requesters.humans", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.requesters.bots", federation, view, period, "metrics.http.requesters.bots", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.requesters-ipv4ipv6", federation, view, period, "http.requesters (ipv4 + ipv6)", "metrics.http.requesters.ipv4", ChartColor.YELLOW,
"metrics.http.requesters.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.requesters.ipv4", federation, view, period, "metrics.http.requesters.ipv4", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.requesters.ipv6", federation, view, period, "metrics.http.requesters.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.visitors", federation, view, period, "metrics.http.visitors", ChartColor.BLUE);
FederationMetricHtmlizer.htmlize(data, "http.visitors-ipv4ipv6", federation, view, period, "http.visitors (ipv4 + ipv6)", "metrics.http.visitors.ipv4", ChartColor.YELLOW,
"metrics.http.visitors.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.visitors.ipv4", federation, view, period, "metrics.http.visitors.ipv4", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.visitors.ipv6", federation, view, period, "metrics.http.visitors.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.visits", federation, view, period, "metrics.http.visits", ChartColor.BLUE);
FederationMetricHtmlizer.htmlize(data, "http.visits-ipv4ipv6", federation, view, period, "http.visits (ipv4 + ipv6)", "metrics.http.visits.ipv4", ChartColor.YELLOW,
"metrics.http.visits.ipv6", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "http.visits.ipv4", federation, view, period, "metrics.http.visits.ipv4", ChartColor.YELLOW);
FederationMetricHtmlizer.htmlize(data, "http.visits.ipv6", federation, view, period, "metrics.http.visits.ipv6", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString();
//
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Metrics web");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-web-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,97 +0,0 @@
/*
* Copyright (C) 2020-2022 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.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationOrganizationsPage.
*/
public class FederationOrganizationsPage
{
private static Logger logger = LoggerFactory.getLogger(FederationOrganizationsPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
*/
public static void build() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
//
logger.info("PAGE FEDERATION organizations page: {}.", federation.getName());
String page = htmlize(federation);
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-organizations.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* 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.setContent("federationHeaderView", FederationHeaderView.htmlize(federation));
data.setContent("organizationListView", OrganizationListView.htmlize(federation.getMemberOrganizations(), federation.getAwayOrganizations()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationOrganizations.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation organizations page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,128 +0,0 @@
/*
* 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.catgenerator.core.CatGenerator;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu;
/**
* The Class FederationPage.
*/
public class FederationPages
{
private static Logger logger = LoggerFactory.getLogger(FederationPages.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
*/
public static void build() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
//
logger.info("PAGE FEDERATION Htmlize federation logo.");
htmlizeFederationLogo(federation, cache, htmlizeDirectory);
//
logger.info("PAGE FEDERATION Htmlize federation properties files.");
FileUtils.copyFile(federation.getInputFile(), new File(htmlizeDirectory, federation.getTechnicalName() + ".properties"));
logger.info("PAGE FEDERATION federation page: {}.", federation.getName());
String page = FederationOrganizationsPage.htmlize(federation);
FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8);
//
FederationOrganizationsPage.build();
FederationServicesPage.build();
FederationServicesFiguresPage.build();
FederationCrawlJournalPage.build();
FederationPropertyCheckPage.build();
FederationPropertyAlertPage.buildAll();
FederationStatsPage.build();
FederationUptimePage.build();
//
logger.info("Htmlize federation metric pages: {}.", federation.getName());
for (ViewMenu view : ViewMenu.values())
{
for (PeriodMenu period : PeriodMenu.values())
{
if ((view != ViewMenu.YEARS) || (period == PeriodMenu.FULL))
{
if (view != ViewMenu.DAYS)
{
FederationMetricSummaryPage.build(htmlizeDirectory, federation, view, period);
FederationMetricGenericPage.build(htmlizeDirectory, federation, view, period);
FederationMetricSpecificPage.build(htmlizeDirectory, federation, view, period);
FederationMetricWebPage.build(htmlizeDirectory, federation, view, period);
}
}
}
}
}
/**
* Htmlize federation logo.
*
* @param federation
* the federation
* @param cache
* the cache
* @param htmlizeDirectory
* the htmlize directory
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void htmlizeFederationLogo(final Federation federation, final CrawlCache cache, final File htmlizeDirectory) throws IOException
{
logger.info("Htmlize federation logo.");
File target = new File(htmlizeDirectory, federation.getLogoFileName());
File logoFile = cache.restoreFile(federation.getLogoURL());
if (logoFile == null)
{
logger.info("CatGeneratoring cat avatar: {}", target.getAbsoluteFile());
CatGenerator.buildAvatarTo(federation.getTechnicalName(), target);
}
else
{
FileUtils.copyFile(logoFile, target);
}
}
}

View file

@ -1,154 +0,0 @@
/*
* 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 scope
* the scope
* @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

@ -1,95 +0,0 @@
/*
* 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.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class PropertyFileCheckPage.
*/
public class FederationPropertyCheckPage
{
private static Logger logger = LoggerFactory.getLogger(FederationPropertyCheckPage.class);
/**
* Builds the.
*
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static void build() throws IOException, StatoolInfosException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
String page = htmlize(federation);
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Htmlize.
*
* @param federation
* the federation
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Federation federation) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", FederationHeaderView.htmlize(federation));
data.setContent("contentView", PropertyCheckView.htmlize(federation.getInputChecks()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Propriétés", federation.getLocalFileBaseName() + "-propertycheck.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation property file check page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,96 +0,0 @@
/*
* Copyright (C) 2022 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.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationServicesFiguresPage.
*/
public class FederationServicesFiguresPage
{
private static Logger logger = LoggerFactory.getLogger(FederationServicesFiguresPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
*/
public static void build() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
//
logger.info("PAGE FEDERATION services figures page: {}.", federation.getName());
String page = htmlize(federation);
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-services-figures.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* 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.setContent("federationHeaderView", FederationHeaderView.htmlize(federation));
data.setContent("serviceListView", ServiceFigureView.htmlize(federation.getServices()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation services figures page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,96 +0,0 @@
/*
* 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.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationServicesPage.
*/
public class FederationServicesPage
{
private static Logger logger = LoggerFactory.getLogger(FederationServicesPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
*/
public static void build() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
//
logger.info("PAGE FEDERATION services page: {}.", federation.getName());
String page = htmlize(federation);
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-services.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* 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.setContent("federationHeaderView", FederationHeaderView.htmlize(federation));
data.setContent("serviceListView", ServiceListView.htmlize(federation.getServices()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation services page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,122 +0,0 @@
/*
* Copyright (C) 2020-2022 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.Organizations;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationStatsPage.
*/
public class FederationStatsPage
{
private static Logger logger = LoggerFactory.getLogger(FederationStatsPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build() throws StatoolInfosException, IOException
{
try
{
logger.debug("Building federation stats page {}…");
Federation federation = HtmlizerContext.instance().getFederation();
// CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
Organizations organizations = federation.getActiveOrganizations();
Services services = federation.getActiveServices();
TagDataManager data = new TagDataManager();
data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation));
data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organizations));
data.setContent("organizationCountryChart", ChartHtmlizer.htmlizeOrganizationCountryChart(organizations));
data.setContent("organizationCountChart", ChartHtmlizer.htmlizeOrganizationCountChart(federation));
data.setContent("organizationInOutChart", ChartHtmlizer.htmlizeOrganizationInOutChart(federation));
data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(federation));
data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services));
data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services));
data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services));
data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services));
data.setContent("hostProviderHypervisorChart", ChartHtmlizer.htmlizeHostProviderHypervisorChart(services));
data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services));
data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services));
{
RegistrationStats stats = StatAgent.statRegistrationTypes(services);
data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats));
data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats));
data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats));
data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats));
data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats));
}
data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services));
data.setContent("organisationTypeChart", ChartHtmlizer.htmlizeOrganizationTypeChart(organizations));
data.setContent("softwareDistributionPieChart", ChartHtmlizer.htmlizeSoftwareDistributionPieChart(services));
data.setContent("categoryDistributionPieChart", ChartHtmlizer.htmlizeCatergoryDistributionPieChart(services));
data.setContent("softwareDistributionChart", ChartHtmlizer.htmlizeSoftwareDistributionChart());
data.setContent("categoryDistributionChart", ChartHtmlizer.htmlizeCategoryDistributionChart());
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml", data).toString();
//
BreadcrumbTrail trail = new BreadcrumbTrail();
String page = WebCharterView.build(content, trail);
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-stats.xhtml"), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation stats page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,100 +0,0 @@
/*
* Copyright (C) 2021-2022 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.StatoolInfosException;
import fr.devinsy.statoolinfos.uptime.UptimeJournal;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class FederationUptimePage.
*/
public class FederationUptimePage
{
private static Logger logger = LoggerFactory.getLogger(FederationUptimePage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
UptimeJournal journal = HtmlizerContext.instance().getUptimeJournal();
String page = htmlize(federation, journal);
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-uptimes.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Htmlize.
*
* @param federation
* the federation
* @param journal
* the journal
* @return the string
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static String htmlize(final Federation federation, final UptimeJournal journal) throws StatoolInfosException, IOException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", FederationHeaderView.htmlize(federation));
data.setContent("uptimeView", UptimeView.htmlize(federation.getActiveServices(), journal));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimePage.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Disponibilité des services", federation.getLocalFileBaseName() + "-uptimes.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building FederationUptime page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,184 +0,0 @@
/*
* 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 org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Category;
import fr.devinsy.statoolinfos.core.Configuration;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.util.URLUtils;
/**
* The Class Htmlizer.
*/
public class Htmlizer
{
private static Logger logger = LoggerFactory.getLogger(Htmlizer.class);
/**
* Instantiates a new htmlizer.
*/
private Htmlizer()
{
}
/**
* Clear.
*
* @param configuration
* the configuration
*/
public static void clear(final Configuration configuration)
{
logger.info("Htmlize directory setting: {}", configuration.getHtmlizeDirectoryPath());
String htmlDirectoryPath = configuration.getHtmlizeDirectoryPath();
if (StringUtils.isBlank(htmlDirectoryPath))
{
logger.warn("Undefined htmlize directory.");
}
else if (!new File(htmlDirectoryPath).exists())
{
logger.warn("Htmlize directory does not exist: {}.", htmlDirectoryPath);
}
else
{
File htmlizeDirectory = configuration.getHtmlizeDirectory();
for (File file : htmlizeDirectory.listFiles())
{
if ((file.isFile()) && (StringUtils.endsWithAny(file.getName(), ".properties", ".js", ".html", ".ico", ".css", ".jpg", ".png", ".xhtml")))
{
logger.info("Deleting " + file.getName());
file.delete();
}
}
}
}
/**
* Copy categories stuff.
*
* @param path
* the path
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void copyCategoriesStuff(final String path, final File targetDirectory) throws IOException
{
if (StringUtils.isNotBlank(path))
{
File source = new File(path);
File target = new File(targetDirectory, "categories");
for (File file : source.listFiles())
{
if (file.isFile())
{
FileUtils.copyFileToDirectory(file, target);
}
}
}
// Check.
for (Category category : HtmlizerContext.instance().getCategories())
{
File categoryFile = new File(targetDirectory, category.getLogoPath());
if (!categoryFile.exists())
{
category.setLogoPath(null);
}
}
}
/**
* Copy stuff.
*
* @param target
* the target
* @throws IOException
*/
private static void copyStuff(final File targetDirectory) throws IOException
{
// Copy commons files (index, images, favicon, css).
if (!new File(targetDirectory, "index.html").exists())
{
String source = "/fr/devinsy/statoolinfos/htmlize/stuff/";
URLUtils.copyDeeply(StatoolInfosUtils.class.getResource(source), targetDirectory);
URLUtils.copyResource(source + "statoolinfos-logo.jpg", new File(targetDirectory, "logo.jpg"));
URLUtils.copyResource(source + "statoolinfos-logo.ico", new File(targetDirectory, "favicon.ico"));
}
}
/**
* Htmlize.
*
* @param configurationFile
* the configuration file
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void htmlize(final File configurationFile) throws StatoolInfosException, IOException
{
logger.info("Htmlize {}", configurationFile.getAbsolutePath());
HtmlizerContext.instance().configure(configurationFile);
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
copyStuff(htmlizeDirectory);
copyCategoriesStuff(HtmlizerContext.instance().getConfiguration().get("conf.htmlize.categories.icons"), htmlizeDirectory);
AboutPage.build();
CategoriesPage.build();
CategoryPage.buildAll();
EditoPage.build();
ExportsPage.build();
FederationPages.build();
OrganizationPage.buildAll();
OrganizationCrawlJournalPage.buildAll();
OrganizationUptimePage.buildAll();
OrganizationPropertyCheckPage.buildAll();
OrganizationPropertyAlertPage.buildAll();
PropertiesFilesPage.build();
PropertyStatsPage.buildAll();
ServicePage.buildAll();
ServiceCrawlJournalPage.buildAll();
ServicePropertyCheckPage.buildAll();
ServicePropertyAlertPage.buildAll();
ServiceUptimePage.buildAll();
ServicesPage.build();
SoftwaresPage.build();
SoftwarePage.buildAll();
SocialNetworksPage.buildAll();
// PropertyCheckView.buildAll();
}
}

View file

@ -1,94 +0,0 @@
/*
* Copyright (C) 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 CrawlJournalOrganizationPage.
*/
public class OrganizationCrawlJournalPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationCrawlJournalPage.class);
/**
* Builds the.
*
* @param organization
* the organization
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final Organization organization) throws StatoolInfosException, IOException
{
try
{
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
TagDataManager data = new TagDataManager();
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
data.setContent("contentView", CrawlJournalView.htmlize(organization.getCrawlJournal()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
String page = WebCharterView.build(content, trail);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-crawl.xhtml"), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organization crawl journal page: " + exception.getMessage(), exception);
}
}
/**
* Builds the all.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void buildAll() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
for (Organization organization : federation.getOrganizations())
{
build(organization);
}
}
}

View file

@ -1,181 +0,0 @@
/*
* Copyright (C) 2021-2022 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.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.checker.PropertyChecks;
import fr.devinsy.statoolinfos.core.Organization;
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 OrganizationHeaderView.
*/
public class OrganizationHeaderView
{
private static Logger logger = LoggerFactory.getLogger(OrganizationHeaderView.class);
/**
* 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
{
logger.debug("htmlizing service header page {}…", organization.get("service.name"));
TagDataManager data = new TagDataManager();
data.setAttribute("organizationRawButton", "href", organization.getTechnicalName() + ".properties");
data.setAttribute("organizationLogo", "src", organization.getLogoFileName());
data.setEscapedContent("organizationName", organization.get("organization.name"));
if (organization.getWebsiteURL() != null)
{
data.setEscapedContent("organizationURL", organization.getWebsiteURL().toString());
data.setEscapedAttribute("organizationURL", "href", organization.getWebsiteURL().toString());
}
data.setEscapedContent("organizationDescription", organization.get("organization.description"));
data.setEscapedContent("organizationMemberOfName", StringUtils.defaultIfBlank(organization.getFederation().getName(), "n/a"));
data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDateValue(), "n/a"));
data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDateValue(), "n/a"));
data.setContent("organizationAge", StringUtils.defaultIfBlank(organization.getAge(), "n/a"));
if (StringUtils.isBlank(organization.getEndDateValue()))
{
data.setContent("organizationMemberOfWord", "depuis");
data.setAttribute("organizationEndDateData", "style", "display: none;");
}
else
{
data.setContent("organizationMemberOfWord", ":");
}
data.setContent("organizationMemberStartDate", StringUtils.defaultIfBlank(organization.getMemberStartDateValue(), "n/a"));
data.setContent("organizationMemberEndDate", StringUtils.defaultIfBlank(organization.getMemberEndDateValue(), "n/a"));
data.setContent("organizationMemberAge", StringUtils.defaultIfBlank(organization.getMemberAge(), "n/a"));
if (StringUtils.isBlank(organization.getMemberEndDateValue()))
{
data.setAttribute("organizationMemberEndDateData", "style", "display: none;");
}
else
{
data.setContent("organizationStartDateWord", "");
}
data.setAttribute("organizationsLink", "href", organization.getFederation().getTechnicalName() + "-organizations.xhtml");
data.setAttribute("servicesLink", "href", organization.getTechnicalName() + "-services.xhtml");
data.setAttribute("rawLink", "href", organization.getTechnicalName() + ".properties");
data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-propertycheck.xhtml");
data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml");
data.setAttribute("metricsLink", "href", organization.getTechnicalName() + "-metrics-summary-months-last.xhtml");
data.setAttribute("crawlLink", "href", organization.getTechnicalName() + "-crawl.xhtml");
if (organization.getCrawlJournal().getErrors().isEmpty())
{
data.setAttribute("crawlLinkImg", "src", "circle-icons/download-mono.svg");
}
else
{
data.setAttribute("crawlLinkImg", "src", "circle-icons/download.svg");
}
data.setAttribute("uptimeLink", "href", organization.getLocalFileBaseName() + "-uptimes.xhtml");
if (HtmlizerContext.instance().getUptimeJournal().hasRecentError(organization.getActiveServices()))
{
data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ko-mono.svg");
}
else
{
data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ok-mono.svg");
}
{
PropertyChecks checks = organization.getInputChecksAll();
data.setContent("errorCount", checks.getErrorCount());
data.setContent("warningCount", checks.getWarningCount());
data.setContent("voidCount", checks.getVoidCount());
data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-propertyalerts.xhtml");
}
if (organization.getLegalURL() != null)
{
data.setEscapedAttribute("legalLink", "href", organization.getLegalURL().toString());
data.setAttribute("legalLinkImg", "class", "");
data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (organization.getContactURL() != null)
{
data.setEscapedAttribute("contactLink", "href", organization.getContactURL().toString());
data.setAttribute("contactLinkImg", "class", "");
data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(organization.getContactEmail()))
{
data.setEscapedAttribute("emailLink", "href", "mailto:" + organization.getContactEmail());
data.setAttribute("emailLinkImg", "class", "");
data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (organization.getUserGuideURL() != null)
{
data.setEscapedAttribute("userDocLink", "href", organization.getUserGuideURL().toString());
data.setAttribute("userDocLinkImg", "class", "");
data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (organization.getTechnicalGuideURL() != null)
{
data.setEscapedAttribute("technicalDocLink", "href", organization.getTechnicalGuideURL().toString());
data.setAttribute("technicalDocLinkImg", "class", "");
data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service header view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,137 +0,0 @@
/*
* Copyright (C) 2020-2022 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 java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Organizations;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.strings.StringList;
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 OrganizationsView.
*/
public class OrganizationListView
{
private static Logger logger = LoggerFactory.getLogger(OrganizationListView.class);
/**
* Htmlize.
*
* @param organizations
* the organizations
* @return the string
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static String htmlize(final Organizations organizations, final Organizations aways) throws StatoolInfosException, IOException
{
String result;
try
{
TagDataManager data = new TagDataManager();
Organizations actives = organizations.filterActive();
data.setContent("organizationCount", actives.size());
data.setContent("serviceCount", actives.getActiveServiceCount());
String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", "&#160;");
data.setContent("monthLabel", monthLabel);
data.setAttribute("userCountHeaderColumn", "title", monthLabel);
data.setAttribute("visitCountHeaderColumn", "title", monthLabel);
int index = 0;
for (Organization organization : actives.sortByReverseServiceCount())
{
data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml");
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getLogoFileName());
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName());
if (organization.getWebsiteURL() != null)
{
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString());
data.setEscapedAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString());
}
data.setContent("organizationListLine", index, "organizationListLineServiceCount", StatoolInfosUtils.defaultIfZero(organization.getActiveServiceCount(), "😿"));
data.setContent("organizationListLine", index, "organizationListLineUserCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthUserCount(), "😢"));
data.setContent("organizationListLine", index, "organizationListLineVisitCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthVisitCount(), "😞"));
data.setContent("organizationListLine", index, "organizationListLineDate", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY")));
data.setAttribute("organizationListLine", index, "organizationListLineDate", "title", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
index += 1;
}
Organizations idles = organizations.getIdles();
if (idles.isEmpty())
{
data.setContent("idleMembers", "aucun.");
}
else
{
StringList buffer = new StringList();
for (Organization idle : idles)
{
buffer.add(String.format("<a href=\"%s\" style=\"text-decoration: none;\">%s</a>", idle.getTechnicalName() + ".xhtml", idle.getName()));
}
data.setContent("idleMembers", buffer.toString("", ", ", "."));
}
if (aways.isEmpty())
{
data.setContent("awayMembers", "aucun.");
}
else
{
StringList buffer = new StringList();
for (Organization away : aways)
{
buffer.add(String.format("<a href=\"%s\" style=\"text-decoration: none;\">%s</a>", away.getTechnicalName() + ".xhtml", away.getName()));
}
data.setContent("awayMembers", buffer.toString("", ", ", "."));
}
String page = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(page);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organizations view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,101 +0,0 @@
/*
* Copyright (C) 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.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationGenericMetricPage.
*/
public class OrganizationMetricGenericPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationMetricGenericPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param organization
* the organization
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.GENERIC, view, period));
//
OrganizationMetricHtmlizer.htmlize(data, "graphic.users", organization, view, period, "metrics.service.users", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.users.ipv4-ipv6", organization, view, period, "service.users (ipv4 + ipv6)", "metrics.service.users.ipv4", ChartColor.YELLOW,
"metrics.service.users.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.users.ipv4", organization, view, period, "metrics.service.users.ipv4", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "graphic.users.ipv6", organization, view, period, "metrics.service.users.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts", organization, view, period, "metrics.service.accounts", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts.active", organization, view, period, "metrics.service.accounts.active", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.database.bytes", organization, view, period, "metrics.service.database.bytes", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", organization, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml");
trail.add("Metrics génériques");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-generic-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organization generic metric page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,190 +0,0 @@
/*
* Copyright (C) 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.time.YearMonth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.threeten.extra.YearWeek;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.statoolinfos.properties.MonthValues;
import fr.devinsy.statoolinfos.properties.WeekValues;
import fr.devinsy.statoolinfos.properties.YearValues;
import fr.devinsy.xidyn.data.TagDataManager;
/**
* The Class OrganizationMetricHtmlizer.
*/
public class OrganizationMetricHtmlizer
{
private static Logger logger = LoggerFactory.getLogger(OrganizationMetricHtmlizer.class);
/**
* Htmlize data.
*
* @param data
* the data
* @param metricId
* the metric id
* @param organization
* the organization
* @param metricPath
* the metric path
* @param color
* the color
* @throws StatoolInfosException
* the statool infos exception
*/
public static void htmlize(final TagDataManager data, final String metricId, final Organization organization, final ViewMenu view, final PeriodMenu period, final String metricPath,
final ChartColor color) throws StatoolInfosException
{
if (view == ViewMenu.YEARS)
{
YearValues yearMetric = organization.getMetricYearValuesAll(metricPath);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color));
}
}
else if (view == ViewMenu.MONTHS)
{
MonthValues monthMetric = organization.getMetricMonthValuesAll(metricPath);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(year, 01), YearMonth.of(year, 12), monthMetric, color));
}
}
else if (view == ViewMenu.WEEKS)
{
WeekValues weekMetric = organization.getMetricWeekValuesAll(metricPath);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(year, 01), YearWeek.of(year, 53), weekMetric, color));
}
}
}
/**
* Htmlize data.
*
* @param data
* the data
* @param metricId
* the metric id
* @param organization
* the organization
* @param view
* the view
* @param period
* the period
* @param metricLabel
* the metric label
* @param metricPath1
* the metric path 1
* @param color1
* the color 1
* @param metricPath2
* the metric path 2
* @param color2
* the color 2
* @throws StatoolInfosException
* the statool infos exception
*/
public static void htmlize(final TagDataManager data, final String metricId, final Organization organization, final ViewMenu view, final PeriodMenu period, final String metricLabel,
final String metricPath1, final ChartColor color1, final String metricPath2, final ChartColor color2) throws StatoolInfosException
{
if (view == ViewMenu.YEARS)
{
YearValues yearMetric1 = organization.getMetricYearValuesAll(metricPath1);
YearValues yearMetric2 = organization.getMetricYearValuesAll(metricPath2);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId,
ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2));
}
}
else if (view == ViewMenu.MONTHS)
{
MonthValues monthMetric1 = organization.getMetricMonthValuesAll(metricPath1);
MonthValues monthMetric2 = organization.getMetricMonthValuesAll(metricPath2);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId,
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId,
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(year, 01), YearMonth.of(year, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
}
}
else if (view == ViewMenu.WEEKS)
{
WeekValues weekMetric1 = organization.getMetricWeekValuesAll(metricPath1);
WeekValues weekMetric2 = organization.getMetricWeekValuesAll(metricPath2);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(year, 01), YearWeek.of(year, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
}
}
}
}

View file

@ -1,264 +0,0 @@
/*
* Copyright (C) 2021-2023 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.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class OrganizationMetricMenuView.
*/
public class OrganizationMetricMenuView
{
private static Logger logger = LoggerFactory.getLogger(OrganizationMetricMenuView.class);
public enum PeriodMenu
{
FULL,
LAST,
Y2021,
Y2022;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
if (this.name().startsWith("Y"))
{
result = this.name().substring(1);
}
else
{
result = this.name().toLowerCase();
}
//
return result;
}
/**
* Gets the years.
*
* @return the years
*/
public static PeriodMenu[] getYears()
{
PeriodMenu[] result;
ArrayList<PeriodMenu> list = new ArrayList<PeriodMenu>();
for (PeriodMenu item : values())
{
if (item.name().startsWith("Y"))
{
list.add(item);
}
}
result = list.toArray(new PeriodMenu[0]);
//
return result;
}
}
public enum TypeMenu
{
SUMMARY,
WEB,
GENERIC,
SPECIFIC;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
result = this.name().toLowerCase();
//
return result;
}
}
public enum ViewMenu
{
YEARS,
MONTHS,
WEEKS,
DAYS;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
result = this.name().toLowerCase();
//
return result;
}
}
/**
* Htmlize.
*
* @param organization
* the service
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Organization organization, final TypeMenu type, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
//
String filename = String.format("%s-metrics-summary-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("summaryTypeButton", "href", filename);
filename = String.format("%s-metrics-generic-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("genericTypeButton", "href", filename);
filename = String.format("%s-metrics-specific-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("specificTypeButton", "href", filename);
filename = String.format("%s-metrics-web-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("webTypeButton", "href", filename);
//
filename = String.format("%s-metrics-%s-years-%s.xhtml", organization.getLocalFileBaseName(), type.getName(), PeriodMenu.FULL.getName());
data.setAttribute("yearsViewButton", "href", filename);
filename = String.format("%s-metrics-%s-months-%s.xhtml", organization.getLocalFileBaseName(), type.getName(), period.getName());
data.setAttribute("monthsViewButton", "href", filename);
filename = String.format("%s-metrics-%s-weeks-%s.xhtml", organization.getLocalFileBaseName(), type.getName(), period.getName());
data.setAttribute("weeksViewButton", "href", filename);
data.setAttribute("daysViewButton", "href", "#");
//
if (view != ViewMenu.YEARS)
{
filename = String.format("%s-metrics-%s-%s-full.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("fullPeriodButton", "href", filename);
filename = String.format("%s-metrics-%s-%s-last.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("lastPeriodButton", "href", filename);
filename = String.format("%s-metrics-%s-%s-2021.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("2021PeriodButton", "href", filename);
filename = String.format("%s-metrics-%s-%s-2022.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("2022PeriodButton", "href", filename);
}
//
if ((type == null) || (type == TypeMenu.SUMMARY))
{
data.appendAttribute("summaryTypeButton", "class", "button selected");
}
else if (type == TypeMenu.GENERIC)
{
data.appendAttribute("genericTypeButton", "class", "button selected");
}
else if (type == TypeMenu.WEB)
{
data.appendAttribute("webTypeButton", "class", "button selected");
}
else if (type == TypeMenu.SPECIFIC)
{
data.appendAttribute("specificTypeButton", "class", "button selected");
}
//
if ((view == null) || (view == ViewMenu.YEARS))
{
data.appendAttribute("yearsViewButton", "class", "button selected");
}
else if (view == ViewMenu.MONTHS)
{
data.appendAttribute("monthsViewButton", "class", "button selected");
}
else if (view == ViewMenu.WEEKS)
{
data.appendAttribute("weeksViewButton", "class", "button selected");
}
else if (view == ViewMenu.DAYS)
{
data.appendAttribute("daysViewButton", "class", "button selected");
}
//
if ((period == null) || (period == PeriodMenu.FULL))
{
data.appendAttribute("fullPeriodButton", "class", "button selected");
}
else if (period == PeriodMenu.LAST)
{
data.appendAttribute("lastPeriodButton", "class", "button selected");
}
else if (period == PeriodMenu.Y2021)
{
data.appendAttribute("2021PeriodButton", "class", "button selected");
}
else if (period == PeriodMenu.Y2022)
{
data.appendAttribute("2022PeriodButton", "class", "button selected");
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building metric menu view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,89 +0,0 @@
/*
* Copyright (C) 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.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationSpecificMetricPage.
*/
public class OrganizationMetricSpecificPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationMetricSpecificPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param organization
* the organization
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
logger.debug("Building oranization specific metric page {}…", organization.get("service.name"));
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.SPECIFIC, view, period));
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml");
trail.add("Metrics spécifiques");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-specific-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organization specific metric page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,93 +0,0 @@
/*
* 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.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationGeneralStatsPage.
*/
public class OrganizationMetricSummaryPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationMetricSummaryPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param organization
* the organization
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.SUMMARY, view, period));
OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans", organization, view, period, "metrics.http.hits.humans", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.visitors", organization, view, period, "metrics.http.visitors", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.visits", organization, view, period, "metrics.http.visits", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
//
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml");
trail.add("Metrics résumé");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-summary-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organization summary page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,151 +0,0 @@
/*
* Copyright (C) 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.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationWebMetricPage.
*/
public class OrganizationMetricWebPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationMetricWebPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param organization
* the organization
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.WEB, view, period));
//
OrganizationMetricHtmlizer.htmlize(data, "http.hits", organization, view, period, "metrics.http.hits", ChartColor.BLUE);
OrganizationMetricHtmlizer.htmlize(data, "http.hits-ipv4ipv6", organization, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW,
"metrics.http.hits.ipv6",
ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.hits.ipv4", organization, view, period, "metrics.http.hits.ipv4", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.hits.ipv6", organization, view, period, "metrics.http.hits.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.hits-humansbots", organization, view, period, "http.hits (humans + bots)", "metrics.http.hits.humans", ChartColor.GREEN,
"metrics.http.hits.bots", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans", organization, view, period, "metrics.http.hits.humans", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.hits.bots", organization, view, period, "metrics.http.hits.bots", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans-ipv4ipv6", organization, view, period, "http.hits.humans (ipv4 + ipv6)", "metrics.http.hits.humans.ipv4", ChartColor.YELLOW,
"metrics.http.hits.humans.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv4", organization, view, period, "metrics.http.hits.humans.ipv4", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv6", organization, view, period, "metrics.http.hits.humans.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.errors", organization, view, period, "metrics.http.errors", ChartColor.RED);
OrganizationMetricHtmlizer.htmlize(data, "http.errors.php", organization, view, period, "metrics.http.errors.php", ChartColor.RED);
OrganizationMetricHtmlizer.htmlize(data, "http.files", organization, view, period, "metrics.http.files", ChartColor.BLUE);
OrganizationMetricHtmlizer.htmlize(data, "http.pages", organization, view, period, "metrics.http.pages", ChartColor.BLUE);
OrganizationMetricHtmlizer.htmlize(data, "http.bytes", organization, view, period, "metrics.http.bytes", ChartColor.BLUE);
OrganizationMetricHtmlizer.htmlize(data, "http.ip", organization, view, period, "metrics.http.ip", ChartColor.BLUE);
OrganizationMetricHtmlizer.htmlize(data, "http.ip-humansbots", organization, view, period, "http.ip (humans + bots)", "metrics.http.ip.humans", ChartColor.GREEN,
"metrics.http.ip.bots", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.ip.humans", organization, view, period, "metrics.http.ip.humans", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.ip.bots", organization, view, period, "metrics.http.ip.bots", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.ip-ipv4ipv6", organization, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6",
ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.ip.ipv4", organization, view, period, "metrics.http.ip.ipv4", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.ip.ipv6", organization, view, period, "metrics.http.ip.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.requesters", organization, view, period, "metrics.http.requesters", ChartColor.BLUE);
OrganizationMetricHtmlizer.htmlize(data, "http.requesters-humansbots", organization, view, period, "http.requesters (humans + bots)", "metrics.http.requesters.humans", ChartColor.GREEN,
"metrics.http.requesters.bots", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.requesters.humans", organization, view, period, "metrics.http.requesters.humans", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.requesters.bots", organization, view, period, "metrics.http.requesters.bots", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.requesters-ipv4ipv6", organization, view, period, "http.requesters(ipv4 + ipv6)", "metrics.http.requesters.ipv4", ChartColor.YELLOW,
"metrics.http.requesters.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.requesters.ipv4", organization, view, period, "metrics.http.requesters.ipv4", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.requesters.ipv6", organization, view, period, "metrics.http.requesters.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.visitors", organization, view, period, "metrics.http.visitors", ChartColor.BLUE);
OrganizationMetricHtmlizer.htmlize(data, "http.visitors-ipv4ipv6", organization, view, period, "http.visitors (ipv4 + ipv6)", "metrics.http.visitors.ipv4", ChartColor.YELLOW,
"metrics.http.visitors.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.visitors.ipv4", organization, view, period, "metrics.http.visitors.ipv4", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.visitors.ipv6", organization, view, period, "metrics.http.visitors.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.visits", organization, view, period, "metrics.http.visits", ChartColor.BLUE);
OrganizationMetricHtmlizer.htmlize(data, "http.visits-ipv4ipv6", organization, view, period, "http.visits (ipv4 + ipv6)", "metrics.http.visits.ipv4", ChartColor.YELLOW,
"metrics.http.visits.ipv6", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "http.visits.ipv4", organization, view, period, "metrics.http.visits.ipv4", ChartColor.YELLOW);
OrganizationMetricHtmlizer.htmlize(data, "http.visits.ipv6", organization, view, period, "metrics.http.visits.ipv6", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml");
trail.add("Metrics web");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-web-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organization web metric page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,182 +0,0 @@
/*
* 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.catgenerator.core.CatGenerator;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationPage.
*/
public class OrganizationPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationPage.class);
/**
* Builds the view.
*
* @param organization
* the organization
* @throws IOException
* @throws StatoolInfosException
*/
public static void build(final Organization organization) throws IOException, StatoolInfosException
{
CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
// Manage the logo file.
logger.info("Htmlize organization logo: {}.", organization.getName());
htmlizeOrganizationLogo(organization, cache, htmlizeDirectory);
//
logger.info("Htmlize organization properties file: {}.", organization.getName());
FileUtils.copyFile(organization.getInputFile(), new File(htmlizeDirectory, organization.getTechnicalName() + ".properties"));
//
logger.info("Htmlize organization page: {}.", organization.getName());
String page = OrganizationPage.htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-services.xhtml"), page, StandardCharsets.UTF_8);
//
OrganizationPropertyAlertPage.buildAll();
//
logger.info("Htmlize organization general stats page: {}.", organization.getName());
page = OrganizationStatsPage.htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats.xhtml"), page, StandardCharsets.UTF_8);
//
logger.info("Htmlize organization metric pages: {}.", organization.getName());
for (ViewMenu view : ViewMenu.values())
{
for (PeriodMenu period : PeriodMenu.values())
{
if ((view != ViewMenu.YEARS) || (period == PeriodMenu.FULL))
{
if (view != ViewMenu.DAYS)
{
OrganizationMetricSummaryPage.build(htmlizeDirectory, organization, view, period);
OrganizationMetricGenericPage.build(htmlizeDirectory, organization, view, period);
OrganizationMetricSpecificPage.build(htmlizeDirectory, organization, view, period);
OrganizationMetricWebPage.build(htmlizeDirectory, organization, view, period);
}
}
}
}
}
/**
* Builds the all.
*
* @throws StatoolInfosException
* @throws IOException
*/
public static void buildAll() throws IOException, StatoolInfosException
{
for (Organization organization : HtmlizerContext.instance().getFederation().getOrganizations())
{
build(organization);
}
}
/**
* Builds the.
*
* @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
{
logger.debug("Building organization page {}…", organization.get("organization.name"));
TagDataManager data = new TagDataManager();
//
data.setContent("organizationHeaderView", OrganizationHeaderView.htmlize(organization));
data.setContent("serviceListView", ServiceListView.htmlize(organization.getServices().sortByName()));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organization.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organization page: " + exception.getMessage(), exception);
}
//
return result;
}
/**
* Htmlize organization logo.
*
* @param organization
* the organization
* @param cache
* the cache
* @param htmlizeDirectory
* the htmlize directory
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void htmlizeOrganizationLogo(final Organization organization, final CrawlCache cache, final File htmlizeDirectory) throws IOException
{
File target = new File(htmlizeDirectory, organization.getLogoFileName());
File logoFile = cache.restoreFile(organization.getLogoURL());
if (logoFile == null)
{
logger.info("CatGeneratoring cat avatar: {}", target.getAbsoluteFile());
CatGenerator.buildAvatarTo(organization.getTechnicalName(), target);
}
else
{
FileUtils.copyFile(logoFile, target);
}
}
}

View file

@ -1,99 +0,0 @@
/*
* 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

@ -1,99 +0,0 @@
/*
* 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 OrganizationPropertyFileCheckView.
*/
public class OrganizationPropertyCheckPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyCheckPage.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() + "-propertycheck.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", PropertyCheckView.htmlize(organization.getInputChecks()));
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", organization.getLocalFileBaseName() + "-propertycheck.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organization property file check page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,110 +0,0 @@
/*
* Copyright (C) 2020-2022 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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationStatsPage.
*/
public class OrganizationStatsPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationStatsPage.class);
/**
* Htmlize.
*
* @param organization
* the organization
* @return the string
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static String htmlize(final Organization organization) throws StatoolInfosException, IOException
{
String result;
try
{
logger.debug("Building organization stats page {}…");
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
//
data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organization));
Services services = organization.getActiveServices();
data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization));
data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services));
data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services));
data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services));
data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services));
data.setContent("hostProviderHypervisorChart", ChartHtmlizer.htmlizeHostProviderHypervisorChart(services));
data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services));
data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services));
{
RegistrationStats stats = StatAgent.statRegistrationTypes(services);
data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats));
data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats));
data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats));
data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats));
data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats));
}
data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services));
data.setContent("organisationTypeChart", ChartHtmlizer.htmlizeOrganizationTypeChart(organization));
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml", data).toString();
//
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building organization stats page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,115 +0,0 @@
/*
* Copyright (C) 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.statoolinfos.uptime.UptimeJournal;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationUptimePage.
*/
public class OrganizationUptimePage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationUptimePage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final Organization organization) throws StatoolInfosException, IOException
{
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
UptimeJournal journal = HtmlizerContext.instance().getUptimeJournal();
String page = htmlize(organization, journal);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-uptimes.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the all.
*
* @throws IOException
* @throws StatoolInfosException
*/
public static void buildAll() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
for (Organization organization : federation.getOrganizations())
{
build(organization);
}
}
/**
* Htmlize.
*
* @param organization
* the organization
* @param journal
* the journal
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Organization organization, final UptimeJournal journal) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
data.setContent("uptimeView", UptimeView.htmlize(organization.getServices(), journal));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimePage.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml");
trail.add("Disponibilité des services", organization.getLocalFileBaseName() + "-uptimes.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building about page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,165 +0,0 @@
/*
* 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.net.MalformedURLException;
import java.nio.charset.StandardCharsets;
import java.time.format.DateTimeFormatter;
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.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.propertyfiles.PropertiesFileStat;
import fr.devinsy.statoolinfos.stats.propertyfiles.PropertiesFileStats;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationPage.
*/
public class PropertiesFilesPage
{
private static Logger logger = LoggerFactory.getLogger(PropertiesFilesPage.class);
/**
* Builds the.
*
* @throws IOException
* @throws MalformedURLException
* @throws StatoolInfosException
*/
public static void build() throws MalformedURLException, IOException, StatoolInfosException
{
Federation federation = HtmlizerContext.instance().getFederation();
CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
logger.info("Htmlize propertiesFiles page.");
PropertiesFileStats stats = StatAgent.statAllPropertiesFiles(federation, cache).sortByName();
String page = PropertiesFilesPage.htmlize(stats);
FileUtils.write(new File(htmlizeDirectory, "propertiesFiles.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
* @param stats
* the stats
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final PropertiesFileStats stats) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building propertyFiles page.");
TagDataManager data = new TagDataManager();
data.setContent("fileCount", stats.size());
data.setContent("lineCount", stats.getLineCount());
data.setContent("propertyCount", stats.getPropertyCount());
data.setContent("blankPropertyCount", stats.getBlankPropertyCount());
data.setContent("filledPropertyCount", stats.getFilledPropertyCount());
data.setContent("warningCount", stats.getWarningCount());
data.setContent("errorCount", stats.getErrorCount());
data.setContent("voidCount", stats.getVoidCount());
//
int index = 0;
for (PropertiesFileStat stat : stats.sortByName())
{
data.setAttribute("fileListLine", index, "fileListLineNameLink", "href", stat.getLocalName());
data.setEscapedContent("fileListLine", index, "fileListLineNameLink", stat.getLocalName());
data.setAttribute("fileListLine", index, "fileListLineOwnerLink", "href", stat.getOrganization().getTechnicalName() + ".xhtml");
data.setEscapedContent("fileListLine", index, "fileListLineNameValue", stat.getOrganization().getName());
data.setAttribute("fileListLine", index, "fileListLineOwnerLogo", "src", stat.getOrganization().getLogoFileName());
data.setContent("fileListLine", index, "fileListLineLineCount", stat.getLineCount());
data.setContent("fileListLine", index, "fileListLineActiveCount", stat.getPropertyCount());
data.setContent("fileListLine", index, "fileListLineBlankPropertyCount", stat.getBlankPropertyCount());
data.setContent("fileListLine", index, "fileListLineFilledPropertyCount", stat.getFilledPropertyCount());
if (stat.getWarningCount() > 0)
{
data.setAttribute("fileListLine", index, "fileListLineWarningCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml"));
data.setContent("fileListLine", index, "fileListLineWarningCountLink", stat.getWarningCount());
data.setAttribute("fileListLine", index, "fileListLineWarningCount", "style", "background-color: yellow;");
}
else
{
data.setContent("fileListLine", index, "fileListLineWarningCount", stat.getWarningCount());
}
if (stat.getErrorCount() > 0)
{
data.setAttribute("fileListLine", index, "fileListLineErrorCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml"));
data.setContent("fileListLine", index, "fileListLineErrorCountLink", stat.getErrorCount());
data.setAttribute("fileListLine", index, "fileListLineErrorCount", "style", "background-color: red;");
}
else
{
data.setContent("fileListLine", index, "fileListLineErrorCount", stat.getErrorCount());
}
if (stat.getVoidCount() > 0)
{
data.setAttribute("fileListLine", index, "fileListLineVoidCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml"));
data.setContent("fileListLine", index, "fileListLineVoidCountLink", stat.getVoidCount());
data.setAttribute("fileListLine", index, "fileListLineVoidCount", "style", "background-color: rgb(54, 162, 235, 0.2);");
}
else
{
data.setContent("fileListLine", index, "fileListLineVoidCount", stat.getVoidCount());
}
data.setContent("fileListLine", index, "fileListLineDate", stat.getUpdateDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY")));
data.setAttribute("fileListLine", index, "fileListLineDate", "title", stat.getUpdateDate().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
index += 1;
}
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Fichiers", "propertiesFiles.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building propertiesFiles page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,146 +0,0 @@
/*
* 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;
/**
* The Class PropertyFileCheckPage.
*/
public class PropertyAlertPage
{
private static Logger logger = LoggerFactory.getLogger(PropertyAlertPage.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 String title, final PropertyChecks checks) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building propertyFilesCheck page…");
TagDataManager data = new TagDataManager();
data.setContent("lineCount", checks.size());
data.setContent("errorCount", checks.getErrorCount());
data.setContent("warningCount", checks.getWarningCount());
data.setContent("voidCount", checks.getVoidCount());
//
data.setContent("statsTitle", title);
//
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/propertyCheck.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Propriétés", "propertyStats.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + 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

@ -1,137 +0,0 @@
/*
* 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);
/**
* Htmlize.
*
* @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

@ -1,253 +0,0 @@
/*
* 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.PropertyCheck;
import fr.devinsy.statoolinfos.checker.PropertyChecks;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Metrics;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Service;
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 PropertyFileCheckView.
*/
public class PropertyCheckView
{
private static Logger logger = LoggerFactory.getLogger(PropertyCheckView.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();
PropertyChecks allAlertChecks = new PropertyChecks();
PropertyChecks federationAlertChecks = new PropertyChecks();
PropertyChecks organizationAlertChecks = new PropertyChecks();
PropertyChecks serviceAlertChecks = new PropertyChecks();
//
PropertyChecks alerts = federation.getInputChecks().getAlertLines().setFileName(federation.getName());
allAlertChecks.addAll(alerts);
federationAlertChecks.addAll(alerts);
//
for (Organization organization : federation.getOrganizations())
{
PropertyChecks checks = organization.getInputChecks();
// Ignore ghost organizations.
if (organization.getServiceCount() > 0)
{
alerts = checks.getAlertLines().setFileName(organization.getLocalFileName());
allAlertChecks.addAll(alerts);
organizationAlertChecks.addAll(alerts);
for (Service service : organization.getServices())
{
alerts = service.getInputChecks().getAlertLines().setFileName(service.getLocalFileName());
allAlertChecks.addAll(alerts);
serviceAlertChecks.addAll(alerts);
for (Metrics metrics : service.getMetrics())
{
alerts = metrics.getInputChecks().getAlertLines().setFileName(metrics.getLocalFileName());
allAlertChecks.addAll(alerts);
serviceAlertChecks.addAll(alerts);
}
}
}
}
//
String page = PropertyAlertPage.htmlize("Tous", allAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks.xhtml"), page, StandardCharsets.UTF_8);
page = PropertyAlertPage.htmlize("Fédération", federationAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks-federation.xhtml"), page, StandardCharsets.UTF_8);
page = PropertyAlertPage.htmlize("Membres", organizationAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks-organizations.xhtml"), page, StandardCharsets.UTF_8);
page = PropertyAlertPage.htmlize("Services", serviceAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks-services.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Htmlize.
*
* @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("warningCount", checks.getWarningCount());
data.setContent("errorCount", checks.getErrorCount());
data.setContent("voidCount", checks.getVoidCount());
//
data.setContent("statsTitle", "Propriétés");
//
int index = 0;
if (checks.isEmpty())
{
data.setAttribute("fullBlockTable", "class", "xid:nodisplay");
}
else
{
for (PropertyCheck check : checks)
{
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;
}
}
//
index = 0;
PropertyChecks subchecks = checks.getActiveLines();
if (subchecks.isEmpty())
{
data.setAttribute("shrunkBlockTable", "class", "xid:nodisplay");
}
else
{
for (PropertyCheck check : subchecks)
{
data.setContent("shrunkLine", index, "shrunkLineIndex", check.getIndex());
data.setEscapedContent("shrunkLine", index, "shrunkLineContent", check.getLine());
data.setEscapedContent("shrunkLine", index, "shrunkLineComment", check.getComment());
data.setAttribute("shrunkLine", index, "shrunkLineContent", "class", statusToCSS(check.getStatus()));
index += 1;
}
}
//
index = 0;
subchecks = checks.getAlertLines();
if (subchecks.isEmpty())
{
data.setAttribute("alertBlockTable", "class", "xid:nodisplay");
}
else
{
for (PropertyCheck check : subchecks)
{
data.setContent("alertLine", index, "alertLineIndex", check.getIndex());
data.setEscapedContent("alertLine", index, "alertLineContent", check.getLine());
data.setEscapedContent("alertLine", index, "alertLineComment", check.getComment());
data.setAttribute("alertLine", index, "alertLineContent", "class", statusToCSS(check.getStatus()));
index += 1;
}
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyCheckView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building property check 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

@ -1,153 +0,0 @@
/*
* Copyright (C) 2020-2023 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.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.properties.PropertyStat;
import fr.devinsy.statoolinfos.stats.properties.PropertyStatList;
import fr.devinsy.statoolinfos.stats.properties.PropertyStats;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class PropertyStatsPage.
*/
public class PropertyStatsPage
{
private static Logger logger = LoggerFactory.getLogger(PropertyStatsPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void buildAll() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
logger.info("Htmlize propertyStats page.");
PropertyStats stats = StatAgent.statAllProperties(federation);
String page = PropertyStatsPage.htmlize("Toutes les propriétés", stats);
FileUtils.write(new File(htmlizeDirectory, "propertyStats.xhtml"), page, StandardCharsets.UTF_8);
PropertyStats federationStats = StatAgent.statFederationProperties(federation);
page = PropertyStatsPage.htmlize("Les propriétés de la fédération", federationStats);
FileUtils.write(new File(htmlizeDirectory, "propertyStats-federation.xhtml"), page, StandardCharsets.UTF_8);
PropertyStats organizationsStats = StatAgent.statOrganizationsProperties(federation.getActiveOrganizations());
page = PropertyStatsPage.htmlize("Les propriétés des organizations", organizationsStats);
FileUtils.write(new File(htmlizeDirectory, "propertyStats-organizations.xhtml"), page, StandardCharsets.UTF_8);
PropertyStats servicesStats = StatAgent.statServicesProperties(federation.getActiveServices());
page = PropertyStatsPage.htmlize("Les propriétés des services", servicesStats);
FileUtils.write(new File(htmlizeDirectory, "propertyStats-services.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
* @param title
* the title
* @param stats
* the stats
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final String title, final PropertyStats stats) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building propertyStats page…");
TagDataManager data = new TagDataManager();
//
data.setContent("statsTitle", title);
data.setContent("propertyCount", stats.getPropertyCount());
data.setContent("fileCount", stats.getFileCount());
//
PropertyStatList generalStats = stats.getGeneralPropertyStats().getList().sortByReverseFilledCount();
data.setContent("generalPropertyCount", generalStats.size());
int index = 0;
for (PropertyStat stat : generalStats)
{
data.setEscapedContent("generalPropertyLine", index, "generalPropertyLinePath", stat.getPath());
data.setContent("generalPropertyLine", index, "generalPropertyLineBlankCount", stat.getBlankCount());
data.setContent("generalPropertyLine", index, "generalPropertyLineBlankCountPercentage", StatoolInfosUtils.toPercentage(stat.getBlankCount(), stats.getFileCount()));
data.setContent("generalPropertyLine", index, "generalPropertyLineFilledCount", stat.getFilledCount());
data.setContent("generalPropertyLine", index, "generalPropertyLineFilledCountPercentage", StatoolInfosUtils.toPercentage(stat.getFilledCount(), stats.getFileCount()));
index += 1;
}
//
PropertyStatList metricStats = stats.getMetricPropertyStats().getList().sortByReverseFilledCount();
data.setContent("metricPropertyCount", metricStats.size());
index = 0;
for (PropertyStat stat : metricStats)
{
data.setEscapedContent("metricPropertyLine", index, "metricPropertyLinePath", stat.getPath());
data.setContent("metricPropertyLine", index, "metricPropertyLineBlankCount", stat.getBlankCount());
data.setContent("metricPropertyLine", index, "metricPropertyLineBlankCountPercentage", StatoolInfosUtils.toPercentage(stat.getBlankCount(), stats.getFileCount()));
data.setContent("metricPropertyLine", index, "metricPropertyLineFilledCount", stat.getFilledCount());
data.setContent("metricPropertyLine", index, "metricPropertyLineFilledCountPercentage", StatoolInfosUtils.toPercentage(stat.getFilledCount(), stats.getFileCount()));
index += 1;
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Propriétés", "propertyStats.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,96 +0,0 @@
/*
* Copyright (C) 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.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 CrawlJournalServicePage.
*/
public class ServiceCrawlJournalPage
{
private static Logger logger = LoggerFactory.getLogger(ServiceCrawlJournalPage.class);
/**
* Builds the.
*
* @param service
* the service
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final Service service) throws StatoolInfosException, IOException
{
try
{
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
TagDataManager data = new TagDataManager();
data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("contentView", CrawlJournalView.htmlize(service.getCrawlJournal()));
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");
String page = WebCharterView.build(content, trail);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-crawl.xhtml"), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service crawl journal page: " + exception.getMessage(), exception);
}
}
/**
* Builds the all.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void buildAll() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
for (Service service : federation.getServicesAll())
{
build(service);
}
}
}

View file

@ -1,126 +0,0 @@
/*
* Copyright (C) 2022 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.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
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 ServiceFigureView.
*/
public class ServiceFigureView
{
private static Logger logger = LoggerFactory.getLogger(ServiceFigureView.class);
/**
* Builds the.
*
* @param services
* the services
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Services services) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building services figures view.");
TagDataManager data = new TagDataManager();
data.setContent("serviceCount", services.size());
YearMonth month = YearMonth.now();
data.setContent("currentMonth", month.format(DateTimeFormatter.ofPattern("MMMM yyyy")));
if (services.isEmpty())
{
data.setAttribute("serviceListLine", "class", "xid:nodisplay");
}
else
{
String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", "&#160;");
data.setContent("monthLabel", monthLabel);
data.setAttribute("userCountHeaderColumn", "title", monthLabel);
data.setAttribute("visitCountHeaderColumn", "title", monthLabel);
int index = 0;
for (Service service : services.sortByName())
{
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml");
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getLogoFileName());
data.setEscapedAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "title", service.getOrganization().getName());
data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getLogoFileName());
data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName());
data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
data.setAttribute("serviceListLine", index, "serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png");
data.setAttribute("serviceListLine", index, "serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString()));
if (service.getWebsiteURL() != null)
{
data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsiteURL().toString());
data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsiteURL().toString());
data.setEscapedAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsiteURL().toString());
}
data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName());
data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml");
data.setContent("serviceListLine", index, "serviceListLineHitCount", StatoolInfosUtils.defaultIfZero(service.getMonthHitCount(month), "😢"));
data.setContent("serviceListLine", index, "serviceListLineVisitCount", StatoolInfosUtils.defaultIfZero(service.getMonthVisitCount(month), "😞"));
data.setContent("serviceListLine", index, "serviceListLineVisitorCount", StatoolInfosUtils.defaultIfZero(service.getMonthVisitorCount(month), "😞"));
data.setContent("serviceListLine", index, "serviceListLineUserCount", StatoolInfosUtils.defaultIfZero(service.getMonthUserCount(month), "😢"));
data.setContent("serviceListLine", index, "serviceListLineAccountCount", StatoolInfosUtils.defaultIfZero(service.getMonthAccountCount(month), "😇"));
data.setContent("serviceListLine", index, "serviceListLineActiveAccountCount", StatoolInfosUtils.defaultIfZero(service.getMonthActiveAccountCount(month), "😇"));
data.setContent("serviceListLine", index, "serviceListLineDatabaseBytes", StatoolInfosUtils.defaultIfZero(service.getMonthDatabaseBytes(month), "😇"));
data.setContent("serviceListLine", index, "serviceListLineDatafilesBytes", StatoolInfosUtils.defaultIfZero(service.getMonthDatafilesBytes(month), "😇"));
index += 1;
}
}
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceFigureView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(result);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,220 +0,0 @@
/*
* Copyright (C) 2020-2022 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.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.checker.PropertyChecks;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services;
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 ServiceHeaderView.
*/
public class ServiceHeaderView
{
private static Logger logger = LoggerFactory.getLogger(ServiceHeaderView.class);
/**
* 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.setAttribute("serviceLogo", "src", service.getLogoFileName());
data.setEscapedContent("serviceName", service.getName());
if (service.getWebsiteURL() != null)
{
data.setEscapedAttribute("serviceName", "href", service.getWebsiteURL().toString());
data.setEscapedContent("serviceURL", service.getWebsiteURL().toString());
data.setEscapedAttribute("serviceURL", "href", service.getWebsiteURL().toString());
}
data.setEscapedContent("serviceDescription", StringUtils.defaultIfBlank(service.getDescription(), "n/a"));
data.setContent("serviceStartDate", StringUtils.defaultIfBlank(service.getStartDateValue(), "n/a"));
data.setContent("serviceEndDate", StringUtils.defaultIfBlank(service.getEndDateValue(), "n/a"));
data.setContent("serviceAge", StringUtils.defaultIfBlank(service.getAge(), "n/a"));
if (StringUtils.isBlank(service.getEndDateValue()))
{
data.setAttribute("serviceEndDateData", "style", "display: none;");
}
else
{
data.setAttribute("serviceStartDateWord", "style", "display: none;");
}
data.setAttribute("serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png");
data.setAttribute("serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString()));
data.setAttribute("organizationsLink", "href", service.getOrganization().getTechnicalName() + "-services.xhtml");
data.setAttribute("servicesLink", "href", service.getLocalFileBaseName() + "-services.xhtml");
data.setAttribute("rawLink", "href", service.getLocalFileBaseName() + ".properties");
data.setAttribute("rawCheckLink", "href", service.getLocalFileBaseName() + "-propertycheck.xhtml");
data.setAttribute("statsLink", "href", service.getLocalFileBaseName() + ".xhtml");
data.setAttribute("metricsLink", "href", service.getLocalFileBaseName() + "-metrics-summary-months-last.xhtml");
if (service.getLegalURL() != null)
{
data.setEscapedAttribute("legalLink", "href", service.getLegalURL().toString());
data.setAttribute("legalLinkImg", "class", "");
data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getContactURL() != null)
{
data.setEscapedAttribute("contactLink", "href", service.getContactURL().toString());
data.setAttribute("contactLinkImg", "class", "");
data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(service.getContactEmail()))
{
data.setEscapedAttribute("emailLink", "href", "mailto:" + service.getContactEmail());
data.setAttribute("emailLinkImg", "class", "");
data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getUserGuideURL() != null)
{
data.setEscapedAttribute("userDocLink", "href", service.getUserGuideURL().toString());
data.setAttribute("userDocLinkImg", "class", "");
data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getTechnicalGuideURL() != null)
{
data.setEscapedAttribute("technicalDocLink", "href", service.getTechnicalGuideURL().toString());
data.setAttribute("technicalDocLinkImg", "class", "");
data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
//
if (service.isRegistrationNone())
{
data.setAttribute("registrationNoneImg", "class", "");
data.getIdData("registrationNoneImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.isRegistrationFree())
{
data.setAttribute("registrationFreeImg", "class", "");
data.getIdData("registrationFreeImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.isRegistrationMember())
{
data.setAttribute("registrationMemberImg", "class", "");
data.getIdData("registrationMemberImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.isRegistrationClient())
{
data.setAttribute("registrationClientImg", "class", "");
data.getIdData("registrationClientImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.isRegistrationLoadFull())
{
data.setAttribute("registrationLoadImg", "class", "");
data.getIdData("registrationLoadImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
//
data.setEscapedContent("softwareName", StringUtils.defaultIfBlank(service.getSoftwareName(), "n/a"));
data.setContent("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "n/a"));
data.setEscapedContent("softwareLicenseName", StringUtils.defaultIfBlank(service.getSoftwareLicenseName(), "n/a"));
if (service.getSoftwareWebsite() != null)
{
data.setEscapedAttribute("softwareWebsiteLink", "href", service.getSoftwareWebsite().toString());
data.setAttribute("softwareWebsiteLinkImg", "class", "");
data.getIdData("softwareWebsiteLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getSoftwareLicenseURL() != null)
{
data.setEscapedAttribute("softwareLicenseLink", "href", service.getSoftwareLicenseURL().toString());
data.setAttribute("softwareLicenseLinkImg", "class", "");
data.getIdData("softwareLicenseLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getSoftwareSourceURL() != null)
{
data.setEscapedAttribute("softwareSourceLink", "href", service.getSoftwareSourceURL().toString());
data.setAttribute("softwareSourceLinkImg", "class", "");
data.getIdData("softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
data.setAttribute("crawlLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-crawl.xhtml");
if (service.getCrawlJournal().getErrors().isEmpty())
{
data.setAttribute("crawlLinkImg", "src", "circle-icons/download-mono.svg");
}
else
{
data.setAttribute("crawlLinkImg", "src", "circle-icons/download.svg");
}
data.setAttribute("uptimeLink", "href", service.getLocalFileBaseName() + "-uptimes.xhtml");
Services services = new Services();
services.add(service);
if (HtmlizerContext.instance().getUptimeJournal().hasRecentError(services))
{
data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ko-mono.svg");
}
else
{
data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ok-mono.svg");
}
{
PropertyChecks checks = service.getInputChecksAll();
data.setContent("errorCount", checks.getErrorCount());
data.setContent("warningCount", checks.getWarningCount());
data.setContent("voidCount", checks.getVoidCount());
data.setAttribute("alertLink", "href", service.getLocalFileBaseName() + "-propertyalerts.xhtml");
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service header view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,202 +0,0 @@
/*
* Copyright (C) 2020-2022 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.time.LocalDate;
import java.time.format.DateTimeFormatter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
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 ServiceListView.
*/
public class ServiceListView
{
private static Logger logger = LoggerFactory.getLogger(ServiceListView.class);
/**
* Builds the.
*
* @param services
* the services
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Services services) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building service list view.");
TagDataManager data = new TagDataManager();
data.setContent("serviceCount", services.size());
if (services.isEmpty())
{
data.setAttribute("serviceListLine", "class", "xid:nodisplay");
}
else
{
String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", "&#160;");
data.setContent("monthLabel", monthLabel);
data.setAttribute("userCountHeaderColumn", "title", monthLabel);
data.setAttribute("visitCountHeaderColumn", "title", monthLabel);
int index = 0;
for (Service service : services.sortByName())
{
data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getLogoFileName());
data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName());
data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml");
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getLogoFileName());
data.setEscapedContent("serviceListLine", index, "serviceListLineOrganizationValue", service.getOrganization().getName());
if (service.getWebsiteURL() != null)
{
data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsiteURL().toString());
data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsiteURL().toString());
data.setEscapedAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsiteURL().toString());
}
data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName());
data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml");
data.setContent("serviceListLine", index, "serviceListLineUserCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthUserCount(), "😢"));
data.setContent("serviceListLine", index, "serviceListLineVisitCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthVisitCount(), "😞"));
data.setEscapedContent("serviceListLine", index, "serviceListLineDate", service.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY")));
data.setEscapedAttribute("serviceListLine", index, "serviceListLineDate", "title", service.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
data.setAttribute("serviceListLine", index, "serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png");
data.setAttribute("serviceListLine", index, "serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString()));
if (service.getLegalURL() != null)
{
data.setEscapedAttribute("serviceListLine", index, "legalLink", "href", service.getLegalURL().toString());
data.setAttribute("serviceListLine", index, "legalLinkImg", "class", "");
data.getIdData("serviceListLine", index, "legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getContactURL() != null)
{
data.setEscapedAttribute("serviceListLine", index, "contactLink", "href", service.getContactURL().toString());
data.setAttribute("serviceListLine", index, "contactLinkImg", "class", "");
data.getIdData("serviceListLine", index, "contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (StringUtils.isNotBlank(service.getContactEmail()))
{
data.setEscapedAttribute("serviceListLine", index, "emailLink", "href", "mailto:" + service.getContactEmail());
data.setAttribute("serviceListLine", index, "emailLinkImg", "class", "");
data.getIdData("serviceListLine", index, "emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getUserGuideURL() != null)
{
data.setEscapedAttribute("serviceListLine", index, "userDocLink", "href", service.getUserGuideURL().toString());
data.setAttribute("serviceListLine", index, "userDocLinkImg", "class", "");
data.getIdData("serviceListLine", index, "userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getTechnicalGuideURL() != null)
{
data.setEscapedAttribute("serviceListLine", index, "technicalDocLink", "href", service.getTechnicalGuideURL().toString());
data.setAttribute("serviceListLine", index, "technicalDocLinkImg", "class", "");
data.getIdData("serviceListLine", index, "technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
//
if (service.isRegistrationNone())
{
data.setAttribute("serviceListLine", index, "serviceListLineRegistrationNoneImg", "class", "toto");
data.getIdData("serviceListLine", index, "serviceListLineRegistrationNoneImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.isRegistrationFree())
{
data.setAttribute("serviceListLine", index, "serviceListLineRegistrationFreeImg", "class", "");
data.getIdData("serviceListLine", index, "serviceListLineRegistrationFreeImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.isRegistrationMember())
{
data.setAttribute("serviceListLine", index, "serviceListLineRegistrationMemberImg", "class", "");
data.getIdData("serviceListLine", index, "serviceListLineRegistrationMemberImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.isRegistrationClient())
{
data.setAttribute("serviceListLine", index, "serviceListLineRegistrationClientImg", "class", "");
data.getIdData("serviceListLine", index, "serviceListLineRegistrationClientImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.isRegistrationLoadFull())
{
data.setAttribute("serviceListLine", index, "serviceListLineRegistrationLoadImg", "class", "");
data.getIdData("serviceListLine", index, "serviceListLineRegistrationLoadImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
//
data.setEscapedContent("softwareName", StringUtils.defaultIfBlank(service.getSoftwareName(), "n/a"));
data.setEscapedContent("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "n/a"));
data.setEscapedContent("softwareLicenseName", StringUtils.defaultIfBlank(service.getSoftwareLicenseName(), "n/a"));
if (service.getSoftwareWebsite() != null)
{
data.setEscapedAttribute("serviceListLine", index, "softwareWebsiteLink", "href", service.getSoftwareWebsite().toString());
data.setAttribute("serviceListLine", index, "softwareWebsiteLinkImg", "class", "");
data.getIdData("serviceListLine", index, "softwareWebsiteLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getSoftwareLicenseURL() != null)
{
data.setEscapedAttribute("serviceListLine", index, "softwareLicenseLink", "href", service.getSoftwareLicenseURL().toString());
data.setAttribute("serviceListLine", index, "softwareLicenseLinkImg", "class", "");
data.getIdData("serviceListLine", index, "softwareLicenseLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
if (service.getSoftwareSourceURL() != null)
{
data.setEscapedAttribute("serviceListLine", index, "softwareSourceLink", "href", service.getSoftwareSourceURL().toString());
data.setAttribute("serviceListLine", index, "softwareSourceLinkImg", "class", "");
data.getIdData("serviceListLine", index, "softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
}
index += 1;
}
}
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceListView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(result);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,110 +0,0 @@
/*
* 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.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ServicePage.
*/
public class ServiceMetricGenericPage
{
private static Logger logger = LoggerFactory.getLogger(ServiceMetricGenericPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param service
* the service
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.GENERIC, view, period));
//
ServiceMetricHtmlizer.htmlize(data, "graphic.users", service, view, period, "metrics.service.users", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.users.ipv4-ipv6", service, view, period, "service.users (ipv4 + ipv6)", "metrics.service.users.ipv4", ChartColor.YELLOW,
"metrics.service.users.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.users.ipv4", service, view, period, "metrics.service.users.ipv4", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "graphic.users.ipv6", service, view, period, "metrics.service.users.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.accounts", service, view, period, "metrics.service.accounts", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.accounts.active", service, view, period, "metrics.service.accounts.active", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.database.bytes", service, view, period, "metrics.service.database.bytes", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", service, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN);
// TODO
// metrics.moderation.accounts.reported.* =
// metrics.moderation.accounts.sanctioned.* =
// metrics.moderation.accounts.disabled.* =
// metrics.moderation.accounts.silenced.* =
// metrics.moderation.accounts.cancelled.* =
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.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("Metrics génériques");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-generic-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service generic metric view: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,187 +0,0 @@
/*
* Copyright (C) 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.time.YearMonth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.threeten.extra.YearWeek;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.statoolinfos.properties.MonthValues;
import fr.devinsy.statoolinfos.properties.WeekValues;
import fr.devinsy.statoolinfos.properties.YearValues;
import fr.devinsy.xidyn.data.TagDataManager;
/**
* The Class MetricHtmlizeDataUtils.
*/
public class ServiceMetricHtmlizer
{
private static Logger logger = LoggerFactory.getLogger(ServiceMetricHtmlizer.class);
/**
* Htmlize data.
*
* @param data
* the data
* @param metricId
* the metric id
* @param service
* the service
* @param metricPath
* the metric path
* @param color
* the color
* @throws StatoolInfosException
* the statool infos exception
*/
public static void htmlize(final TagDataManager data, final String metricId, final Service service, final ViewMenu view, final PeriodMenu period, final String metricPath,
final ChartColor color) throws StatoolInfosException
{
if (view == ViewMenu.YEARS)
{
YearValues yearMetric = service.getMetricYearValues(metricPath);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color));
}
}
else if (view == ViewMenu.MONTHS)
{
MonthValues monthMetric = service.getMetricMonthValues(metricPath);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(year, 01), YearMonth.of(year, 12), monthMetric, color));
}
}
else if (view == ViewMenu.WEEKS)
{
WeekValues weekMetric = service.getMetricWeekValues(metricPath);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(year, 01), YearWeek.of(year, 53), weekMetric, color));
}
}
}
/**
* Htmlize data.
*
* @param data
* the data
* @param metricId
* the metric id
* @param service
* the service
* @param metricLabel
* the metric label
* @param metricPath1
* the metric path 1
* @param color1
* the color 1
* @param metricPath2
* the metric path 2
* @param color2
* the color 2
* @throws StatoolInfosException
* the statool infos exception
*/
public static void htmlize(final TagDataManager data, final String metricId, final Service service, final ViewMenu view, final PeriodMenu period, final String metricLabel,
final String metricPath1, final ChartColor color1, final String metricPath2, final ChartColor color2) throws StatoolInfosException
{
if (view == ViewMenu.YEARS)
{
YearValues yearMetric1 = service.getMetricYearValues(metricPath1);
YearValues yearMetric2 = service.getMetricYearValues(metricPath2);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId,
ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2));
}
}
else if (view == ViewMenu.MONTHS)
{
MonthValues monthMetric1 = service.getMetricMonthValues(metricPath1);
MonthValues monthMetric2 = service.getMetricMonthValues(metricPath2);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId,
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId,
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(year, 01), YearMonth.of(year, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
}
}
else if (view == ViewMenu.WEEKS)
{
WeekValues weekMetric1 = service.getMetricWeekValues(metricPath1);
WeekValues weekMetric2 = service.getMetricWeekValues(metricPath2);
if (period == PeriodMenu.FULL)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
}
else if (period == PeriodMenu.LAST)
{
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
}
else
{
int year = Integer.parseInt(period.name().substring(1));
data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(year, 01), YearWeek.of(year, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
}
}
}
}

View file

@ -1,264 +0,0 @@
/*
* Copyright (C) 2021-2023 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.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class ServiceMetricMenuView.
*/
public class ServiceMetricMenuView
{
private static Logger logger = LoggerFactory.getLogger(ServiceMetricMenuView.class);
public enum PeriodMenu
{
FULL,
LAST,
Y2021,
Y2022;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
if (this.name().startsWith("Y"))
{
result = this.name().substring(1);
}
else
{
result = this.name().toLowerCase();
}
//
return result;
}
/**
* Gets the years.
*
* @return the years
*/
public static PeriodMenu[] getYears()
{
PeriodMenu[] result;
ArrayList<PeriodMenu> list = new ArrayList<PeriodMenu>();
for (PeriodMenu item : values())
{
if (item.name().startsWith("Y"))
{
list.add(item);
}
}
result = list.toArray(new PeriodMenu[0]);
//
return result;
}
}
public enum TypeMenu
{
SUMMARY,
WEB,
GENERIC,
SPECIFIC;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
result = this.name().toLowerCase();
//
return result;
}
}
public enum ViewMenu
{
YEARS,
MONTHS,
WEEKS,
DAYS;
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
String result;
result = this.name().toLowerCase();
//
return result;
}
}
/**
* Htmlize.
*
* @param service
* the service
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Service service, final TypeMenu type, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
//
String filename = String.format("%s-metrics-summary-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("summaryTypeButton", "href", filename);
filename = String.format("%s-metrics-generic-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("genericTypeButton", "href", filename);
filename = String.format("%s-metrics-specific-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("specificTypeButton", "href", filename);
filename = String.format("%s-metrics-web-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName());
data.setAttribute("webTypeButton", "href", filename);
//
filename = String.format("%s-metrics-%s-years-%s.xhtml", service.getLocalFileBaseName(), type.getName(), PeriodMenu.FULL.getName());
data.setAttribute("yearsViewButton", "href", filename);
filename = String.format("%s-metrics-%s-months-%s.xhtml", service.getLocalFileBaseName(), type.getName(), period.getName());
data.setAttribute("monthsViewButton", "href", filename);
filename = String.format("%s-metrics-%s-weeks-%s.xhtml", service.getLocalFileBaseName(), type.getName(), period.getName());
data.setAttribute("weeksViewButton", "href", filename);
data.setAttribute("daysViewButton", "href", "#");
//
filename = String.format("%s-metrics-%s-%s-full.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("fullPeriodButton", "href", filename);
if (view != ViewMenu.YEARS)
{
filename = String.format("%s-metrics-%s-%s-last.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("lastPeriodButton", "href", filename);
filename = String.format("%s-metrics-%s-%s-2021.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("2021PeriodButton", "href", filename);
filename = String.format("%s-metrics-%s-%s-2022.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName());
data.setAttribute("2022PeriodButton", "href", filename);
}
//
if ((type == null) || (type == TypeMenu.SUMMARY))
{
data.appendAttribute("summaryTypeButton", "class", "button selected");
}
else if (type == TypeMenu.GENERIC)
{
data.appendAttribute("genericTypeButton", "class", "button selected");
}
else if (type == TypeMenu.WEB)
{
data.appendAttribute("webTypeButton", "class", "button selected");
}
else if (type == TypeMenu.SPECIFIC)
{
data.appendAttribute("specificTypeButton", "class", "button selected");
}
//
if ((view == null) || (view == ViewMenu.YEARS))
{
data.appendAttribute("yearsViewButton", "class", "button selected");
}
else if (view == ViewMenu.MONTHS)
{
data.appendAttribute("monthsViewButton", "class", "button selected");
}
else if (view == ViewMenu.WEEKS)
{
data.appendAttribute("weeksViewButton", "class", "button selected");
}
else if (view == ViewMenu.DAYS)
{
data.appendAttribute("daysViewButton", "class", "button selected");
}
//
if ((period == null) || (period == PeriodMenu.FULL))
{
data.appendAttribute("fullPeriodButton", "class", "button selected");
}
else if (period == PeriodMenu.LAST)
{
data.appendAttribute("lastPeriodButton", "class", "button selected");
}
else if (period == PeriodMenu.Y2021)
{
data.appendAttribute("2021PeriodButton", "class", "button selected");
}
else if (period == PeriodMenu.Y2022)
{
data.appendAttribute("2022PeriodButton", "class", "button selected");
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building metric menu view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,97 +0,0 @@
/*
* 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.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ServicePage.
*/
public class ServiceMetricSpecificPage
{
private static Logger logger = LoggerFactory.getLogger(ServiceMetricSpecificPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param service
* the service
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.SPECIFIC, view, period));
//
int index = 1;
for (String metricPath : service.getMetricSpecificPrefixes())
{
ServiceMetricHtmlizer.htmlize(data, "foo" + index++, service, view, period, metricPath, ChartColor.BLUE);
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSpecificView.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("Metrics spécifiques");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-specific-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service specific metrics view: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,93 +0,0 @@
/*
* 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.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ServiceSummaryMetricPage.
*/
public class ServiceMetricSummaryPage
{
private static Logger logger = LoggerFactory.getLogger(ServiceMetricSummaryPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param service
* the service
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.SUMMARY, view, period));
ServiceMetricHtmlizer.htmlize(data, "http.hits.humans", service, view, period, "metrics.http.hits.humans", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.visitors", service, view, period, "metrics.http.visitors", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.visits", service, view, period, "metrics.http.visits", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.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("Metrics résumé");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-summary-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,150 +0,0 @@
/*
* 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.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.TypeMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ServicePage.
*/
public class ServiceMetricWebPage
{
private static Logger logger = LoggerFactory.getLogger(ServiceMetricWebPage.class);
/**
* Builds the.
*
* @param htmlizeDirectory
* the htmlize directory
* @param service
* the service
* @param view
* the view
* @param period
* the period
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
{
try
{
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.WEB, view, period));
ServiceMetricHtmlizer.htmlize(data, "http.hits", service, view, period, "metrics.http.hits", ChartColor.BLUE);
ServiceMetricHtmlizer.htmlize(data, "http.hits-ipv4ipv6", service, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6",
ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.hits.ipv4", service, view, period, "metrics.http.hits.ipv4", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.hits.ipv6", service, view, period, "metrics.http.hits.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.hits-humansbots", service, view, period, "http.hits (humans + bots)", "metrics.http.hits.humans", ChartColor.GREEN,
"metrics.http.hits.bots",
ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.hits.humans", service, view, period, "metrics.http.hits.humans", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.hits.bots", service, view, period, "metrics.http.hits.bots", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.hits.humans-ipv4ipv6", service, view, period, "http.hits.humans (ipv4 + ipv6)", "metrics.http.hits.humans.ipv4", ChartColor.YELLOW,
"metrics.http.hits.humans.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.hits.humans.ipv4", service, view, period, "metrics.http.hits.humans.ipv4", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.hits.humans.ipv6", service, view, period, "metrics.http.hits.humans.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.errors", service, view, period, "metrics.http.errors", ChartColor.RED);
ServiceMetricHtmlizer.htmlize(data, "http.errors.php", service, view, period, "metrics.http.errors.php", ChartColor.RED);
ServiceMetricHtmlizer.htmlize(data, "http.files", service, view, period, "metrics.http.files", ChartColor.BLUE);
ServiceMetricHtmlizer.htmlize(data, "http.pages", service, view, period, "metrics.http.pages", ChartColor.BLUE);
ServiceMetricHtmlizer.htmlize(data, "http.bytes", service, view, period, "metrics.http.bytes", ChartColor.BLUE);
ServiceMetricHtmlizer.htmlize(data, "http.ip", service, view, period, "metrics.http.ip", ChartColor.BLUE);
ServiceMetricHtmlizer.htmlize(data, "http.ip-humansbots", service, view, period, "http.ip (humans + bots)", "metrics.http.ip.humans", ChartColor.GREEN, "metrics.http.ip.bots",
ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.ip.humans", service, view, period, "metrics.http.ip.humans", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.ip.bots", service, view, period, "metrics.http.ip.bots", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.ip-ipv4ipv6", service, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6",
ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.ip.ipv4", service, view, period, "metrics.http.ip.ipv4", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.ip.ipv6", service, view, period, "metrics.http.ip.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.requesters", service, view, period, "metrics.http.requesters", ChartColor.BLUE);
ServiceMetricHtmlizer.htmlize(data, "http.requesters-humansbots", service, view, period, "http.requesters (humans + bots)", "metrics.http.requesters.humans", ChartColor.GREEN,
"metrics.http.requesters.bots", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.requesters.humans", service, view, period, "metrics.http.requesters.humans", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.requesters.bots", service, view, period, "metrics.http.requesters.bots", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.requesters-ipv4ipv6", service, view, period, "http.requesters (ipv4 + ipv6)", "metrics.http.requesters.ipv4", ChartColor.YELLOW,
"metrics.http.requesters.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.requesters.ipv4", service, view, period, "metrics.http.requesters.ipv4", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.requesters.ipv6", service, view, period, "metrics.http.requesters.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.visitors", service, view, period, "metrics.http.visitors", ChartColor.BLUE);
ServiceMetricHtmlizer.htmlize(data, "http.visitors-ipv4ipv6", service, view, period, "http.visitors (ipv4 + ipv6)", "metrics.http.visitors.ipv4", ChartColor.YELLOW,
"metrics.http.visitors.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.visitors.ipv4", service, view, period, "metrics.http.visitors.ipv4", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.visitors.ipv6", service, view, period, "metrics.http.visitors.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.visits", service, view, period, "metrics.http.visits", ChartColor.BLUE);
ServiceMetricHtmlizer.htmlize(data, "http.visits-ipv4ipv6", service, view, period, "http.visits (ipv4 + ipv6)", "metrics.http.visits.ipv4", ChartColor.YELLOW,
"metrics.http.visits.ipv6", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "http.visits.ipv4", service, view, period, "metrics.http.visits.ipv4", ChartColor.YELLOW);
ServiceMetricHtmlizer.htmlize(data, "http.visits.ipv6", service, view, period, "metrics.http.visits.ipv6", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.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("Metrics web");
String page = WebCharterView.build(content, trail);
String filename = String.format("%s-metrics-web-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName());
FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
}
}

View file

@ -1,185 +0,0 @@
/*
* 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.catgenerator.core.BirdGenerator;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Metrics;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ServicePage.
*/
public class ServicePage
{
private static Logger logger = LoggerFactory.getLogger(ServicePage.class);
/**
* Builds the view.
*
* @throws IOException
* @throws StatoolInfosException
*/
public static void build(final Service service) throws IOException, StatoolInfosException
{
CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
// Manage the logo file.
logger.info("Htmlize service logo: {}.", service.getName());
htmlizeServiceLogo(service, cache, htmlizeDirectory);
//
logger.info("Htmlize service properties file: {}.", service.getName());
FileUtils.copyFile(service.getInputFile(),
new File(htmlizeDirectory, service.getLocalFileBaseName() + ".properties"));
//
for (Metrics metrics : service.getMetrics())
{
FileUtils.copyFile(metrics.getInputFile(),
new File(htmlizeDirectory, metrics.getLocalFileBaseName() + ".properties"));
}
//
logger.info("Htmlize service page: {}.", service.getName());
String page = ServicePage.htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + ".xhtml"), page, StandardCharsets.UTF_8);
ServiceServicesPage.build(service);
//
logger.info("Htmlize service metric pages: {}.", service.getName());
for (ViewMenu view : ViewMenu.values())
{
for (PeriodMenu period : PeriodMenu.values())
{
if ((view != ViewMenu.YEARS) || (period == PeriodMenu.FULL))
{
if (view != ViewMenu.DAYS)
{
ServiceMetricSummaryPage.build(htmlizeDirectory, service, view, period);
ServiceMetricGenericPage.build(htmlizeDirectory, service, view, period);
ServiceMetricSpecificPage.build(htmlizeDirectory, service, view, period);
ServiceMetricWebPage.build(htmlizeDirectory, service, view, period);
}
}
}
}
}
/**
* 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
{
for (Service service : HtmlizerContext.instance().getFederation().getServicesAll())
{
build(service);
}
}
/**
* Builds the.
*
* @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
{
logger.debug("Building service page {}…", service.get("service.name"));
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("statsView", ServiceStatsView.htmlize(service));
//
// data.setContent("fooChart", graphicIndex++,
// LineMonthsChartView.build());
// service.getPrefixes();
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
//
return result;
}
/**
* @param service
* @param cache
* @param htmlizeDirectory
* @throws IOException
*/
private static void htmlizeServiceLogo(final Service service, final CrawlCache cache, final File htmlizeDirectory) throws IOException
{
File target = new File(htmlizeDirectory, service.getLogoFileName());
File logoFile = cache.restoreFile(service.getLogoURL());
if (logoFile == null)
{
logger.info("BirdGeneratoring cat avatar: {}", target.getAbsoluteFile());
BirdGenerator.buildAvatarTo(service.getTechnicalName(), target);
}
else
{
FileUtils.copyFile(logoFile, target);
}
}
}

View file

@ -1,146 +0,0 @@
/*
* 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

@ -1,147 +0,0 @@
/*
* 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 ServicePropertyFileCheckView.
*/
public class ServicePropertyCheckPage
{
private static Logger logger = LoggerFactory.getLogger(ServicePropertyCheckPage.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() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8);
for (Metrics metrics : service.getMetrics())
{
page = htmlize(service, metrics);
FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-propertycheck.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", PropertyCheckView.htmlize(service.getInputChecks()));
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", service.getLocalFileBaseName() + "-propertycheck.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service property file check 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", PropertyCheckView.htmlize(metrics.getInputChecks()));
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", service.getLocalFileBaseName() + "-propertycheck.xhtml");
trail.add("Propriétés", metrics.getLocalFileBaseName() + "-propertycheck.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building metrics property file check page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,106 +0,0 @@
/*
* 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.catgenerator.core.BirdGenerator;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
// TODO: Auto-generated Javadoc
/**
* The Class ServiceServicesPage.
*/
public class ServiceServicesPage
{
private static Logger logger = LoggerFactory.getLogger(ServiceServicesPage.class);
/**
* Builds the view.
*
* @param service
* the service
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static void build(final Service service) throws IOException, StatoolInfosException
{
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
//
String page = htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-services.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
* @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));
Services services = new Services();
services.add(service);
data.setContent("servicesView", ServiceListView.htmlize(services));
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceServices.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,100 +0,0 @@
/*
* Copyright (C) 2020-2022 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.core.Service;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
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 ServiceStatsPage.
*/
public class ServiceStatsView
{
private static Logger logger = LoggerFactory.getLogger(ServiceStatsView.class);
/**
* Builds the.
*
* @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
{
logger.debug("Building service stats view {}…", service.get("service.name"));
TagDataManager data = new TagDataManager();
//
data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(service));
Services services = Services.of(service);
data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services));
data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services));
data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services));
data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services));
data.setContent("hostProviderHypervisorChart", ChartHtmlizer.htmlizeHostProviderHypervisorChart(services));
data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services));
data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services));
{
RegistrationStats stats = StatAgent.statRegistrationTypes(services);
data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats));
data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats));
data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats));
data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats));
data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats));
}
data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(services));
data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services));
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,122 +0,0 @@
/*
* Copyright (C) 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.Service;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.uptime.UptimeJournal;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ServiceUptimePage.
*/
public class ServiceUptimePage
{
private static Logger logger = LoggerFactory.getLogger(ServiceUptimePage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void build(final Service service) throws StatoolInfosException, IOException
{
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
UptimeJournal journal = HtmlizerContext.instance().getUptimeJournal();
String page = htmlize(service, journal);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-uptimes.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the all.
*
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void buildAll() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
for (Service service : federation.getServicesAll())
{
build(service);
}
}
/**
* Htmlize.
*
* @param service
* the service
* @param journal
* the journal
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Service service, final UptimeJournal journal) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setContent("headerView", ServiceHeaderView.htmlize(service));
Services services = new Services();
services.add(service);
data.setContent("uptimeView", UptimeView.htmlize(services, journal));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimePage.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("Disponibilité des services", service.getLocalFileBaseName() + "-uptimes.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building about page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,95 +0,0 @@
/*
* 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.Services;
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 ServicesPage.
*/
public class ServicesPage
{
private static Logger logger = LoggerFactory.getLogger(ServicesPage.class);
/**
* Builds the.
*
* @throws IOException
* @throws StatoolInfosException
*/
public static void build() throws IOException, StatoolInfosException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
logger.info("Htmlize services page.");
String page = ServicesPage.htmlize(federation.getServices());
FileUtils.write(new File(htmlizeDirectory, "services.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
* @param services
* the services
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Services services) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building services page.");
TagDataManager data = new TagDataManager();
data.setContent("serviceListView", ServiceListView.htmlize(services));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/services.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Services", "services.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,173 +0,0 @@
/*
* 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.apache.commons.lang3.StringUtils;
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.Organizations;
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;
/**
* The Class SocialNetworksPage.
*/
public class SocialNetworksPage
{
private static Logger logger = LoggerFactory.getLogger(SocialNetworksPage.class);
/**
* Builds the all.
*
* @throws StatoolInfosException
* @throws IOException
*/
public static void buildAll() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
logger.info("Htmlize social networks pages.");
Organizations organizations = federation.getOrganizations().filterBySocialNetworks();
String page = SocialNetworksPage.htmlize("Réseaux sociaux", organizations);
FileUtils.write(new File(htmlizeDirectory, "socialNetworks.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
* @param title
* the title
* @param organizations
* the organizations
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final String title, final Organizations organizations) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building social networks page {}…");
TagDataManager data = new TagDataManager();
data.setEscapedContent("title", title);
data.setContent("organizationCount", organizations.size());
int index = 0;
for (Organization organization : organizations)
{
data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml");
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getLogoFileName());
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName());
if (organization.getWebsiteURL() != null)
{
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString());
data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString());
}
if (StringUtils.isNotBlank(organization.getDiasporaWebpage()))
{
data.setAttribute("organizationListLine", index, "organizationListLineDiasporaImg", "class", "");
data.getIdData("organizationListLine", index, "organizationListLineDiasporaImg").getAttribute("class").setMode(DisplayMode.REPLACE);
data.setAttribute("organizationListLine", index, "organizationListLineDiasporaLink", "href", organization.getDiasporaWebpage());
data.setAttribute("organizationListLine", index, "organizationListLineDiaspora", "data-search", "1");
data.setAttribute("organizationListLine", index, "organizationListLineDiaspora", "data-order", "1");
}
if (StringUtils.isNotBlank(organization.getFunkwhaleWebpage()))
{
data.setAttribute("organizationListLine", index, "organizationListLineFunkwhaleImg", "class", "");
data.getIdData("organizationListLine", index, "organizationListLineFunkwhaleImg").getAttribute("class").setMode(DisplayMode.REPLACE);
data.setAttribute("organizationListLine", index, "organizationListLineFunkwhaleLink", "href", organization.getFunkwhaleWebpage());
data.setAttribute("organizationListLine", index, "organizationListLineFunkwhale", "data-search", "1");
data.setAttribute("organizationListLine", index, "organizationListLineFunkwhale", "data-order", "1");
}
if (StringUtils.isNotBlank(organization.getMastodonWebpage()))
{
data.setAttribute("organizationListLine", index, "organizationListLineMastodonImg", "class", "");
data.getIdData("organizationListLine", index, "organizationListLineMastodonImg").getAttribute("class").setMode(DisplayMode.REPLACE);
data.setAttribute("organizationListLine", index, "organizationListLineMastodonLink", "href", organization.getMastodonWebpage());
data.setAttribute("organizationListLine", index, "organizationListLineMastodon", "data-search", "1");
data.setAttribute("organizationListLine", index, "organizationListLineMastodon", "data-order", "1");
}
if (StringUtils.isNotBlank(organization.getMobilizonWebpage()))
{
data.setAttribute("organizationListLine", index, "organizationListLineMobilizonImg", "class", "");
data.getIdData("organizationListLine", index, "organizationListLineMobilizonImg").getAttribute("class").setMode(DisplayMode.REPLACE);
data.setAttribute("organizationListLine", index, "organizationListLineMobilizonLink", "href", organization.getMobilizonWebpage());
data.setAttribute("organizationListLine", index, "organizationListLineMobilizon", "data-search", "1");
data.setAttribute("organizationListLine", index, "organizationListLineMobilizon", "data-order", "1");
}
if (StringUtils.isNotBlank(organization.getPixelfedWebpage()))
{
data.setAttribute("organizationListLine", index, "organizationListLinePixelfedImg", "class", "");
data.getIdData("organizationListLine", index, "organizationListLinePixelfedImg").getAttribute("class").setMode(DisplayMode.REPLACE);
data.setAttribute("organizationListLine", index, "organizationListLinePixelfedLink", "href", organization.getPixelfedWebpage());
data.setAttribute("organizationListLine", index, "organizationListLinePixelfed", "data-search", "1");
data.setAttribute("organizationListLine", index, "organizationListLinePixelfed", "data-order", "1");
}
if (StringUtils.isNotBlank(organization.getPeertubeWebpage()))
{
data.setAttribute("organizationListLine", index, "organizationListLinePeertubeImg", "class", "");
data.getIdData("organizationListLine", index, "organizationListLinePeertubeImg").getAttribute("class").setMode(DisplayMode.REPLACE);
data.setAttribute("organizationListLine", index, "organizationListLinePeertubeLink", "href", organization.getPeertubeWebpage());
data.setAttribute("organizationListLine", index, "organizationListLinePeertube", "data-search", "1");
data.setAttribute("organizationListLine", index, "organizationListLinePeertube", "data-order", "1");
}
index += 1;
}
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/socialNetworks.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building social networks page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,109 +0,0 @@
/*
* Copyright (C) 2020 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.Services;
import fr.devinsy.statoolinfos.core.Software;
import fr.devinsy.statoolinfos.core.Softwares;
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 SoftwarePage.
*/
public class SoftwarePage
{
private static Logger logger = LoggerFactory.getLogger(SoftwarePage.class);
/**
* Builds the all.
*
* @throws StatoolInfosException
* @throws IOException
*/
public static void buildAll() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
logger.info("Htmlize software pages.");
Softwares catalog = federation.getSoftwares();
for (Software software : catalog.values())
{
Services services = federation.getServices().getBy(software);
String page = SoftwarePage.htmlize(software, services);
FileUtils.write(new File(htmlizeDirectory, "software-" + software.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
}
}
/**
* Builds the.
*
* @param software
* the software
* @param services
* the services
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Software software, final Services services) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building services page.");
TagDataManager data = new TagDataManager();
data.setEscapedContent("softwareName", software.getName());
data.setEscapedContent("softwareDescription", software.getDescription());
data.setContent("serviceCount", services.size());
data.setContent("serviceListView", ServiceListView.htmlize(services));
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/software.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Logiciels", "softwares.xhtml");
trail.add(software.getName(), "software-" + software.getTechnicalName() + ".xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building software page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,119 +0,0 @@
/*
* Copyright (C) 2020-2022 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.Categories;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.htmlize.CategoriesView.Mode;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.softwares.SoftwareStat;
import fr.devinsy.statoolinfos.stats.softwares.SoftwareStats;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class SoftwaresPage.
*/
public class SoftwaresPage
{
private static Logger logger = LoggerFactory.getLogger(SoftwaresPage.class);
/**
* Builds the.
*
* @throws StatoolInfosException
* @throws IOException
*/
public static void build() throws StatoolInfosException, IOException
{
Federation federation = HtmlizerContext.instance().getFederation();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
Categories categories = HtmlizerContext.instance().getCategories();
logger.info("Htmlize softwares page.");
SoftwareStats stats = StatAgent.statAllSoftwares(federation, categories);
String page = SoftwaresPage.htmlize(stats);
FileUtils.write(new File(htmlizeDirectory, "softwares.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
* @param stats
* the stats
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final SoftwareStats stats) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building softwares page.");
TagDataManager data = new TagDataManager();
data.setContent("softwareCount", stats.size());
int index = 0;
for (SoftwareStat stat : stats.sortByName())
{
data.setEscapedContent("softwareListLine", index, "softwareListLineNameLink", stat.getName());
data.setAttribute("softwareListLine", index, "softwareListLineNameLink", "href", "software-" + stat.getTechnicalName() + ".xhtml");
data.setContent("softwareListLine", index, "softwareListLineCategory", CategoriesView.build(stat.getCategories(), Mode.ALL));
data.setContent("softwareListLine", index, "softwareListLineOrganizationCount", stat.getOrganizationCount());
data.setContent("softwareListLine", index, "softwareListLineServiceCount", StatoolInfosUtils.defaultIfZero(stat.getServiceCount(), "😿"));
data.setContent("softwareListLine", index, "softwareListLineUserCount", StatoolInfosUtils.defaultIfZero(stat.getUserCount(), "😢"));
data.setContent("softwareListLine", index, "softwareListLineVisitCount", StatoolInfosUtils.defaultIfZero(stat.getVisitCount(), "😞"));
index += 1;
}
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/softwares.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Logiciels", "softwares.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building softwares page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,216 +0,0 @@
/*
* Copyright (C) 2021-2022 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.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.uptime.UptimeJournal;
import fr.devinsy.statoolinfos.uptime.UptimeStat;
import fr.devinsy.statoolinfos.uptime.UptimeStatus;
import fr.devinsy.strings.StringList;
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 UptimeView.
*/
public class UptimeView
{
private static Logger logger = LoggerFactory.getLogger(UptimeView.class);
/**
* Gets the stat.
*
* @param services
* the services
* @param date
* the date
* @return the stat
*/
public static UptimeStat getStat(final UptimeJournal journal, final Services services, final LocalDate date)
{
UptimeStat result;
result = new UptimeStat();
if ((services != null) || (date != null))
{
for (Service service : services.sortByName())
{
UptimeStat stat = journal.getStat(service.getWebsiteURL(), date);
if (stat.getStatus() == UptimeStatus.OK)
{
result.incOk();
}
else if (stat.getStatus() == UptimeStatus.WARNING)
{
result.incWarning();
}
else if (stat.getStatus() == UptimeStatus.ALERT)
{
result.incAlert();
}
else if (stat.getStatus() == UptimeStatus.ERROR)
{
result.incError();
}
else if (stat.getStatus() == UptimeStatus.VOID)
{
result.incVoid();
}
}
if (result.getCount() == 0)
{
result.setStatus(UptimeStatus.VOID);
}
else if (result.getOkCount() != result.getCount())
{
result.setStatus(UptimeStatus.ERROR);
}
else
{
result.setStatus(UptimeStatus.OK);
}
}
//
return result;
}
/**
* Htmlize.
*
* @param services
* the services
* @param journal
* the journal
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Services services, final UptimeJournal journal) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
LocalDate now = LocalDate.now();
UptimeStat last = getStat(journal, services, now);
data.setContent("okCount", last.getOkCount());
data.setContent("warningCount", last.getWarningCount());
data.setContent("alertCount", last.getAlertCount());
data.setContent("errorCount", last.getErrorCount());
data.setContent("voidCount", last.getVoidCount());
data.setContent("unavailableCount", last.getUnavailableCount());
for (int dayCount = 0; dayCount < 22; dayCount++)
{
LocalDate date = now.minusDays(dayCount);
//
data.setContent("lineHeader-" + dayCount, StringUtils.capitalize(date.format(DateTimeFormatter.ofPattern("EEEE", Locale.FRENCH)).substring(0, 2)));
data.setAttribute("lineHeader-" + dayCount, "title", date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")));
DayOfWeek weekDay = date.getDayOfWeek();
if ((weekDay == DayOfWeek.SUNDAY) || (weekDay == DayOfWeek.SATURDAY))
{
data.setAttribute("lineHeader-" + dayCount, "style", "background-color: gainsboro;");
}
else
{
data.setAttribute("lineHeader-" + dayCount, "style", "background-color: #ececec;");
}
}
int index = 0;
for (Service service : services.sortByName())
{
//
data.setAttribute("line", index, "lineLogo", "src", service.getLogoFileName());
data.setEscapedContent("line", index, "lineNameValue", service.getName());
data.setAttribute("line", index, "lineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
data.setAttribute("line", index, "lineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml");
data.setAttribute("line", index, "lineOrganizationLogo", "src", service.getOrganization().getLogoFileName());
data.setEscapedContent("line", index, "lineOrganizationValue", service.getOrganization().getName());
//
for (int dayCount = 0; dayCount < 22; dayCount++)
{
LocalDate date = now.minusDays(dayCount);
//
DayOfWeek weekDay = date.getDayOfWeek();
if ((weekDay == DayOfWeek.SUNDAY) || (weekDay == DayOfWeek.SATURDAY))
{
data.setAttribute("line", index, "uptime-" + dayCount, "style", "background-color: gainsboro;");
}
//
UptimeStat stat = journal.getStat(service.getWebsiteURL(), date);
StringList lines = new StringList();
String header = String.format("%d ok + %d err", stat.getOkCount(), stat.getErrorCount());
lines.add(header);
header = date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
lines.add(header);
if (stat.getErrorCount() > 0)
{
lines.addAll(journal.getUptimes(service.getWebsiteURL(), date).toTimeList());
}
data.setAttribute("line", index, "statusImg-" + dayCount, "src", "status-" + stat.getStatus().toString().toLowerCase() + ".png");
// String title = String.format("%d ok + %d err&#10;%s",
// stat.getOkCount(), stat.getErrorCount(),
// date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")));
data.setAttribute("line", index, "statusImg-" + dayCount, "title", lines.toStringSeparatedBy("&#10;"));
}
//
index += 1;
}
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimeView.xhtml", data).toString();
result = XidynUtils.extractBodyContent(content);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building about page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,100 +0,0 @@
/*
* Copyright (C) 2020 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.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.util.BuildInformation;
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 WebCharterView.
*/
public class WebCharterView
{
private static Logger logger = LoggerFactory.getLogger(WebCharterView.class);
/**
* Builds the.
*
* @param content
* the content
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final String content) throws StatoolInfosException
{
String result;
result = build(content, new BreadcrumbTrail());
//
return result;
}
/**
* Builds the.
*
* @param content
* the content
* @param trail
* the trail
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final String content, final BreadcrumbTrail trail) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building WebCharterView.");
TagDataManager data = new TagDataManager();
data.setContent("federationButton", HtmlizerContext.instance().getFederation().getName());
data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
data.setContent("webCharterContent", XidynUtils.extractBodyContent(content));
data.setContent("breadcrumbTrail", trail.toString());
data.setAttribute("federationStatsButton", "href", HtmlizerContext.instance().getFederation().getTechnicalName() + "-stats.xhtml");
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml", data).toString();
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building webCharter view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,27 +0,0 @@
<?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>
<h2>Introduction</h2>
<p>StatoolInfos is a simple tool of statistics about federation, organizations and services.</p>
<h2>License and source repository</h2>
<p>The original author of StatoolInfos is Christian P. MOMON.</p>
<p>StatoolInfo is a free software released under the GNU AGPL license.</p>
<p>The official source repository is:</p>
<ul>
<li><a href="https://forge.devinsy.fr/devinsy/statoolinfos">https://forge.devinsy.fr/devinsy/statoolinfos</a></li>
</ul>
<p>Contributors: Angie, MrFlos, Quentin Duchemin, Fabrice61, Thomas @TConstans, @labecasse, Antoine Jaba, @setop, Jérémy Collot,
Pilou, Kepon, Laurent Sleto…</p>
</body>
</html>

View file

@ -1,92 +0,0 @@
<?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_table" style="width: 1100px;">
<div class="center" >
<h2>Catégories</h2>
<div><span id="categoryCount">n/a</span> catégories</div>
</div>
<table id="categoryList" class="table_classic left">
<thead>
<tr>
<th class="" style="width: 300px;">Nom de la catégorie</th>
<th class="">Logiciels</th>
<th class="" style="width: 100px;">Services</th>
<th class="" style="width: 100px;">Organisations</th>
<th class="" style="width: 100px;">Utilisateurs mensuels</th>
<th class="" style="width: 100px;">Visites mensuelles</th>
</tr>
</thead>
<tbody>
<tr id="categoryListLine">
<td id="categoryListLineName" style="padding-top: 0; padding-bottom: 0;">
<a href="#" id="categoryListLineNameLink">
<img id="categoryListLineNameLogo" src="categories/default.svg" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
<span id="categoryListLineNameValue">n/a</span>
</a>
</td>
<td id="categoryListLineSoftwares">n/a</td>
<td id="categoryListLineServiceCount" class="td_number">n/a</td>
<td id="categoryListLineOrganizationCount" class="td_number">n/a</td>
<td id="categoryListLineUserCount" class="td_number">n/a</td>
<td id="categoryListLineVisitCount" class="td_number">n/a</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
$(document).ready(function()
{
$.extend($.fn.dataTable.ext.type.order,
{
"custom-sort-asc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return -1;
else if (isNaN(y))
return +1;
else
return x-y;
},
"custom-sort-desc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return +1;
else if (isNaN(y))
return -1;
else
return y-x;
}
});
$('#categoryList').DataTable(
{
paging: false,
ordering: true,
"order": [[ 0, "asc" ]],
language: dataTableFrench,
"columnDefs":
[
{ targets: 4, "type": 'custom-sort' },
{ targets: 5, "type": 'custom-sort' }
]
});
});
</script>
</body>
</html>

View file

@ -1,19 +0,0 @@
<?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" />
</head>
<body>
<div id="category">
<a id="categoryLink" href="#" title="Catégorie">
<img id="categoryLogo" src="categories/default.svg" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
<span id="categoryName">n/a</span>
</a>
</div>
</body>
</html>

View file

@ -1,30 +0,0 @@
<?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">
<div class="column">
<img id="categoryLogo" src="categories/default.svg" style="width: 100px; height: 100px;"/>
</div>
<div class="column" style="border: 0px solid red; max-width: 400px;">
<div id="categoryName" class="content_title">n/a</div>
<div class="content_subtitle"><a id="categoryDescription" href="#" style="text-decoration: none;">URL n/a</a></div>
</div>
</div>
<div class="center_table" style="width: 800px;">Logiciels : <span id="categorySoftwares">n/a</span></div>
<div>Nombre de services : <span id="serviceCount">n/a</span></div>
</div>
<div id="serviceListView" />
</body>
</html>

View file

@ -1,228 +0,0 @@
/*
* Copyright (C) 2020-2023 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.charts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The Class BarChart.
*/
public class BarChart
{
private static Logger logger = LoggerFactory.getLogger(BarChart.class);
private String title;
private boolean displayTitle;
private StringList labels;
private BarChartDatasets datasets;
private boolean stacked;
private boolean animated;
/**
* Instantiates a new bar chart.
*
* @param title
* the title
*/
public BarChart(final String title)
{
this.title = title;
this.displayTitle = true;
this.labels = new StringList();
this.datasets = new BarChartDatasets();
this.stacked = false;
this.animated = true;
}
/**
* Adds the.
*
* @param datasetIndex
* the dataset index
* @param value
* the value
* @param color
* the color
*/
public void add(final int datasetIndex, final double value, final ChartColor color)
{
this.datasets.get(datasetIndex).add(new BarChartData(null, value, color));
}
/**
* Adds the.
*
* @param label
* the label
* @param value
* the value
* @param color
* the color
*/
public void add(final String label, final double value, final ChartColor color)
{
this.labels.add(label);
this.datasets.get(0).add(new BarChartData(label, value, color));
}
/**
* Adds the dataset.
*
* @param name
* the name
* @return the int
*/
public int addDataset(final String name)
{
int result;
this.datasets.add(new BarChartDataset(name));
result = this.datasets.size() - 1;
//
return result;
}
/**
* Gets the colors.
*
* @return the colors
*/
public ChartColors getColors()
{
ChartColors result;
result = this.datasets.get(0).getColors();
//
return result;
}
/**
* Gets the dataset.
*
* @param index
* the index
* @return the dataset
*/
public BarChartDataset getDataset(final int index)
{
BarChartDataset result;
result = this.datasets.get(index);
//
return result;
}
/**
* Gets the datasets.
*
* @return the datasets
*/
public BarChartDatasets getDatasets()
{
return this.datasets;
}
/**
* Gets the labels.
*
* @return the labels
*/
public StringList getLabels()
{
StringList result;
result = this.labels;
//
return result;
}
/**
* Gets the title.
*
* @return the title
*/
public String getTitle()
{
return this.title;
}
/**
* Checks if is animated.
*
* @return true, if is animated
*/
public boolean isAnimated()
{
return this.animated;
}
/**
* Checks if is display title.
*
* @return true, if is display title
*/
public boolean isDisplayTitle()
{
return this.displayTitle;
}
/**
* Checks if is stacked.
*
* @return true, if is stacked
*/
public boolean isStacked()
{
return this.stacked;
}
/**
* Sets the animated.
*
* @param animated
* the new animated
*/
public void setAnimated(final boolean animated)
{
this.animated = animated;
}
public void setDisplayTitle(final boolean displayTitle)
{
this.displayTitle = displayTitle;
}
public void setStacked(final boolean stacked)
{
this.stacked = stacked;
}
public void setTitle(final String title)
{
this.title = title;
}
}

View file

@ -1,114 +0,0 @@
/*
* Copyright (C) 2020-2023 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.charts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class BarChartData.
*/
public class BarChartData
{
private static Logger logger = LoggerFactory.getLogger(BarChartData.class);
private String label;
private double value;
private ChartColor color;
/**
* Instantiates a new pie chart data.
*
* @param label
* the label
* @param value
* the value
* @param color
* the color
*/
public BarChartData(final String label, final double value, final ChartColor color)
{
this.label = label;
this.value = value;
this.color = color;
}
/**
* Gets the color.
*
* @return the color
*/
public ChartColor getColor()
{
return this.color;
}
/**
* Gets the label.
*
* @return the label
*/
public String getLabel()
{
return this.label;
}
/**
* Gets the value.
*
* @return the value
*/
public double getValue()
{
return this.value;
}
/**
* Sets the color.
*
* @param color
* the new color
*/
public void setColor(final ChartColor color)
{
this.color = color;
}
/**
* Sets the label.
*
* @param label
* the new label
*/
public void setLabel(final String label)
{
this.label = label;
}
/**
* Sets the value.
*
* @param value
* the new value
*/
public void setValue(final double value)
{
this.value = value;
}
}

View file

@ -1,133 +0,0 @@
/*
* Copyright (C) 2020-2023 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.charts;
import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class BarChartDataset.
*/
public class BarChartDataset extends ArrayList<BarChartData>
{
private static final long serialVersionUID = -5230173915580487951L;
private static Logger logger = LoggerFactory.getLogger(BarChartDataset.class);
private String name;
private int borderWidth;
/**
* Instantiates a new bar chart dataset.
*
* @param name
* the name
*/
public BarChartDataset(final String name)
{
super();
this.name = name;
this.borderWidth = 1;
}
/**
* Gets the border width.
*
* @return the border width
*/
public int getBorderWidth()
{
return this.borderWidth;
}
/**
* Gets the colors.
*
* @return the colors
*/
public ChartColors getColors()
{
ChartColors result;
result = new ChartColors();
for (BarChartData data : this)
{
result.add(data.getColor());
}
//
return result;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName()
{
return this.name;
}
/**
* Gets the values.
*
* @return the values
*/
public double[] getValues()
{
double[] result;
result = new double[this.size()];
int index = 0;
for (BarChartData data : this)
{
result[index] = data.getValue();
index += 1;
}
//
return result;
}
/**
* Sets the border width.
*
* @param borderWidth
* the new border width
*/
public void setBorderWidth(final int borderWidth)
{
this.borderWidth = borderWidth;
}
/**
* Sets the name.
*
* @param name
* the new name
*/
public void setName(final String name)
{
this.name = name;
}
}

View file

@ -1,81 +0,0 @@
/*
* 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.charts;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class BarChartDatasets.
*/
public class BarChartDatasets extends ArrayList<BarChartDataset>
{
private static final long serialVersionUID = 306645976348400468L;
private static Logger logger = LoggerFactory.getLogger(BarChartDatasets.class);
/**
* Instantiates a new bar chart datasets.
*/
public BarChartDatasets()
{
super();
}
/**
* Gets the by name.
*
* @param name
* the name
* @return the by name
*/
public BarChartDataset get(final String name)
{
BarChartDataset result;
boolean ended = false;
result = null;
Iterator<BarChartDataset> iterator = this.iterator();
while (!ended)
{
if (iterator.hasNext())
{
BarChartDataset dataset = iterator.next();
if (StringUtils.equals(dataset.getName(), name))
{
ended = true;
result = dataset;
}
}
else
{
ended = true;
result = null;
}
}
//
return result;
}
}

View file

@ -1,167 +0,0 @@
/*
* Copyright (C) 2020 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.charts;
import java.io.IOException;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.strings.StringList;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class BarChartView.
*/
public class BarChartView
{
private static Logger logger = LoggerFactory.getLogger(BarChartView.class);
/**
* Builds the.
*
* @param chart
* the bar
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final BarChart chart) throws StatoolInfosException
{
String result;
try
{
String source = XidynUtils.load(BarChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/barChartView.xhtml"));
result = XidynUtils.extractBodyContent(source);
result = result.replace("myChart", "myChart_" + DigestUtils.sha1Hex(chart.getTitle() + "barChart" + RandomStringUtils.random(10)));
StringList lines = new StringList();
lines.append("{\n");
lines.append(" type: 'bar',\n");
lines.append(" data: \n");
lines.append(" {\n");
lines.append(" labels: ").append(ChabuUtils.toJSonStrings(chart.getLabels())).appendln(",");
lines.append(" datasets: \n");
lines.append(" [\n");
for (BarChartDataset dataset : chart.getDatasets())
{
lines.append(" {\n");
lines.append(" label: '").append(escape(dataset.getName())).appendln("',");
lines.append(" data: ").append(ChabuUtils.toJSonNumbers(dataset.getValues())).appendln(",");
lines.append(" backgroundColor: ").append(ChabuUtils.toJSonStrings(dataset.getColors().getCodes())).appendln(",");
lines.append(" borderColor: ").append(ChabuUtils.toJSonStrings(dataset.getColors().getLights())).appendln(",");
lines.append(" borderWidth: ").append(dataset.getBorderWidth()).appendln(",");
lines.append(" },\n");
}
lines.append(" ]\n");
lines.append(" },\n");
lines.append(" options: \n");
lines.append(" {\n");
lines.append(" maintainAspectRatio: false,\n");
lines.append(" display: true,\n");
lines.append(" responsive: true,\n");
lines.append(" legend: \n");
lines.append(" {\n");
lines.append(" display: false,\n");
lines.append(" position: 'top',\n");
lines.append(" },\n");
lines.append(" title:\n");
lines.append(" {\n");
lines.append(" display: true,\n");
lines.append(" text: '").append(escape(chart.getTitle())).appendln("'");
lines.append(" },\n");
lines.append(" tooltips:\n");
lines.append(" {\n");
lines.append(" mode: 'index',\n");
lines.append(" intersect: false\n");
lines.append(" },\n");
lines.append(" scales: \n");
lines.append(" {\n");
lines.append(" xAxes:\n");
lines.append(" [{\n");
lines.append(" ticks:\n");
lines.append(" {\n");
lines.append(" beginAtZero: true\n");
lines.append(" },\n");
lines.append(" stacked: ").append(chart.isStacked()).appendln(",");
lines.append(" }],\n");
lines.append(" yAxes:\n");
lines.append(" [{\n");
lines.append(" ticks:\n");
lines.append(" {\n");
lines.append(" beginAtZero: true,\n");
lines.append(" suggestedMax: 10,\n");
lines.append(" precision: 0,\n");
lines.append(" callback: function(value, index, values)");
lines.append(" {\n");
lines.append(
" if (value > 1000000000) return value/1000000000 + 'G'; else if (value > 1000000) return value/1000000 + 'M'; else if (value > 1000) return value/1000 + 'k';else return value;\n");
lines.append(" }\n");
lines.append(" },\n");
lines.append(" stacked: ").append(chart.isStacked()).appendln(",");
lines.append(" }]\n");
lines.append(" },\n");
lines.append(" animation:\n");
lines.append(" {\n");
lines.append(" duration: ").append(chart.isAnimated() ? 1000 : 0).appendln();
lines.append(" }\n");
lines.append(" }\n");
lines.append("}");
result = result.replaceFirst("\\{[\\s\\S]*\\}", lines.toString());
}
catch (IOException exception)
{
throw new StatoolInfosException("Error building bar months chart view: " + exception.getMessage(), exception);
}
//
return result;
}
/**
* Escape.
*
* @param input
* the input
* @return the string
*/
public static String escape(final String input)
{
String result;
if (StringUtils.isBlank(input))
{
result = "";
}
else
{
result = input.replace("'", "\\\\'");
}
//
return result;
}
}

View file

@ -1,718 +0,0 @@
/*
* 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.charts;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Iterator;
import java.util.Locale;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class ChabuUtils.
*/
public class ChabuUtils
{
private static Logger logger = LoggerFactory.getLogger(ChabuUtils.class);
public static final DateTimeFormatter PATTERN_SHORTDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy", Locale.FRANCE);
public static final DateTimeFormatter PATTERN_LONGDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE);
/**
* Builds the month labels.
*
* @param start
* the start
* @param end
* the end
* @return the string list
*/
public static StringList buildMonthLabels(final LocalDate start, final LocalDate end)
{
StringList result;
result = new StringList();
if (start != null)
{
LocalDate normalizedEnd = normaliseMonthDate(end);
LocalDate date = normaliseMonthDate(start);
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
{
String label = date.format(DateTimeFormatter.ISO_DATE);
result.add(label);
date = date.plusMonths(1);
}
}
//
return result;
}
/**
* Builds the week labels.
*
* @param start
* the start
* @return the string list
*/
public static StringList buildWeekLabels(final LocalDate start)
{
StringList result;
result = buildWeekLabels(start, LocalDate.now());
//
return result;
}
/**
* Builds the week labels.
*
* @param start
* the start
* @param end
* the end
* @return the string list
*/
public static StringList buildWeekLabels(final LocalDate start, final LocalDate end)
{
StringList result;
result = new StringList();
if (start != null)
{
LocalDate normalizedEnd = normaliseWeekDate(end);
LocalDate date = normaliseWeekDate(start);
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
{
String label = date.format(DateTimeFormatter.ISO_DATE);
result.add(label);
date = date.plusWeeks(1);
}
}
//
return result;
}
/**
* Builds the year month alpha labels.
*
* @param start
* the start
* @param end
* the end
* @return the string list
*/
public static StringList buildYearMonthAlphaLabels(final LocalDate start, final LocalDate end)
{
StringList result;
result = new StringList();
if (start != null)
{
LocalDate normalizedEnd = normaliseMonthDate(end);
LocalDate date = normaliseMonthDate(start);
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
{
String label = date.format(DateTimeFormatter.ofPattern("YYYY-MMM", Locale.FRANCE));
result.add(label);
date = date.plusMonths(1);
}
}
//
return result;
}
/**
* Builds the year month labels.
*
* @param start
* the start
* @param end
* the end
* @return the string list
*/
public static StringList buildYearMonthLabels(final LocalDate start, final LocalDate end)
{
StringList result;
result = new StringList();
if (start != null)
{
LocalDate normalizedEnd = normaliseMonthDate(end);
LocalDate date = normaliseMonthDate(start);
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
{
String label = date.format(DateTimeFormatter.ofPattern("YYYY-MM", Locale.FRANCE));
result.add(label);
date = date.plusMonths(1);
}
}
//
return result;
}
/**
* Escape JSONXML.
*
* @param data
* the data
* @return the string
*/
public static String escapeJSONXML(final String data)
{
String result;
if (data == null)
{
result = null;
}
else
{
result = XidynUtils.escapeXmlBlank(data.replace("'", "\\\\'"));
}
//
return result;
}
/**
* Normalise month date.
*
* @param source
* the source
* @return the local date
*/
public static LocalDate normaliseMonthDate(final LocalDate source)
{
LocalDate result;
if (source == null)
{
result = source;
}
else
{
result = source.minusDays(source.getDayOfMonth() - 1);
}
//
return result;
}
/**
* Normalise week date.
*
* @param source
* the source
* @return the local date
*/
public static LocalDate normaliseWeekDate(final LocalDate source)
{
LocalDate result;
if (source == null)
{
result = source;
}
else
{
result = source.minusDays(source.getDayOfWeek().getValue() - 1);
}
//
return result;
}
/**
* Normalized month count list.
*
* @param source
* the source
* @param start
* the start
* @param end
* the end
* @return the date count list
*/
public static DateCountList normalizedMonthCountList(final DateCountList source, final LocalDate start, final LocalDate end)
{
DateCountList result;
result = new DateCountList();
LocalDate normalizedEnd = normaliseMonthDate(end);
LocalDate date = normaliseMonthDate(start);
int index = source.indexOf(toYearMonth(start));
if (index == -1)
{
index = 0;
}
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
{
String dateToken = toYearMonth(date);
long count;
if (index < source.size())
{
DateCount current = source.get(index);
// ChabuUtils.logger.info("===> " + dateToken + " " +
// current.getDate());
if (StringUtils.equals(current.getDate(), dateToken))
{
count = current.getCount();
index += 1;
}
else
{
count = 0;
}
}
else
{
count = 0;
}
result.add(new DateCount(dateToken, count));
date = date.plusMonths(1);
}
//
return result;
}
/**
* Normalized week count list.
*
* @param source
* the source
* @param start
* the start
* @param end
* the end
* @return the date count list
*/
public static DateCountList normalizedWeekCountList(final DateCountList source, final LocalDate start, final LocalDate end)
{
DateCountList result;
result = new DateCountList();
LocalDate normalizedEnd = normaliseWeekDate(end);
LocalDate date = normaliseWeekDate(start);
int index = source.indexOf(toYearWeek(start));
if (index == -1)
{
index = 0;
}
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
{
String dateToken = toYearWeek(date);
long count;
if (index < source.size())
{
DateCount current = source.get(index);
// AgirStatoolUtils.logger.info("===> " + dateToken + " " +
// current.getDate());
if (StringUtils.equals(current.getDate(), dateToken))
{
count = current.getCount();
index += 1;
}
else
{
count = 0;
}
}
else
{
count = 0;
}
result.add(new DateCount(dateToken, count));
date = date.plusWeeks(1);
}
//
return result;
}
/**
* Builds the week created count list.
*
* @param source
* the source
* @param start
* the start
* @return the date count list
*/
public static DateCountList normalizedWeekCountList(final DateCountMap source, final LocalDate start)
{
DateCountList result;
result = new DateCountList();
LocalDate date = normaliseWeekDate(start);
LocalDate end = normaliseWeekDate(LocalDate.now());
long count = 0;
while (date.isBefore(end) || date.isEqual(end))
{
String dateToken = toYearWeek(date);
DateCount current = source.get(dateToken);
if (current != null)
{
count += current.getCount();
}
result.add(new DateCount(dateToken, count));
date = date.plusWeeks(1);
}
//
return result;
}
/**
* Gets the current time in long format.
*
* @return the long
*/
public static long now()
{
return new Date().getTime();
}
/**
* Select stat indicator.
*
* @param value
* the value
* @return the string
*/
public static String selectStatIndicator(final long value)
{
String result;
if (value < 10)
{
result = null;
}
else if (value < 20)
{
result = "caution";
}
else if (value < 50)
{
result = "warning";
}
else
{
result = "alert";
}
//
return result;
}
/**
* Select unassigned indicator.
*
* @param value
* the value
* @return the string
*/
public static String selectUnassignedIndicator(final long value)
{
String result;
if (value == 0)
{
result = null;
}
else
{
result = "alert";
}
//
return result;
}
/**
* To human long.
*
* @param value
* the value
* @return the string
*/
public static String toHumanLong(final LocalDateTime value)
{
String result;
result = toHumanLong(value, null);
//
return result;
}
/**
* To human long.
*
* @param value
* the value
* @param defaultValue
* the default value
* @return the string
*/
public static String toHumanLong(final LocalDateTime value, final String defaultValue)
{
String result;
if (value == null)
{
result = null;
}
else
{
result = value.format(PATTERN_LONGDATE);
}
//
return result;
}
/**
* To human short.
*
* @param value
* the value
* @return the string
*/
public static String toHumanShort(final LocalDateTime value)
{
String result;
result = toHumanShort(value, null);
//
return result;
}
/**
* To human short.
*
* @param value
* the value
* @param defaultValue
* the default value
* @return the string
*/
public static String toHumanShort(final LocalDateTime value, final String defaultValue)
{
String result;
if (value == null)
{
result = null;
}
else
{
result = value.format(PATTERN_SHORTDATE);
}
//
return result;
}
public static Integer toInteger(final String value)
{
Integer result;
if ((value == null) || (!NumberUtils.isDigits(value)))
{
result = null;
}
else
{
result = Integer.parseInt(value);
}
//
return result;
}
/**
* To J son numbers.
*
* @param values
* the values
* @return the string
*/
public static String toJSonNumbers(final double[] values)
{
String result;
StringList data = new StringList(values);
result = toJSonNumbers(data);
//
return result;
}
/**
* To J son numbers.
*
* @param values
* the values
* @return the string
*/
public static String toJSonNumbers(final StringList values)
{
String result;
result = StringsUtils.toString(values, "[", ",", "]");
//
return result;
}
/**
* To J son numbers.
*
* @param labels
* the labels
* @param values
* the source
* @return the string
*/
public static String toJSonNumbers(final StringList labels, final StringList values)
{
String result;
Iterator<String> labelIterator = labels.iterator();
Iterator<String> valueIterator = values.iterator();
StringList buffer = new StringList();
while (labelIterator.hasNext())
{
String label = labelIterator.next();
String value = valueIterator.next();
buffer.append(String.format("{t: '%s', y: %s}", label, value));
}
result = StringsUtils.toString(buffer, "[", ",", "]");
//
return result;
}
/**
* To Json strings.
*
* @param source
* the source
* @return the string
*/
public static String toJSonStrings(final StringList source)
{
String result;
StringList target = new StringList();
target.append("[");
for (String string : source)
{
target.append("'");
target.append(escapeJSONXML(string));
target.append("'");
target.append(",");
}
if (!source.isEmpty())
{
target.removeLast();
}
target.append("]");
result = target.toString();
//
return result;
}
/**
* To year month.
*
* @param source
* the source
* @return the string
*/
public static String toYearMonth(final LocalDate source)
{
String result;
if (source == null)
{
result = null;
}
else
{
result = source.format(DateTimeFormatter.ofPattern("YYYYMM", Locale.FRANCE));
}
//
return result;
}
/**
* To year week.
*
* @param source
* the source
* @return the string
*/
public static String toYearWeek(final LocalDate source)
{
String result;
if (source == null)
{
result = null;
}
else
{
result = source.format(DateTimeFormatter.ofPattern("YYYYww", Locale.FRANCE));
}
//
return result;
}
}

View file

@ -1,104 +0,0 @@
/*
* 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.charts;
/**
* The Enum ChartColor.
*/
public enum ChartColor
{
// https://html-color-codes.info/
GREEN0("rgb(0, 128, 0)"), // #008000
GREEN("rgb(75, 192, 192)"), // #4bc0c0
YELLOW("rgb(255, 205, 86)"), // #ffcd56
ORANGE("rgb(255, 159, 64)"), // #ff9f40
RED("rgb(255, 99, 132)"), // #ff6384
HOTPINK("rgb(255, 105, 180)"), // #FF69B4
VIOLET("rgb(190,129,247)"), // #be81f7
PURPLE("rgb(153, 102, 255)"), // #9966ff
BLUE("rgb(54, 162, 235)"), // #36a2eb
TURQUOISE("rgb(64, 224, 208)"), // #40e0d0
GREY("rgb(201, 203, 207)"); // #c9cbcf
private String code;
private String light;
/**
* Instantiates a new chart colors.
*
* @param code
* the code
*/
ChartColor(final String code)
{
this.code = code;
this.light = code.replace(")", ", 0.2)");
}
/**
* Code.
*
* @return the string
*/
public String code()
{
String result;
result = this.code;
//
return result;
}
/**
* Light.
*
* @return the string
*/
public String light()
{
String result;
result = this.light;
//
return result;
}
/**
* To list.
*
* @return the chart colors
*/
public static ChartColors valueList()
{
ChartColors result;
result = new ChartColors();
ChartColor[] values = values();
for (int index = 0; index < values.length; index++)
{
result.add(values[index]);
}
//
return result;
}
}

View file

@ -1,111 +0,0 @@
/*
* Copyright (C) 2020 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.charts;
import java.util.ArrayList;
import fr.devinsy.strings.StringList;
/**
* The Class ChartColors.
*/
public class ChartColors extends ArrayList<ChartColor>
{
private static final long serialVersionUID = -8084994308407843536L;
/**
* Instantiates a new chart colors.
*/
public ChartColors()
{
super();
}
/**
* Adds the all.
*
* @param colors
* the colors
*/
public void addAll(final ChartColor[] colors)
{
for (int index = 0; index < colors.length; index++)
{
add(colors[index]);
}
}
/**
* Gets the ChartColor of the index with safe overflow.
*
* @param index
* the index
* @return the chart color
*/
@Override
public ChartColor get(final int index)
{
ChartColor result;
result = super.get(index % size());
//
return result;
}
/**
* Gets the colors.
*
* @return the colors
*/
public StringList getCodes()
{
StringList result;
result = new StringList();
for (ChartColor color : this)
{
result.add(color.code());
}
//
return result;
}
/**
* Gets the light colors.
*
* @return the light colors
*/
public StringList getLights()
{
StringList result;
result = new StringList();
for (ChartColor color : this)
{
result.add(color.light());
}
//
return result;
}
}

View file

@ -1,93 +0,0 @@
/*
* Copyright (C) 2020-2023 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.charts;
import org.apache.commons.lang3.StringUtils;
/**
* The Class Projects.
*/
public class DateCount
{
private String date;
private long count;
/**
* Instantiates a new date count.
*
* @param date
* the date
* @param count
* the count
*/
public DateCount(final String date, final long count)
{
setDate(date);
this.count = count;
}
/**
* Gets the count.
*
* @return the count
*/
public long getCount()
{
return this.count;
}
/**
* Gets the date.
*
* @return the date
*/
public String getDate()
{
return this.date;
}
/**
* Sets the count.
*
* @param count
* the new count
*/
public void setCount(final long count)
{
this.count = count;
}
/**
* Sets the date.
*
* @param date
* the new date
*/
public void setDate(final String date)
{
if (StringUtils.isBlank(date))
{
throw new IllegalArgumentException("Null parameter.");
}
else
{
this.date = date;
}
}
}

View file

@ -1,112 +0,0 @@
/*
* Copyright (C) 2020 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.charts;
import java.util.ArrayList;
import org.apache.commons.lang3.StringUtils;
import fr.devinsy.strings.StringList;
/**
* The Class Projects.
*/
public class DateCountList extends ArrayList<DateCount>
{
private static final long serialVersionUID = -5526492552751712533L;
/**
* Instantiates a new date count map.
*/
public DateCountList()
{
super();
}
/**
* Instantiates a new date count list.
*
* @param capacity
* the capacity
*/
public DateCountList(final int capacity)
{
super(capacity);
}
/**
* Indexof.
*
* @param dateToken
* the date token
* @return the int
*/
public int indexOf(final String dateToken)
{
int result;
boolean ended = false;
result = -1;
int index = 0;
while (!ended)
{
if (index < this.size())
{
DateCount current = get(index);
if (StringUtils.equals(current.getDate(), dateToken))
{
ended = true;
result = index;
}
else
{
index += 1;
}
}
else
{
ended = true;
result = -1;
}
}
//
return result;
}
/**
* To value list.
*
* @return the string list
*/
public StringList toValueList()
{
StringList result;
result = new StringList();
for (DateCount item : this)
{
result.append(item.getCount());
}
//
return result;
}
}

View file

@ -1,37 +0,0 @@
/*
* Copyright (C) 2020 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.charts;
import java.util.HashMap;
/**
* The Class Projects.
*/
public class DateCountMap extends HashMap<String, DateCount>
{
private static final long serialVersionUID = -5526492552751712533L;
/**
* Instantiates a new date count map.
*/
public DateCountMap()
{
super();
}
}

View file

@ -1,52 +0,0 @@
/*
* Copyright (C) 2020 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.charts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
/**
* The Class DoughnutChartView.
*/
public class DoughnutChartView
{
private static Logger logger = LoggerFactory.getLogger(DoughnutChartView.class);
/**
* Builds the.
*
* @param pie
* the pie
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final PieChart pie) throws StatoolInfosException
{
String result;
pie.setType(PieChart.PieType.DOUGHNUT);
result = PieChartView.build(pie);
//
return result;
}
}

View file

@ -1,88 +0,0 @@
/*
* Copyright (C) 2020 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.charts;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.strings.StringList;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class projectsRawPageBuilder.
*/
public class FooChartView
{
private static Logger logger = LoggerFactory.getLogger(FooChartView.class);
public static String build() throws StatoolInfosException
{
String result;
try
{
String source = XidynUtils.load(FooChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml"));
String code = XidynUtils.extractBodyContent(source);
code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(LocalDateTime.now() + "lineChart"));
// DO MonthsBarChart
LocalDate start = LocalDate.parse("2020-01-01");
LocalDate end = LocalDate.parse("2020-12-31");
DateCountList dates = new DateCountList();
dates.add(new DateCount("202001", 7));
dates.add(new DateCount("202002", 9));
dates.add(new DateCount("202003", 4));
dates.add(new DateCount("202004", 2));
dates.add(new DateCount("202005", 1));
dates.add(new DateCount("202006", 7));
StringList labels = ChabuUtils.buildYearMonthLabels(start, end);
StringList values = ChabuUtils.normalizedMonthCountList(dates, start, end).toValueList();
code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values));
/*
StringList labels = ChabuUtils.buildWeekLabels(LocalDate.parse("2020-01-01"), LocalDate.parse("2020-12-31"));
DateCountList dates = project.issueStats().getWeekCreatedIssueCounts();
StringList values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList();
code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values));
dates = project.issueStats().getWeekConcludedIssueCounts();
values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList();
code = code.replaceAll("data: \\[.*\\] ", "data: " + ChabuUtils.toJSonNumbers(labels, values));
*/
result = code.toString();
}
catch (IOException exception)
{
throw new StatoolInfosException("Error building foo charts view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,88 +0,0 @@
/*
* Copyright (C) 2020 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.charts;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.strings.StringList;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class projectsRawPageBuilder.
*/
public class LineMonthsChartView
{
private static Logger logger = LoggerFactory.getLogger(LineMonthsChartView.class);
public static String build() throws StatoolInfosException
{
String result;
try
{
String source = XidynUtils.load(LineMonthsChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml"));
String code = XidynUtils.extractBodyContent(source);
code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(LocalDateTime.now() + "lineChart"));
// DO MonthsBarChart
LocalDate start = LocalDate.parse("2020-01-01");
LocalDate end = LocalDate.parse("2020-12-31");
DateCountList dates = new DateCountList();
dates.add(new DateCount("202001", 7));
dates.add(new DateCount("202002", 9));
dates.add(new DateCount("202003", 4));
dates.add(new DateCount("202004", 2));
dates.add(new DateCount("202005", 1));
dates.add(new DateCount("202006", 7));
StringList labels = ChabuUtils.buildYearMonthLabels(start, end);
StringList values = ChabuUtils.normalizedMonthCountList(dates, start, end).toValueList();
code = code.replaceFirst("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values));
/*
StringList labels = ChabuUtils.buildWeekLabels(LocalDate.parse("2020-01-01"), LocalDate.parse("2020-12-31"));
DateCountList dates = project.issueStats().getWeekCreatedIssueCounts();
StringList values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList();
code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values));
dates = project.issueStats().getWeekConcludedIssueCounts();
values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList();
code = code.replaceAll("data: \\[.*\\] ", "data: " + ChabuUtils.toJSonNumbers(labels, values));
*/
result = code.toString();
}
catch (IOException exception)
{
throw new StatoolInfosException("Error building foo charts view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,240 +0,0 @@
/*
* 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.charts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The Class PieChart.
*/
public class PieChart
{
private static Logger logger = LoggerFactory.getLogger(PieChart.class);
public enum PieType
{
DOUGHNUT,
PIE
}
public enum Position
{
TOP,
RIGHT,
BOTTOM,
LEFT
}
private String title;
private boolean titleVisible;
private Position titlePosition;
private PieType type;
private PieChartDatas datas;
private boolean legendVisible;
private Position legendPosition;
/**
* Instantiates a new pie chart.
*/
public PieChart(final String title)
{
this.title = title;
this.titleVisible = true;
this.titlePosition = Position.TOP;
this.type = PieType.PIE;
this.datas = new PieChartDatas();
this.legendVisible = true;
this.legendPosition = Position.TOP;
}
/**
* Adds the.
*
* @param label
* the label
* @param value
* the value
* @param color
* the color
*/
public void add(final String label, final double value, final ChartColor color)
{
this.datas.add(new PieChartData(label, value, color));
}
/**
* Gets the colors.
*
* @return the colors
*/
public StringList getColors()
{
StringList result;
result = new StringList();
for (PieChartData data : this.datas)
{
result.add(data.getColor().code());
}
//
return result;
}
public PieChartDatas getDatas()
{
return this.datas;
}
/**
* Gets the labels.
*
* @return the labels
*/
public StringList getLabels()
{
StringList result;
result = new StringList();
for (PieChartData data : this.datas)
{
result.add(data.getLabel());
}
//
return result;
}
public Position getLegendPosition()
{
return this.legendPosition;
}
/**
* Gets the legend position value.
*
* @return the legend position value
*/
public String getLegendPositionValue()
{
String result;
result = this.legendPosition.toString().toLowerCase();
//
return result;
}
public String getTitle()
{
return this.title;
}
public Position getTitlePosition()
{
return this.titlePosition;
}
/**
* Gets the title position value.
*
* @return the title position value
*/
public String getTitlePositionValue()
{
String result;
result = this.titlePosition.toString().toLowerCase();
//
return result;
}
public PieType getType()
{
return this.type;
}
/**
* Gets the values.
*
* @return the values
*/
public double[] getValues()
{
double[] result;
result = new double[this.datas.size()];
int index = 0;
for (PieChartData data : this.datas)
{
result[index] = data.getValue();
index += 1;
}
//
return result;
}
public boolean isLegendVisible()
{
return this.legendVisible;
}
public boolean isTitleVisible()
{
return this.titleVisible;
}
public void setLegendPosition(final Position legendPosition)
{
this.legendPosition = legendPosition;
}
public void setLegendVisible(final boolean legendVisible)
{
this.legendVisible = legendVisible;
}
public void setTitle(final String title)
{
this.title = title;
}
public void setTitlePosition(final Position titlePosition)
{
this.titlePosition = titlePosition;
}
public void setTitleVisible(final boolean titleVisible)
{
this.titleVisible = titleVisible;
}
public void setType(final PieType type)
{
this.type = type;
}
}

View file

@ -1,81 +0,0 @@
/*
* 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.charts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class PieChartData.
*/
public class PieChartData
{
private static Logger logger = LoggerFactory.getLogger(PieChartData.class);
private String label;
private double value;
private ChartColor color;
/**
* Instantiates a new pie chart data.
*
* @param label
* the label
* @param value
* the value
* @param color
* the color
*/
public PieChartData(final String label, final double value, final ChartColor color)
{
this.label = label;
this.value = value;
this.color = color;
}
public ChartColor getColor()
{
return this.color;
}
public String getLabel()
{
return this.label;
}
public double getValue()
{
return this.value;
}
public void setColor(final ChartColor color)
{
this.color = color;
}
public void setLabel(final String label)
{
this.label = label;
}
public void setValue(final double value)
{
this.value = value;
}
}

View file

@ -1,42 +0,0 @@
/*
* Copyright (C) 2020 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.charts;
import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class PieChartDatas.
*/
public class PieChartDatas extends ArrayList<PieChartData>
{
private static final long serialVersionUID = 6300072061870020566L;
private static Logger logger = LoggerFactory.getLogger(PieChartDatas.class);
/**
* Instantiates a new pie chart datas.
*/
public PieChartDatas()
{
super();
}
}

View file

@ -1,73 +0,0 @@
/*
* Copyright (C) 2020 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.charts;
import java.io.IOException;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.strings.StringList;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class PieChartView.
*/
public class PieChartView
{
private static Logger logger = LoggerFactory.getLogger(PieChartView.class);
/**
* Builds the.
*
* @param pie
* the pie
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final PieChart pie) throws StatoolInfosException
{
String result;
try
{
String source = XidynUtils.load(PieChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/pieChartView.xhtml"));
result = XidynUtils.extractBodyContent(source);
result = result.replaceFirst("type: '.*'", "type: '" + pie.getType().toString().toLowerCase() + "'");
result = result.replace("myChart", "myChart_" + DigestUtils.sha1Hex(pie.getTitle() + "PieChart"));
result = result.replaceFirst("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(new StringList(pie.getValues())));
result = result.replaceFirst("backgroundColor: \\[.*\\]", "backgroundColor: " + ChabuUtils.toJSonStrings(pie.getColors()));
result = result.replaceFirst("text: '.*'", "text: '" + pie.getTitle().replace("'", "\\\\'") + "'");
result = result.replaceFirst("labels: \\[.*\\]", "labels: " + ChabuUtils.toJSonStrings(pie.getLabels()));
result = result.replaceFirst("legend: .*,", String.format("legend: { display: %b, position: '%s' },", pie.isLegendVisible(), pie.getLegendPositionValue()));
result = result.replaceFirst("title: .*,",
String.format("title: { display: %b, position: '%s', text: '%s' },", pie.isTitleVisible(), pie.getTitlePositionValue(), pie.getTitle().replace("'", "\\\\'")));
}
catch (IOException exception)
{
throw new StatoolInfosException("Error building bar months chart view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -1,77 +0,0 @@
<?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>
<script src="Chart.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
</head>
<body>
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx,
{
type: 'bar',
data:
{
labels: ['New', 'Started', 'Waiting', 'Maybe', 'Resolved', 'Closed'],
datasets:
[{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: ['rgba(255, 99, 132, 0.2)','rgba(54, 162, 235, 0.2)','rgba(255, 206, 86, 0.2)','rgba(75, 192, 192, 0.2)','rgba(153, 102, 255, 0.2)','rgba(255, 159, 64, 0.2)'],
borderColor: ['rgba(255, 99, 132, 1)','rgba(54, 162, 235, 1)','rgba(255, 206, 86, 1)','rgba(75, 192, 192, 1)','rgba(153, 102, 255, 1)','rgba(255, 159, 64, 1)'],
borderWidth: 1
}]
},
options:
{
maintainAspectRatio: false,
display: true,
responsive: true,
legend:
{
display: false,
position: 'top',
},
title:
{
display: true,
text: 'a title'
},
tooltips:
{
mode: 'index',
intersect: false
},
scales:
{
xAxes:
[{
ticks:
{
beginAtZero: true
}
}],
yAxes:
[{
ticks:
{
beginAtZero: true,
suggestedMax: 10,
precision: 0
}
}]
}
}
});
</script>
</body>
</html>

View file

@ -1,69 +0,0 @@
<?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>
<script src="Chart.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
</head>
<body>
<div style="width: 100%; height: 100%; text-align: center; margin: 0 0; border: 1px solid red;" title="description">
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx,
{
type: 'bar',
data:
{
labels: ['New', 'Started', 'Waiting', 'Maybe', 'Resolved', 'Closed'],
datasets:
[{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: 'rgb(54, 162, 235, 0.2)',
borderColor: 'rgb(54, 162, 235)',
borderWidth: 1
}]
},
options:
{
maintainAspectRatio: false,
scales:
{
xAxes:
[{
distribution: 'linear',
ticks:
{
beginAtZero: false,
maxTicksLimit: 0
},
gridLines:
{
zeroLineColor: 'rgba(0, 0, 0, 0.1)',
offsetGridLines: true
}
}],
yAxes:
[{
ticks:
{
beginAtZero: true,
suggestedMax: 10,
precision: 0
}
}]
}
}
});
</script>
</div>
</body>
</html>

View file

@ -1,69 +0,0 @@
<?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>
<script src="Chart.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
</head>
<body>
<div style="width: 100%; height: 100%; text-align: center; margin: 0 0; border: 1px solid red;" title="titre utile ?">
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx,
{
type: 'bar',
data:
{
labels: ['New', 'Started', 'Waiting', 'Maybe', 'Resolved', 'Closed'],
datasets:
[{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1
}]
},
options:
{
maintainAspectRatio: false,
scales:
{
xAxes:
[{
distribution: 'linear',
ticks:
{
beginAtZero: false,
maxTicksLimit: 0
},
gridLines:
{
zeroLineColor: 'rgba(0, 0, 0, 0.1)',
offsetGridLines: true
}
}],
yAxes:
[{
ticks:
{
beginAtZero: true,
suggestedMax: 10,
precision: 0
}
}]
}
}
});
</script>
</div>
</body>
</html>

View file

@ -1,98 +0,0 @@
<?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>
<script src="Chart.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
</head>
<body>
<div style="width: 100%; height: 100%; text-align: center; margin: 0 0; border: 1px solid red;" title="Created and Closed Issue Count">
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx,
{
type: 'line',
data:
{
datasets:
[
{
label: 'Created',
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1,
fill: true,
/* cubicInterpolationMode: 'monotone', */
lineTension: 0,
pointBorderWidth: 0.00000001,
data: [2, 9, 13, 15, 22, 23]
},
{
label: 'Closedᴿ',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1,
fill: true,
lineTension: 0,
pointBorderWidth: 0.00000001,
data: [1, 5, 9, 13, 15, 22]
}
]
},
options:
{
maintainAspectRatio: false,
title: {
display: false,
text: 'Min and Max Settings'
},
scales:
{
xAxes:
[{
type: 'time',
time:
{
unit: 'month',
isoWeekday: true,
displayFormats:
{
month: 'YYYY MMM'
}
},
distribution: 'linear',
ticks:
{
beginAtZero: false,
maxTicksLimit: 0
},
gridLines:
{
zeroLineColor: 'rgba(0, 0, 0, 0.1)',
offsetGridLines: false
}
}],
yAxes:
[{
ticks:
{
beginAtZero: false,
suggestedMax: 10,
precision: 0
}
}]
}
}
});
</script>
</div>
</body>
</html>

View file

@ -1,101 +0,0 @@
<?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>
<script src="Chart.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
</head>
<body>
<div style="width: 100%; height: 100%; text-align: center; margin: 0 0; border: 1px solid red;" title="Created and Closed Issue Count">
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx,
{
type: 'bar',
data:
{
datasets:
[
{
label: 'Created',
steppedLine: true,
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1,
fill: true,
/* cubicInterpolationMode: 'monotone', */
lineTension: 0,
pointBorderWidth: 0.00000001,
data: [2, 9, 13, 15, 22, 23]
},
{
label: 'Closedᴿ',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1,
fill: true,
lineTension: 0,
pointBorderWidth: 0.00000001,
data: [{t: '2020-01', y: 7},{t: '2020-02', y: 9},{t: '2020-03', y: 4},{t: '2020-04', y: 2},{t: '2020-05', y: 1},{t: '2020-06', y: 7},{t: '2020-07', y: 0},{t: '2020-08', y: 0},{t: '2020-09', y: 0},{t: '2020-10', y: 0},{t: '2020-11', y: 0},{t: '2020-12', y: 0}]
}
]
},
options:
{
maintainAspectRatio: false,
title: {
display: false,
text: 'Min and Max Settings'
},
scales:
{
xAxes:
[{
type: 'time',
time:
{
unit: 'month',
isoWeekday: true,
displayFormats:
{
month: 'YYYY MMM'
}
},
distribution: 'linear',
ticks:
{
beginAtZero: false,
maxTicksLimit: 0
},
stacked: true,
gridLines:
{
zeroLineColor: 'rgba(0, 0, 0, 0.1)',
offsetGridLines: true
}
}],
yAxes:
[{
ticks:
{
beginAtZero: false,
suggestedMax: 10,
precision: 0
},
stacked: true,
}]
}
}
});
</script>
</div>
</body>
</html>

View file

@ -1,98 +0,0 @@
<?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>
<script src="Chart.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
</head>
<body>
<div style="width: 100%; height: 100%; text-align: center; margin: 0 0; border: 1px solid red;" title="Created and Closed Issue Count">
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx,
{
type: 'line',
data:
{
datasets:
[
{
label: 'Created',
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1,
fill: true,
/* cubicInterpolationMode: 'monotone', */
lineTension: 0,
pointBorderWidth: 0.00000001,
data: [2, 9, 13, 15, 22, 23]
},
{
label: 'Closedᴿ',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1,
fill: true,
lineTension: 0,
pointBorderWidth: 0.00000001,
data: [1, 5, 9, 13, 15, 22]
}
]
},
options:
{
maintainAspectRatio: false,
title: {
display: false,
text: 'Min and Max Settings'
},
scales:
{
xAxes:
[{
type: 'time',
time:
{
unit: 'month',
isoWeekday: true,
displayFormats:
{
month: 'YYYY MMM'
}
},
distribution: 'linear',
ticks:
{
beginAtZero: false,
maxTicksLimit: 0
},
gridLines:
{
zeroLineColor: 'rgba(0, 0, 0, 0.1)',
offsetGridLines: false
}
}],
yAxes:
[{
ticks:
{
beginAtZero: false,
suggestedMax: 10,
precision: 0
}
}]
}
}
});
</script>
</div>
</body>
</html>

View file

@ -1,41 +0,0 @@
<?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>
<script src="Chart.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
</head>
<body>
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx,
{
type: 'pie',
data: {
datasets:
[{
data: [ 10,40,50 ],
backgroundColor: [window.chartColors.red,window.chartColors.orange,window.chartColors.yellow,window.chartColors.green,window.chartColors.blue]
}],
labels: ['Red', 'Orange', 'Yellow', 'Green', 'Blue']
},
options:
{
maintainAspectRatio: false,
display: true,
responsive: true,
legend: { display: true, position: 'right' },
title: { display: true, position: 'top', text: 'a title' },
}
});
</script>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show more