/admin/plugins: Fix update check

This commit is contained in:
Marcel Klehr 2013-03-27 12:02:19 +01:00
parent d01a209cbf
commit c4d9a71156
4 changed files with 21 additions and 19 deletions

View File

@ -35,9 +35,9 @@ exports.socketio = function (hook_name, args, cb) {
socket.emit("results:installed", {installed: installed}); socket.emit("results:installed", {installed: installed});
}); });
socket.on("getUpdatable", function() { socket.on("checkUpdates", function() {
// Check plugins for updates // Check plugins for updates
installer.getAvailable(/*maxCacheAge:*/60*10, function(er, results) { installer.getAvailablePlugins(/*maxCacheAge:*/60*10, function(er, results) {
if(er) { if(er) {
console.warn(er); console.warn(er);
socket.emit("results:updatable", {updatable: {}}); socket.emit("results:updatable", {updatable: {}});

View File

@ -139,6 +139,7 @@ td, th {
#installed-plugins td>div { #installed-plugins td>div {
position: relative;/* Allows us to position the loading indicator relative to this row */ position: relative;/* Allows us to position the loading indicator relative to this row */
display: inline-block; /*make this fill the whole cell*/ display: inline-block; /*make this fill the whole cell*/
width:100%;
} }
.messages td>* { .messages td>* {

View File

@ -46,7 +46,7 @@ $(document).ready(function () {
show: function(plugin, msg) { show: function(plugin, msg) {
$('.installed-results .'+plugin+' .progress').show() $('.installed-results .'+plugin+' .progress').show()
$('.installed-results .'+plugin+' .progress .message').text(msg) $('.installed-results .'+plugin+' .progress .message').text(msg)
$(window).scrollTop(0) $(window).scrollTop($('.'+plugin).offset().top-100)
}, },
hide: function(plugin) { hide: function(plugin) {
$('.installed-results .'+plugin+' .progress').hide() $('.installed-results .'+plugin+' .progress').hide()
@ -116,9 +116,13 @@ $(document).ready(function () {
$(".do-install, .do-update").unbind('click').click(function (e) { $(".do-install, .do-update").unbind('click').click(function (e) {
var $row = $(e.target).closest("tr") var $row = $(e.target).closest("tr")
, plugin = $row.data('plugin'); , plugin = $row.data('plugin');
$row.remove().appendTo('#installed-plugins') if($(this).hasClass('do-install')) {
$row.remove().appendTo('#installed-plugins')
installed.progress.show(plugin, 'Installing')
}else{
installed.progress.show(plugin, 'Updating')
}
socket.emit("install", plugin); socket.emit("install", plugin);
installed.progress.show(plugin, 'Installing')
installed.messages.hide("nothing-installed") installed.messages.hide("nothing-installed")
}); });
@ -200,20 +204,17 @@ $(document).ready(function () {
if(installed.list.length > 0) { if(installed.list.length > 0) {
displayPluginList(installed.list, $("#installed-plugins"), $("#installed-plugin-template")); displayPluginList(installed.list, $("#installed-plugins"), $("#installed-plugin-template"));
socket.emit('checkUpdates');
}else { }else {
installed.messages.show("nothing-installed") installed.messages.show("nothing-installed")
} }
}); });
socket.on('results:updatable', function(data) { socket.on('results:updatable', function(data) {
$('#installed-plugins > tr').each(function(i, tr) { data.updatable.forEach(function(pluginName) {
var pluginName = $(tr).find('.name').text() var $row = $('#installed-plugins > tr.'+pluginName)
, actions = $row.find('.actions')
if (data.updatable.indexOf(pluginName) >= 0) { actions.append('<input class="do-update" type="button" value="Update" />')
var actions = $(tr).find('.actions')
actions.append('<input class="do-update" type="button" value="Update" />')
actions.css('width', 200)
}
}) })
updateHandlers(); updateHandlers();
}) })
@ -251,8 +252,8 @@ $(document).ready(function () {
socket.emit("getInstalled"); socket.emit("getInstalled");
search(''); search('');
// check for updates every 15mins // check for updates every 5mins
setInterval(function() { setInterval(function() {
socket.emit('checkUpdates'); socket.emit('checkUpdates');
}, 1000*60*15) }, 1000*60*5)
}); });

View File

@ -46,8 +46,8 @@
<td class="name" data-label="Name"></td> <td class="name" data-label="Name"></td>
<td class="description" data-label="Description"></td> <td class="description" data-label="Description"></td>
<td class="version" data-label="Version"></td> <td class="version" data-label="Version"></td>
<td class="actions"> <td>
<div> <div class="actions">
<input type="button" value="Uninstall" class="do-uninstall"> <input type="button" value="Uninstall" class="do-uninstall">
<div class="progress"><p><img src="../static/img/loading.gif"/></p><p><span class="message"></span></p></div> <div class="progress"><p><img src="../static/img/loading.gif"/></p><p><span class="message"></span></p></div>
</div> </div>
@ -86,8 +86,8 @@
<td class="name" data-label="Name"></td> <td class="name" data-label="Name"></td>
<td class="description" data-label="Description"></td> <td class="description" data-label="Description"></td>
<td class="version" data-label="Version"></td> <td class="version" data-label="Version"></td>
<td class="actions"> <td>
<div> <div class="actions">
<input type="button" value="Install" class="do-install"> <input type="button" value="Install" class="do-install">
<div class="progress"><p><img src="../static/img/loading.gif"/></p><p><span class="message"></span></p></div> <div class="progress"><p><img src="../static/img/loading.gif"/></p><p><span class="message"></span></p></div>
</div> </div>