mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-15 17:56:07 +01:00
Added Check for Updates button that does a flushed GPM repository ping
This commit is contained in:
@@ -254,13 +254,14 @@ class AdminPlugin extends Plugin
|
||||
public function onTaskGPM()
|
||||
{
|
||||
$action = $_POST['action']; // getUpdatable | getUpdatablePlugins | getUpdatableThemes | gravUpdates
|
||||
$flush = isset($_POST['flush']) && $_POST['flush'] == true ? true : false;
|
||||
|
||||
if (isset($this->grav['session'])) {
|
||||
$this->grav['session']->close();
|
||||
}
|
||||
|
||||
try {
|
||||
$gpm = new GPM();
|
||||
$gpm = new GPM($flush);
|
||||
|
||||
switch ($action) {
|
||||
case 'getUpdates':
|
||||
@@ -276,7 +277,7 @@ class AdminPlugin extends Plugin
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"payload" => ["resources" => $resources_updates, "grav" => $grav_updates, "installed" => $gpm->countInstalled()]
|
||||
"payload" => ["resources" => $resources_updates, "grav" => $grav_updates, "installed" => $gpm->countInstalled(), 'flushed' => $flush]
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -225,15 +225,32 @@ $(function () {
|
||||
});
|
||||
});
|
||||
|
||||
var GPMRefresh = function () {
|
||||
$('[data-gpm-checkupdates]').on('click', function(){
|
||||
var element = $(this);
|
||||
element.find('i').addClass('fa-spin');
|
||||
GPMRefresh({
|
||||
flush: true,
|
||||
callback: function() {
|
||||
element.find('i').removeClass('fa-spin');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var GPMRefresh = function (options) {
|
||||
options = options || {};
|
||||
|
||||
var data = {
|
||||
task: 'GPM',
|
||||
action: 'getUpdates'
|
||||
};
|
||||
|
||||
if (options.flush) { data.flush = true; }
|
||||
|
||||
GravAjax({
|
||||
dataType: "JSON",
|
||||
url: window.location.href,
|
||||
method: "POST",
|
||||
data: {
|
||||
task: 'GPM',
|
||||
action: 'getUpdates'
|
||||
},
|
||||
data: data,
|
||||
toastErrors: true,
|
||||
success: function (response) {
|
||||
var grav = response.payload.grav,
|
||||
@@ -264,6 +281,9 @@ $(function () {
|
||||
var missing = (resources.total + (grav.isUpdatable ? 1 : 0)) * 100 / (installed + (grav.isUpdatable ? 1 : 0)),
|
||||
updated = 100 - missing;
|
||||
UpdatesChart.update({series: [updated, missing]});
|
||||
if (resources.total) {
|
||||
$('#updates [data-maintenance-update]').fadeIn();
|
||||
}
|
||||
}
|
||||
|
||||
if (!resources.total) {
|
||||
@@ -304,7 +324,9 @@ $(function () {
|
||||
$.each(resources.plugins, function (key, value) {
|
||||
plugin = $('[data-gpm-plugin="' + key + '"] .gpm-name');
|
||||
url = plugin.find('a');
|
||||
if (!plugin.find('.badge.update').length) {
|
||||
plugin.append('<a href="' + url.attr('href') + '"><span class="badge update">Update available!</span></a>');
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
@@ -347,9 +369,12 @@ $(function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options.callback && typeof options.callback == 'function') options.callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
GPMRefresh();
|
||||
|
||||
function reIndex (collection) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{% block titlebar %}
|
||||
<div class="button-bar">
|
||||
<div class="button-group">
|
||||
<button data-clear-cache="{{ base_url_relative }}/cache.json/task:clearCache" class="button"><i class="fa fa-fw fa-trash"></i> Clear Cache</button>
|
||||
<button data-clear-cache="{{ base_url_relative }}/cache.json/task:clearCache" class="button"><i class="fa fa-trash"></i> Clear Cache</button>
|
||||
<button type="button" class="button dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
</button>
|
||||
@@ -14,6 +14,7 @@
|
||||
<li><a data-clear-cache="{{ base_url_relative }}/cache.json/task:clearCache/cleartype:cache-only" href="#">Cache Only</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<button data-gpm-checkupdates="" class="button"><i class="fa fa-refresh"></i> Check for Updates</button>
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-th"></i> Dashboard</h1>
|
||||
{% endblock %}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
{% else %}
|
||||
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> Back</a>
|
||||
<a class="button" href="{{ base_url_relative }}/plugins/install"><i class="fa fa-plus"></i> Add</a>
|
||||
<button data-gpm-checkupdates="" class="button"><i class="fa fa-refresh"></i> Check for Updates</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-plug"></i> Plugins</h1>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
{% else %}
|
||||
<a class="button" href="{{ base_url }}/"><i class="fa fa-reply"></i> Back</a>
|
||||
<a class="button" href="{{ base_url_relative }}/themes/install"><i class="fa fa-plus"></i> Add</a>
|
||||
<button data-gpm-checkupdates="" class="button"><i class="fa fa-refresh"></i> Check for Updates</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-plug"></i> Themes</h1>
|
||||
|
||||
Reference in New Issue
Block a user