diff --git a/views/default.handlebars b/views/default.handlebars index a09e2136..b9ffa8f7 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -2365,23 +2365,7 @@ } case 'pluginVersionsAvailable': { if (pluginHandler == null) break; - try { - var td = Q('pluginRow-'+message.list.id).querySelectorAll(".pluginUpgradeAvailable"); - var sel = Q('pluginRow-'+message.list.id).querySelectorAll(".pluginAction > select"); - td = td[0]; - sel = sel[0]; - if (message.list.hasUpdate && message.list.status) { - td.innerHTML = '' + message.list.version + ''; - if (sel.innerHTML.indexOf('Upgrade') === -1) { - var option = document.createElement("option"); - option.value = "install" - option.text = "Upgrade"; - sel.add(option); - } - } else { - td.innerHTML = "Up to date"; - } - } catch (e) { } + updatePluginList(message.list); break; } case 'plugin': { @@ -9434,8 +9418,12 @@ } } - function updatePluginList() { + function updatePluginList(versInfo) { if (installedPluginList.length) { + if (versInfo != null) { + if (installedPluginList['version_info'] == null) installedPluginList['version_info'] = []; + installedPluginList['version_info'][versInfo.id] = versInfo; + } var tr = Q('p7tbl').querySelectorAll(".p7tblRow"); if (tr.length) { for (const i in Object.values(tr)) { @@ -9458,24 +9446,51 @@ 'delete': 'Delete' }, 1: { - 'disable': 'Disable' + 'disable': 'Disable', + 'upgrade': 'Upgrade' } }; + var vers_not_compat = ` [ ! ]`; + var tbl = Q('p7tbl'); installedPluginList.forEach(function(p){ + var cant_action = []; if (p.hasAdminPanel == true) { p.name = `${p.name}`; } p.statusText = statusMap[p.status].text; p.statusColor = statusMap[p.status].color; + + + if (!p.status) { // It isn't technically installed, so no version number + p.version = ' - '; + } + p.upgradeAvail = 'Checking...'; + if (installedPluginList['version_info'] != null && installedPluginList['version_info'][p._id] != null) { + var vin = installedPluginList['version_info'][p._id]; + if (vin.hasUpdate) { + p.upgradeAvail = '' + vin.version + ''; + } else { + cant_action.push('upgrade'); + if (p.status) p.upgradeAvail = 'Up to date'; + else p.upgradeAvail = '' + vin.version + ''; + } + if (!vin.meshCentralCompat) { + p.upgradeAvail += vers_not_compat; + cant_action.push('install'); + } + } + p.actions = '' + p.actions += ''; - let tpl = `${p.name}${p.description}Homepage${p.version}Checking...${p.statusText}${p.actions}`; + let tpl = `${p.name}${p.description}Homepage${p.version}${p.upgradeAvail}${p.statusText}${p.actions}`; let tr = tbl.insertRow(-1); tr.innerHTML = tpl; tr.classList.add('p7tblRow'); @@ -9488,7 +9503,7 @@ tr[i].parentNode.removeChild(tr[i]); } } - refreshPluginLatest(); + if (versInfo == null) refreshPluginLatest(); } function refreshPluginLatest() { @@ -9498,18 +9513,16 @@ function pluginActionEx() { var act = Q('lastPluginAct').value, id = Q('lastPluginId').value; switch(act) { - case 'install': { + case 'upgrade': + case 'install': meshserver.send({ "action": "installplugin", "id": id }); break; - } - case 'delete': { + case 'delete': meshserver.send({ "action": "removeplugin", "id": id }); break; - } - case 'disable': { + case 'disable': meshserver.send({ "action": "disableplugin", "id": id }); break; - } } QS('pluginRestartNotice').display = ''; }