Refactored stats menu in organization and service.

This commit is contained in:
Christian P. MOMON 2021-05-27 05:08:19 +02:00
parent ddf4132386
commit b4b01f5610
17 changed files with 276 additions and 187 deletions

View file

@ -37,8 +37,8 @@ public class OrganizationMetricMenuView
public enum MenuItem public enum MenuItem
{ {
SUMMARY,
GENERAL, GENERAL,
SUMMARY,
GENERIC, GENERIC,
WEB, WEB,
SPECIFIC SPECIFIC
@ -61,20 +61,20 @@ public class OrganizationMetricMenuView
{ {
TagDataManager data = new TagDataManager(); TagDataManager data = new TagDataManager();
data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-stats.xhtml"); data.setAttribute("generalTypeButton", "href", organization.getTechnicalName() + "-stats.xhtml");
data.setAttribute("generalTypeButton", "href", organization.getTechnicalName() + "-stats-general.xhtml"); data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-stats-summarymetrics.xhtml");
data.setAttribute("genericTypeButton", "href", organization.getTechnicalName() + "-stats-genericmetrics.xhtml"); data.setAttribute("genericTypeButton", "href", organization.getTechnicalName() + "-stats-genericmetrics.xhtml");
data.setAttribute("webTypeButton", "href", organization.getTechnicalName() + "-stats-webmetrics.xhtml"); data.setAttribute("webTypeButton", "href", organization.getTechnicalName() + "-stats-webmetrics.xhtml");
data.setAttribute("specificTypeButton", "href", organization.getTechnicalName() + "-stats-specificmetrics.xhtml"); data.setAttribute("specificTypeButton", "href", organization.getTechnicalName() + "-stats-specificmetrics.xhtml");
if ((item == null) || (item == MenuItem.SUMMARY)) if ((item == null) || (item == MenuItem.GENERAL))
{
data.appendAttribute("summaryTypeButton", "class", "button selected");
}
else if (item == MenuItem.GENERAL)
{ {
data.appendAttribute("generalTypeButton", "class", "button selected"); data.appendAttribute("generalTypeButton", "class", "button selected");
} }
else if (item == MenuItem.SUMMARY)
{
data.appendAttribute("summaryTypeButton", "class", "button selected");
}
else if (item == MenuItem.GENERIC) else if (item == MenuItem.GENERIC)
{ {
data.appendAttribute("genericTypeButton", "class", "button selected"); data.appendAttribute("genericTypeButton", "class", "button selected");

View file

@ -77,9 +77,9 @@ 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 general metric page: {}.", organization.getName()); logger.info("Htmlize organization summarty metric page: {}.", organization.getName());
page = OrganizationGeneralStatsPage.htmlize(organization); page = OrganizationSummaryStatsPage.htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-general.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-summarymetrics.xhtml"), page, StandardCharsets.UTF_8);
logger.info("Htmlize organization generic metric page: {}.", organization.getName()); logger.info("Htmlize organization generic metric page: {}.", organization.getName());
page = OrganizationGenericMetricPage.htmlize(organization); page = OrganizationGenericMetricPage.htmlize(organization);

View file

@ -20,7 +20,6 @@ package fr.devinsy.statoolinfos.htmlize;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.time.YearMonth;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -29,8 +28,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.htmlize.OrganizationMetricMenuView.MenuItem; import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.htmlize.charts.MonthValues; import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
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;
@ -67,32 +66,32 @@ public class OrganizationStatsPage
// //
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, MenuItem.GENERAL));
String tagIds[] = { "fullChart", "lastChart", "2020Chart", "2021Chart" }; //
YearMonth starts[] = { null, YearMonth.now().minusMonths(11), YearMonth.of(2020, 01), YearMonth.of(2021, 01) }; data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization));
YearMonth ends[] = { null, YearMonth.now(), YearMonth.of(2020, 12), YearMonth.of(2021, 12) }; data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(organization.getServices()));
for (int index = 0; index < tagIds.length; index++) data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organization));
data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(organization.getServices()));
data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(organization.getServices()));
data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(organization.getServices()));
data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(organization.getServices()));
//
{ {
String tagId = tagIds[index]; RegistrationStats stats = StatAgent.statRegistrationTypes(organization.getServices());
YearMonth start = starts[index];
YearMonth end = ends[index];
int graphicIndex = 0; data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats));
data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats));
MonthValues metric = organization.getMetricMonthValuesAll("metrics.http.hits.visitors"); data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats));
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats));
data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats));
metric = organization.getMetricMonthValuesAll("metrics.http.ip.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
metric = organization.getMetricMonthValuesAll("metrics.http.visits.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
} }
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStatsView.xhtml", data).toString();
// //
BreadcrumbTrail trail = new BreadcrumbTrail(); BreadcrumbTrail trail = new BreadcrumbTrail();

