mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-22 14:08:23 -05:00
Merge pull request #189 from neon-mmd/feat-error-box-for-engine-errors
✨ Error box UI to show which engines failed with several UI improvements
This commit is contained in:
commit
7f371bf91b
1
public/images/info.svg
Normal file
1
public/images/info.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#000000" data-darkreader-inline-color="" style="--darkreader-inline-color: #e8e6e3;"><path d="M12 11.5v5M12 7.51l.01-.011M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z" stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #000000;"></path></svg>
|
After Width: | Height: | Size: 532 B |
BIN
public/images/no_results.gif
Normal file
BIN
public/images/no_results.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 233 KiB |
1
public/images/warning.svg
Normal file
1
public/images/warning.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#000000" data-darkreader-inline-color="" style="--darkreader-inline-color: #e8e6e3;"><path d="M20.043 21H3.957c-1.538 0-2.5-1.664-1.734-2.997l8.043-13.988c.77-1.337 2.699-1.337 3.468 0l8.043 13.988C22.543 19.336 21.58 21 20.043 21zM12 9v4" stroke="#000000" stroke-width="1.5" stroke-linecap="round" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #000000;"></path><path d="M12 17.01l.01-.011" stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #000000;"></path></svg>
|
After Width: | Height: | Size: 750 B |
7
public/static/error_box.js
Normal file
7
public/static/error_box.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* This function provides the ability for the button to toggle the dropdown error-box
|
||||||
|
* in the search page.
|
||||||
|
*/
|
||||||
|
function toggleErrorBox() {
|
||||||
|
document.querySelector('.dropdown_error_box').classList.toggle('show')
|
||||||
|
}
|
@ -70,15 +70,90 @@ body {
|
|||||||
filter: brightness(1.2);
|
filter: brightness(1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.result_not_found {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: var(--foreground-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.result_not_found p {
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result_not_found ul {
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result_not_found img {
|
||||||
|
width: 40rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* styles for the error box */
|
||||||
|
.error_box .error_box_toggle_button {
|
||||||
|
background: var(--foreground-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error_box .dropdown_error_box {
|
||||||
|
position: absolute;
|
||||||
|
display: none;
|
||||||
|
flex-direction: column;
|
||||||
|
background: var(--background-color);
|
||||||
|
border-radius: 0;
|
||||||
|
margin-left: 2rem;
|
||||||
|
min-height: 20rem;
|
||||||
|
min-width: 22rem;
|
||||||
|
}
|
||||||
|
.error_box .dropdown_error_box.show {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.error_box .dropdown_error_box .error_item,
|
||||||
|
.error_box .dropdown_error_box .no_errors {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
color: var(--foreground-color);
|
||||||
|
letter-spacing: 0.1rem;
|
||||||
|
padding: 1rem;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
.error_box .dropdown_error_box .error_item {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.error_box .dropdown_error_box .no_errors {
|
||||||
|
min-height: 18rem;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error_box .dropdown_error_box .error_item:hover {
|
||||||
|
box-shadow: inset 0 0 100px 100px rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error_box .error_item .severity_color {
|
||||||
|
width: 1.2rem;
|
||||||
|
height: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
/* styles for the footer and header */
|
/* styles for the footer and header */
|
||||||
|
|
||||||
header {
|
header,
|
||||||
background: var(--background-color);
|
footer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
background: var(--background-color);
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: right;
|
|
||||||
align-items: center;
|
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
header h1 a {
|
||||||
|
text-transform: capitalize;
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--foreground-color);
|
||||||
|
letter-spacing: 0.1rem;
|
||||||
|
margin-left: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
header ul,
|
header ul,
|
||||||
@ -121,13 +196,8 @@ footer div {
|
|||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
background: var(--background-color);
|
|
||||||
width: 100%;
|
|
||||||
padding: 1rem;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Styles for the search page */
|
/* Styles for the search page */
|
||||||
|
3
public/templates/bar.html
Normal file
3
public/templates/bar.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<div class="search_bar">
|
||||||
|
<input type="search" name="search-box" value="{{this.pageQuery}}" placeholder="Type to search" />
|
||||||
|
<button type="submit" onclick="searchWeb()">search</button>
|
@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
@ -10,5 +10,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="getClientSettings()">
|
<body onload="getClientSettings()">
|
||||||
<header>{{>navbar}}</header>
|
<header>
|
||||||
|
<h1><a href="/">Websurfx</a></h1>
|
||||||
|
{{>navbar}}
|
||||||
|
</header>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
{{>header this}}
|
{{>header this}}
|
||||||
<main class="search-container">
|
<main class="search-container">
|
||||||
<img src="../images/websurfx_logo.png" alt="Websurfx meta-search engine logo" />
|
<img src="../images/websurfx_logo.png" alt="Websurfx meta-search engine logo" />
|
||||||
{{>search_bar}}
|
{{>bar}}
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<script src="static/index.js"></script>
|
<script src="static/index.js"></script>
|
||||||
{{>footer}}
|
{{>footer}}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{{>header this.style}}
|
{{>header this.style}}
|
||||||
<main class="results">
|
<main class="results">
|
||||||
{{>search_bar}}
|
{{>search_bar this}}
|
||||||
<div class="results_aggregated">
|
<div class="results_aggregated">
|
||||||
{{#each results}}
|
{{#if results}} {{#each results}}
|
||||||
<div class="result">
|
<div class="result">
|
||||||
<h1><a href="{{{this.url}}}">{{{this.title}}}</a></h1>
|
<h1><a href="{{{this.url}}}">{{{this.title}}}</a></h1>
|
||||||
<small>{{{this.url}}}</small>
|
<small>{{{this.url}}}</small>
|
||||||
@ -13,13 +13,27 @@
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}} {{else}}
|
||||||
|
<div class="result_not_found">
|
||||||
|
<p>Your search - {{{this.pageQuery}}} - did not match any documents.</p>
|
||||||
|
<p class="suggestions">Suggestions:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Make sure that all words are spelled correctly.</li>
|
||||||
|
<li>Try different keywords.</li>
|
||||||
|
<li>Try more general keywords.</li>
|
||||||
|
</ul>
|
||||||
|
<img src="./images/no_results.gif" alt="Man fishing gif" />
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="page_navigation">
|
<div class="page_navigation">
|
||||||
<button type="button" onclick="navigate_backward()">← previous</button>
|
<button type="button" onclick="navigate_backward()">
|
||||||
|
← previous
|
||||||
|
</button>
|
||||||
<button type="button" onclick="navigate_forward()">next →</button>
|
<button type="button" onclick="navigate_forward()">next →</button>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<script src="static/index.js"></script>
|
<script src="static/index.js"></script>
|
||||||
<script src="static/pagination.js"></script>
|
<script src="static/pagination.js"></script>
|
||||||
|
<script src="static/error_box.js"></script>
|
||||||
{{>footer}}
|
{{>footer}}
|
||||||
|
@ -1,9 +1,27 @@
|
|||||||
<div class="search_bar">
|
{{>bar this}}
|
||||||
<input
|
<div class="error_box">
|
||||||
type="search"
|
{{#if engineErrorsInfo}}
|
||||||
name="search-box"
|
<button onclick="toggleErrorBox()" class="error_box_toggle_button">
|
||||||
value="{{this.pageQuery}}"
|
<img src="./images/warning.svg" alt="Info icon for error box" />
|
||||||
placeholder="Type to search"
|
</button>
|
||||||
/>
|
<div class="dropdown_error_box">
|
||||||
<button type="submit" onclick="searchWeb()">search</button>
|
{{#each engineErrorsInfo}}
|
||||||
|
<div class="error_item">
|
||||||
|
<span class="engine_name">{{{this.engine}}}</span>
|
||||||
|
<span class="engine_name">{{{this.error}}}</span>
|
||||||
|
<span class="severity_color" style="background: {{{this.severity_color}}};"></span>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<button onclick="toggleErrorBox()" class="error_box_toggle_button">
|
||||||
|
<img src="./images/info.svg" alt="Warning icon for error box" />
|
||||||
|
</button>
|
||||||
|
<div class="dropdown_error_box">
|
||||||
|
<div class="no_errors">
|
||||||
|
Everything looks good 🙂!!
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -63,10 +63,12 @@ impl SearchResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct EngineErrorInfo {
|
pub struct EngineErrorInfo {
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub engine: String,
|
pub engine: String,
|
||||||
|
pub severity_color: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EngineErrorInfo {
|
impl EngineErrorInfo {
|
||||||
@ -78,6 +80,11 @@ impl EngineErrorInfo {
|
|||||||
EngineError::UnexpectedError => String::from("UnexpectedError"),
|
EngineError::UnexpectedError => String::from("UnexpectedError"),
|
||||||
},
|
},
|
||||||
engine,
|
engine,
|
||||||
|
severity_color: match error {
|
||||||
|
EngineError::RequestError => String::from("green"),
|
||||||
|
EngineError::EmptyResultSet => String::from("blue"),
|
||||||
|
EngineError::UnexpectedError => String::from("red"),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user