From fa55cd47598a1813d16ec48e4402f3bebfc43e80 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 24 Jan 2013 22:39:52 +0100 Subject: [PATCH 1/2] [/admin/plugins] Add real-time on keypress search also, I reduced the size of the activity indicator --- src/static/css/admin.css | 40 +++++--------------------------- src/static/js/admin/plugins.js | 35 +++++++++++++++------------- src/templates/admin/plugins.html | 22 +++++++----------- 3 files changed, 34 insertions(+), 63 deletions(-) diff --git a/src/static/css/admin.css b/src/static/css/admin.css index cc3e49344..4669e4b98 100644 --- a/src/static/css/admin.css +++ b/src/static/css/admin.css @@ -86,9 +86,6 @@ input[type="button"].do-install, input[type="button"].do-uninstall { float: right; width: 100px; } -input[type="button"]#do-search { - display: block; -} input[type="text"] { border-radius: 3px; box-sizing: border-box; @@ -117,41 +114,16 @@ td, th { .template { display: none; } -.dialog { - display: none; +#progress { position: absolute; - left: 50%; - top: 50%; - width: 700px; - height: 500px; - margin-left: -350px; - margin-top: -250px; - border: 3px solid #999; - background: #eee; + bottom: 50px; } -.dialog .title { - margin: 0; - padding: 2px; - border-bottom: 3px solid #999; - font-size: 24px; - line-height: 24px; - height: 24px; - overflow: hidden; -} -.dialog .title .close { +#progress .historylink { float: right; - padding: 1px 10px; } -.dialog .history { - background: #222; - color: #eee; - position: absolute; - top: 41px; - bottom: 10px; - left: 10px; - right: 10px; - padding: 2px; - overflow: auto; +#progress .history { + white-space: pre; + font-family: monospace; } .settings { margin-top:10px; diff --git a/src/static/js/admin/plugins.js b/src/static/js/admin/plugins.js index 03f6203b8..d0058522b 100644 --- a/src/static/js/admin/plugins.js +++ b/src/static/js/admin/plugins.js @@ -25,10 +25,6 @@ $(document).ready(function () { } function updateHandlers() { - $("#progress.dialog .close").unbind('click').click(function () { - $("#progress.dialog").hide(); - }); - $("form").submit(function(){ var query = $('.search-results').data('query'); query.pattern = $("#search-query").val(); @@ -36,8 +32,8 @@ $(document).ready(function () { search(); return false; }); - - $("#do-search").unbind('click').click(function () { + + $("#search-query").unbind('keyup').keyup(function () { var query = $('.search-results').data('query'); query.pattern = $("#search-query").val(); query.offset = 0; @@ -72,37 +68,44 @@ $(document).ready(function () { } search(); }); + + $('#progress .showhistory').unbind('click').click(function() { + $("#progress .history").toggle() + }); } updateHandlers(); socket.on('progress', function (data) { - if (data.progress > 0 && $('#progress.dialog').data('progress') > data.progress) return; + if (data.progress > 0 && $('#progress').data('progress') > data.progress) return; - $("#progress.dialog .close").hide(); - $("#progress.dialog").show(); + $("#progress .history").hide(); + $("#progress").show(); - $('#progress.dialog').data('progress', data.progress); + $('#progress').data('progress', data.progress); var message = "Unknown status"; if (data.message) { message = "" + data.message.toString() + ""; } if (data.error) { - message = "" + data.error.toString() + ""; + data.progress = 1; } - $("#progress.dialog .message").html(message); - $("#progress.dialog .history").append("
" + message + "
"); + + $("#progress .message").html(message); + $("#progress .history").append("
" + message + "
"); if (data.progress >= 1) { + $("#progress").hide(); + $("#progress .history").html(''); + if (data.error) { - $("#progress.dialog .close").show(); - } else { + alert('An error occurred: '+data.error+' -- the server log might know more...'); + }else { if (doUpdate) { doUpdate = false; socket.emit("load"); } - $("#progress.dialog").hide(); } } }); diff --git a/src/templates/admin/plugins.html b/src/templates/admin/plugins.html index 914812a6d..12f801580 100644 --- a/src/templates/admin/plugins.html +++ b/src/templates/admin/plugins.html @@ -18,12 +18,16 @@ <% } %> -
@@ -53,11 +57,12 @@
-

Search for plugins to install

+ +

Available plugins

- - +
+ @@ -86,16 +91,7 @@ - -
-

- Please wait: - -

-
-
-
From 23dd4c73e225eac8a624d43e7590cef405956b2a Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 24 Jan 2013 22:40:31 +0100 Subject: [PATCH 2/2] pluginfw/installer.js: Don't freak out users with cryptic errors, just use the error message --- src/static/js/pluginfw/installer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/static/js/pluginfw/installer.js b/src/static/js/pluginfw/installer.js index e491f0771..eb10f8afd 100644 --- a/src/static/js/pluginfw/installer.js +++ b/src/static/js/pluginfw/installer.js @@ -15,7 +15,10 @@ var withNpm = function (npmfn, final, cb) { cb({progress: 0.5, message:message.msg + ": " + message.pref}); }); npmfn(function (er, data) { - if (er) return cb({progress:1, error:er.code + ": " + er.path}); + if (er) { + console.error(er); + return cb({progress:1, error: er.message}); + } if (!data) data = {}; data.progress = 1; data.message = "Done.";