f5bc6b413957f25f24799f15e836757e4f82a668 chmalee Tue Aug 22 13:27:51 2023 -0700 Make warnings show up in search results, refs #31965 diff --git src/hg/js/hgSearch.js src/hg/js/hgSearch.js index b31b736..4dc5ab3 100644 --- src/hg/js/hgSearch.js +++ src/hg/js/hgSearch.js @@ -674,30 +674,33 @@ function changeSearchResultsLabel() { // change the title to indicate what assembly was search: $("#dbPlaceholder").empty(); $("#dbPlaceholder").append("on " + db + " (" + $("#dbSelect")[0].selectedOptions[0].label+ ")"); } function checkJsonData(jsonData, callerName) { // Return true if jsonData isn't empty and doesn't contain an error; // otherwise complain on behalf of caller. if (! jsonData) { alert(callerName + ': empty response from server'); } else if (jsonData.error && !jsonData.error.startsWith("Sorry, couldn't locate")) { console.error(jsonData.error); alert(callerName + ': error from server: ' + jsonData.error); + } else if (jsonData.warning) { + alert("Warning: " + jsonData.warning); + return true; } else { if (debugCartJson) { console.log('from server:\n', jsonData); } return true; } return false; } function updateStateAndPage(jsonData, doSaveHistory) { // Update uiState with new values and update the page. _.assign(uiState, jsonData); db = uiState.db; if (jsonData.positionMatches !== undefined) { // clear the old resultHash @@ -789,30 +792,33 @@ window.location = window.location.href.replace(re,"db="+newDb); } function init() { cart.setCgi('hgSearch'); cart.debug(debugCartJson); // If a user clicks search before the page has finished loading // start processing it now: $("#searchBarSearchButton").click(sendUserSearch); if (typeof cartJson !== "undefined") { if (cartJson.db !== undefined) { db = cartJson.db; } else { alert("Error no database from request"); } + if (cartJson.warning !== undefined) { + alert("Warning: " + cartJson.warning); + } // check right away for a special redirect to hgTracks: if (cartJson.positionMatches !== undefined && cartJson.positionMatches.length == 1 && cartJson.positionMatches[0].matches[0].doRedirect === true) { positionMatch = cartJson.positionMatches[0]; match = positionMatch.matches[0]; position = match.position; newUrl = "../cgi-bin/hgTracks" + "?db=" + db + "&position=" + position; if (match.highlight) { newUrl += "&addHighlight=" + match.highlight; } if (positionMatch.name !== "chromInfo") { newUrl += "&" + positionMatch.name + "=pack"; } window.location.replace(newUrl);