mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-16 18:26:06 +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()
|
public function onTaskGPM()
|
||||||
{
|
{
|
||||||
$action = $_POST['action']; // getUpdatable | getUpdatablePlugins | getUpdatableThemes | gravUpdates
|
$action = $_POST['action']; // getUpdatable | getUpdatablePlugins | getUpdatableThemes | gravUpdates
|
||||||
|
$flush = isset($_POST['flush']) && $_POST['flush'] == true ? true : false;
|
||||||
|
|
||||||
if (isset($this->grav['session'])) {
|
if (isset($this->grav['session'])) {
|
||||||
$this->grav['session']->close();
|
$this->grav['session']->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$gpm = new GPM();
|
$gpm = new GPM($flush);
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'getUpdates':
|
case 'getUpdates':
|
||||||
@@ -276,7 +277,7 @@ class AdminPlugin extends Plugin
|
|||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
"status" => "success",
|
"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;
|
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({
|
GravAjax({
|
||||||
dataType: "JSON",
|
dataType: "JSON",
|
||||||
url: window.location.href,
|
url: window.location.href,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: {
|
data: data,
|
||||||
task: 'GPM',
|
|
||||||
action: 'getUpdates'
|
|
||||||
},
|
|
||||||
toastErrors: true,
|
toastErrors: true,
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
var grav = response.payload.grav,
|
var grav = response.payload.grav,
|
||||||
@@ -264,6 +281,9 @@ $(function () {
|
|||||||
var missing = (resources.total + (grav.isUpdatable ? 1 : 0)) * 100 / (installed + (grav.isUpdatable ? 1 : 0)),
|
var missing = (resources.total + (grav.isUpdatable ? 1 : 0)) * 100 / (installed + (grav.isUpdatable ? 1 : 0)),
|
||||||
updated = 100 - missing;
|
updated = 100 - missing;
|
||||||
UpdatesChart.update({series: [updated, missing]});
|
UpdatesChart.update({series: [updated, missing]});
|
||||||
|
if (resources.total) {
|
||||||
|
$('#updates [data-maintenance-update]').fadeIn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resources.total) {
|
if (!resources.total) {
|
||||||
@@ -304,7 +324,9 @@ $(function () {
|
|||||||
$.each(resources.plugins, function (key, value) {
|
$.each(resources.plugins, function (key, value) {
|
||||||
plugin = $('[data-gpm-plugin="' + key + '"] .gpm-name');
|
plugin = $('[data-gpm-plugin="' + key + '"] .gpm-name');
|
||||||
url = plugin.find('a');
|
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>');
|
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();
|
GPMRefresh();
|
||||||
|
|
||||||
function reIndex (collection) {
|
function reIndex (collection) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
{% block titlebar %}
|
{% block titlebar %}
|
||||||
<div class="button-bar">
|
<div class="button-bar">
|
||||||
<div class="button-group">
|
<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">
|
<button type="button" class="button dropdown-toggle" data-toggle="dropdown">
|
||||||
<i class="fa fa-caret-down"></i>
|
<i class="fa fa-caret-down"></i>
|
||||||
</button>
|
</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>
|
<li><a data-clear-cache="{{ base_url_relative }}/cache.json/task:clearCache/cleartype:cache-only" href="#">Cache Only</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<button data-gpm-checkupdates="" class="button"><i class="fa fa-refresh"></i> Check for Updates</button>
|
||||||
</div>
|
</div>
|
||||||
<h1><i class="fa fa-fw fa-th"></i> Dashboard</h1>
|
<h1><i class="fa fa-fw fa-th"></i> Dashboard</h1>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> Back</a>
|
<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>
|
<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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1><i class="fa fa-fw fa-plug"></i> Plugins</h1>
|
<h1><i class="fa fa-fw fa-plug"></i> Plugins</h1>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<a class="button" href="{{ base_url }}/"><i class="fa fa-reply"></i> Back</a>
|
<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>
|
<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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1><i class="fa fa-fw fa-plug"></i> Themes</h1>
|
<h1><i class="fa fa-fw fa-plug"></i> Themes</h1>
|
||||||
|
|||||||
Reference in New Issue
Block a user