View file

@ -20,6 +20,7 @@ package fr.devinsy.statoolinfos.htmlize;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.time.YearMonth;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -28,8 +29,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.htmlize.OrganizationMetricMenuView.MenuItem; import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem;
import fr.devinsy.statoolinfos.stats.StatAgent; import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.statoolinfos.stats.services.RegistrationStats; import fr.devinsy.statoolinfos.htmlize.charts.MonthValues;
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;
@ -37,9 +38,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils;
/** /**
* The Class OrganizationGeneralStatsPage. * The Class OrganizationGeneralStatsPage.
*/ */
public class OrganizationGeneralStatsPage public class OrganizationSummaryStatsPage
{ {
private static Logger logger = LoggerFactory.getLogger(OrganizationGeneralStatsPage.class); private static Logger logger = LoggerFactory.getLogger(OrganizationSummaryStatsPage.class);
/** /**
* Htmlize. * Htmlize.
@ -58,7 +59,7 @@ public class OrganizationGeneralStatsPage
try try
{ {
logger.debug("Building organization general page {}…"); logger.debug("Building organization summary page {}…");
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
@ -68,30 +69,30 @@ public class OrganizationGeneralStatsPage
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, MenuItem.SUMMARY));
// String tagIds[] = { "fullChart", "lastChart", "2020Chart", "2021Chart" };
data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization)); YearMonth starts[] = { null, YearMonth.now().minusMonths(11), YearMonth.of(2020, 01), YearMonth.of(2021, 01) };
data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(organization.getServices())); YearMonth ends[] = { null, YearMonth.now(), YearMonth.of(2020, 12), YearMonth.of(2021, 12) };
data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organization)); for (int index = 0; index < tagIds.length; index++)
data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(organization.getServices()));
data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(organization.getServices()));
data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(organization.getServices()));
data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(organization.getServices()));
//
{ {
RegistrationStats stats = StatAgent.statRegistrationTypes(organization.getServices()); String tagId = tagIds[index];
YearMonth start = starts[index];
YearMonth end = ends[index];
data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats)); int graphicIndex = 0;
data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats));
data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats)); MonthValues metric = organization.getMetricMonthValuesAll("metrics.http.hits.visitors");
data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats)); data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats));
metric = organization.getMetricMonthValuesAll("metrics.http.ip.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
metric = organization.getMetricMonthValuesAll("metrics.http.visits.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
} }
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationGeneralStatsView.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml", data).toString();
// //
BreadcrumbTrail trail = new BreadcrumbTrail(); BreadcrumbTrail trail = new BreadcrumbTrail();
@ -100,7 +101,7 @@ public class OrganizationGeneralStatsPage
} }
catch (XidynException exception) catch (XidynException exception)
{ {
throw new StatoolInfosException("Error building organization general page: " + exception.getMessage(), exception); throw new StatoolInfosException("Error building organization summary page: " + exception.getMessage(), exception);
} }
// //

View file

@ -50,19 +50,19 @@ public class ServiceGenericMetricPage
try try
{ {
logger.debug("Building service page {}…", service.get("service.name")); 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("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERIC)); data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERIC));
// //
int graphicIndex = 0; int graphicIndex = 0;
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricView.xhtml", data).toString();
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");
@ -71,7 +71,7 @@ public class ServiceGenericMetricPage
} }
catch (XidynException exception) catch (XidynException exception)
{ {
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); throw new StatoolInfosException("Error building service generic metric view: " + exception.getMessage(), exception);
} }
// //

View file

@ -37,10 +37,10 @@ public class ServiceMetricMenuView
public enum MenuItem public enum MenuItem
{ {
SUMMARY,
GENERAL, GENERAL,
GENERIC, SUMMARY,
WEB, WEB,
GENERIC,
SPECIFIC SPECIFIC
} }
@ -61,20 +61,20 @@ public class ServiceMetricMenuView
{ {
TagDataManager data = new TagDataManager(); TagDataManager data = new TagDataManager();
data.setAttribute("summaryTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); data.setAttribute("generalTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
data.setAttribute("generalTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-general.xhtml"); data.setAttribute("summaryTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-summarymetrics.xhtml");
data.setAttribute("genericTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-generic.xhtml"); data.setAttribute("genericTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-genericmetrics.xhtml");
data.setAttribute("webTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-web.xhtml"); data.setAttribute("webTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-webmetrics.xhtml");
data.setAttribute("specificTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-specific.xhtml"); data.setAttribute("specificTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-specificmetrics.xhtml");
if ((item == null) || (item == MenuItem.SUMMARY)) if ((item == null) || (item == MenuItem.GENERAL))
{
data.appendAttribute("summaryTypeButton", "class", "button selected");
}
else if (item == MenuItem.GENERAL)
{ {
data.appendAttribute("generalTypeButton", "class", "button selected"); data.appendAttribute("generalTypeButton", "class", "button selected");
} }
else if (item == MenuItem.SUMMARY)
{
data.appendAttribute("summaryTypeButton", "class", "button selected");
}
else if (item == MenuItem.GENERIC) else if (item == MenuItem.GENERIC)
{ {
data.appendAttribute("genericTypeButton", "class", "button selected"); data.appendAttribute("genericTypeButton", "class", "button selected");

View file

@ -21,7 +21,6 @@ package fr.devinsy.statoolinfos.htmlize;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.YearMonth;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -33,9 +32,6 @@ 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.MenuItem;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.statoolinfos.htmlize.charts.MonthValues;
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;
@ -80,22 +76,22 @@ 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 general metric page: {}.", service.getName()); logger.info("Htmlize service summary metric page: {}.", service.getName());
page = ServiceStatsPage.htmlize(service); page = ServiceSummaryMetricPage.htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-general.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-summarymetrics.xhtml"), page, StandardCharsets.UTF_8);
// //
logger.info("Htmlize service generic metric page: {}.", service.getName()); logger.info("Htmlize service generic metric page: {}.", service.getName());
page = ServiceGenericMetricPage.htmlize(service); page = ServiceGenericMetricPage.htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-genericmetrics.xhtml"), page, StandardCharsets.UTF_8);
logger.info("Htmlize service web metric page: {}.", service.getName()); logger.info("Htmlize service web metric page: {}.", service.getName());
page = ServiceWebMetricPage.htmlize(service); page = ServiceWebMetricPage.htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-webmetrics.xhtml"), page, StandardCharsets.UTF_8);
logger.info("Htmlize service specific metric page: {}.", service.getName()); logger.info("Htmlize service specific metric page: {}.", service.getName());
page = ServiceSpecificMetricPage.htmlize(service); page = ServiceSpecificMetricPage.htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-specificmetrics.xhtml"), page, StandardCharsets.UTF_8);
} }
/** /**
@ -135,7 +131,7 @@ public class ServicePage
// //
data.setContent("headerView", ServiceHeaderView.htmlize(service)); data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SUMMARY)); data.setContent("statsView", ServiceStatsView.htmlize(service));
// //
// data.setContent("fooChart", graphicIndex++, // data.setContent("fooChart", graphicIndex++,
@ -143,28 +139,6 @@ public class ServicePage
// service.getPrefixes(); // service.getPrefixes();
String tagIds[] = { "fullChart", "lastChart", "2020Chart", "2021Chart" };
YearMonth starts[] = { null, YearMonth.now().minusMonths(11), YearMonth.of(2020, 01), YearMonth.of(2021, 01) };
YearMonth ends[] = { null, YearMonth.now(), YearMonth.of(2020, 12), YearMonth.of(2021, 12) };
for (int index = 0; index < tagIds.length; index++)
{
String tagId = tagIds[index];
YearMonth start = starts[index];
YearMonth end = ends[index];
int graphicIndex = 0;
MonthValues metric = service.getMetricMonthValues("metrics.http.hits.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
metric = service.getMetricMonthValues("metrics.http.ip.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
metric = service.getMetricMonthValues("metrics.http.visits.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
}
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString();

View file

@ -50,19 +50,19 @@ public class ServiceSpecificMetricPage
try try
{ {
logger.debug("Building service specific page {}…", service.get("service.name")); 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("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SPECIFIC)); data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SPECIFIC));
// //
int graphicIndex = 0; int graphicIndex = 0;
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricView.xhtml", data).toString();
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");
@ -71,7 +71,7 @@ public class ServiceSpecificMetricPage
} }
catch (XidynException exception) catch (XidynException exception)
{ {
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); throw new StatoolInfosException("Error building service specific metrics view: " + exception.getMessage(), exception);
} }
// //

View file

@ -30,13 +30,14 @@ import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
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;
import fr.devinsy.xidyn.utils.XidynUtils;
/** /**
* The Class ServiceStatsPage. * The Class ServiceStatsPage.
*/ */
public class ServiceStatsPage public class ServiceStatsView
{ {
private static Logger logger = LoggerFactory.getLogger(ServiceStatsPage.class); private static Logger logger = LoggerFactory.getLogger(ServiceStatsView.class);
/** /**
* Builds the. * Builds the.
@ -53,13 +54,12 @@ public class ServiceStatsPage
try try
{ {
logger.debug("Building service stats page {}…", service.get("service.name")); logger.debug("Building service stats view {}…", service.get("service.name"));
TagDataManager data = new TagDataManager(); TagDataManager data = new TagDataManager();
// //
data.setContent("headerView", ServiceHeaderView.htmlize(service)); data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERAL));
data.setContent("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERAL));
// //
data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(service)); data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(service));
@ -86,16 +86,13 @@ public class ServiceStatsPage
data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(mock)); data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(mock));
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceStats.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail(); result = XidynUtils.extractBodyContent(content);
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) catch (XidynException exception)
{ {
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); throw new StatoolInfosException("Error building service view: " + exception.getMessage(), exception);
} }
// //

View file

@ -0,0 +1,104 @@
/*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
* StatoolInfos is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* StatoolInfos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.htmlize;
import java.time.YearMonth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.MenuItem;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.statoolinfos.htmlize.charts.MonthValues;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class ServiceSummaryMetricPage.
*/
public class ServiceSummaryMetricPage
{
private static Logger logger = LoggerFactory.getLogger(ServiceSummaryMetricPage.class);
/**
* Builds the.
*
* @param service
* the service
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final Service service) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building service summary view {}…", service.get("service.name"));
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SUMMARY));
//
String tagIds[] = { "fullChart", "lastChart", "2020Chart", "2021Chart" };
YearMonth starts[] = { null, YearMonth.now().minusMonths(11), YearMonth.of(2020, 01), YearMonth.of(2021, 01) };
YearMonth ends[] = { null, YearMonth.now(), YearMonth.of(2020, 12), YearMonth.of(2021, 12) };
for (int index = 0; index < tagIds.length; index++)
{
String tagId = tagIds[index];
YearMonth start = starts[index];
YearMonth end = ends[index];
int graphicIndex = 0;
MonthValues metric = service.getMetricMonthValues("metrics.http.hits.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
metric = service.getMetricMonthValues("metrics.http.ip.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
metric = service.getMetricMonthValues("metrics.http.visits.visitors");
data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN));
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricView.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 summary metrics view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -60,7 +60,7 @@ public class ServiceWebMetricPage
// //
data.setContent("headerView", ServiceHeaderView.htmlize(service)); data.setContent("headerView", ServiceHeaderView.htmlize(service));
data.setContent("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.WEB)); data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.WEB));
// service.getPrefixes(); // service.getPrefixes();
@ -138,7 +138,7 @@ public class ServiceWebMetricPage
} }
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricView.xhtml", data).toString();
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");

View file

@ -14,8 +14,8 @@
<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 onclick="javascript:selectTypeMenu('general');" href="#" id="generalTypeButton" class="button">Général</a> <a onclick="javascript:selectTypeMenu('general');" href="#" id="generalTypeButton" class="button">Général</a>
<a onclick="javascript:selectTypeMenu('summary');" href="#" id="summaryTypeButton" class="button">Résumé</a>
<a onclick="javascript:selectTypeMenu('generic');" href="#" id="genericTypeButton" class="button">Génériques</a> <a onclick="javascript:selectTypeMenu('generic');" href="#" id="genericTypeButton" class="button">Génériques</a>
<a onclick="javascript:selectTypeMenu('web');" href="#" id="webTypeButton" class="button">Web</a> <a onclick="javascript:selectTypeMenu('web');" href="#" id="webTypeButton" class="button">Web</a>
<a onclick="javascript:selectTypeMenu('specific');" href="#" id="specificTypeButton" class="button">Spécifiques</a> <a onclick="javascript:selectTypeMenu('specific');" href="#" id="specificTypeButton" class="button">Spécifiques</a>

View file

@ -12,20 +12,6 @@
</head> </head>
<body> <body>
<div id="headerView" /> <div id="headerView" />
<div id="metricZone"> <div id="statsView" />
<div id="serviceMetricMenuView" />
<div id="fullCharts" style="display: none;">
<div id="fullChart" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
<div id="lastCharts" style="display: block;">
<div id="lastChart" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
<div id="2020Charts" style="display: none;">
<div id="2020Chart" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
<div id="2021Charts" style="display: none;">
<div id="2021Chart" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
</div>
</body> </body>
</html> </html>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>StatoolInfos</title>
<meta charset="UTF-8" />
<meta name="keywords" content="statoolinfos,devinsy,federation" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="statoolinfos.css" />
<script src="sorttable.js" />
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div id="headerView" />
<div id="metricZone">
<div id="metricMenuView" />
<div id="fullCharts" style="display: none;">
<div id="fullChart" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
<div id="lastCharts" style="display: block;">
<div id="lastChart" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
<div id="2020Charts" style="display: none;">
<div id="2020Chart" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
<div id="2021Charts" style="display: none;">
<div id="2021Chart" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
</div>
</body>
</html>

View file

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>StatoolInfos</title>
<meta charset="UTF-8" />
<meta name="keywords" content="statoolinfos,devinsy,federation" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="statoolinfos.css" />
<script src="sorttable.js" />
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div id="headerView" />
<div id="metricZone">
<!-- h2 id="title" class="center">Statistiques</h2-->
<div id="serviceMetricMenuView" />
<div>
<div>
<div id="turnoutChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
</div>
<div>
<div id="hostServerTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div id="hostProviderTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div id="serviceInstallTypeChart" class="chartborder" style="width: 250px; height: 230px; display: inline-block; vertical-align: top;"/>
<div id="serviceCountryChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
</div>
<div class="row">
<div id="registrationTypeChart" class="column chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div class="column">
<div class="row">
<div id="registrationNoneTypeChart" class="chartborder" style="width: 122px; height: 97px; display: inline-block;"/>
<div id="registrationFreeTypeChart" class="chartborder" style="width: 122px; height: 97px; display: inline-block;"/>
</div>
<div class="row">
<div id="registrationMemberTypeChart" class="chartborder" style="width: 122px; height: 97px; display: inline-block;"/>
<div id="registrationClientTypeChart" class="chartborder" style="width: 122px; height: 97px; display: inline-block;"/>
</div>
</div>
</div>
<div>
<div id="serviceDateStatusChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div id="serviceCountYearChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>StatoolInfos</title>
<meta charset="UTF-8" />
<meta name="keywords" content="statoolinfos,devinsy,federation" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="statoolinfos.css" />
<script src="sorttable.js" />
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div id="metricMenuView" />
<div id="metricZone" class="row center_table" style="width: 1100px;">
<!-- h2 id="title" class="center">Statistiques</h2-->
<div>
<div id="turnoutChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
</div>
<div>
<div id="hostServerTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div id="hostProviderTypeChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div id="serviceInstallTypeChart" class="chartborder" style="width: 250px; height: 230px; display: inline-block; vertical-align: top;"/>
<div id="serviceCountryChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
</div>
<div class="row">
<div id="registrationTypeChart" class="column chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div class="column">
<div class="row">
<div id="registrationNoneTypeChart" class="chartborder" style="width: 122px; height: 97px; display: inline-block;"/>
<div id="registrationFreeTypeChart" class="chartborder" style="width: 122px; height: 97px; display: inline-block;"/>
</div>
<div class="row">
<div id="registrationMemberTypeChart" class="chartborder" style="width: 122px; height: 97px; display: inline-block;"/>
<div id="registrationClientTypeChart" class="chartborder" style="width: 122px; height: 97px; display: inline-block;"/>
</div>
</div>
</div>
<div>
<div id="serviceDateStatusChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
<div id="serviceCountYearChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
</div>
</div>
</body>
</html>