Browse Source

add general statistics

master
o.moresis 2 years ago
parent
commit
591abad7d3
  1. 2
      public/js/mru-info.js
  2. 7
      src/Controllers/StatsController.php
  3. 1
      src/Routing/controls.php
  4. 2
      src/Routing/routes.php
  5. 39
      src/Views/main-statistics.php

2
public/js/mru-info.js

@ -71,11 +71,9 @@ function mruInfo() {
}); });
}, },
populateFeatureGrid(grid) { populateFeatureGrid(grid) {
console.debug(grid);
const features = Alpine.store('mru'); const features = Alpine.store('mru');
const featureCols = Object.getOwnPropertyNames(Alpine.store('mru')).filter(name => aliasMap.has(name)); const featureCols = Object.getOwnPropertyNames(Alpine.store('mru')).filter(name => aliasMap.has(name));
const featureVals = featureCols.map(col => {return {feature: aliasMap.get(col), value: features[col]}}); const featureVals = featureCols.map(col => {return {feature: aliasMap.get(col), value: features[col]}});
console.debug(featureVals);
new gridjs.Grid({ new gridjs.Grid({
data: featureVals data: featureVals
}).render(grid); }).render(grid);

7
src/Controllers/StatsController.php

@ -12,6 +12,13 @@ class StatsController {
require __DIR__.'/../Data/users.php'; require __DIR__.'/../Data/users.php';
} }
public function all() {
$sql = "SELECT * FROM webapp.stats_general";
$result = PgSql::getJson($sql);
echo $result;
}
public function countTypes() { public function countTypes() {
$sql = "SELECT * FROM webapp.stats_count_per_type"; $sql = "SELECT * FROM webapp.stats_count_per_type";
$result = PgSql::getJson($sql); $result = PgSql::getJson($sql);

1
src/Routing/controls.php

@ -14,3 +14,4 @@ $router->map('GET', '/actions/requests/[i:id]?', 'MSFD\Controllers\ActionControl
// STATS // STATS
$router->map('GET', '/interface/stats/typecount', 'MSFD\Controllers\StatsController@countTypes', 'stat_types'); $router->map('GET', '/interface/stats/typecount', 'MSFD\Controllers\StatsController@countTypes', 'stat_types');
$router->map('GET', '/interface/stats/totalrows', 'MSFD\Controllers\StatsController@countTotal', 'stat_total'); $router->map('GET', '/interface/stats/totalrows', 'MSFD\Controllers\StatsController@countTotal', 'stat_total');
$router->map('GET', '/interface/stats/general', 'MSFD\Controllers\StatsController@all', 'stat_all');

2
src/Routing/routes.php

@ -26,3 +26,5 @@ $router->map('GET', '/geonetwork/getrecords', 'MSFD\Controllers\GeonetworkContro
// Admin panel routes // Admin panel routes
$router->map('GET', '/cp/fetch_user_list', 'MSFD\Controllers\AdminController@fetchUsers', 'users'); $router->map('GET', '/cp/fetch_user_list', 'MSFD\Controllers\AdminController@fetchUsers', 'users');

39
src/Views/main-statistics.php

@ -1,22 +1,33 @@
<section id="statistics-view" :class="isActiveTab(4) ? '' : 'is-hidden'" x-init=""> <section id="statistics-view" :class="isActiveTab(4) ? '' : 'is-hidden'" x-init="">
<article class="panel is-info">
<p class="panel-heading">
General
</p>
<div id="stats-chart-1"> <div id="stats-chart-1">
</div> </div>
<p>Total Raw data Rows in database: <span ></span></p> <div id="grid" x-init="populateStatisticsGrid"></div>
</article>
<article class="panel is-info">
<p class="panel-heading">
Timeline
</p>
<div id="stats-chart-1">
</div>
<div id="timeseries"></div>
</article>
</section> </section>
<script> <script>
function getStatistics() {
return {
totalRows: 0,
queryStats() {
const url = BASE_URL + '/statistics/';
fetch(url)
.then(res => {
return res.json();
}).then(data => {
}).then(d => {
});
}
};
function populateStatisticsGrid() {
console.debug('statistsiscsc');
const statsGrid = new gridjs.Grid({
columns: ['stations', 'cruises', 'parameters', 'descriptors', 'criteria'],
server: {
url: BASE_URL + '/interface/stats/general',
then: data => data.map(stats => {
return [stats.total_stations, stats.total_cruises, stats.total_parameters, stats.total_criterias, stats.total_descriptors]
})
}
}).render(grid);
} }
</script> </script>

Loading…
Cancel
Save