From: Moritz Warning Date: Thu, 5 Mar 2020 13:13:24 +0000 (+0100) Subject: Use updated server API (#14) X-Git-Tag: v2.1.0~12 X-Git-Url: http://git.openwrt.org/openwrt/feeds.git?a=commitdiff_plain;h=f050bfcf795aaf367baac8b481a3d3eaf9f01f2a;p=web%2Ffirmware-selector-openwrt-org.git Use updated server API (#14) Instead of returning the full url to the binary directory now returns `bin_dir` only. This is possible as `asu_url` is already defined locally. This approach allows devices not using https to download content unencrypted, meaning the server response does not delegate the protocol. In addition a boolean value is returned stating if a buildlog was created, which is shown in case of failures. Signed-off-by: Paul Spooren --- diff --git a/config.js b/config.js index ec033b5..9bfb51a 100644 --- a/config.js +++ b/config.js @@ -13,5 +13,5 @@ var config = { }, // Build custom images // See https://github.com/aparcar/sasu - //asu_url: '/api/build' + // asu_url: 'http://localhost:5000' }; diff --git a/index.html b/index.html index a32c932..d13eed5 100644 --- a/index.html +++ b/index.html @@ -68,6 +68,7 @@ Image of unknown purpose. + Buildlog diff --git a/index.js b/index.js index 5c6efb8..893600e 100644 --- a/index.js +++ b/index.js @@ -47,7 +47,7 @@ function build_asa_request() { console.log('disable request button / show loading spinner') - fetch(config.asu_url, { + fetch(config.asu_url + '/api/build', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(request_data) @@ -61,11 +61,12 @@ function build_asa_request() { response.json() .then(mobj => { console.log(mobj) + var download_url = config.asu_url + '/store/' + mobj.bin_dir updateImages( mobj.version_number, mobj.version_code, get_model_titles(mobj.titles), - mobj.url, mobj, true + download_url, mobj, true ); }); break; @@ -81,6 +82,10 @@ function build_asa_request() { console.log('error (' + response.status + ')'); response.json() .then(mobj => { + if (mobj.buildlog == true) { + $('buildlog').href = config.asu_url + '/store/' + mobj.bin_dir + '/buildlog.txt'; + show('buildlog') + } alert(mobj.message) }); break; @@ -258,6 +263,7 @@ function setupAutocompleteList(input, items, onselection) { } function updateImages(version, code, model, url, mobj, is_custom) { + hide('buildlog') // add download button for image function addLink(type, file) { var a = document.createElement('A');