/admin/plugins: Display an update button for all plugins that are outdated
This commit is contained in:
Родитель
0549a4fec7
Коммит
541aeb3a98
|
@ -82,7 +82,7 @@ input[type="button"] {
|
||||||
padding: 4px 6px;
|
padding: 4px 6px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
input[type="button"].do-install, input[type="button"].do-uninstall {
|
table input[type="button"] {
|
||||||
float: right;
|
float: right;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
var search = function () {
|
var search = function () {
|
||||||
socket.emit("search", $('.search-results').data('query'));
|
socket.emit("search", $('.search-results').data('query'));
|
||||||
|
tasks++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHandlers() {
|
function updateHandlers() {
|
||||||
|
@ -40,16 +41,18 @@ $(document).ready(function () {
|
||||||
search();
|
search();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".do-install").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");
|
||||||
doUpdate = true;
|
doUpdate = true;
|
||||||
socket.emit("install", row.find(".name").text());
|
socket.emit("install", row.find(".name").text());
|
||||||
|
tasks++;
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".do-uninstall").unbind('click').click(function (e) {
|
$(".do-uninstall").unbind('click').click(function (e) {
|
||||||
var row = $(e.target).closest("tr");
|
var row = $(e.target).closest("tr");
|
||||||
doUpdate = true;
|
doUpdate = true;
|
||||||
socket.emit("uninstall", row.find(".name").text());
|
socket.emit("uninstall", row.find(".name").text());
|
||||||
|
tasks++;
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".do-prev-page").unbind('click').click(function (e) {
|
$(".do-prev-page").unbind('click').click(function (e) {
|
||||||
|
@ -72,11 +75,9 @@ $(document).ready(function () {
|
||||||
|
|
||||||
updateHandlers();
|
updateHandlers();
|
||||||
|
|
||||||
|
var tasks = 0;
|
||||||
socket.on('progress', function (data) {
|
socket.on('progress', function (data) {
|
||||||
if (data.progress > 0 && $('#progress').data('progress') > data.progress) return;
|
|
||||||
|
|
||||||
$("#progress").show();
|
$("#progress").show();
|
||||||
|
|
||||||
$('#progress').data('progress', data.progress);
|
$('#progress').data('progress', data.progress);
|
||||||
|
|
||||||
var message = "Unknown status";
|
var message = "Unknown status";
|
||||||
|
@ -90,7 +91,12 @@ $(document).ready(function () {
|
||||||
$("#progress .message").html(message);
|
$("#progress .message").html(message);
|
||||||
|
|
||||||
if (data.progress >= 1) {
|
if (data.progress >= 1) {
|
||||||
$("#progress").hide();
|
tasks--;
|
||||||
|
if (tasks <= 0) {
|
||||||
|
// Hide the activity indicator once all tasks are done
|
||||||
|
$("#progress").hide();
|
||||||
|
tasks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
alert('An error occurred: '+data.error+' -- the server log might know more...');
|
alert('An error occurred: '+data.error+' -- the server log might know more...');
|
||||||
|
@ -98,6 +104,7 @@ $(document).ready(function () {
|
||||||
if (doUpdate) {
|
if (doUpdate) {
|
||||||
doUpdate = false;
|
doUpdate = false;
|
||||||
socket.emit("load");
|
socket.emit("load");
|
||||||
|
tasks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,9 +128,7 @@ $(document).ready(function () {
|
||||||
for (plugin_name in data.results) {
|
for (plugin_name in data.results) {
|
||||||
var plugin = data.results[plugin_name];
|
var plugin = data.results[plugin_name];
|
||||||
var row = widget.find(".template tr").clone();
|
var row = widget.find(".template tr").clone();
|
||||||
var version = '0.0.0';
|
|
||||||
// hack to access "versions" property of the npm package object
|
|
||||||
for (version in data.results[plugin_name].versions) break;
|
|
||||||
for (attr in plugin) {
|
for (attr in plugin) {
|
||||||
if(attr == "name"){ // Hack to rewrite URLS into name
|
if(attr == "name"){ // Hack to rewrite URLS into name
|
||||||
row.find(".name").html("<a target='_blank' href='https://npmjs.org/package/"+plugin['name']+"'>"+plugin[attr]+"</a>");
|
row.find(".name").html("<a target='_blank' href='https://npmjs.org/package/"+plugin['name']+"'>"+plugin[attr]+"</a>");
|
||||||
|
@ -131,7 +136,7 @@ $(document).ready(function () {
|
||||||
row.find("." + attr).html(plugin[attr]);
|
row.find("." + attr).html(plugin[attr]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
row.find(".version").html(version);
|
row.find(".version").html( data.results[plugin_name]['dist-tags'].latest );
|
||||||
|
|
||||||
widget.find(".results").append(row);
|
widget.find(".results").append(row);
|
||||||
}
|
}
|
||||||
|
@ -141,6 +146,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
socket.on('installed-results', function (data) {
|
socket.on('installed-results', function (data) {
|
||||||
$("#installed-plugins *").remove();
|
$("#installed-plugins *").remove();
|
||||||
|
|
||||||
for (plugin_name in data.results) {
|
for (plugin_name in data.results) {
|
||||||
if (plugin_name == "ep_etherpad-lite") continue; // Hack...
|
if (plugin_name == "ep_etherpad-lite") continue; // Hack...
|
||||||
var plugin = data.results[plugin_name];
|
var plugin = data.results[plugin_name];
|
||||||
|
@ -156,9 +162,26 @@ $(document).ready(function () {
|
||||||
$("#installed-plugins").append(row);
|
$("#installed-plugins").append(row);
|
||||||
}
|
}
|
||||||
updateHandlers();
|
updateHandlers();
|
||||||
|
|
||||||
|
socket.emit('checkUpdates');
|
||||||
|
tasks++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('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('<input class="do-update" type="button" value="Update" />')
|
||||||
|
actions.css('width', 200)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
updateHandlers();
|
||||||
|
})
|
||||||
|
|
||||||
socket.emit("load");
|
socket.emit("load");
|
||||||
|
tasks++;
|
||||||
|
|
||||||
search();
|
search();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче