/**
* Side bar links
*/
-
+ $aside = Array();
// array( url, name, extra css classes )
- $aside = Array(
+ // not part of $aside to make the template more adjustable
+ $asidesubpages = Array(
'site' => Array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"),
'users' => Array($a->get_baseurl(true)."/admin/users/", t("Users") , "users"),
'plugins'=> Array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"),
'themes' => Array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"),
'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"),
'queue' => Array($a->get_baseurl(true)."/admin/queue/", t('Inspect Queue'), "queue"),
+ 'federation' => Array($a->get_baseurl(true)."/admin/federation/", t('Federation Statistics'), "federation"),
//'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update")
);
$t = get_markup_template("admin_aside.tpl");
$a->page['aside'] .= replace_macros( $t, array(
- '$admin' => $aside,
+ '$admin' => $aside,
+ '$subpages' => $asidesubpages,
'$admtxt' => t('Admin'),
'$plugadmtxt' => t('Plugin Features'),
'$logtxt' => t('Logs'),
case 'queue':
$o = admin_page_queue($a);
break;
+ case 'federation':
+ $o = admin_page_federation($a);
+ break;
default:
notice( t("Item not found.") );
}
}
}
+/**
+ * Admin Federation Stats Page; display some numbers from gserver
+ * @param App $a
+ * returning string
+ */
+function admin_page_federation(&$a) {
+ // get counts on active friendica, diaspora, redmatrix, hubzilla, gnu
+ // social and statusnet nodes this node is knowing
+ //
+ // We are looking for the following platforms in the DB, "Red" should find
+ // all variants of that platform ID string as the q() function is stripping
+ // off one % two of them are needed in the query
+ $platforms = array('Diaspora', 'Friendica', '%%red%%', 'Hubzilla', 'GNU Social', 'StatusNet');
+ $counts = array();
+ foreach ($platforms as $p) {
+ // get a totaƶ count for the platform, the name and version of the
+ // highest version and the protocol tpe
+ $c = q('select count(*), platform, network, version from gserver where platform like "'.$p.'" and last_contact > last_failure order by version asc;');
+ // what versions for that platform do we know at all?
+ // again only the active nodes
+ $v = q('select count(*), version from gserver where last_contact > last_failure and platform like "'.$p.'" group by version order by version;');
+ // the 3rd array item is needed for the JavaScript graphs as JS does
+ // not like some characters in the names of variables...
+ $counts[$p]=array($c[0], $v, str_replace(array(' ','%'),'',$p));
+ }
+ // some helpful text
+ $intro = t('This page offers you some numbers to the known part of the federated social network your Friendica node is part of. These numbers are not complete but only reflect the part of the network your node is aware of.');
+ $hint = t('The <em>Auto Discovered Contact Directory</em> feature is not enabled, it will improve the data displayed here.');
+ // load the template, replace the macros and return the page content
+ $t = get_markup_template("admin_federation.tpl");
+ return replace_macros($t, array(
+ '$title' => t('Administration'),
+ '$page' => t('Federation Statistics'),
+ '$intro' => $intro,
+ '$hint' => $hint,
+ '$autoactive' => get_config('system', 'poco_completion'),
+ '$counts' => $counts,
+ '$version' => FRIENDICA_VERSION,
+ '$legendtext' => t('Currently this node is aware of nodes from the following platforms:'),
+ ));
+}
/**
* Admin Inspect Queue Page
* @param App $a
--- /dev/null
+<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
+<canvas id="FederationChart" style="width: 400px; height: 400px; float: right; margin: 20px;"></canvas>
+<div id="adminpage">
+ <h1>{{$title}} - {{$page}}</h1>
+ <p>{{$intro}}</p>
+ {{if not $autoactive}}
+ <p class="error-message">{{$hint}}</p>
+ {{/if}}
+ <p>{{$legendtext}}
+ <ul>
+ {{foreach $counts as $c}}
+ <li>{{$c[0]['platform']}} ({{$c[0]['count(*)']}})</li>
+ {{/foreach}}
+ </ul>
+ </p>
+</div>
+<script>
+var FedData = [
+{{foreach $counts as $c}}
+ { value: {{$c[0]['count(*)']}}, label: "{{$c[0]['platform']}}", color: "#90EE90", highlight: "#EE90A1", },
+{{/foreach}}
+];
+var ctx = document.getElementById("FederationChart").getContext("2d");
+var myDoughnutChart = new Chart(ctx).Doughnut(FedData,
+ {
+ animateRotate : false,
+ });
+document.getElementById('FederationLegend').innerHTML = myDoughnutChart.generateLegend();
+</script>
+
+<table style="width: 100%">
+{{foreach $counts as $c}}
+<tr>
+ <th>{{$c[0]['platform']}}</th>
+ <th><strong>{{$c[0]['count(*)']}}</strong></td>
+ <td>{{$c[0]['network']}}</td>
+</tr>
+<tr>
+<td colspan="3" style="border-bottom: 1px solid #000;">
+<canvas id="{{$c[2]}}Chart" style="width: 240px; height: 240px; float: left;
+margin: 20px;"></canvas>
+<script>
+var {{$c[2]}}data = [
+{{foreach $c[1] as $v}}
+ { value: {{$v['count(*)']}}, label: '{{$v['version']}}', color: "#90EE90", highlight: "#EE90A1",},
+{{/foreach}}
+];
+var ctx = document.getElementById("{{$c[2]}}Chart").getContext("2d");
+var my{{$c[2]}}DoughnutChart = new Chart(ctx).Doughnut({{$c[2]}}data,
+{animateRotate : false,});
+</script>
+<ul class="federation-stats">
+{{foreach $c[1] as $v}}
+<li>{{if ($c[0]['platform']==='Friendica' and $version===$v['version']) }}<span class="version-match">{{$v['version']}}</span>{{else}}{{$v['version']}}{{/if}} ({{$v['count(*)']}})</li>
+{{/foreach}}
+</ul>
+</td>
+</tr>
+{{/foreach}}
+</table>