Andy Baugh 5 anni fa
parent
commit
59d51f0471
3 ha cambiato i file con 23 aggiunte e 4 eliminazioni
  1. 21 4
      js/pgupgrade.js
  2. 1 0
      lib/Troglodyne/API/Postgres.pm
  3. 1 0
      templates/ui/pgupgrade.tmpl

+ 21 - 4
js/pgupgrade.js

@@ -1,8 +1,14 @@
-function doAPIRequestWithCallback (mod, func, handler) {
+function doAPIRequestWithCallback (mod, func, handler, args) {
     'use strict';
-    var oReq = new XMLHttpRequest();
+    let oReq = new XMLHttpRequest();
     oReq.addEventListener("load", handler);
-    oReq.open("GET", `api.cgi?module=${mod}&function=${func}`);
+    let argstr = ''; 
+    if( typeof args === 'Object' ) {
+        Object.keys(args).forEach( function(argument) {
+            argstr += `&${argument}=${args[argument]}`;
+        });
+    }
+    oReq.open("GET", `api.cgi?module=${mod}&function=${func}${argstr}`);
     oReq.send();
     return false;
 }
@@ -11,6 +17,7 @@ function versionHandler () {
     'use strict';
     let obj = JSON.parse(this.responseText);
     if(obj.result === 1) {
+        console.log(obj);
 
         // Construct version warning/display
         let pgVersion = obj.data.installed_version.major + '.' + obj.data.installed_version.minor;
@@ -18,7 +25,14 @@ function versionHandler () {
         let html = `<strong>${pgVersion}</strong>`;
         if( parseFloat(pgVersion) < parseFloat(obj.data.minimum_supported_version) ) {
             elem.classList.add('callout', 'callout-danger');
-            html += " -- You are using a version of PostgreSQL Server that is no longer supported! Immediate upgrade recommended.";
+            html += ' -- You are using a version of PostgreSQL Server that is no longer supported by ';
+            html += '<a href="https://www.postgresql.org/support/versioning/" title="PostgreSQL Supported versions page">postgresql.org</a>!<br>';
+            if( obj.data.eol_versions.hasOwnProperty(pgVersion) ) {
+                console.log(obj.data.eol_versions[pgVersion]);
+                console.log(obj.data.eol_versions[pgVersion].EOL);
+                html += "<strong>EOL</strong> -- " + new Date(obj.data.eol_versions[pgVersion].EOL * 1000).toLocaleString( undefined, { year: 'numeric', month: 'long', day: 'numeric' } ) + "<br>";
+            }
+            html += "<strong>Immediate upgrade is recommended.</strong>";
         }
         elem.innerHTML = html;
 
@@ -88,6 +102,9 @@ window.doUpgrade = function () {
     submitBtn.innerHTML = '<span class="fa fa-spin fa-spinner"></span>';
     document.getElementById('upgradeDiv').innerHTML = '<pre id="upgradeWell" class="well">Ensuring that the PostgreSQL Community repository is installed...\n</pre>';
     doAPIRequestWithCallback('Postgres', 'enable_community_repositories', doInstallScroller );
+    let versionSelectedElem = document.querySelector('input[name="selectedVersion"]:checked');
+    let version2install = versionSelectedElem.value;
+    doAPIRequestWithCallback( 'Postgres', 'install_postgres', doInstallScroller, { "version": "9.5" } );
     return false;
 }
 

+ 1 - 0
lib/Troglodyne/API/Postgres.pm

@@ -13,6 +13,7 @@ sub get_postgresql_versions {
         'installed_version'         => { 'major' => $ver_arr[0], 'minor' => $ver_arr[1] },
         'minimum_supported_version' => $Troglodyne::CpPostgreSQL::MINIMUM_SUPPORTED_VERSION,
         'available_versions'        => \%Troglodyne::CpPostgreSQL::SUPPORTED_VERSIONS_MAP,
+        'eol_versions'              => \%Troglodyne::CpPostgreSQL::CP_UNSUPPORTED_VERSIONS_MAP,
     };
 }
 

+ 1 - 0
templates/ui/pgupgrade.tmpl

@@ -71,5 +71,6 @@ This interface at least attempts to take care of those issues for you.
     </form>
 </div>
 <button id="submit" class="btn btn-success" title="Please select a version above to continue" onclick="window.doUpgrade();">Continue</button>
+<br><br>
 <script type="text/javascript" src="js/pgupgrade.js"></script>
 [% END %]