From c4d9a71156c39d84350230e88ef9ebab148f1a2a Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Wed, 27 Mar 2013 12:02:19 +0100 Subject: /admin/plugins: Fix update check --- src/node/hooks/express/adminplugins.js | 4 ++-- src/static/css/admin.css | 1 + src/static/js/admin/plugins.js | 27 ++++++++++++++------------- src/templates/admin/plugins.html | 8 ++++---- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/node/hooks/express/adminplugins.js b/src/node/hooks/express/adminplugins.js index 611a6b14..d8f19bba 100644 --- a/src/node/hooks/express/adminplugins.js +++ b/src/node/hooks/express/adminplugins.js @@ -35,9 +35,9 @@ exports.socketio = function (hook_name, args, cb) { socket.emit("results:installed", {installed: installed}); }); - socket.on("getUpdatable", function() { + socket.on("checkUpdates", function() { // Check plugins for updates - installer.getAvailable(/*maxCacheAge:*/60*10, function(er, results) { + installer.getAvailablePlugins(/*maxCacheAge:*/60*10, function(er, results) { if(er) { console.warn(er); socket.emit("results:updatable", {updatable: {}}); diff --git a/src/static/css/admin.css b/src/static/css/admin.css index 31b16b9c..2260e27d 100644 --- a/src/static/css/admin.css +++ b/src/static/css/admin.css @@ -139,6 +139,7 @@ td, th { #installed-plugins td>div { position: relative;/* Allows us to position the loading indicator relative to this row */ display: inline-block; /*make this fill the whole cell*/ + width:100%; } .messages td>* { diff --git a/src/static/js/admin/plugins.js b/src/static/js/admin/plugins.js index 3937e666..bc7a0208 100644 --- a/src/static/js/admin/plugins.js +++ b/src/static/js/admin/plugins.js @@ -46,7 +46,7 @@ $(document).ready(function () { show: function(plugin, msg) { $('.installed-results .'+plugin+' .progress').show() $('.installed-results .'+plugin+' .progress .message').text(msg) - $(window).scrollTop(0) + $(window).scrollTop($('.'+plugin).offset().top-100) }, hide: function(plugin) { $('.installed-results .'+plugin+' .progress').hide() @@ -116,9 +116,13 @@ $(document).ready(function () { $(".do-install, .do-update").unbind('click').click(function (e) { var $row = $(e.target).closest("tr") , 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); - installed.progress.show(plugin, 'Installing') installed.messages.hide("nothing-installed") }); @@ -200,20 +204,17 @@ $(document).ready(function () { if(installed.list.length > 0) { displayPluginList(installed.list, $("#installed-plugins"), $("#installed-plugin-template")); + socket.emit('checkUpdates'); }else { installed.messages.show("nothing-installed") } }); socket.on('results:updatable', function(data) { - $('#installed-plugins > tr').each(function(i, tr) { - var pluginName = $(tr).find('.name').text() - - if (data.updatable.indexOf(pluginName) >= 0) { - var actions = $(tr).find('.actions') - actions.append('') - actions.css('width', 200) - } + data.updatable.forEach(function(pluginName) { + var $row = $('#installed-plugins > tr.'+pluginName) + , actions = $row.find('.actions') + actions.append('') }) updateHandlers(); }) @@ -251,8 +252,8 @@ $(document).ready(function () { socket.emit("getInstalled"); search(''); - // check for updates every 15mins + // check for updates every 5mins setInterval(function() { socket.emit('checkUpdates'); - }, 1000*60*15) + }, 1000*60*5) }); diff --git a/src/templates/admin/plugins.html b/src/templates/admin/plugins.html index 270fbfd7..1b69549c 100644 --- a/src/templates/admin/plugins.html +++ b/src/templates/admin/plugins.html @@ -46,8 +46,8 @@ - -
+ +

@@ -86,8 +86,8 @@ - -
+ +

-- cgit v1.2.3