Refactored metric pages with huge splitting.
This commit is contained in:
parent
a1e1a60c5a
commit
c601ddad44
32 changed files with 1520 additions and 850 deletions
3
build.num.tmp
Normal file
3
build.num.tmp
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#Build Number for ANT. Do not edit!
|
||||||
|
#Sun Sep 13 02:31:30 CEST 2020
|
||||||
|
build.number=0
|
|
@ -92,7 +92,7 @@ public class CategoryPage
|
||||||
data.setEscapedContent("categoryDescription", category.getDescription());
|
data.setEscapedContent("categoryDescription", category.getDescription());
|
||||||
data.setEscapedContent("categorySoftwares", category.getSoftwares().sort().toStringWithFrenchCommas());
|
data.setEscapedContent("categorySoftwares", category.getSoftwares().sort().toStringWithFrenchCommas());
|
||||||
data.setContent("serviceCount", services.size());
|
data.setContent("serviceCount", services.size());
|
||||||
data.setContent("serviceListView", ServiceListView.build(services.sortByName()));
|
data.setContent("serviceListView", ServiceListView.htmlize(services.sortByName()));
|
||||||
|
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/category.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/category.xhtml", data).toString();
|
||||||
|
|
||||||
|
|
|
@ -588,6 +588,7 @@ public class ChartHtmlizer
|
||||||
|
|
||||||
BarChart chart = new BarChart(dataset.getLabel());
|
BarChart chart = new BarChart(dataset.getLabel());
|
||||||
// chart.setStacked(true);
|
// chart.setStacked(true);
|
||||||
|
chart.setAnimated(false);
|
||||||
chart.addDataset(dataset.getLabel());
|
chart.addDataset(dataset.getLabel());
|
||||||
|
|
||||||
if (startTarget != null)
|
if (startTarget != null)
|
||||||
|
@ -619,6 +620,8 @@ public class ChartHtmlizer
|
||||||
* the dataset
|
* the dataset
|
||||||
* @param color
|
* @param color
|
||||||
* the color
|
* the color
|
||||||
|
* @param animated
|
||||||
|
* the animated
|
||||||
* @return the string
|
* @return the string
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
|
@ -659,6 +662,7 @@ public class ChartHtmlizer
|
||||||
|
|
||||||
BarChart chart = new BarChart(dataset.getLabel());
|
BarChart chart = new BarChart(dataset.getLabel());
|
||||||
// chart.setStacked(true);
|
// chart.setStacked(true);
|
||||||
|
chart.setAnimated(false);
|
||||||
chart.addDataset(dataset.getLabel());
|
chart.addDataset(dataset.getLabel());
|
||||||
|
|
||||||
if (startTarget != null)
|
if (startTarget != null)
|
||||||
|
@ -730,6 +734,7 @@ public class ChartHtmlizer
|
||||||
|
|
||||||
BarChart chart = new BarChart(dataset.getLabel());
|
BarChart chart = new BarChart(dataset.getLabel());
|
||||||
// chart.setStacked(true);
|
// chart.setStacked(true);
|
||||||
|
chart.setAnimated(false);
|
||||||
chart.addDataset(dataset.getLabel());
|
chart.addDataset(dataset.getLabel());
|
||||||
|
|
||||||
if (startTarget != null)
|
if (startTarget != null)
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class FederationHeaderView
|
||||||
data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties");
|
data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties");
|
||||||
data.setAttribute("rawCheckLink", "href", federation.getTechnicalName() + "-check.xhtml");
|
data.setAttribute("rawCheckLink", "href", federation.getTechnicalName() + "-check.xhtml");
|
||||||
data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml");
|
data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml");
|
||||||
data.setAttribute("metricsLink", "href", federation.getTechnicalName() + "-metrics.xhtml");
|
data.setAttribute("metricsLink", "href", federation.getTechnicalName() + "-metrics-summary-months-last.xhtml");
|
||||||
|
|
||||||
data.setAttribute("crawlLink", "href", federation.getTechnicalName() + "-crawl.xhtml");
|
data.setAttribute("crawlLink", "href", federation.getTechnicalName() + "-crawl.xhtml");
|
||||||
if (federation.getCrawlJournal().getErrors().isEmpty())
|
if (federation.getCrawlJournal().getErrors().isEmpty())
|
||||||
|
|
|
@ -18,14 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Federation;
|
import fr.devinsy.statoolinfos.core.Federation;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -41,12 +46,20 @@ public class FederationMetricGenericPage
|
||||||
/**
|
/**
|
||||||
* Builds the.
|
* Builds the.
|
||||||
*
|
*
|
||||||
|
* @param htmlizeDirectory
|
||||||
|
* the htmlize directory
|
||||||
|
* @param federation
|
||||||
|
* the federation
|
||||||
|
* @param view
|
||||||
|
* the view
|
||||||
|
* @param period
|
||||||
|
* the period
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* Signals that an I/O exception has occurred.
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Federation federation) throws StatoolInfosException, IOException
|
public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
|
@ -55,26 +68,26 @@ public class FederationMetricGenericPage
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
||||||
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, MenuItem.GENERIC));
|
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.GENERIC, view, period));
|
||||||
|
|
||||||
//
|
//
|
||||||
MetricHtmlizer.htmlizeData(data, "users.count", federation, "metrics.users.count", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "users.count", federation, view, period, "metrics.users.count", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "database.bytes", federation, "metrics.database.bytes", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "database.bytes", federation, view, period, "metrics.database.bytes", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "files.bytes", federation, "metrics.http.visits.visitors", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "files.bytes", federation, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();
|
||||||
|
|
||||||
//
|
//
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,192 @@
|
||||||
|
/*
|
||||||
|
* 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.htmlize.charts.MonthValues;
|
||||||
|
import fr.devinsy.statoolinfos.htmlize.charts.WeekValues;
|
||||||
|
import fr.devinsy.statoolinfos.htmlize.charts.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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -29,18 +31,110 @@ import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||||
import fr.devinsy.xidyn.utils.XidynUtils;
|
import fr.devinsy.xidyn.utils.XidynUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class FederationMetricMenuView.
|
* The Class OrganizationMetricMenuView.
|
||||||
*/
|
*/
|
||||||
public class FederationMetricMenuView
|
public class FederationMetricMenuView
|
||||||
{
|
{
|
||||||
private static Logger logger = LoggerFactory.getLogger(FederationMetricMenuView.class);
|
private static Logger logger = LoggerFactory.getLogger(FederationMetricMenuView.class);
|
||||||
|
|
||||||
public enum MenuItem
|
public enum PeriodMenu
|
||||||
|
{
|
||||||
|
FULL,
|
||||||
|
LAST,
|
||||||
|
Y2020,
|
||||||
|
Y2021;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
SUMMARY,
|
||||||
GENERIC,
|
|
||||||
WEB,
|
WEB,
|
||||||
SPECIFIC
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +146,7 @@ public class FederationMetricMenuView
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Federation federation, final MenuItem item) throws StatoolInfosException
|
public static String htmlize(final Federation federation, final TypeMenu type, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
|
@ -60,35 +154,108 @@ public class FederationMetricMenuView
|
||||||
{
|
{
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setAttribute("summaryTypeButton", "href", federation.getTechnicalName() + "-metrics.xhtml");
|
//
|
||||||
data.setAttribute("genericTypeButton", "href", federation.getTechnicalName() + "-metrics-generic.xhtml");
|
String filename = String.format("%s-metrics-summary-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName());
|
||||||
data.setAttribute("webTypeButton", "href", federation.getTechnicalName() + "-metrics-web.xhtml");
|
data.setAttribute("summaryTypeButton", "href", filename);
|
||||||
data.setAttribute("specificTypeButton", "href", federation.getTechnicalName() + "-metrics-specific.xhtml");
|
|
||||||
|
|
||||||
if ((item == null) || (item == MenuItem.SUMMARY))
|
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-2020.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName());
|
||||||
|
data.setAttribute("2020PeriodButton", "href", filename);
|
||||||
|
|
||||||
|
filename = String.format("%s-metrics-%s-%s-2021.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName());
|
||||||
|
data.setAttribute("2021PeriodButton", "href", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if ((type == null) || (type == TypeMenu.SUMMARY))
|
||||||
{
|
{
|
||||||
data.appendAttribute("summaryTypeButton", "class", "button selected");
|
data.appendAttribute("summaryTypeButton", "class", "button selected");
|
||||||
}
|
}
|
||||||
else if (item == MenuItem.GENERIC)
|
else if (type == TypeMenu.GENERIC)
|
||||||
{
|
{
|
||||||
data.appendAttribute("genericTypeButton", "class", "button selected");
|
data.appendAttribute("genericTypeButton", "class", "button selected");
|
||||||
}
|
}
|
||||||
else if (item == MenuItem.WEB)
|
else if (type == TypeMenu.WEB)
|
||||||
{
|
{
|
||||||
data.appendAttribute("webTypeButton", "class", "button selected");
|
data.appendAttribute("webTypeButton", "class", "button selected");
|
||||||
}
|
}
|
||||||
else if (item == MenuItem.SPECIFIC)
|
else if (type == TypeMenu.SPECIFIC)
|
||||||
{
|
{
|
||||||
data.appendAttribute("specificTypeButton", "class", "button selected");
|
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.Y2020)
|
||||||
|
{
|
||||||
|
data.appendAttribute("2020PeriodButton", "class", "button selected");
|
||||||
|
}
|
||||||
|
else if (period == PeriodMenu.Y2021)
|
||||||
|
{
|
||||||
|
data.appendAttribute("2021PeriodButton", "class", "button selected");
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString();
|
||||||
result = XidynUtils.extractBodyContent(content);
|
result = XidynUtils.extractBodyContent(content);
|
||||||
}
|
}
|
||||||
catch (XidynException exception)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building service metric menu view: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building metric menu view: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -18,14 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Federation;
|
import fr.devinsy.statoolinfos.core.Federation;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.MenuItem;
|
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.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||||
|
@ -45,7 +50,7 @@ public class FederationMetricSpecificPage
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* Signals that an I/O exception has occurred.
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Federation federation) throws StatoolInfosException, IOException
|
public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
|
@ -54,21 +59,21 @@ public class FederationMetricSpecificPage
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
||||||
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, MenuItem.SPECIFIC));
|
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.SPECIFIC, view, period));
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
||||||
|
|
||||||
//
|
//
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Federation;
|
import fr.devinsy.statoolinfos.core.Federation;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -41,12 +46,20 @@ public class FederationMetricSummaryPage
|
||||||
/**
|
/**
|
||||||
* Builds the.
|
* Builds the.
|
||||||
*
|
*
|
||||||
|
* @param htmlizeDirectory
|
||||||
|
* the htmlize directory
|
||||||
|
* @param federation
|
||||||
|
* the federation
|
||||||
|
* @param view
|
||||||
|
* the view
|
||||||
|
* @param period
|
||||||
|
* the period
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* Signals that an I/O exception has occurred.
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Federation federation) throws StatoolInfosException, IOException
|
public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
|
@ -55,25 +68,25 @@ public class FederationMetricSummaryPage
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
||||||
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, MenuItem.SUMMARY));
|
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.SUMMARY, view, period));
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.visitors", federation, "metrics.http.hits.visitors", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "http.hits.visitors", federation, view, period, "metrics.http.hits.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.visitors", federation, "metrics.http.ip.visitors", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "http.ip.visitors", federation, view, period, "metrics.http.ip.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits.visitors", federation, "metrics.http.visits.visitors", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "http.visits.visitors", federation, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
||||||
|
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
|
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Federation;
|
import fr.devinsy.statoolinfos.core.Federation;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -46,7 +51,7 @@ public class FederationMetricWebPage
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* Signals that an I/O exception has occurred.
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Federation federation) throws StatoolInfosException, IOException
|
public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
|
@ -55,58 +60,61 @@ public class FederationMetricWebPage
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
data.setContent("headerView", FederationHeaderView.htmlize(federation));
|
||||||
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, MenuItem.WEB));
|
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.WEB, view, period));
|
||||||
|
|
||||||
//
|
//
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits", federation, "metrics.http.hits", ChartColor.BLUE);
|
FederationMetricHtmlizer.htmlize(data, "http.hits", federation, view, period, "metrics.http.hits", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits-ipv4ipv6", federation, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "http.hits-ipv4ipv6", federation, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6",
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.ipv4", federation, "metrics.http.hits.ipv4", ChartColor.YELLOW);
|
ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.ipv6", federation, "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);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits-visitorsbots", federation, "http.hits (visitors + bots)", "metrics.http.hits.visitors", ChartColor.GREEN, "metrics.http.hits.bots",
|
FederationMetricHtmlizer.htmlize(data, "http.hits-visitorsbots", federation, view, period, "http.hits (visitors + bots)", "metrics.http.hits.visitors", ChartColor.GREEN,
|
||||||
|
"metrics.http.hits.bots",
|
||||||
ChartColor.YELLOW);
|
ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.visitors", federation, "metrics.http.hits.visitors", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "http.hits.visitors", federation, view, period, "metrics.http.hits.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.bots", federation, "metrics.http.hits.bots", ChartColor.YELLOW);
|
FederationMetricHtmlizer.htmlize(data, "http.hits.bots", federation, view, period, "metrics.http.hits.bots", ChartColor.YELLOW);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.errors", federation, "metrics.http.errors", ChartColor.RED);
|
FederationMetricHtmlizer.htmlize(data, "http.errors", federation, view, period, "metrics.http.errors", ChartColor.RED);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.errors.php", federation, "metrics.http.errors.php", ChartColor.RED);
|
FederationMetricHtmlizer.htmlize(data, "http.errors.php", federation, view, period, "metrics.http.errors.php", ChartColor.RED);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.files", federation, "metrics.http.files", ChartColor.BLUE);
|
FederationMetricHtmlizer.htmlize(data, "http.files", federation, view, period, "metrics.http.files", ChartColor.BLUE);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.pages", federation, "metrics.http.pages", ChartColor.BLUE);
|
FederationMetricHtmlizer.htmlize(data, "http.pages", federation, view, period, "metrics.http.pages", ChartColor.BLUE);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.bytes", federation, "metrics.http.bytes", ChartColor.BLUE);
|
FederationMetricHtmlizer.htmlize(data, "http.bytes", federation, view, period, "metrics.http.bytes", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip", federation, "metrics.http.ip", ChartColor.BLUE);
|
FederationMetricHtmlizer.htmlize(data, "http.ip", federation, view, period, "metrics.http.ip", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip-visitorsbots", federation, "http.ip (visitors + bots)", "metrics.http.ip.visitors", ChartColor.GREEN, "metrics.http.ip.bots",
|
FederationMetricHtmlizer.htmlize(data, "http.ip-visitorsbots", federation, view, period, "http.ip (visitors + bots)", "metrics.http.ip.visitors", ChartColor.GREEN, "metrics.http.ip.bots",
|
||||||
ChartColor.YELLOW);
|
ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.visitors", federation, "metrics.http.ip.visitors", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "http.ip.visitors", federation, view, period, "metrics.http.ip.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.bots", federation, "metrics.http.ip.bots", ChartColor.YELLOW);
|
FederationMetricHtmlizer.htmlize(data, "http.ip.bots", federation, view, period, "metrics.http.ip.bots", ChartColor.YELLOW);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip-ipv4ipv6", federation, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "http.ip-ipv4ipv6", federation, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6",
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.ipv4", federation, "metrics.http.ip.ipv4", ChartColor.YELLOW);
|
ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.ipv6", federation, "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);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits", federation, "metrics.http.visits", ChartColor.BLUE);
|
FederationMetricHtmlizer.htmlize(data, "http.visits", federation, view, period, "metrics.http.visits", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits-visitorsbots", federation, "http.visits (visitors + bots)", "metrics.http.visits.visitors", ChartColor.GREEN, "metrics.http.visits.bots",
|
FederationMetricHtmlizer.htmlize(data, "http.visits-visitorsbots", federation, view, period, "http.visits (visitors + bots)", "metrics.http.visits.visitors", ChartColor.GREEN,
|
||||||
ChartColor.YELLOW);
|
"metrics.http.visits.bots", ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits.bots", federation, "metrics.http.visits.bots", ChartColor.YELLOW);
|
FederationMetricHtmlizer.htmlize(data, "http.visits.bots", federation, view, period, "metrics.http.visits.bots", ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits.visitors", federation, "metrics.http.visits.visitors", ChartColor.GREEN);
|
FederationMetricHtmlizer.htmlize(data, "http.visits.visitors", federation, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString();
|
||||||
|
|
||||||
//
|
//
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ import fr.devinsy.statoolinfos.core.Federation;
|
||||||
import fr.devinsy.statoolinfos.core.Organization;
|
import fr.devinsy.statoolinfos.core.Organization;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
||||||
|
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu;
|
||||||
|
import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||||
|
@ -74,21 +76,23 @@ public class FederationPage
|
||||||
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8);
|
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
//
|
//
|
||||||
logger.info("Htmlize organization summarty metric page: {}.", federation.getName());
|
logger.info("Htmlize federation metric pages: {}.", federation.getName());
|
||||||
page = FederationMetricSummaryPage.htmlize(federation);
|
for (ViewMenu view : ViewMenu.values())
|
||||||
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-metrics.xhtml"), page, StandardCharsets.UTF_8);
|
{
|
||||||
|
for (PeriodMenu period : PeriodMenu.values())
|
||||||
logger.info("Htmlize organization generic metric page: {}.", federation.getName());
|
{
|
||||||
page = FederationMetricGenericPage.htmlize(federation);
|
if ((view != ViewMenu.YEARS) || (period == PeriodMenu.FULL))
|
||||||
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8);
|
{
|
||||||
|
if (view != ViewMenu.DAYS)
|
||||||
logger.info("Htmlize organization web metric page: {}.", federation.getName());
|
{
|
||||||
page = FederationMetricWebPage.htmlize(federation);
|
FederationMetricSummaryPage.build(htmlizeDirectory, federation, view, period);
|
||||||
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8);
|
FederationMetricGenericPage.build(htmlizeDirectory, federation, view, period);
|
||||||
|
FederationMetricSpecificPage.build(htmlizeDirectory, federation, view, period);
|
||||||
logger.info("Htmlize service specific metric page: {}.", federation.getName());
|
FederationMetricWebPage.build(htmlizeDirectory, federation, view, period);
|
||||||
page = FederationMetricSpecificPage.htmlize(federation);
|
}
|
||||||
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,379 +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.Organization;
|
|
||||||
import fr.devinsy.statoolinfos.core.Service;
|
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
|
||||||
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.MenuItem;
|
|
||||||
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
|
|
||||||
import fr.devinsy.statoolinfos.htmlize.charts.MonthValues;
|
|
||||||
import fr.devinsy.statoolinfos.htmlize.charts.WeekValues;
|
|
||||||
import fr.devinsy.statoolinfos.htmlize.charts.YearValues;
|
|
||||||
import fr.devinsy.xidyn.XidynException;
|
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
|
||||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class MetricHtmlizeDataUtils.
|
|
||||||
*/
|
|
||||||
public class MetricHtmlizer
|
|
||||||
{
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(MetricHtmlizer.class);
|
|
||||||
|
|
||||||
private static final int CHART_YEARS_FULL = 0;
|
|
||||||
private static final int CHART_MONTHS_FULL = 1;
|
|
||||||
private static final int CHART_MONTHS_LAST = 2;
|
|
||||||
private static final int CHART_MONTHS_2020 = 3;
|
|
||||||
private static final int CHART_MONTHS_2021 = 4;
|
|
||||||
private static final int CHART_WEEKS_FULL = 5;
|
|
||||||
private static final int CHART_WEEKS_LAST = 6;
|
|
||||||
private static final int CHART_WEEKS_2020 = 7;
|
|
||||||
private static final int CHART_WEEKS_2021 = 8;
|
|
||||||
private static final int CHART_DAYS_LAST = 9;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
{
|
|
||||||
logger.debug("Building service generic metric page {}…", service.get("service.name"));
|
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
|
||||||
|
|
||||||
//
|
|
||||||
data.setContent("headerView", ServiceHeaderView.htmlize(service));
|
|
||||||
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.WEB));
|
|
||||||
|
|
||||||
htmlizeData(data, "http.hits", service, "metrics.http.hits", ChartColor.BLUE);
|
|
||||||
|
|
||||||
htmlizeData(data, "http.hits-ipv4ipv6", service, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6", ChartColor.GREEN);
|
|
||||||
htmlizeData(data, "http.hits.ipv4", service, "metrics.http.hits.ipv4", ChartColor.YELLOW);
|
|
||||||
htmlizeData(data, "http.hits.ipv6", service, "metrics.http.hits.ipv6", ChartColor.GREEN);
|
|
||||||
|
|
||||||
htmlizeData(data, "http.hits-visitorsbots", service, "http.hits (visitors + bots)", "metrics.http.hits.visitors", ChartColor.GREEN, "metrics.http.hits.bots", ChartColor.YELLOW);
|
|
||||||
htmlizeData(data, "http.hits.visitors", service, "metrics.http.hits.visitors", ChartColor.GREEN);
|
|
||||||
htmlizeData(data, "http.hits.bots", service, "metrics.http.hits.bots", ChartColor.YELLOW);
|
|
||||||
|
|
||||||
htmlizeData(data, "http.errors", service, "metrics.http.errors", ChartColor.RED);
|
|
||||||
htmlizeData(data, "http.errors.php", service, "metrics.http.errors.php", ChartColor.RED);
|
|
||||||
|
|
||||||
htmlizeData(data, "http.files", service, "metrics.http.files", ChartColor.BLUE);
|
|
||||||
htmlizeData(data, "http.pages", service, "metrics.http.pages", ChartColor.BLUE);
|
|
||||||
htmlizeData(data, "http.bytes", service, "metrics.http.bytes", ChartColor.BLUE);
|
|
||||||
|
|
||||||
htmlizeData(data, "http.ip", service, "metrics.http.ip", ChartColor.BLUE);
|
|
||||||
|
|
||||||
htmlizeData(data, "http.ip-visitorsbots", service, "http.ip (visitors + bots)", "metrics.http.ip.visitors", ChartColor.GREEN, "metrics.http.ip.bots", ChartColor.YELLOW);
|
|
||||||
htmlizeData(data, "http.ip.visitors", service, "metrics.http.ip.visitors", ChartColor.GREEN);
|
|
||||||
htmlizeData(data, "http.ip.bots", service, "metrics.http.ip.bots", ChartColor.YELLOW);
|
|
||||||
|
|
||||||
htmlizeData(data, "http.ip-ipv4ipv6", service, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6", ChartColor.GREEN);
|
|
||||||
htmlizeData(data, "http.ip.ipv4", service, "metrics.http.ip.ipv4", ChartColor.YELLOW);
|
|
||||||
htmlizeData(data, "http.ip.ipv6", service, "metrics.http.ip.ipv6", ChartColor.GREEN);
|
|
||||||
|
|
||||||
htmlizeData(data, "http.visits", service, "metrics.http.visits", ChartColor.BLUE);
|
|
||||||
|
|
||||||
htmlizeData(data, "http.visits-visitorsbots", service, "http.visits (visitors + bots)", "metrics.http.visits.visitors", ChartColor.GREEN, "metrics.http.visits.bots", ChartColor.YELLOW);
|
|
||||||
htmlizeData(data, "http.visits.bots", service, "metrics.http.visits.bots", ChartColor.YELLOW);
|
|
||||||
htmlizeData(data, "http.visits.visitors", service, "metrics.http.visits.visitors", ChartColor.GREEN);
|
|
||||||
|
|
||||||
//
|
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricView2.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Htmlize data.
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
* the data
|
|
||||||
* @param metricId
|
|
||||||
* the metric id
|
|
||||||
* @param federation
|
|
||||||
* the federation
|
|
||||||
* @param metricPath
|
|
||||||
* the metric path
|
|
||||||
* @param color
|
|
||||||
* the color
|
|
||||||
* @throws StatoolInfosException
|
|
||||||
* the statool infos exception
|
|
||||||
*/
|
|
||||||
public static void htmlizeData(final TagDataManager data, final String metricId, final Federation federation, final String metricPath, final ChartColor color) throws StatoolInfosException
|
|
||||||
{
|
|
||||||
YearValues yearMetric = federation.getMetricYearValuesAll(metricPath);
|
|
||||||
data.setContent("charts", CHART_YEARS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color));
|
|
||||||
|
|
||||||
MonthValues monthMetric = federation.getMetricMonthValuesAll(metricPath);
|
|
||||||
data.setContent("charts", CHART_MONTHS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color));
|
|
||||||
data.setContent("charts", CHART_MONTHS_LAST, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2020, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(2020, 01), YearMonth.of(2020, 12), monthMetric, color));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2021, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(2021, 01), YearMonth.of(2021, 12), monthMetric, color));
|
|
||||||
|
|
||||||
WeekValues weekMetric = federation.getMetricWeekValuesAll(metricPath);
|
|
||||||
data.setContent("charts", CHART_WEEKS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color));
|
|
||||||
data.setContent("charts", CHART_WEEKS_LAST, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2020, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(2020, 01), YearWeek.of(2020, 53), weekMetric, color));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2021, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(2021, 01), YearWeek.of(2021, 53), weekMetric, color));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Htmlize data.
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
* the data
|
|
||||||
* @param metricId
|
|
||||||
* the metric id
|
|
||||||
* @param federation
|
|
||||||
* the federation
|
|
||||||
* @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 htmlizeData(final TagDataManager data, final String metricId, final Federation federation, final String metricLabel, final String metricPath1,
|
|
||||||
final ChartColor color1, final String metricPath2, final ChartColor color2) throws StatoolInfosException
|
|
||||||
{
|
|
||||||
//
|
|
||||||
YearValues yearMetric1 = federation.getMetricYearValuesAll(metricPath1);
|
|
||||||
YearValues yearMetric2 = federation.getMetricYearValuesAll(metricPath2);
|
|
||||||
data.setContent("charts", CHART_YEARS_FULL, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2));
|
|
||||||
|
|
||||||
//
|
|
||||||
MonthValues monthMetric1 = federation.getMetricMonthValuesAll(metricPath1);
|
|
||||||
MonthValues monthMetric2 = federation.getMetricMonthValuesAll(metricPath2);
|
|
||||||
data.setContent("charts", CHART_MONTHS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
data.setContent("charts", CHART_MONTHS_LAST, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2020, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(2020, 01), YearMonth.of(2020, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2021, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(2021, 01), YearMonth.of(2021, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
|
|
||||||
//
|
|
||||||
WeekValues weekMetric1 = federation.getMetricWeekValuesAll(metricPath1);
|
|
||||||
WeekValues weekMetric2 = federation.getMetricWeekValuesAll(metricPath2);
|
|
||||||
data.setContent("charts", CHART_WEEKS_FULL, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
data.setContent("charts", CHART_WEEKS_LAST, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2020, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(2020, 01), YearWeek.of(2020, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2021, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(2021, 01), YearWeek.of(2021, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 htmlizeData(final TagDataManager data, final String metricId, final Organization organization, final String metricPath, final ChartColor color) throws StatoolInfosException
|
|
||||||
{
|
|
||||||
YearValues yearMetric = organization.getMetricYearValuesAll(metricPath);
|
|
||||||
data.setContent("charts", CHART_YEARS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color));
|
|
||||||
|
|
||||||
MonthValues monthMetric = organization.getMetricMonthValuesAll(metricPath);
|
|
||||||
data.setContent("charts", CHART_MONTHS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color));
|
|
||||||
data.setContent("charts", CHART_MONTHS_LAST, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2020, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(2020, 01), YearMonth.of(2020, 12), monthMetric, color));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2021, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(2021, 01), YearMonth.of(2021, 12), monthMetric, color));
|
|
||||||
|
|
||||||
WeekValues weekMetric = organization.getMetricWeekValuesAll(metricPath);
|
|
||||||
data.setContent("charts", CHART_WEEKS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color));
|
|
||||||
data.setContent("charts", CHART_WEEKS_LAST, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2020, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(2020, 01), YearWeek.of(2020, 53), weekMetric, color));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2021, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(2021, 01), YearWeek.of(2021, 53), weekMetric, color));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void htmlizeData(final TagDataManager data, final String metricId, final Organization organization, final String metricLabel, final String metricPath1,
|
|
||||||
final ChartColor color1,
|
|
||||||
final String metricPath2,
|
|
||||||
final ChartColor color2) throws StatoolInfosException
|
|
||||||
{
|
|
||||||
//
|
|
||||||
YearValues yearMetric1 = organization.getMetricYearValuesAll(metricPath1);
|
|
||||||
YearValues yearMetric2 = organization.getMetricYearValuesAll(metricPath2);
|
|
||||||
data.setContent("charts", CHART_YEARS_FULL, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2));
|
|
||||||
|
|
||||||
//
|
|
||||||
MonthValues monthMetric1 = organization.getMetricMonthValuesAll(metricPath1);
|
|
||||||
MonthValues monthMetric2 = organization.getMetricMonthValuesAll(metricPath2);
|
|
||||||
data.setContent("charts", CHART_MONTHS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
data.setContent("charts", CHART_MONTHS_LAST, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2020, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(2020, 01), YearMonth.of(2020, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2021, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(2021, 01), YearMonth.of(2021, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
|
|
||||||
//
|
|
||||||
WeekValues weekMetric1 = organization.getMetricWeekValuesAll(metricPath1);
|
|
||||||
WeekValues weekMetric2 = organization.getMetricWeekValuesAll(metricPath2);
|
|
||||||
data.setContent("charts", CHART_WEEKS_FULL, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
data.setContent("charts", CHART_WEEKS_LAST, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2020, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(2020, 01), YearWeek.of(2020, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2021, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(2021, 01), YearWeek.of(2021, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 htmlizeData(final TagDataManager data, final String metricId, final Service service, final String metricPath, final ChartColor color) throws StatoolInfosException
|
|
||||||
{
|
|
||||||
YearValues yearMetric = service.getMetricYearValues(metricPath);
|
|
||||||
data.setContent("charts", CHART_YEARS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color));
|
|
||||||
|
|
||||||
MonthValues monthMetric = service.getMetricMonthValues(metricPath);
|
|
||||||
data.setContent("charts", CHART_MONTHS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color));
|
|
||||||
data.setContent("charts", CHART_MONTHS_LAST, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2020, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(2020, 01), YearMonth.of(2020, 12), monthMetric, color));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2021, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(2021, 01), YearMonth.of(2021, 12), monthMetric, color));
|
|
||||||
|
|
||||||
WeekValues weekMetric = service.getMetricWeekValues(metricPath);
|
|
||||||
data.setContent("charts", CHART_WEEKS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color));
|
|
||||||
data.setContent("charts", CHART_WEEKS_LAST, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2020, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(2020, 01), YearWeek.of(2020, 53), weekMetric, color));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2021, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(2021, 01), YearWeek.of(2021, 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 htmlizeData(final TagDataManager data, final String metricId, final Service service, final String metricLabel, final String metricPath1,
|
|
||||||
final ChartColor color1,
|
|
||||||
final String metricPath2,
|
|
||||||
final ChartColor color2) throws StatoolInfosException
|
|
||||||
{
|
|
||||||
//
|
|
||||||
YearValues yearMetric1 = service.getMetricYearValues(metricPath1);
|
|
||||||
YearValues yearMetric2 = service.getMetricYearValues(metricPath2);
|
|
||||||
data.setContent("charts", CHART_YEARS_FULL, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2));
|
|
||||||
|
|
||||||
//
|
|
||||||
MonthValues monthMetric1 = service.getMetricMonthValues(metricPath1);
|
|
||||||
MonthValues monthMetric2 = service.getMetricMonthValues(metricPath2);
|
|
||||||
data.setContent("charts", CHART_MONTHS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
data.setContent("charts", CHART_MONTHS_LAST, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2020, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(2020, 01), YearMonth.of(2020, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
data.setContent("charts", CHART_MONTHS_2021, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(2021, 01), YearMonth.of(2021, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2));
|
|
||||||
|
|
||||||
//
|
|
||||||
WeekValues weekMetric1 = service.getMetricWeekValues(metricPath1);
|
|
||||||
WeekValues weekMetric2 = service.getMetricWeekValues(metricPath2);
|
|
||||||
data.setContent("charts", CHART_WEEKS_FULL, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
data.setContent("charts", CHART_WEEKS_LAST, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2020, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(2020, 01), YearWeek.of(2020, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
data.setContent("charts", CHART_WEEKS_2021, metricId,
|
|
||||||
ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(2021, 01), YearWeek.of(2021, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -98,7 +98,7 @@ public class OrganizationHeaderView
|
||||||
data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-check.xhtml");
|
data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-check.xhtml");
|
||||||
|
|
||||||
data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml");
|
data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml");
|
||||||
data.setAttribute("metricsLink", "href", organization.getTechnicalName() + "-metrics.xhtml");
|
data.setAttribute("metricsLink", "href", organization.getTechnicalName() + "-metrics-summary-months-last.xhtml");
|
||||||
|
|
||||||
data.setAttribute("crawlLink", "href", organization.getTechnicalName() + "-crawl.xhtml");
|
data.setAttribute("crawlLink", "href", organization.getTechnicalName() + "-crawl.xhtml");
|
||||||
if (organization.getCrawlJournal().getErrors().isEmpty())
|
if (organization.getCrawlJournal().getErrors().isEmpty())
|
||||||
|
|
|
@ -18,12 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Organization;
|
import fr.devinsy.statoolinfos.core.Organization;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -45,24 +52,20 @@ public class OrganizationMetricGenericPage
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Organization organization) throws StatoolInfosException
|
public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.debug("Building oranization generic metric page {}…", organization.get("service.name"));
|
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
//
|
//
|
||||||
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
|
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
|
||||||
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.GENERIC));
|
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.GENERIC, view, period));
|
||||||
|
|
||||||
//
|
//
|
||||||
MetricHtmlizer.htmlizeData(data, "users.count", organization, "metrics.users.count", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "users.count", organization, view, period, "metrics.users.count", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "database.bytes", organization, "metrics.database.bytes", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "database.bytes", organization, view, period, "metrics.database.bytes", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "files.bytes", organization, "metrics.http.visits.visitors", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "files.bytes", organization, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
||||||
|
@ -70,14 +73,14 @@ public class OrganizationMetricGenericPage
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
|
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
|
||||||
trail.add(organization.getName(), organization.getTechnicalName() + "-" + organization.getTechnicalName() + ".xhtml");
|
trail.add(organization.getName(), organization.getTechnicalName() + "-" + organization.getTechnicalName() + ".xhtml");
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building organization generic metric page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building organization generic metric page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,190 @@
|
||||||
|
/*
|
||||||
|
* 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.htmlize.charts.MonthValues;
|
||||||
|
import fr.devinsy.statoolinfos.htmlize.charts.WeekValues;
|
||||||
|
import fr.devinsy.statoolinfos.htmlize.charts.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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -35,12 +37,104 @@ public class OrganizationMetricMenuView
|
||||||
{
|
{
|
||||||
private static Logger logger = LoggerFactory.getLogger(OrganizationMetricMenuView.class);
|
private static Logger logger = LoggerFactory.getLogger(OrganizationMetricMenuView.class);
|
||||||
|
|
||||||
public enum MenuItem
|
public enum PeriodMenu
|
||||||
|
{
|
||||||
|
FULL,
|
||||||
|
LAST,
|
||||||
|
Y2020,
|
||||||
|
Y2021;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
SUMMARY,
|
||||||
GENERIC,
|
|
||||||
WEB,
|
WEB,
|
||||||
SPECIFIC
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +146,7 @@ public class OrganizationMetricMenuView
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Organization organization, final MenuItem item) throws StatoolInfosException
|
public static String htmlize(final Organization organization, final TypeMenu type, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
|
@ -60,35 +154,108 @@ public class OrganizationMetricMenuView
|
||||||
{
|
{
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-metrics.xhtml");
|
//
|
||||||
data.setAttribute("genericTypeButton", "href", organization.getTechnicalName() + "-metrics-generic.xhtml");
|
String filename = String.format("%s-metrics-summary-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName());
|
||||||
data.setAttribute("webTypeButton", "href", organization.getTechnicalName() + "-metrics-web.xhtml");
|
data.setAttribute("summaryTypeButton", "href", filename);
|
||||||
data.setAttribute("specificTypeButton", "href", organization.getTechnicalName() + "-metrics-specific.xhtml");
|
|
||||||
|
|
||||||
if ((item == null) || (item == MenuItem.SUMMARY))
|
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-2020.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName());
|
||||||
|
data.setAttribute("2020PeriodButton", "href", filename);
|
||||||
|
|
||||||
|
filename = String.format("%s-metrics-%s-%s-2021.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName());
|
||||||
|
data.setAttribute("2021PeriodButton", "href", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if ((type == null) || (type == TypeMenu.SUMMARY))
|
||||||
{
|
{
|
||||||
data.appendAttribute("summaryTypeButton", "class", "button selected");
|
data.appendAttribute("summaryTypeButton", "class", "button selected");
|
||||||
}
|
}
|
||||||
else if (item == MenuItem.GENERIC)
|
else if (type == TypeMenu.GENERIC)
|
||||||
{
|
{
|
||||||
data.appendAttribute("genericTypeButton", "class", "button selected");
|
data.appendAttribute("genericTypeButton", "class", "button selected");
|
||||||
}
|
}
|
||||||
else if (item == MenuItem.WEB)
|
else if (type == TypeMenu.WEB)
|
||||||
{
|
{
|
||||||
data.appendAttribute("webTypeButton", "class", "button selected");
|
data.appendAttribute("webTypeButton", "class", "button selected");
|
||||||
}
|
}
|
||||||
else if (item == MenuItem.SPECIFIC)
|
else if (type == TypeMenu.SPECIFIC)
|
||||||
{
|
{
|
||||||
data.appendAttribute("specificTypeButton", "class", "button selected");
|
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.Y2020)
|
||||||
|
{
|
||||||
|
data.appendAttribute("2020PeriodButton", "class", "button selected");
|
||||||
|
}
|
||||||
|
else if (period == PeriodMenu.Y2021)
|
||||||
|
{
|
||||||
|
data.appendAttribute("2021PeriodButton", "class", "button selected");
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString();
|
||||||
result = XidynUtils.extractBodyContent(content);
|
result = XidynUtils.extractBodyContent(content);
|
||||||
}
|
}
|
||||||
catch (XidynException exception)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building service metric menu view: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building metric menu view: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -18,12 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Organization;
|
import fr.devinsy.statoolinfos.core.Organization;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem;
|
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.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||||
|
@ -44,10 +51,8 @@ public class OrganizationMetricSpecificPage
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Organization organization) throws StatoolInfosException
|
public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.debug("Building oranization specific metric page {}…", organization.get("service.name"));
|
logger.debug("Building oranization specific metric page {}…", organization.get("service.name"));
|
||||||
|
@ -56,7 +61,7 @@ public class OrganizationMetricSpecificPage
|
||||||
|
|
||||||
//
|
//
|
||||||
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
|
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
|
||||||
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.SPECIFIC));
|
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.SPECIFIC, view, period));
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
||||||
|
@ -64,14 +69,14 @@ public class OrganizationMetricSpecificPage
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
|
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
|
||||||
trail.add(organization.getName(), organization.getTechnicalName() + "-" + organization.getTechnicalName() + ".xhtml");
|
trail.add(organization.getName(), organization.getTechnicalName() + "-" + organization.getTechnicalName() + ".xhtml");
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building organization specific metric page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building organization specific metric page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Organization;
|
import fr.devinsy.statoolinfos.core.Organization;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -49,23 +54,19 @@ public class OrganizationMetricSummaryPage
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* Signals that an I/O exception has occurred.
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Organization organization) throws StatoolInfosException, IOException
|
public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.debug("Building organization summary page {}…");
|
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
//
|
//
|
||||||
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
|
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
|
||||||
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.SUMMARY));
|
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.SUMMARY, view, period));
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.visitors", organization, "metrics.http.hits.visitors", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "http.hits.visitors", organization, view, period, "metrics.http.hits.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.visitors", organization, "metrics.http.ip.visitors", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "http.ip.visitors", organization, view, period, "metrics.http.ip.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits.visitors", organization, "metrics.http.visits.visitors", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "http.visits.visitors", organization, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
||||||
|
@ -73,14 +74,14 @@ public class OrganizationMetricSummaryPage
|
||||||
//
|
//
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
|
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building organization summary page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building organization summary page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Organization;
|
import fr.devinsy.statoolinfos.core.Organization;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -39,62 +46,68 @@ public class OrganizationMetricWebPage
|
||||||
/**
|
/**
|
||||||
* Builds the.
|
* Builds the.
|
||||||
*
|
*
|
||||||
|
* @param htmlizeDirectory
|
||||||
|
* the htmlize directory
|
||||||
* @param organization
|
* @param organization
|
||||||
* the service
|
* the organization
|
||||||
* @return the string
|
* @param view
|
||||||
|
* the view
|
||||||
|
* @param period
|
||||||
|
* the period
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
|
* @throws IOException
|
||||||
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Organization organization) throws StatoolInfosException
|
public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.debug("Building oranization web metric page {}…", organization.get("service.name"));
|
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
//
|
//
|
||||||
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
|
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
|
||||||
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.WEB));
|
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.WEB, view, period));
|
||||||
|
|
||||||
//
|
//
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits", organization, "metrics.http.hits", ChartColor.BLUE);
|
OrganizationMetricHtmlizer.htmlize(data, "http.hits", organization, view, period, "metrics.http.hits", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits-ipv4ipv6", organization, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "http.hits-ipv4ipv6", organization, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW,
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.ipv4", organization, "metrics.http.hits.ipv4", ChartColor.YELLOW);
|
"metrics.http.hits.ipv6",
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.ipv6", organization, "metrics.http.hits.ipv6", ChartColor.GREEN);
|
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);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits-visitorsbots", organization, "http.hits (visitors + bots)", "metrics.http.hits.visitors", ChartColor.GREEN, "metrics.http.hits.bots",
|
OrganizationMetricHtmlizer.htmlize(data, "http.hits-visitorsbots", organization, view, period, "http.hits (visitors + bots)", "metrics.http.hits.visitors", ChartColor.GREEN,
|
||||||
ChartColor.YELLOW);
|
"metrics.http.hits.bots", ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.visitors", organization, "metrics.http.hits.visitors", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "http.hits.visitors", organization, view, period, "metrics.http.hits.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.bots", organization, "metrics.http.hits.bots", ChartColor.YELLOW);
|
OrganizationMetricHtmlizer.htmlize(data, "http.hits.bots", organization, view, period, "metrics.http.hits.bots", ChartColor.YELLOW);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.errors", organization, "metrics.http.errors", ChartColor.RED);
|
OrganizationMetricHtmlizer.htmlize(data, "http.errors", organization, view, period, "metrics.http.errors", ChartColor.RED);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.errors.php", organization, "metrics.http.errors.php", ChartColor.RED);
|
OrganizationMetricHtmlizer.htmlize(data, "http.errors.php", organization, view, period, "metrics.http.errors.php", ChartColor.RED);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.files", organization, "metrics.http.files", ChartColor.BLUE);
|
OrganizationMetricHtmlizer.htmlize(data, "http.files", organization, view, period, "metrics.http.files", ChartColor.BLUE);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.pages", organization, "metrics.http.pages", ChartColor.BLUE);
|
OrganizationMetricHtmlizer.htmlize(data, "http.pages", organization, view, period, "metrics.http.pages", ChartColor.BLUE);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.bytes", organization, "metrics.http.bytes", ChartColor.BLUE);
|
OrganizationMetricHtmlizer.htmlize(data, "http.bytes", organization, view, period, "metrics.http.bytes", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip", organization, "metrics.http.ip", ChartColor.BLUE);
|
OrganizationMetricHtmlizer.htmlize(data, "http.ip", organization, view, period, "metrics.http.ip", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip-visitorsbots", organization, "http.ip (visitors + bots)", "metrics.http.ip.visitors", ChartColor.GREEN, "metrics.http.ip.bots",
|
OrganizationMetricHtmlizer.htmlize(data, "http.ip-visitorsbots", organization, view, period, "http.ip (visitors + bots)", "metrics.http.ip.visitors", ChartColor.GREEN,
|
||||||
ChartColor.YELLOW);
|
"metrics.http.ip.bots", ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.visitors", organization, "metrics.http.ip.visitors", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "http.ip.visitors", organization, view, period, "metrics.http.ip.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.bots", organization, "metrics.http.ip.bots", ChartColor.YELLOW);
|
OrganizationMetricHtmlizer.htmlize(data, "http.ip.bots", organization, view, period, "metrics.http.ip.bots", ChartColor.YELLOW);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip-ipv4ipv6", organization, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "http.ip-ipv4ipv6", organization, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6",
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.ipv4", organization, "metrics.http.ip.ipv4", ChartColor.YELLOW);
|
ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.ipv6", organization, "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);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits", organization, "metrics.http.visits", ChartColor.BLUE);
|
OrganizationMetricHtmlizer.htmlize(data, "http.visits", organization, view, period, "metrics.http.visits", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits-visitorsbots", organization, "http.visits (visitors + bots)", "metrics.http.visits.visitors", ChartColor.GREEN, "metrics.http.visits.bots",
|
OrganizationMetricHtmlizer.htmlize(data, "http.visits-visitorsbots", organization, view, period, "http.visits (visitors + bots)", "metrics.http.visits.visitors", ChartColor.GREEN,
|
||||||
ChartColor.YELLOW);
|
"metrics.http.visits.bots", ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits.bots", organization, "metrics.http.visits.bots", ChartColor.YELLOW);
|
OrganizationMetricHtmlizer.htmlize(data, "http.visits.bots", organization, view, period, "metrics.http.visits.bots", ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits.visitors", organization, "metrics.http.visits.visitors", ChartColor.GREEN);
|
OrganizationMetricHtmlizer.htmlize(data, "http.visits.visitors", organization, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString();
|
||||||
|
@ -102,14 +115,15 @@ public class OrganizationMetricWebPage
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
|
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
|
||||||
trail.add(organization.getName(), organization.getTechnicalName() + "-" + organization.getTechnicalName() + ".xhtml");
|
trail.add(organization.getName(), organization.getTechnicalName() + "-" + organization.getTechnicalName() + ".xhtml");
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building organization web metric page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building organization web metric page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@ import fr.devinsy.statoolinfos.HtmlizerContext;
|
||||||
import fr.devinsy.statoolinfos.core.Organization;
|
import fr.devinsy.statoolinfos.core.Organization;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
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.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||||
|
@ -77,21 +79,24 @@ public class OrganizationPage
|
||||||
page = OrganizationStatsPage.htmlize(organization);
|
page = OrganizationStatsPage.htmlize(organization);
|
||||||
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats.xhtml"), page, StandardCharsets.UTF_8);
|
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats.xhtml"), page, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
logger.info("Htmlize organization summarty metric page: {}.", organization.getName());
|
//
|
||||||
page = OrganizationMetricSummaryPage.htmlize(organization);
|
logger.info("Htmlize organization metric pages: {}.", organization.getName());
|
||||||
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics.xhtml"), page, StandardCharsets.UTF_8);
|
for (ViewMenu view : ViewMenu.values())
|
||||||
|
{
|
||||||
logger.info("Htmlize organization generic metric page: {}.", organization.getName());
|
for (PeriodMenu period : PeriodMenu.values())
|
||||||
page = OrganizationMetricGenericPage.htmlize(organization);
|
{
|
||||||
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8);
|
if ((view != ViewMenu.YEARS) || (period == PeriodMenu.FULL))
|
||||||
|
{
|
||||||
logger.info("Htmlize organization web metric page: {}.", organization.getName());
|
if (view != ViewMenu.DAYS)
|
||||||
page = OrganizationMetricWebPage.htmlize(organization);
|
{
|
||||||
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8);
|
OrganizationMetricSummaryPage.build(htmlizeDirectory, organization, view, period);
|
||||||
|
OrganizationMetricGenericPage.build(htmlizeDirectory, organization, view, period);
|
||||||
logger.info("Htmlize service specific metric page: {}.", organization.getName());
|
OrganizationMetricSpecificPage.build(htmlizeDirectory, organization, view, period);
|
||||||
page = OrganizationMetricSpecificPage.htmlize(organization);
|
OrganizationMetricWebPage.build(htmlizeDirectory, organization, view, period);
|
||||||
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,7 +134,7 @@ public class OrganizationPage
|
||||||
|
|
||||||
//
|
//
|
||||||
data.setContent("organizationHeaderView", OrganizationHeaderView.htmlize(organization));
|
data.setContent("organizationHeaderView", OrganizationHeaderView.htmlize(organization));
|
||||||
data.setContent("serviceListView", ServiceListView.build(organization.getServices().sortByName()));
|
data.setContent("serviceListView", ServiceListView.htmlize(organization.getServices().sortByName()));
|
||||||
|
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organization.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organization.xhtml", data).toString();
|
||||||
|
|
||||||
|
|
|
@ -82,11 +82,11 @@ public class ServiceHeaderView
|
||||||
data.setAttribute("serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png");
|
data.setAttribute("serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png");
|
||||||
data.setAttribute("serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString()));
|
data.setAttribute("serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString()));
|
||||||
|
|
||||||
data.setAttribute("rawLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".properties");
|
data.setAttribute("rawLink", "href", service.getLocalFileBaseName() + ".properties");
|
||||||
data.setAttribute("rawCheckLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-check.xhtml");
|
data.setAttribute("rawCheckLink", "href", service.getLocalFileBaseName() + "-check.xhtml");
|
||||||
|
|
||||||
data.setAttribute("statsLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
data.setAttribute("statsLink", "href", service.getLocalFileBaseName() + ".xhtml");
|
||||||
data.setAttribute("metricsLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics.xhtml");
|
data.setAttribute("metricsLink", "href", service.getLocalFileBaseName() + "-metrics-summary-months-last.xhtml");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(service.getLegalWebsite()))
|
if (StringUtils.isNotBlank(service.getLegalWebsite()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class ServiceListView
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
*/
|
*/
|
||||||
public static String build(final Services services) throws StatoolInfosException
|
public static String htmlize(final Services services) throws StatoolInfosException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Service;
|
import fr.devinsy.statoolinfos.core.Service;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -39,30 +46,33 @@ public class ServiceMetricGenericPage
|
||||||
/**
|
/**
|
||||||
* Builds the.
|
* Builds the.
|
||||||
*
|
*
|
||||||
|
* @param htmlizeDirectory
|
||||||
|
* the htmlize directory
|
||||||
* @param service
|
* @param service
|
||||||
* the service
|
* the service
|
||||||
* @return the string
|
* @param view
|
||||||
|
* the view
|
||||||
|
* @param period
|
||||||
|
* the period
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
|
* @throws IOException
|
||||||
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Service service) throws StatoolInfosException
|
public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.debug("Building service generic metrics view {}…", service.get("service.name"));
|
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
//
|
//
|
||||||
data.setContent("headerView", ServiceHeaderView.htmlize(service));
|
data.setContent("headerView", ServiceHeaderView.htmlize(service));
|
||||||
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERIC));
|
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.GENERIC, view, period));
|
||||||
|
|
||||||
//
|
//
|
||||||
MetricHtmlizer.htmlizeData(data, "users.count", service, "metrics.users.count", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlize(data, "users.count", service, view, period, "metrics.users.count", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "database.bytes", service, "metrics.database.bytes", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlize(data, "database.bytes", service, view, period, "metrics.database.bytes", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "files.bytes", service, "metrics.http.visits.visitors", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlize(data, "files.bytes", service, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();
|
||||||
|
@ -70,14 +80,14 @@ public class ServiceMetricGenericPage
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
|
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
|
||||||
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building service generic metric view: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building service generic metric view: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
187
src/fr/devinsy/statoolinfos/htmlize/ServiceMetricHtmlizer.java
Normal file
187
src/fr/devinsy/statoolinfos/htmlize/ServiceMetricHtmlizer.java
Normal file
|
@ -0,0 +1,187 @@
|
||||||
|
/*
|
||||||
|
* 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.htmlize.charts.MonthValues;
|
||||||
|
import fr.devinsy.statoolinfos.htmlize.charts.WeekValues;
|
||||||
|
import fr.devinsy.statoolinfos.htmlize.charts.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 htmlizeData(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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -35,12 +37,104 @@ public class ServiceMetricMenuView
|
||||||
{
|
{
|
||||||
private static Logger logger = LoggerFactory.getLogger(ServiceMetricMenuView.class);
|
private static Logger logger = LoggerFactory.getLogger(ServiceMetricMenuView.class);
|
||||||
|
|
||||||
public enum MenuItem
|
public enum PeriodMenu
|
||||||
|
{
|
||||||
|
FULL,
|
||||||
|
LAST,
|
||||||
|
Y2020,
|
||||||
|
Y2021;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
SUMMARY,
|
||||||
WEB,
|
WEB,
|
||||||
GENERIC,
|
GENERIC,
|
||||||
SPECIFIC
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +146,7 @@ public class ServiceMetricMenuView
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Service service, final MenuItem item) throws StatoolInfosException
|
public static String htmlize(final Service service, final TypeMenu type, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
|
@ -60,35 +154,108 @@ public class ServiceMetricMenuView
|
||||||
{
|
{
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setAttribute("summaryTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics.xhtml");
|
//
|
||||||
data.setAttribute("genericTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-generic.xhtml");
|
String filename = String.format("%s-metrics-summary-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName());
|
||||||
data.setAttribute("webTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-web.xhtml");
|
data.setAttribute("summaryTypeButton", "href", filename);
|
||||||
data.setAttribute("specificTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-specific.xhtml");
|
|
||||||
|
|
||||||
if ((item == null) || (item == MenuItem.SUMMARY))
|
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-2020.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName());
|
||||||
|
data.setAttribute("2020PeriodButton", "href", filename);
|
||||||
|
|
||||||
|
filename = String.format("%s-metrics-%s-%s-2021.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName());
|
||||||
|
data.setAttribute("2021PeriodButton", "href", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if ((type == null) || (type == TypeMenu.SUMMARY))
|
||||||
{
|
{
|
||||||
data.appendAttribute("summaryTypeButton", "class", "button selected");
|
data.appendAttribute("summaryTypeButton", "class", "button selected");
|
||||||
}
|
}
|
||||||
else if (item == MenuItem.GENERIC)
|
else if (type == TypeMenu.GENERIC)
|
||||||
{
|
{
|
||||||
data.appendAttribute("genericTypeButton", "class", "button selected");
|
data.appendAttribute("genericTypeButton", "class", "button selected");
|
||||||
}
|
}
|
||||||
else if (item == MenuItem.WEB)
|
else if (type == TypeMenu.WEB)
|
||||||
{
|
{
|
||||||
data.appendAttribute("webTypeButton", "class", "button selected");
|
data.appendAttribute("webTypeButton", "class", "button selected");
|
||||||
}
|
}
|
||||||
else if (item == MenuItem.SPECIFIC)
|
else if (type == TypeMenu.SPECIFIC)
|
||||||
{
|
{
|
||||||
data.appendAttribute("specificTypeButton", "class", "button selected");
|
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.Y2020)
|
||||||
|
{
|
||||||
|
data.appendAttribute("2020PeriodButton", "class", "button selected");
|
||||||
|
}
|
||||||
|
else if (period == PeriodMenu.Y2021)
|
||||||
|
{
|
||||||
|
data.appendAttribute("2021PeriodButton", "class", "button selected");
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString();
|
||||||
result = XidynUtils.extractBodyContent(content);
|
result = XidynUtils.extractBodyContent(content);
|
||||||
}
|
}
|
||||||
catch (XidynException exception)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building service metric menu view: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building metric menu view: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -18,12 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Service;
|
import fr.devinsy.statoolinfos.core.Service;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -39,31 +46,34 @@ public class ServiceMetricSpecificPage
|
||||||
/**
|
/**
|
||||||
* Builds the.
|
* Builds the.
|
||||||
*
|
*
|
||||||
|
* @param htmlizeDirectory
|
||||||
|
* the htmlize directory
|
||||||
* @param service
|
* @param service
|
||||||
* the service
|
* the service
|
||||||
* @return the string
|
* @param view
|
||||||
|
* the view
|
||||||
|
* @param period
|
||||||
|
* the period
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
|
* @throws IOException
|
||||||
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Service service) throws StatoolInfosException
|
public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.debug("Building service specific metric view {}…", service.get("service.name"));
|
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
//
|
//
|
||||||
data.setContent("headerView", ServiceHeaderView.htmlize(service));
|
data.setContent("headerView", ServiceHeaderView.htmlize(service));
|
||||||
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SPECIFIC));
|
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.SPECIFIC, view, period));
|
||||||
|
|
||||||
//
|
//
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (String metricPath : service.getMetricSpecificPrefixes())
|
for (String metricPath : service.getMetricSpecificPrefixes())
|
||||||
{
|
{
|
||||||
MetricHtmlizer.htmlizeData(data, "foo" + index++, service, metricPath, ChartColor.BLUE);
|
ServiceMetricHtmlizer.htmlize(data, "foo" + index++, service, view, period, metricPath, ChartColor.BLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -72,14 +82,14 @@ public class ServiceMetricSpecificPage
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
|
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
|
||||||
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building service specific metrics view: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building service specific metrics view: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Service;
|
import fr.devinsy.statoolinfos.core.Service;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -36,43 +43,35 @@ public class ServiceMetricSummaryPage
|
||||||
{
|
{
|
||||||
private static Logger logger = LoggerFactory.getLogger(ServiceMetricSummaryPage.class);
|
private static Logger logger = LoggerFactory.getLogger(ServiceMetricSummaryPage.class);
|
||||||
|
|
||||||
private static final int CHART_YEARS_FULL = 0;
|
|
||||||
private static final int CHART_MONTHS_FULL = 1;
|
|
||||||
private static final int CHART_MONTHS_LAST = 2;
|
|
||||||
private static final int CHART_MONTHS_2020 = 3;
|
|
||||||
private static final int CHART_MONTHS_2021 = 4;
|
|
||||||
private static final int CHART_WEEKS_FULL = 5;
|
|
||||||
private static final int CHART_WEEKS_LAST = 6;
|
|
||||||
private static final int CHART_WEEKS_2020 = 7;
|
|
||||||
private static final int CHART_WEEKS_2021 = 8;
|
|
||||||
private static final int CHART_DAYS_LAST = 9;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Htmlize.
|
* Builds the.
|
||||||
*
|
*
|
||||||
|
* @param htmlizeDirectory
|
||||||
|
* the htmlize directory
|
||||||
* @param service
|
* @param service
|
||||||
* the service
|
* the service
|
||||||
* @return the string
|
* @param view
|
||||||
|
* the view
|
||||||
|
* @param period
|
||||||
|
* the period
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
|
* @throws IOException
|
||||||
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Service service) throws StatoolInfosException
|
public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.debug("Building service generic metric page {}…", service.get("service.name"));
|
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
//
|
//
|
||||||
data.setContent("headerView", ServiceHeaderView.htmlize(service));
|
data.setContent("headerView", ServiceHeaderView.htmlize(service));
|
||||||
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SUMMARY));
|
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.SUMMARY, view, period));
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.visitors", service, "metrics.http.hits.visitors", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlize(data, "http.hits.visitors", service, view, period, "metrics.http.hits.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.visitors", service, "metrics.http.ip.visitors", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlize(data, "http.ip.visitors", service, view, period, "metrics.http.ip.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits.visitors", service, "metrics.http.visits.visitors", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlize(data, "http.visits.visitors", service, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
|
||||||
|
@ -80,14 +79,14 @@ public class ServiceMetricSummaryPage
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
|
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
|
||||||
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.htmlize;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import fr.devinsy.statoolinfos.core.Service;
|
import fr.devinsy.statoolinfos.core.Service;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.MenuItem;
|
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.statoolinfos.htmlize.charts.ChartColor;
|
||||||
import fr.devinsy.xidyn.XidynException;
|
import fr.devinsy.xidyn.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
|
@ -37,63 +44,70 @@ public class ServiceMetricWebPage
|
||||||
private static Logger logger = LoggerFactory.getLogger(ServiceMetricWebPage.class);
|
private static Logger logger = LoggerFactory.getLogger(ServiceMetricWebPage.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Htmlize.
|
* Builds the.
|
||||||
*
|
*
|
||||||
|
* @param htmlizeDirectory
|
||||||
|
* the htmlize directory
|
||||||
* @param service
|
* @param service
|
||||||
* the service
|
* the service
|
||||||
* @return the string
|
* @param view
|
||||||
|
* the view
|
||||||
|
* @param period
|
||||||
|
* the period
|
||||||
* @throws StatoolInfosException
|
* @throws StatoolInfosException
|
||||||
* the statool infos exception
|
* the statool infos exception
|
||||||
|
* @throws IOException
|
||||||
|
* Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
public static String htmlize(final Service service) throws StatoolInfosException
|
public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException
|
||||||
{
|
{
|
||||||
String result;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.debug("Building service generic metric page {}…", service.get("service.name"));
|
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
//
|
//
|
||||||
data.setContent("headerView", ServiceHeaderView.htmlize(service));
|
data.setContent("headerView", ServiceHeaderView.htmlize(service));
|
||||||
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.WEB));
|
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.WEB, view, period));
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits", service, "metrics.http.hits", ChartColor.BLUE);
|
ServiceMetricHtmlizer.htmlize(data, "http.hits", service, view, period, "metrics.http.hits", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits-ipv4ipv6", service, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlizeData(data, "http.hits-ipv4ipv6", service, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6",
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.ipv4", service, "metrics.http.hits.ipv4", ChartColor.YELLOW);
|
ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.ipv6", service, "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);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits-visitorsbots", service, "http.hits (visitors + bots)", "metrics.http.hits.visitors", ChartColor.GREEN, "metrics.http.hits.bots",
|
ServiceMetricHtmlizer.htmlizeData(data, "http.hits-visitorsbots", service, view, period, "http.hits (visitors + bots)", "metrics.http.hits.visitors", ChartColor.GREEN,
|
||||||
|
"metrics.http.hits.bots",
|
||||||
ChartColor.YELLOW);
|
ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.visitors", service, "metrics.http.hits.visitors", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlize(data, "http.hits.visitors", service, view, period, "metrics.http.hits.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.hits.bots", service, "metrics.http.hits.bots", ChartColor.YELLOW);
|
ServiceMetricHtmlizer.htmlize(data, "http.hits.bots", service, view, period, "metrics.http.hits.bots", ChartColor.YELLOW);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.errors", service, "metrics.http.errors", ChartColor.RED);
|
ServiceMetricHtmlizer.htmlize(data, "http.errors", service, view, period, "metrics.http.errors", ChartColor.RED);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.errors.php", service, "metrics.http.errors.php", ChartColor.RED);
|
ServiceMetricHtmlizer.htmlize(data, "http.errors.php", service, view, period, "metrics.http.errors.php", ChartColor.RED);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.files", service, "metrics.http.files", ChartColor.BLUE);
|
ServiceMetricHtmlizer.htmlize(data, "http.files", service, view, period, "metrics.http.files", ChartColor.BLUE);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.pages", service, "metrics.http.pages", ChartColor.BLUE);
|
ServiceMetricHtmlizer.htmlize(data, "http.pages", service, view, period, "metrics.http.pages", ChartColor.BLUE);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.bytes", service, "metrics.http.bytes", ChartColor.BLUE);
|
ServiceMetricHtmlizer.htmlize(data, "http.bytes", service, view, period, "metrics.http.bytes", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip", service, "metrics.http.ip", ChartColor.BLUE);
|
ServiceMetricHtmlizer.htmlize(data, "http.ip", service, view, period, "metrics.http.ip", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip-visitorsbots", service, "http.ip (visitors + bots)", "metrics.http.ip.visitors", ChartColor.GREEN, "metrics.http.ip.bots",
|
ServiceMetricHtmlizer.htmlizeData(data, "http.ip-visitorsbots", service, view, period, "http.ip (visitors + bots)", "metrics.http.ip.visitors", ChartColor.GREEN, "metrics.http.ip.bots",
|
||||||
ChartColor.YELLOW);
|
ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.visitors", service, "metrics.http.ip.visitors", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlize(data, "http.ip.visitors", service, view, period, "metrics.http.ip.visitors", ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.bots", service, "metrics.http.ip.bots", ChartColor.YELLOW);
|
ServiceMetricHtmlizer.htmlize(data, "http.ip.bots", service, view, period, "metrics.http.ip.bots", ChartColor.YELLOW);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip-ipv4ipv6", service, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlizeData(data, "http.ip-ipv4ipv6", service, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6",
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.ipv4", service, "metrics.http.ip.ipv4", ChartColor.YELLOW);
|
ChartColor.GREEN);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.ip.ipv6", service, "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);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits", service, "metrics.http.visits", ChartColor.BLUE);
|
ServiceMetricHtmlizer.htmlize(data, "http.visits", service, view, period, "metrics.http.visits", ChartColor.BLUE);
|
||||||
|
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits-visitorsbots", service, "http.visits (visitors + bots)", "metrics.http.visits.visitors", ChartColor.GREEN, "metrics.http.visits.bots",
|
ServiceMetricHtmlizer.htmlizeData(data, "http.visits-visitorsbots", service, view, period, "http.visits (visitors + bots)", "metrics.http.visits.visitors", ChartColor.GREEN,
|
||||||
|
"metrics.http.visits.bots",
|
||||||
ChartColor.YELLOW);
|
ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits.bots", service, "metrics.http.visits.bots", ChartColor.YELLOW);
|
ServiceMetricHtmlizer.htmlize(data, "http.visits.bots", service, view, period, "metrics.http.visits.bots", ChartColor.YELLOW);
|
||||||
MetricHtmlizer.htmlizeData(data, "http.visits.visitors", service, "metrics.http.visits.visitors", ChartColor.GREEN);
|
ServiceMetricHtmlizer.htmlize(data, "http.visits.visitors", service, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString();
|
||||||
|
@ -101,14 +115,14 @@ public class ServiceMetricWebPage
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
|
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
|
||||||
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
||||||
result = WebCharterView.build(content, trail);
|
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)
|
catch (XidynException exception)
|
||||||
{
|
{
|
||||||
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
|
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@ import fr.devinsy.statoolinfos.core.Metrics;
|
||||||
import fr.devinsy.statoolinfos.core.Service;
|
import fr.devinsy.statoolinfos.core.Service;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
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.XidynException;
|
||||||
import fr.devinsy.xidyn.data.TagDataManager;
|
import fr.devinsy.xidyn.data.TagDataManager;
|
||||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||||
|
@ -76,22 +78,23 @@ public class ServicePage
|
||||||
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
//
|
//
|
||||||
logger.info("Htmlize service summary metric page: {}.", service.getName());
|
logger.info("Htmlize service metric pages: {}.", service.getName());
|
||||||
page = ServiceMetricSummaryPage.htmlize(service);
|
for (ViewMenu view : ViewMenu.values())
|
||||||
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics.xhtml"), page, StandardCharsets.UTF_8);
|
{
|
||||||
|
for (PeriodMenu period : PeriodMenu.values())
|
||||||
//
|
{
|
||||||
logger.info("Htmlize service generic metric page: {}.", service.getName());
|
if ((view != ViewMenu.YEARS) || (period == PeriodMenu.FULL))
|
||||||
page = ServiceMetricGenericPage.htmlize(service);
|
{
|
||||||
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8);
|
if (view != ViewMenu.DAYS)
|
||||||
|
{
|
||||||
logger.info("Htmlize service web metric page: {}.", service.getName());
|
ServiceMetricSummaryPage.build(htmlizeDirectory, service, view, period);
|
||||||
page = ServiceMetricWebPage.htmlize(service);
|
ServiceMetricGenericPage.build(htmlizeDirectory, service, view, period);
|
||||||
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8);
|
ServiceMetricSpecificPage.build(htmlizeDirectory, service, view, period);
|
||||||
|
ServiceMetricWebPage.build(htmlizeDirectory, service, view, period);
|
||||||
logger.info("Htmlize service specific metric page: {}.", service.getName());
|
}
|
||||||
page = ServiceMetricSpecificPage.htmlize(service);
|
}
|
||||||
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class ServicesPage
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
|
||||||
data.setContent("serviceListView", ServiceListView.build(services));
|
data.setContent("serviceListView", ServiceListView.htmlize(services));
|
||||||
|
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/services.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/services.xhtml", data).toString();
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class SoftwarePage
|
||||||
data.setEscapedContent("softwareDescription", software.getDescription());
|
data.setEscapedContent("softwareDescription", software.getDescription());
|
||||||
data.setContent("serviceCount", services.size());
|
data.setContent("serviceCount", services.size());
|
||||||
|
|
||||||
data.setContent("serviceListView", ServiceListView.build(services));
|
data.setContent("serviceListView", ServiceListView.htmlize(services));
|
||||||
|
|
||||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/software.xhtml", data).toString();
|
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/software.xhtml", data).toString();
|
||||||
|
|
||||||
|
|
|
@ -14,164 +14,28 @@
|
||||||
<div>
|
<div>
|
||||||
<div style="margin: 5px;">
|
<div style="margin: 5px;">
|
||||||
<span style="display: inline-block; width: 100px">Type</span>
|
<span style="display: inline-block; width: 100px">Type</span>
|
||||||
<a onclick="javascript:selectTypeMenu('summary');" href="#" id="summaryTypeButton" class="button">Résumé</a>
|
<a id="summaryTypeButton" href="#" class="button">Résumé</a>
|
||||||
<a onclick="javascript:selectTypeMenu('generic');" href="#" id="genericTypeButton" class="button">Génériques</a>
|
<a id="genericTypeButton" href="#" class="button">Génériques</a>
|
||||||
<a onclick="javascript:selectTypeMenu('specific');" href="#" id="specificTypeButton" class="button">Spécifiques</a>
|
<a id="specificTypeButton" href="#" class="button">Spécifiques</a>
|
||||||
<a onclick="javascript:selectTypeMenu('web');" href="#" id="webTypeButton" class="button">Web</a>
|
<a id="webTypeButton" href="#" class="button">Web</a>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin: 5px;">
|
<div style="margin: 5px;">
|
||||||
<span style="display: inline-block; width: 100px">Vue</span>
|
<span style="display: inline-block; width: 100px">Vue</span>
|
||||||
<a onclick="javascript:selectViewMenu('years');" href="#" id="yearsViewButton" class="button">Années</a>
|
<a id="yearsViewButton" href="#" class="button">Années</a>
|
||||||
<a onclick="javascript:selectViewMenu('months');" href="#" id="monthsViewButton" class="button">Mois</a>
|
<a id="monthsViewButton" href="#" class="button">Mois</a>
|
||||||
<a onclick="javascript:selectViewMenu('weeks');" href="#" id="weeksViewButton" class="button">Semaines</a>
|
<a id="weeksViewButton" href="#" class="button">Semaines</a>
|
||||||
<a onclick="javascript:selectViewMenu('days');" href="#" id="daysViewButton" class="button">Jours</a>
|
<a id="daysViewButton" href="#" class="button">Jours</a>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin: 5px;">
|
<div style="margin: 5px;">
|
||||||
<span style="display: inline-block; width: 100px">Période</span>
|
<span style="display: inline-block; width: 100px">Période</span>
|
||||||
<a onclick="javascript:selectPeriodMenu('full');" href="#" id="fullPeriodButton" class="button">Tout</a>
|
<a id="fullPeriodButton" href="#" class="button">Tout</a>
|
||||||
<a onclick="javascript:selectPeriodMenu('last');" href="#" id="lastPeriodButton" class="button">12 mois</a>
|
<a id="lastPeriodButton" href="#" class="button">12 mois</a>
|
||||||
<a onclick="javascript:selectPeriodMenu('2020');" href="#" id="2020PeriodButton" class="button">2020</a>
|
<a id="2020PeriodButton" href="#" class="button">2020</a>
|
||||||
<a onclick="javascript:selectPeriodMenu('2021');" href="#" id="2021PeriodButton" class="button">2021</a>
|
<a id="2021PeriodButton" href="#" class="button">2021</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var CHART_YEARS_FULL = 0;
|
</script>
|
||||||
var CHART_MONTHS_FULL = 1;
|
|
||||||
var CHART_MONTHS_LAST = 2;
|
|
||||||
var CHART_MONTHS_2020 = 3;
|
|
||||||
var CHART_MONTHS_2021 = 4;
|
|
||||||
var CHART_WEEKS_FULL = 5;
|
|
||||||
var CHART_WEEKS_LAST = 6;
|
|
||||||
var CHART_WEEKS_2020 = 7;
|
|
||||||
var CHART_WEEKS_2021 = 8;
|
|
||||||
var CHART_DAYS_LAST = 9;
|
|
||||||
|
|
||||||
var currentView = 'months';
|
|
||||||
var currentPeriod = 'last';
|
|
||||||
|
|
||||||
function refreshMenu()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
document.getElementById('yearsViewButton').classList.remove('selected');
|
|
||||||
document.getElementById('monthsViewButton').classList.remove('selected');
|
|
||||||
document.getElementById('weeksViewButton').classList.remove('selected');
|
|
||||||
document.getElementById('daysViewButton').classList.remove('selected');
|
|
||||||
|
|
||||||
document.getElementById(currentView + 'ViewButton').classList.add('selected');
|
|
||||||
|
|
||||||
//
|
|
||||||
document.getElementById('fullPeriodButton').classList.remove('selected');
|
|
||||||
document.getElementById('lastPeriodButton').classList.remove('selected');
|
|
||||||
document.getElementById('2020PeriodButton').classList.remove('selected');
|
|
||||||
document.getElementById('2021PeriodButton').classList.remove('selected');
|
|
||||||
|
|
||||||
document.getElementById(currentPeriod + 'PeriodButton').classList.add('selected');
|
|
||||||
|
|
||||||
//
|
|
||||||
document.getElementById('charts_' + CHART_YEARS_FULL).style.display = 'none';
|
|
||||||
document.getElementById('charts_' + CHART_MONTHS_FULL).style.display = 'none';
|
|
||||||
document.getElementById('charts_' + CHART_MONTHS_LAST).style.display = 'none';
|
|
||||||
document.getElementById('charts_' + CHART_MONTHS_2020).style.display = 'none';
|
|
||||||
document.getElementById('charts_' + CHART_MONTHS_2021).style.display = 'none';
|
|
||||||
document.getElementById('charts_' + CHART_WEEKS_FULL).style.display = 'none';
|
|
||||||
document.getElementById('charts_' + CHART_WEEKS_LAST).style.display = 'none';
|
|
||||||
document.getElementById('charts_' + CHART_WEEKS_2020).style.display = 'none';
|
|
||||||
document.getElementById('charts_' + CHART_WEEKS_2021).style.display = 'none';
|
|
||||||
//document.getElementById('charts_' + CHART_DAYS_LAST).style.display = 'none';
|
|
||||||
|
|
||||||
if (currentView == 'years')
|
|
||||||
{
|
|
||||||
if (currentPeriod == 'full')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_YEARS_FULL).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == 'last')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_YEARS_FULL).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == '2020')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_YEARS_FULL).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == '2021')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_YEARS_FULL).style.display = 'block';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (currentView == 'months')
|
|
||||||
{
|
|
||||||
if (currentPeriod == 'full')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_MONTHS_FULL).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == 'last')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_MONTHS_LAST).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == '2020')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_MONTHS_2020).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == '2021')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_MONTHS_2021).style.display = 'block';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (currentView == 'weeks')
|
|
||||||
{
|
|
||||||
if (currentPeriod == 'full')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_WEEKS_FULL).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == 'last')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_WEEKS_LAST).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == '2020')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_WEEKS_2020).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == '2021')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_WEEKS_2021).style.display = 'block';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (currentView == 'days')
|
|
||||||
{
|
|
||||||
if (currentPeriod == 'full')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_DAYS_LAST).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == 'last')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_DAYS_LAST).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == '2020')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_DAYS_LAST).style.display = 'block';
|
|
||||||
}
|
|
||||||
else if (currentPeriod == '2021')
|
|
||||||
{
|
|
||||||
document.getElementById('charts_' + CHART_DAYS_LAST).style.display = 'block';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectViewMenu(selection)
|
|
||||||
{
|
|
||||||
currentView = selection;
|
|
||||||
refreshMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectPeriodMenu(selection)
|
|
||||||
{
|
|
||||||
currentPeriod = selection;
|
|
||||||
refreshMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
window.onload=function() {refreshMenu();}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue