diff --git a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java index 174b61d..430c5f8 100644 --- a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java +++ b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java @@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.core.StatoolInfos; import fr.devinsy.statoolinfos.util.BuildInformation; +import fr.devinsy.statoolinfos.util.Chrono; import fr.devinsy.statoolinfos.util.Files; import fr.devinsy.statoolinfos.util.FilesUtils; import fr.devinsy.strings.StringList; @@ -262,6 +263,7 @@ public final class StatoolInfosCLI } else if (isMatching(args, "crawl", "\\s*.+\\s*")) { + Chrono chrono = new Chrono().start(); Files inputs = convertPath(StringUtils.trim(args[1])); for (File input : inputs) { @@ -275,6 +277,7 @@ public final class StatoolInfosCLI exception.printStackTrace(); } } + System.out.println(chrono.format()); } else if (isMatching(args, "format", "\\s*.+\\s*")) { @@ -294,6 +297,7 @@ public final class StatoolInfosCLI } else if (isMatching(args, "htmlize", "\\s*.+\\s*")) { + Chrono chrono = new Chrono().start(); Files inputs = convertPath(StringUtils.trim(args[1])); for (File input : inputs) { @@ -307,6 +311,7 @@ public final class StatoolInfosCLI exception.printStackTrace(); } } + System.out.println(chrono.format()); } else if (isMatching(args, "probe", "\\s*.+\\s*")) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java index 624d3aa..2fd610a 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java @@ -99,6 +99,7 @@ public class OrganizationHeaderView data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-check.xhtml"); data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml"); + data.setAttribute("metricsLink", "href", organization.getTechnicalName() + "-metrics.xhtml"); data.setAttribute("crawlLink", "href", organization.getTechnicalName() + "-crawl.xhtml"); if (organization.getCrawlJournal().getErrors().isEmpty()) diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java index f82238b..b62e73d 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java @@ -37,7 +37,6 @@ public class OrganizationMetricMenuView public enum MenuItem { - GENERAL, SUMMARY, GENERIC, WEB, @@ -61,17 +60,12 @@ public class OrganizationMetricMenuView { TagDataManager data = new TagDataManager(); - data.setAttribute("generalTypeButton", "href", organization.getTechnicalName() + "-stats.xhtml"); - data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-stats-summarymetrics.xhtml"); - data.setAttribute("genericTypeButton", "href", organization.getTechnicalName() + "-stats-genericmetrics.xhtml"); - data.setAttribute("webTypeButton", "href", organization.getTechnicalName() + "-stats-webmetrics.xhtml"); - data.setAttribute("specificTypeButton", "href", organization.getTechnicalName() + "-stats-specificmetrics.xhtml"); + data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-metrics.xhtml"); + data.setAttribute("genericTypeButton", "href", organization.getTechnicalName() + "-metrics-generic.xhtml"); + data.setAttribute("webTypeButton", "href", organization.getTechnicalName() + "-metrics-web.xhtml"); + data.setAttribute("specificTypeButton", "href", organization.getTechnicalName() + "-metrics-specific.xhtml"); - if ((item == null) || (item == MenuItem.GENERAL)) - { - data.appendAttribute("generalTypeButton", "class", "button selected"); - } - else if (item == MenuItem.SUMMARY) + if ((item == null) || (item == MenuItem.SUMMARY)) { data.appendAttribute("summaryTypeButton", "class", "button selected"); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java index 10cc72e..01b4e68 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java @@ -78,20 +78,20 @@ public class OrganizationPage FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats.xhtml"), page, StandardCharsets.UTF_8); logger.info("Htmlize organization summarty metric page: {}.", organization.getName()); - page = OrganizationSummaryStatsPage.htmlize(organization); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-summarymetrics.xhtml"), page, StandardCharsets.UTF_8); + page = OrganizationSummaryMetricPage.htmlize(organization); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics.xhtml"), page, StandardCharsets.UTF_8); logger.info("Htmlize organization generic metric page: {}.", organization.getName()); page = OrganizationGenericMetricPage.htmlize(organization); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-genericmetrics.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8); logger.info("Htmlize organization web metric page: {}.", organization.getName()); page = OrganizationWebMetricPage.htmlize(organization); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-webmetrics.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8); logger.info("Htmlize service specific metric page: {}.", organization.getName()); page = OrganizationSpecificMetricPage.htmlize(organization); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-specificmetrics.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8); } /** diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java index d895d50..73c8f45 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java @@ -18,16 +18,13 @@ */ package fr.devinsy.statoolinfos.htmlize; -import java.io.File; import java.io.IOException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fr.devinsy.statoolinfos.HtmlizerContext; import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem; import fr.devinsy.statoolinfos.stats.StatAgent; import fr.devinsy.statoolinfos.stats.services.RegistrationStats; import fr.devinsy.xidyn.XidynException; @@ -60,13 +57,10 @@ public class OrganizationStatsPage { logger.debug("Building organization stats page {}…"); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - TagDataManager data = new TagDataManager(); // data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.GENERAL)); // data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization)); @@ -91,7 +85,7 @@ public class OrganizationStatsPage } // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStatsView.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml", data).toString(); // BreadcrumbTrail trail = new BreadcrumbTrail(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationSummaryStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationSummaryMetricPage.java similarity index 98% rename from src/fr/devinsy/statoolinfos/htmlize/OrganizationSummaryStatsPage.java rename to src/fr/devinsy/statoolinfos/htmlize/OrganizationSummaryMetricPage.java index aff254a..386f7ac 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationSummaryStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationSummaryMetricPage.java @@ -38,9 +38,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils; /** * The Class OrganizationGeneralStatsPage. */ -public class OrganizationSummaryStatsPage +public class OrganizationSummaryMetricPage { - private static Logger logger = LoggerFactory.getLogger(OrganizationSummaryStatsPage.class); + private static Logger logger = LoggerFactory.getLogger(OrganizationSummaryMetricPage.class); /** * Htmlize. diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java index d0d707f..d00c94e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java @@ -86,6 +86,7 @@ public class ServiceHeaderView data.setAttribute("rawCheckLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-check.xhtml"); data.setAttribute("statsLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); + data.setAttribute("metricsLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics.xhtml"); if (StringUtils.isNotBlank(service.getLegalWebsite())) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java index 45571f8..381330b 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java @@ -37,7 +37,6 @@ public class ServiceMetricMenuView public enum MenuItem { - GENERAL, SUMMARY, WEB, GENERIC, @@ -61,17 +60,12 @@ public class ServiceMetricMenuView { TagDataManager data = new TagDataManager(); - data.setAttribute("generalTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); - data.setAttribute("summaryTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-summarymetrics.xhtml"); - data.setAttribute("genericTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-genericmetrics.xhtml"); - data.setAttribute("webTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-webmetrics.xhtml"); - data.setAttribute("specificTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-specificmetrics.xhtml"); + data.setAttribute("summaryTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics.xhtml"); + data.setAttribute("genericTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-generic.xhtml"); + data.setAttribute("webTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-web.xhtml"); + data.setAttribute("specificTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-specific.xhtml"); - if ((item == null) || (item == MenuItem.GENERAL)) - { - data.appendAttribute("generalTypeButton", "class", "button selected"); - } - else if (item == MenuItem.SUMMARY) + if ((item == null) || (item == MenuItem.SUMMARY)) { data.appendAttribute("summaryTypeButton", "class", "button selected"); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java index fd00e9b..6111156 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java @@ -78,20 +78,20 @@ public class ServicePage // logger.info("Htmlize service summary metric page: {}.", service.getName()); page = ServiceSummaryMetricPage.htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-summarymetrics.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics.xhtml"), page, StandardCharsets.UTF_8); // logger.info("Htmlize service generic metric page: {}.", service.getName()); page = ServiceGenericMetricPage.htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-genericmetrics.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8); logger.info("Htmlize service web metric page: {}.", service.getName()); page = ServiceWebMetricPage.htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-webmetrics.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8); logger.info("Htmlize service specific metric page: {}.", service.getName()); page = ServiceSpecificMetricPage.htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-specificmetrics.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8); } /** diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java index 33cd96e..841b4be 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java @@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.Services; import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.MenuItem; import fr.devinsy.statoolinfos.stats.StatAgent; import fr.devinsy.statoolinfos.stats.services.RegistrationStats; import fr.devinsy.xidyn.XidynException; @@ -58,9 +57,6 @@ public class ServiceStatsView TagDataManager data = new TagDataManager(); - // - data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERAL)); - // data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(service)); diff --git a/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml index 45b8ede..2ae525b 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml @@ -14,7 +14,6 @@
Type - Général Résumé Génériques Web @@ -22,7 +21,7 @@
Période - Full + Tout 12 mois 2020 2021 @@ -40,7 +39,6 @@ function selectTypeMenu(selection) { document.getElementById ('summaryTypeButton').classList.remove('selected'); - document.getElementById ('generalTypeButton').classList.remove('selected'); document.getElementById ('genericTypeButton').classList.remove('selected'); document.getElementById ('webTypeButton').classList.remove('selected'); document.getElementById ('specificTypeButton').classList.remove('selected'); @@ -53,10 +51,6 @@ function selectTypeMenu(selection) { document.getElementById ('genericTypeButton').classList.add('selected'); } - else if (selection == 'general') - { - document.getElementById ('generalTypeButton').classList.add('selected'); - } else if (selection == 'web') { document.getElementById ('webTypeButton').classList.add('selected'); diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml index 586cdc7..98fc3bb 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml @@ -34,7 +34,8 @@ - + +
n/a
diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationStatsView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml similarity index 96% rename from src/fr/devinsy/statoolinfos/htmlize/organizationStatsView.xhtml rename to src/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml index 79a4d5a..ca22763 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/organizationStatsView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml @@ -12,9 +12,8 @@
-
- +

Statistiques

diff --git a/src/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml index 5d1a2b5..1a68398 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml @@ -42,7 +42,8 @@ - + +
n/a
diff --git a/src/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml index df13320..a482980 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml @@ -11,9 +11,8 @@ -
- +

Statistiques

diff --git a/src/fr/devinsy/statoolinfos/htmlize/stuff/circle-icons/piechart-mono.svg b/src/fr/devinsy/statoolinfos/htmlize/stuff/circle-icons/piechart-mono.svg new file mode 100644 index 0000000..ab35657 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/stuff/circle-icons/piechart-mono.svg @@ -0,0 +1,72 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/htmlize/stuff/circle-icons/piechart.svg b/src/fr/devinsy/statoolinfos/htmlize/stuff/circle-icons/piechart.svg new file mode 100644 index 0000000..9bdd110 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/stuff/circle-icons/piechart.svg @@ -0,0 +1,129 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/util/Chrono.java b/src/fr/devinsy/statoolinfos/util/Chrono.java new file mode 100644 index 0000000..c3debba --- /dev/null +++ b/src/fr/devinsy/statoolinfos/util/Chrono.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2021 Christian Pierre MOMON + * + * This file is part of Logar, simple tool to manage http log files. + * + * Logar 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. + * + * Logar 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 Logar. If not, see . + */ +package fr.devinsy.statoolinfos.util; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.ZoneOffset; + +/** + * The Class Chrono. + */ +public class Chrono +{ + private LocalDateTime start; + + /** + * Instantiates a new time keeper. + */ + public Chrono() + { + reset(); + } + + /** + * Duration. + * + * @return the long + */ + public long duration() + { + long result; + + result = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC) - this.start.toEpochSecond(ZoneOffset.UTC); + + // + return result; + } + + /** + * Format. + * + * @return the string + */ + public String format() + { + String result; + + if (this.start == null) + { + result = "n/a"; + } + else + { + LocalDateTime end = LocalDateTime.now(); + Duration duration = Duration.between(this.start, end); + + result = String.format("%02d:%02d:%02d", duration.getSeconds() / 60 / 60, duration.getSeconds() / 60, duration.getSeconds() % 60); + } + + // + return result; + } + + /** + * Reset. + */ + public void reset() + { + this.start = null; + } + + /** + * Start. + */ + public Chrono start() + { + Chrono result; + + this.start = LocalDateTime.now(); + + result = this; + + // + return result; + } + + /** + * To string. + * + * @return the string + */ + @Override + public String toString() + { + String result; + + result = format(); + + // + return result; + } +}