mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-16 10:16:07 +01:00
Real data updates chart
This commit is contained in:
@@ -258,7 +258,7 @@ class AdminPlugin extends Plugin
|
|||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
"success" => true,
|
"success" => true,
|
||||||
"payload" => ["resources" => $resources_updates, "grav" => $grav_updates]
|
"payload" => ["resources" => $resources_updates, "grav" => $grav_updates, "installed" => $gpm->countInstalled()]
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,29 @@ $(function () {
|
|||||||
"positionClass": "toast-top-right"
|
"positionClass": "toast-top-right"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dashboard
|
||||||
|
var chart = $('.updates-chart'), UpdatesChart;
|
||||||
|
if (chart.length) {
|
||||||
|
var data = {
|
||||||
|
series: [100, 0]
|
||||||
|
};
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
donut: true,
|
||||||
|
donutWidth: 10,
|
||||||
|
startAngle: 0,
|
||||||
|
total: 100,
|
||||||
|
showLabel: false,
|
||||||
|
height: 150
|
||||||
|
};
|
||||||
|
|
||||||
|
UpdatesChart = Chartist.Pie('.updates-chart .ct-chart', data, options);
|
||||||
|
UpdatesChart.on('draw', function(data){
|
||||||
|
if (data.index) { return; }
|
||||||
|
chart.find('.numeric span').text(Math.round(data.value) + '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Cache Clear
|
// Cache Clear
|
||||||
$('[data-clear-cache]').on('click', function(e) {
|
$('[data-clear-cache]').on('click', function(e) {
|
||||||
|
|
||||||
@@ -53,6 +76,7 @@ $(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var grav = response.payload.grav,
|
var grav = response.payload.grav,
|
||||||
|
installed = response.payload.installed,
|
||||||
resources = response.payload.resources;
|
resources = response.payload.resources;
|
||||||
|
|
||||||
//console.log(grav, resources);
|
//console.log(grav, resources);
|
||||||
@@ -67,6 +91,13 @@ $(function () {
|
|||||||
$('[data-gpm-grav]').addClass('grav').html('<p>' + icon + content + button + '</p>');
|
$('[data-gpm-grav]').addClass('grav').html('<p>' + icon + content + button + '</p>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dashboard
|
||||||
|
if ($('.updates-chart').length) {
|
||||||
|
var missing = resources.total * 100 / installed,
|
||||||
|
updated = 100 - missing;
|
||||||
|
UpdatesChart.update({series: [updated, missing]});
|
||||||
|
}
|
||||||
|
|
||||||
if (resources.total > 0) {
|
if (resources.total > 0) {
|
||||||
var length,
|
var length,
|
||||||
icon = '<i class="fa fa-bullhorn"></i>',
|
icon = '<i class="fa fa-bullhorn"></i>',
|
||||||
|
|||||||
@@ -22,21 +22,7 @@
|
|||||||
<div class="updates-chart">
|
<div class="updates-chart">
|
||||||
<div class="chart-wrapper">
|
<div class="chart-wrapper">
|
||||||
<div class="ct-chart"></div>
|
<div class="ct-chart"></div>
|
||||||
<script>
|
<span class="numeric"><span>-</span><em>updated</em></span>
|
||||||
var data = {
|
|
||||||
series: [75,25]
|
|
||||||
};
|
|
||||||
var options = {
|
|
||||||
donut: true,
|
|
||||||
donutWidth: 10,
|
|
||||||
startAngle: 0,
|
|
||||||
total: 100,
|
|
||||||
showLabel: false,
|
|
||||||
height: 150
|
|
||||||
};
|
|
||||||
Chartist.Pie('.updates-chart .ct-chart', data, options);
|
|
||||||
</script>
|
|
||||||
<span class="numeric">75%<em>updated</em></span>
|
|
||||||
</div>
|
</div>
|
||||||
<p>Updates Available</p>
|
<p>Updates Available</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user