/admin/plugins: Dry up displaying of info messages

This commit is contained in:
Marcel Klehr 2013-03-26 21:04:21 +01:00
parent 76c879bb47
commit d01a209cbf
3 changed files with 37 additions and 17 deletions

View File

@ -141,9 +141,9 @@ td, th {
display: inline-block; /*make this fill the whole cell*/ display: inline-block; /*make this fill the whole cell*/
} }
.messages * { .messages td>* {
text-align: center;
display: none; display: none;
text-align: center;
} }
.messages .fetching { .messages .fetching {

View File

@ -30,17 +30,37 @@ $(document).ready(function () {
search.sortBy = 'name'; search.sortBy = 'name';
search.sortDir = /*DESC?*/true; search.sortDir = /*DESC?*/true;
search.end = true;// have we received all results already? search.end = true;// have we received all results already?
search.messages = {
show: function(msg) {
$('.search-results .messages').show()
$('.search-results .messages .'+msg+'').show()
},
hide: function(msg) {
$('.search-results .messages').hide()
$('.search-results .messages .'+msg+'').hide()
}
}
var installed = { var installed = {
progress: { progress: {
show: function(plugin, msg) { show: function(plugin, msg) {
$('#installed-plugins .'+plugin+' .progress').show() $('.installed-results .'+plugin+' .progress').show()
$('#installed-plugins .'+plugin+' .progress .message').text(msg) $('.installed-results .'+plugin+' .progress .message').text(msg)
$(window).scrollTop(0) $(window).scrollTop(0)
}, },
hide: function(plugin) { hide: function(plugin) {
$('#installed-plugins .'+plugin+' .progress').hide() $('.installed-results .'+plugin+' .progress').hide()
$('#installed-plugins .'+plugin+' .progress .message').text('') $('.installed-results .'+plugin+' .progress .message').text('')
}
},
messages: {
show: function(msg) {
$('.installed-results .messages').show()
$('.installed-results .messages .'+msg+'').show()
},
hide: function(msg) {
$('.installed-results .messages').hide()
$('.installed-results .messages .'+msg+'').hide()
} }
}, },
list: [] list: []
@ -99,7 +119,7 @@ $(document).ready(function () {
$row.remove().appendTo('#installed-plugins') $row.remove().appendTo('#installed-plugins')
socket.emit("install", plugin); socket.emit("install", plugin);
installed.progress.show(plugin, 'Installing') installed.progress.show(plugin, 'Installing')
$(".installed-results .nothing-installed").hide() installed.messages.hide("nothing-installed")
}); });
// uninstall // uninstall
@ -132,8 +152,8 @@ $(document).ready(function () {
socket.on('results:search', function (data) { socket.on('results:search', function (data) {
if(!data.results.length) search.end = true; if(!data.results.length) search.end = true;
$(".search-results .nothing-found").hide() search.messages.hide('nothing-found')
$(".search-results .fetching").hide() search.messages.hide('fetching')
$("#search-query").removeAttr('disabled') $("#search-query").removeAttr('disabled')
console.log('got search results', data) console.log('got search results', data)
@ -155,15 +175,15 @@ $(document).ready(function () {
if(search.results.length > 0) { if(search.results.length > 0) {
displayPluginList(search.results, searchWidget.find(".results"), searchWidget.find(".template tr")) displayPluginList(search.results, searchWidget.find(".results"), searchWidget.find(".template tr"))
}else { }else {
$(".search-results .nothing-found").show() search.messages.show('nothing-found')
} }
$('#search-progress').hide() $('#search-progress').hide()
checkInfiniteScroll() checkInfiniteScroll()
}); });
socket.on('results:installed', function (data) { socket.on('results:installed', function (data) {
$(".installed-results .nothing-installed").hide() installed.messages.hide("fetching")
$(".installed-results .fetching").hide() installed.messages.hide("nothing-installed")
installed.list = data.installed installed.list = data.installed
sortPluginList(installed.list, 'name', /*ASC?*/true); sortPluginList(installed.list, 'name', /*ASC?*/true);
@ -181,7 +201,7 @@ $(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"));
}else { }else {
$(".installed-results .nothing-installed").show() installed.messages.show("nothing-installed")
} }
}); });

View File

@ -56,8 +56,8 @@
</tbody> </tbody>
<tbody id="installed-plugins"> <tbody id="installed-plugins">
</tbody> </tbody>
<tbody> <tbody class="messages">
<tr><td></td><td class="messages"> <tr><td></td><td>
<p class="nothing-installed">You haven't installed any plugins yet.</p> <p class="nothing-installed">You haven't installed any plugins yet.</p>
<p class="fetching">Fetching installed plugins...</p> <p class="fetching">Fetching installed plugins...</p>
</td><td></td></tr> </td><td></td></tr>
@ -96,8 +96,8 @@
</tbody> </tbody>
<tbody class="results"> <tbody class="results">
</tbody> </tbody>
<tbody> <tbody class="messages">
<tr><td></td><td class="messages"> <tr><td></td><td>
<div class="search-progress" class="progress"><img src="../static/img/loading.gif"/></div> <div class="search-progress" class="progress"><img src="../static/img/loading.gif"/></div>
<p class="nothing-found">No plugins found.</p> <p class="nothing-found">No plugins found.</p>
<p class="fetching">Fetching catalogue...</p> <p class="fetching">Fetching catalogue...</p>