From bf095d79eb885065d5ee6a1e08f9d6b066c730f8 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Fri, 12 Jun 2020 22:36:26 +0200 Subject: [PATCH] show asu build log for build success --- index.js | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 497e9e1..6264c8a 100644 --- a/index.js +++ b/index.js @@ -33,32 +33,22 @@ function build_asa_request() { return; } - function showStatus(text) { + function showStatus(message, url) { show('buildstatus'); - $('buildstatus').innerHTML = text; + var tr = message.startsWith('tr-') ? message : ''; + if (url) { + $('buildstatus').innerHTML = '' + message + ''; + } else { + $('buildstatus').innerHTML = ''; + } translate(); } - function handleError(response) { - hide('buildspinner'); - - response.json() - .then(mobj => { - var message = mobj['message'] || ''; - if (mobj.buildlog == true) { - var url = config.asu_url + '/store/' + mobj.bin_dir + '/buildlog.txt'; - showStatus('' + message + ''); - } else { - showStatus(message); - } - }); - } - // hide image view updateImages(); show('buildspinner'); - showStatus(''); + showStatus('tr-request-image'); var request_data = { 'target': current_model.target, @@ -76,11 +66,12 @@ function build_asa_request() { switch (response.status) { case 200: hide('buildspinner'); - showStatus(''); + showStatus('tr-build-successful'); response.json() .then(mobj => { var download_url = config.asu_url + '/store/' + mobj.bin_dir; + showStatus('tr-build-successful', download_url + '/buildlog.txt'); updateImages( mobj.version_number, mobj.version_code, @@ -91,13 +82,19 @@ function build_asa_request() { }); break; case 202: - showStatus(''); + showStatus('tr-check-again'); setTimeout(_ => { build_asa_request() }, 5000); break; case 400: // bad request case 422: // bad package case 500: // build failed - handleError(response); + hide('buildspinner'); + response.json() + .then(mobj => { + var message = mobj['message'] || 'tr-build-failed'; + var url = mobj.buildlog ? (config.asu_url + '/store/' + mobj.bin_dir + '/buildlog.txt') : undefined; + showStatus(message, url); + }) break; } }) -- 2.30.2