Merge pull request #1404 from ether/feature/real-time-plugin-search

real-time plugin search
This commit is contained in:
John McLear 2013-01-24 14:09:30 -08:00
commit 568b641ee9
4 changed files with 38 additions and 64 deletions

View file

@ -86,9 +86,6 @@ input[type="button"].do-install, input[type="button"].do-uninstall {
float: right; float: right;
width: 100px; width: 100px;
} }
input[type="button"]#do-search {
display: block;
}
input[type="text"] { input[type="text"] {
border-radius: 3px; border-radius: 3px;
box-sizing: border-box; box-sizing: border-box;
@ -117,41 +114,16 @@ td, th {
.template { .template {
display: none; display: none;
} }
.dialog { #progress {
display: none;
position: absolute; position: absolute;
left: 50%; bottom: 50px;
top: 50%;
width: 700px;
height: 500px;
margin-left: -350px;
margin-top: -250px;
border: 3px solid #999;
background: #eee;
} }
.dialog .title { #progress .historylink {
margin: 0;
padding: 2px;
border-bottom: 3px solid #999;
font-size: 24px;
line-height: 24px;
height: 24px;
overflow: hidden;
}
.dialog .title .close {
float: right; float: right;
padding: 1px 10px;
} }
.dialog .history { #progress .history {
background: #222; white-space: pre;
color: #eee; font-family: monospace;
position: absolute;
top: 41px;
bottom: 10px;
left: 10px;
right: 10px;
padding: 2px;
overflow: auto;
} }
.settings { .settings {
margin-top:10px; margin-top:10px;

View file

@ -25,10 +25,6 @@ $(document).ready(function () {
} }
function updateHandlers() { function updateHandlers() {
$("#progress.dialog .close").unbind('click').click(function () {
$("#progress.dialog").hide();
});
$("form").submit(function(){ $("form").submit(function(){
var query = $('.search-results').data('query'); var query = $('.search-results').data('query');
query.pattern = $("#search-query").val(); query.pattern = $("#search-query").val();
@ -37,7 +33,7 @@ $(document).ready(function () {
return false; return false;
}); });
$("#do-search").unbind('click').click(function () { $("#search-query").unbind('keyup').keyup(function () {
var query = $('.search-results').data('query'); var query = $('.search-results').data('query');
query.pattern = $("#search-query").val(); query.pattern = $("#search-query").val();
query.offset = 0; query.offset = 0;
@ -72,37 +68,44 @@ $(document).ready(function () {
} }
search(); search();
}); });
$('#progress .showhistory').unbind('click').click(function() {
$("#progress .history").toggle()
});
} }
updateHandlers(); updateHandlers();
socket.on('progress', function (data) { 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 .history").hide();
$("#progress.dialog").show(); $("#progress").show();
$('#progress.dialog').data('progress', data.progress); $('#progress').data('progress', data.progress);
var message = "Unknown status"; var message = "Unknown status";
if (data.message) { if (data.message) {
message = "<span class='status'>" + data.message.toString() + "</span>"; message = "<span class='status'>" + data.message.toString() + "</span>";
} }
if (data.error) { if (data.error) {
message = "<span class='error'>" + data.error.toString() + "<span>"; data.progress = 1;
} }
$("#progress.dialog .message").html(message);
$("#progress.dialog .history").append("<div>" + message + "</div>"); $("#progress .message").html(message);
$("#progress .history").append("<div>" + message + "</div>");
if (data.progress >= 1) { if (data.progress >= 1) {
$("#progress").hide();
$("#progress .history").html('');
if (data.error) { if (data.error) {
$("#progress.dialog .close").show(); alert('An error occurred: '+data.error+' -- the server log might know more...');
} else { }else {
if (doUpdate) { if (doUpdate) {
doUpdate = false; doUpdate = false;
socket.emit("load"); socket.emit("load");
} }
$("#progress.dialog").hide();
} }
} }
}); });

View file

@ -15,7 +15,10 @@ var withNpm = function (npmfn, final, cb) {
cb({progress: 0.5, message:message.msg + ": " + message.pref}); cb({progress: 0.5, message:message.msg + ": " + message.pref});
}); });
npmfn(function (er, data) { 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 = {}; if (!data) data = {};
data.progress = 1; data.progress = 1;
data.message = "Done."; data.message = "Done.";

View file

@ -18,12 +18,16 @@
</div> </div>
<% } %> <% } %>
<div class="menu"> <div class="menu">
<h1>Etherpad lite</h1> <h1>Etherpad lite</h1>
<li><a href="plugins">Plugin manager</a> </li> <li><a href="plugins">Plugin manager</a> </li>
<li><a href="settings">Settings</a> </li> <li><a href="settings">Settings</a> </li>
<li><a href="plugins/info">Troubleshooting information</a> </li> <li><a href="plugins/info">Troubleshooting information</a> </li>
<div id="progress">
<p><img src="../static/img/loading.gif" alt=""/>&nbsp;&nbsp;<span class="message"></span> <a class="showhistory" href="javascript:void(0)">(show&nbsp;progress)</a></p>
<div class="history"></div>
</div>
</div> </div>
<div class="innerwrapper"> <div class="innerwrapper">
@ -53,11 +57,12 @@
<div class="paged listing search-results"> <div class="paged listing search-results">
<div class="separator"></div> <div class="separator"></div>
<h2>Search for plugins to install</h2>
<h2>Available plugins</h2>
<form> <form>
<input type="text" name="search" placeholder="Search term" id="search-query"> <input type="text" name="search" placeholder="Search for plugins to install" id="search-query">
<input type="button" value="Search" id="do-search">
</form> </form>
<table> <table>
<thead> <thead>
<tr> <tr>
@ -86,16 +91,7 @@
</div> </div>
</div> </div>
<div id="progress" class="dialog">
<h1 class="title">
Please wait: <span class="message"></span>
<input type="button" class="close" value="Close">
</h1>
<div class="history"></div>
</div> </div>
</div>
<div id="topborder"></div> <div id="topborder"></div>
</body> </body>
</html> </html>