From 5af3b251aad7c31cd41b805fe0179117302d0b2f Mon Sep 17 00:00:00 2001 From: Helena Jeeves Date: Wed, 16 Nov 2022 15:16:01 -0800 Subject: [PATCH] CADC-11882: launch form fields resetting correctly now. Service error reported in a modal if service returns a 401 (unauthorized) and for any other value. Prior it turned the status bar red and said nothing more --- src/main/webapp/js/science_portal.js | 105 +++++++++----------- src/main/webapp/js/science_portal_form.js | 113 ++++++++++------------ 2 files changed, 98 insertions(+), 120 deletions(-) diff --git a/src/main/webapp/js/science_portal.js b/src/main/webapp/js/science_portal.js index 2da07e8..f3ca41c 100644 --- a/src/main/webapp/js/science_portal.js +++ b/src/main/webapp/js/science_portal.js @@ -150,19 +150,7 @@ } }) - - portalCore.subscribe(portalSessions, cadc.web.science.portal.session.events.onLoadSessionListError, function (e, request){ - // This should be triggered if the user doesn't have access to Skaha resources, as well as - // other error conditions. Without access to Skaha, the user should be blocked from using the page, - // but be directed to some place they can ask for what they need (a resource allocation.) - - if (request.status == 403) { - portalCore.setInfoModal('Skaha authorization issue', portalCore.getRcDisplayText(request), true, false, false) - } else { - // There some other problem contacting the session service. Report the error - portalCore.setAjaxFail(request) - } - }) + portalCore.subscribe(portalSessions, cadc.web.science.portal.session.events.onLoadSessionListError, handleServiceError) portalCore.subscribe(portalSessions, cadc.web.science.portal.session.events.onPollingContinue, function (e) { // Rebuild session list on top of page @@ -180,29 +168,30 @@ checkForSessions() }) - - // TODO: make sure this works somehow - try triggering it in - // a situation where the context call works? - // If this method does work, change the sesion list error to use it as well - // This should only happen once during a page load + // Portal Form listeners portalCore.subscribe(portalForm, cadc.web.science.portal.form.events.onLoadFormDataDone, initForm) - portalCore.subscribe(portalSessions, cadc.web.science.portal.form.events.onLoadContextDataError, handleServiceError) - portalCore.subscribe(portalSessions, cadc.web.science.portal.form.events.onLoadImageDataError, handleServiceError) + portalCore.subscribe(portalForm, cadc.web.science.portal.form.events.onLoadContextDataError, handleServiceError) + portalCore.subscribe(portalForm, cadc.web.science.portal.form.events.onLoadImageDataError, handleServiceError) } // end attachListeners() - function handleServiceError(e, request) { + + // Stop any outstanding ajax calls from being processed. If one has failed, + // it's assumed the skaha service is unreachable or has something else wrong, + // so the page becomes unavailable + portalForm.interruptAjaxProcessing() + // This should be triggered if the user doesn't have access to Skaha resources, as well as // other error conditions. Without access to Skaha, the user should be blocked from using the page, // but be directed to some place they can ask for what they need (a resource allocation.) - - if (request.status == 403) { - portalCore.setInfoModal('Skaha authorization issue', portalCore.getRcDisplayText(request), true, false, false) - } else { - // There some other problem contacting the session service. Report the error - portalCore.setAjaxFail(request) + var msgHeader = 'Service Error' + var msgBody = portalCore.getRcDisplayText(request) + if (request.status === 403 || request.status === 401) { + msgHeader = 'Skaha authorization issue' + msgBody = 'Your userid is not authorized to use Skaha resources. Contact CANFAR admin for assistance.' } + portalCore.setInfoModal(msgHeader, msgBody, true, false, false) } // ------------ Data display functions @@ -381,6 +370,10 @@ + 'Reload this page to try again. ', true, false, false) } + // set dropdown defaults for context + // image default is handled when it's populated elsewhere + _resetFormDropdown("sp_cores", portalForm.getCoresDefault()) + _resetFormDropdown("sp_memory", portalForm.getRAMDefault()) } function populateSelect(selectID, optionData, placeholderText, defaultOptionID) { @@ -399,6 +392,7 @@ var curOption = optionData[i] var option = $('