From 1dcf802257be82aea862db882258f8d0f5d49f16 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Mon, 18 Mar 2019 16:41:23 +0100 Subject: [PATCH] luci-app-attendedsysupgrade: add 409 error code HTTP Error code is send by the upgrade server in case of package conflicts, like when requesting to install both `odhcpd` and `odhcpd-ipv6only`. Also put a

around download links to make them look more appealing. Signed-off-by: Paul Spooren --- .../resources/attendedsysupgrade.js | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/applications/luci-app-attendedsysupgrade/root/www/luci-static/resources/attendedsysupgrade.js b/applications/luci-app-attendedsysupgrade/root/www/luci-static/resources/attendedsysupgrade.js index a5fb0a1cb..2cf5cc6e1 100644 --- a/applications/luci-app-attendedsysupgrade/root/www/luci-static/resources/attendedsysupgrade.js +++ b/applications/luci-app-attendedsysupgrade/root/www/luci-static/resources/attendedsysupgrade.js @@ -157,12 +157,15 @@ function ubus_call(command, argument, params, variable) { request.send(request_json); } -function set_status(type, message, loading) { +function set_status(type, message, loading, show_log) { $("#status_box").className = "alert-message " + type; var loading_image = ''; if (loading) { loading_image = 'Loading '; } + if (show_log && data.log) { + message += '

Build log

' + } $("#status_box").innerHTML = loading_image + message; show("#status_box") } @@ -238,13 +241,13 @@ function upgrade_request() { function upgrade_request_callback(request) { // ready to download - var request_json = JSON.parse(request); - data.files = request_json.files; - data.sysupgrade = request_json.sysupgrade; + var request_json = JSON.parse(request) + data.files = request_json.files + data.sysupgrade = request_json.sysupgrade + data.log = request_json.log - var info_output = 'Firmware created: ' + data.sysupgrade + '' - info_output += ' Build log' - set_status("info", info_output); + var info_output = '

Firmware created

Created file: ' + data.sysupgrade + '

' + set_status("success", info_output, false, true); show("#keep_container"); var upgrade_button = $("#upgrade_button") @@ -378,6 +381,12 @@ function server_request(path, callback) { request_json = JSON.parse(request_text) set_status("danger", request_json.error) + } else if (request.status === 409) { + // bad request + request_json = JSON.parse(request_text) + data.log = request_json.log + set_status("danger", "Incompatible package selection. See build log for details", false, true) + } else if (request.status === 412) { // this is a bit generic set_status("danger", "Unsupported device, release, target, subtraget or board") @@ -394,9 +403,9 @@ function server_request(path, callback) { var error_box_content = "Internal server error
" error_box_content += request_json.error if (request_json.log != undefined) { - data.log_url = request_json.log + data.log = request_json.log } - set_status("danger", error_box_content) + set_status("danger", error_box_content, false, true) } else if (request.status === 501) { set_status("danger", "No sysupgrade file produced, may not supported by model.") -- 2.25.1