Step in add of figures view.
This commit is contained in:
parent
57d7c3cc97
commit
f750d648fb
7 changed files with 440 additions and 11 deletions
|
@ -447,6 +447,116 @@ public class Service extends PathPropertyList
|
|||
return this.metricsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the month account count.
|
||||
*
|
||||
* @return the month account count
|
||||
*/
|
||||
public long getMonthAccountCount(final YearMonth month)
|
||||
{
|
||||
long result;
|
||||
|
||||
result = getMonthCount("metrics.service.accounts", month);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the month active account count.
|
||||
*
|
||||
* @return the month active account count
|
||||
*/
|
||||
public long getMonthActiveAccountCount(final YearMonth month)
|
||||
{
|
||||
long result;
|
||||
|
||||
result = getMonthCount("metrics.service.accounts.active", month);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the month count.
|
||||
*
|
||||
* @param path
|
||||
* the path
|
||||
* @return the month count
|
||||
*/
|
||||
public long getMonthCount(final String path, final YearMonth month)
|
||||
{
|
||||
long result;
|
||||
|
||||
MonthValues values = getMetricMonthValues(path);
|
||||
values = values.extract(month, month);
|
||||
|
||||
result = (long) values.sum();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the month hit count.
|
||||
*
|
||||
* @return the month hit count
|
||||
*/
|
||||
public long getMonthHitCount(final YearMonth month)
|
||||
{
|
||||
long result;
|
||||
|
||||
result = getMonthCount("metrics.http.hits", month);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the month user count.
|
||||
*
|
||||
* @return the month user count
|
||||
*/
|
||||
public long getMonthUserCount(final YearMonth month)
|
||||
{
|
||||
long result;
|
||||
|
||||
result = getMonthCount("metrics.service.users", month);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the month visit count.
|
||||
*
|
||||
* @return the month visit count
|
||||
*/
|
||||
public long getMonthVisitCount(final YearMonth month)
|
||||
{
|
||||
long result;
|
||||
|
||||
result = getMonthCount("metrics.http.visits", month);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the month visitor count.
|
||||
*
|
||||
* @return the month visitor count
|
||||
*/
|
||||
public long getMonthVisitorCount(final YearMonth month)
|
||||
{
|
||||
long result;
|
||||
|
||||
result = getMonthCount("metrics.http.visitors", month);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
|
@ -487,12 +597,7 @@ public class Service extends PathPropertyList
|
|||
{
|
||||
long result;
|
||||
|
||||
MonthValues values = getMetricMonthValues("metrics.service.users");
|
||||
|
||||
YearMonth previousMonth = YearMonth.now().minusMonths(1);
|
||||
values = values.extract(previousMonth, previousMonth);
|
||||
|
||||
result = (long) values.sum();
|
||||
result = getMonthUserCount(YearMonth.now().minusMonths(1));
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -507,11 +612,7 @@ public class Service extends PathPropertyList
|
|||
{
|
||||
long result;
|
||||
|
||||
MonthValues values = getMetricMonthValues("metrics.http.visits");
|
||||
|
||||
values = values.extract(YearMonth.now().minusMonths(1), YearMonth.now().minusMonths(1));
|
||||
|
||||
result = (long) values.sum();
|
||||
result = getMonthVisitCount(YearMonth.now().minusMonths(1));
|
||||
|
||||
//
|
||||
return result;
|
||||
|
|
|
@ -77,6 +77,7 @@ public class FederationHeaderView
|
|||
data.setAttribute("propertyCheckLink", "href", federation.getTechnicalName() + "-propertycheck.xhtml");
|
||||
data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml");
|
||||
data.setAttribute("metricsLink", "href", federation.getTechnicalName() + "-metrics-summary-months-last.xhtml");
|
||||
data.setAttribute("figuresLink", "href", federation.getTechnicalName() + "-services-figures.xhtml");
|
||||
|
||||
data.setAttribute("crawlLink", "href", federation.getTechnicalName() + "-crawl.xhtml");
|
||||
data.setAttribute("uptimeLink", "href", federation.getLocalFileBaseName() + "-uptimes.xhtml");
|
||||
|
|
|
@ -69,6 +69,7 @@ public class FederationPages
|
|||
//
|
||||
FederationOrganizationsPage.build();
|
||||
FederationServicesPage.build();
|
||||
FederationServicesFiguresPage.build();
|
||||
FederationCrawlJournalPage.build();
|
||||
FederationPropertyCheckPage.build();
|
||||
FederationPropertyAlertPage.buildAll();
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (C) 2022 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
* StatoolInfos is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* StatoolInfos is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.devinsy.statoolinfos.htmlize;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.statoolinfos.HtmlizerContext;
|
||||
import fr.devinsy.statoolinfos.core.Federation;
|
||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||
import fr.devinsy.xidyn.XidynException;
|
||||
import fr.devinsy.xidyn.data.TagDataManager;
|
||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||
|
||||
/**
|
||||
* The Class FederationServicesFiguresPage.
|
||||
*/
|
||||
public class FederationServicesFiguresPage
|
||||
{
|
||||
private static Logger logger = LoggerFactory.getLogger(FederationServicesFiguresPage.class);
|
||||
|
||||
/**
|
||||
* Builds the.
|
||||
*
|
||||
* @throws StatoolInfosException
|
||||
* the statool infos exception
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void build() throws StatoolInfosException, IOException
|
||||
{
|
||||
Federation federation = HtmlizerContext.instance().getFederation();
|
||||
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
|
||||
|
||||
//
|
||||
logger.info("PAGE FEDERATION services figures page: {}.", federation.getName());
|
||||
String page = htmlize(federation);
|
||||
|
||||
FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-services-figures.xhtml"), page, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the.
|
||||
*
|
||||
* @param federation
|
||||
* the organization
|
||||
* @return the string
|
||||
* @throws StatoolInfosException
|
||||
* the statool infos exception
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String htmlize(final Federation federation) throws StatoolInfosException, IOException
|
||||
{
|
||||
String result;
|
||||
|
||||
try
|
||||
{
|
||||
TagDataManager data = new TagDataManager();
|
||||
|
||||
data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation));
|
||||
data.setContent("serviceListView", ServiceFigureView.htmlize(federation.getServices()));
|
||||
|
||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml", data).toString();
|
||||
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
result = WebCharterView.build(content, trail);
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
throw new StatoolInfosException("Error building federation services figures page: " + exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
123
src/fr/devinsy/statoolinfos/htmlize/ServiceFigureView.java
Normal file
123
src/fr/devinsy/statoolinfos/htmlize/ServiceFigureView.java
Normal file
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* Copyright (C) 2022 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of StatoolInfos, simple service statistics tool.
|
||||
*
|
||||
* StatoolInfos is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* StatoolInfos is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.devinsy.statoolinfos.htmlize;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.statoolinfos.core.Service;
|
||||
import fr.devinsy.statoolinfos.core.Services;
|
||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
|
||||
import fr.devinsy.xidyn.XidynException;
|
||||
import fr.devinsy.xidyn.data.TagDataManager;
|
||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||
import fr.devinsy.xidyn.utils.XidynUtils;
|
||||
|
||||
/**
|
||||
* The Class ServiceFigureView.
|
||||
*/
|
||||
public class ServiceFigureView
|
||||
{
|
||||
private static Logger logger = LoggerFactory.getLogger(ServiceFigureView.class);
|
||||
|
||||
/**
|
||||
* Builds the.
|
||||
*
|
||||
* @param services
|
||||
* the services
|
||||
* @return the string
|
||||
* @throws StatoolInfosException
|
||||
* the statool infos exception
|
||||
*/
|
||||
public static String htmlize(final Services services) throws StatoolInfosException
|
||||
{
|
||||
String result;
|
||||
|
||||
try
|
||||
{
|
||||
logger.debug("Building services figures view.");
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
|
||||
data.setContent("serviceCount", services.size());
|
||||
|
||||
if (services.isEmpty())
|
||||
{
|
||||
data.setAttribute("serviceListLine", "class", "xid:nodisplay");
|
||||
}
|
||||
else
|
||||
{
|
||||
String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", " ");
|
||||
data.setContent("monthLabel", monthLabel);
|
||||
data.setAttribute("userCountHeaderColumn", "title", monthLabel);
|
||||
data.setAttribute("visitCountHeaderColumn", "title", monthLabel);
|
||||
|
||||
int index = 0;
|
||||
for (Service service : services.sortByName())
|
||||
{
|
||||
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml");
|
||||
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getLogoFileName());
|
||||
data.setEscapedAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "title", service.getOrganization().getName());
|
||||
|
||||
data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getLogoFileName());
|
||||
data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName());
|
||||
data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
||||
|
||||
data.setAttribute("serviceListLine", index, "serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png");
|
||||
data.setAttribute("serviceListLine", index, "serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString()));
|
||||
|
||||
if (service.getWebsiteURL() != null)
|
||||
{
|
||||
data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsiteURL().toString());
|
||||
data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsiteURL().toString());
|
||||
data.setEscapedAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsiteURL().toString());
|
||||
}
|
||||
|
||||
data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName());
|
||||
data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml");
|
||||
|
||||
YearMonth month = YearMonth.now();
|
||||
data.setContent("serviceListLine", index, "serviceListLineHitCount", StatoolInfosUtils.defaultIfZero(service.getMonthHitCount(month), "😢"));
|
||||
data.setContent("serviceListLine", index, "serviceListLineVisitCount", StatoolInfosUtils.defaultIfZero(service.getMonthVisitCount(month), "😞"));
|
||||
data.setContent("serviceListLine", index, "serviceListLineVisitorCount", StatoolInfosUtils.defaultIfZero(service.getMonthVisitorCount(month), "😞"));
|
||||
data.setContent("serviceListLine", index, "serviceListLineUserCount", StatoolInfosUtils.defaultIfZero(service.getMonthUserCount(month), "😢"));
|
||||
data.setContent("serviceListLine", index, "serviceListLineAccountCount", StatoolInfosUtils.defaultIfZero(service.getMonthAccountCount(month), "😇"));
|
||||
data.setContent("serviceListLine", index, "serviceListLineActiveAccountCount", StatoolInfosUtils.defaultIfZero(service.getMonthActiveAccountCount(month), "😇"));
|
||||
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceFigureView.xhtml", data).toString();
|
||||
result = XidynUtils.extractBodyContent(result);
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@
|
|||
<a id="crawlLink" href="#"><img id="crawlLinkImg" src="circle-icons/download-mono.svg" title="Statut des téléchargements"/>Journal</a>
|
||||
<a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/piechart-mono.svg" title="Statistiques"/>Stats</a>
|
||||
<a id="metricsLink" href="#"><img id="metricsLinkImg" src="circle-icons/barchart-mono.svg" title="Métriques"/>Metriques</a>
|
||||
<a id="figuresLink" href="#"><img id="figuresLinkImg" src="circle-icons/calculator-mono.svg" title="Chiffres"/>Chiffres</a>
|
||||
<a id="uptimeLink" href="#"><img id="uptimeLinkImg" src="circle-icons/countdown-mono.svg" title="Disponibilité des services"/>Dispos</a>
|
||||
<a id="alertLink" href="#" style="vertical-align: top;">
|
||||
<table style="width: 35px; height: 50px; border-collapse:collapse; margin-bottom: 2px;">
|
||||
|
|
106
src/fr/devinsy/statoolinfos/htmlize/serviceFigureView.xhtml
Normal file
106
src/fr/devinsy/statoolinfos/htmlize/serviceFigureView.xhtml
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>StatoolInfos</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="keywords" content="statoolinfos,devinsy,federation" />
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="statoolinfos.css" />
|
||||
<script src="sorttable.js" />
|
||||
<script src="Chart.bundle.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="center_table" style="width: 1500px;">
|
||||
<br/>
|
||||
<div class="center">Nombre de services : <span id="serviceCount">n/a</span></div>
|
||||
|
||||
<table id="serviceListTable" class="center_table table_classic left">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="" style="width: 225px;">Service</th>
|
||||
<th class="">Logiciel</th>
|
||||
<th id="hitCountHeaderColumn" class="" style="width: 10px;">Hits</th>
|
||||
<th id="visitCountHeaderColumn" class="" style="width: 10px;">Visites</th>
|
||||
<th id="visitorCountHeaderColumn" class="" style="width: 10px;">Visiteurs</th>
|
||||
<th id="userCountHeaderColumn" class="" style="width: 10px;">Utilisateurs</th>
|
||||
<th id="accountCountHeaderColumn" class="" style="width: 10px;">Comptes</th>
|
||||
<th id="activeAccountHeaderColumn" class="" style="width: 10px;">Comptes actifs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr id="serviceListLine" class="serviceListLine">
|
||||
<td id="serviceListLineName" style="padding-top: 0; padding-bottom: 0;">
|
||||
<a href="#" id="serviceListLineOrganizationLink">
|
||||
<img id="serviceListLineOrganizationLogo" src="" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
|
||||
</a>
|
||||
<a href="#" id="serviceListLineNameLink">
|
||||
<img id="serviceListLineLogo" src="" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
|
||||
 <span id="serviceListLineNameValue">n/a</span>
|
||||
</a>
|
||||
<img id="serviceStatusImg" src="status-void.png" title="n/a" style="width: 12px; height: 12px; vertical-align: middle;"/>
|
||||
</td>
|
||||
<td id="serviceListLineSoftware">
|
||||
<a href="#" id="serviceListLineSoftwareLink" title="">n/a</a>
|
||||
</td>
|
||||
<td id="serviceListLineHitCount" class="td_number">n/a</td>
|
||||
<td id="serviceListLineVisitCount" class="td_number">n/a</td>
|
||||
<td id="serviceListLineVisitorCount" class="td_number">n/a</td>
|
||||
<td id="serviceListLineUserCount" class="td_number">n/a</td>
|
||||
<td id="serviceListLineAccountCount" class="td_number">n/a</td>
|
||||
<td id="serviceListLineActiveAccountCount" class="td_number">n/a</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
$.fn.dataTable.moment('DD/MM/YYYY');
|
||||
|
||||
$.extend($.fn.dataTable.ext.type.order,
|
||||
{
|
||||
"custom-sort-asc": function(x, y)
|
||||
{
|
||||
if (!(!isNaN(x) || !isNaN(y)))
|
||||
return 0;
|
||||
else if (isNaN(x))
|
||||
return -1;
|
||||
else if (isNaN(y))
|
||||
return +1;
|
||||
else
|
||||
return x-y;
|
||||
},
|
||||
"custom-sort-desc": function(x, y)
|
||||
{
|
||||
if (!(!isNaN(x) || !isNaN(y)))
|
||||
return 0;
|
||||
else if (isNaN(x))
|
||||
return +1;
|
||||
else if (isNaN(y))
|
||||
return -1;
|
||||
else
|
||||
return y-x;
|
||||
}
|
||||
} );
|
||||
|
||||
$('#serviceListTable').DataTable(
|
||||
{
|
||||
paging: false,
|
||||
ordering: true,
|
||||
"order": [[ 2, "desc" ]],
|
||||
language: dataTableFrench,
|
||||
"columnDefs":
|
||||
[
|
||||
{ targets: 2, "type": 'custom-sort' },
|
||||
{ targets: 3, "type": 'custom-sort' },
|
||||
{ targets: 4, "type": 'custom-sort' },
|
||||
{ targets: 5, "type": 'custom-sort' },
|
||||
{ targets: 6, "type": 'custom-sort' },
|
||||
{ targets: 7, "type": 'custom-sort' }
|
||||
]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue