From 551a9fe1c6621e82e2832beeec46cfecfed63c0f Mon Sep 17 00:00:00 2001 From: chaptergy <26956711+chaptergy@users.noreply.github.com> Date: Thu, 15 Oct 2020 14:55:14 +0200 Subject: [PATCH 1/3] Fixes custom certificate upload --- frontend/js/app/api.js | 9 ++- frontend/js/app/nginx/certificates/form.ejs | 7 +- frontend/js/app/nginx/certificates/form.js | 85 ++++++++++----------- frontend/js/i18n/messages.json | 2 +- 4 files changed, 51 insertions(+), 52 deletions(-) diff --git a/frontend/js/app/api.js b/frontend/js/app/api.js index baa5cb1..9d11d26 100644 --- a/frontend/js/app/api.js +++ b/frontend/js/app/api.js @@ -139,7 +139,11 @@ function FileUpload(path, fd) { xhr.onreadystatechange = function () { if (this.readyState === XMLHttpRequest.DONE) { if (xhr.status !== 200 && xhr.status !== 201) { - reject(new Error('Upload failed: ' + xhr.status)); + try { + reject(new Error('Upload failed: ' + JSON.parse(xhr.responseText).error.message)); + } catch (err) { + reject(new Error('Upload failed: ' + xhr.status)); + } } else { resolve(xhr.responseText); } @@ -587,7 +591,8 @@ module.exports = { * @param {Object} data */ create: function (data) { - const timeout = 180000 + (data.meta.propagation_seconds ? Number(data.meta.propagation_seconds) * 1000 : 0); + + const timeout = 180000 + (data && data.meta && data.meta.propagation_seconds ? Number(data.meta.propagation_seconds) * 1000 : 0); return fetch('post', 'nginx/certificates', data, {timeout}); }, diff --git a/frontend/js/app/nginx/certificates/form.ejs b/frontend/js/app/nginx/certificates/form.ejs index 270ab71..4e40e0b 100644 --- a/frontend/js/app/nginx/certificates/form.ejs +++ b/frontend/js/app/nginx/certificates/form.ejs @@ -4,17 +4,14 @@
<%- i18n('ssl', 'obtaining-certificate-info') %>
+<%- i18n('ssl', 'processing-info') %>