Spaces:
Runtime error
Runtime error
neon_arch
commited on
Commit
•
c4935f2
1
Parent(s):
9fd8275
✨ feat: add images, error_box & new message when no results are provided (#185)
Browse files- public/images/info.svg +1 -0
- public/images/no_results.gif +0 -0
- public/images/warning.svg +1 -0
- public/static/error_box.js +3 -0
- public/static/themes/simple.css +21 -0
- public/templates/search.html +18 -4
- public/templates/search_bar.html +16 -0
- src/results/aggregation_models.rs +7 -0
public/images/info.svg
ADDED
public/images/no_results.gif
ADDED
public/images/warning.svg
ADDED
public/static/error_box.js
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
function toggleErrorBox() {
|
2 |
+
|
3 |
+
}
|
public/static/themes/simple.css
CHANGED
@@ -70,6 +70,27 @@ body {
|
|
70 |
filter: brightness(1.2);
|
71 |
}
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
/* styles for the footer and header */
|
74 |
|
75 |
header {
|
|
|
70 |
filter: brightness(1.2);
|
71 |
}
|
72 |
|
73 |
+
.result_not_found {
|
74 |
+
display: flex;
|
75 |
+
flex-direction: column;
|
76 |
+
font-size: 1.5rem;
|
77 |
+
color: var(--foreground-color);
|
78 |
+
}
|
79 |
+
|
80 |
+
.result_not_found p {
|
81 |
+
margin: 1rem 0;
|
82 |
+
}
|
83 |
+
|
84 |
+
.result_not_found ul {
|
85 |
+
margin: 1rem 0;
|
86 |
+
}
|
87 |
+
|
88 |
+
.result_not_found img {
|
89 |
+
width: 40rem;
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
/* styles for the footer and header */
|
95 |
|
96 |
header {
|
public/templates/search.html
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{{>header this.style}}
|
2 |
<main class="results">
|
3 |
-
{{>search_bar}}
|
4 |
<div class="results_aggregated">
|
5 |
-
{{#each results}}
|
6 |
<div class="result">
|
7 |
<h1><a href="{{{this.visitingUrl}}}">{{{this.title}}}</a></h1>
|
8 |
<small>{{{this.url}}}</small>
|
@@ -13,13 +13,27 @@
|
|
13 |
{{/each}}
|
14 |
</div>
|
15 |
</div>
|
16 |
-
{{/each}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
</div>
|
18 |
<div class="page_navigation">
|
19 |
-
<button type="button" onclick="navigate_backward()"
|
|
|
|
|
20 |
<button type="button" onclick="navigate_forward()">next →</button>
|
21 |
</div>
|
22 |
</main>
|
23 |
<script src="static/index.js"></script>
|
24 |
<script src="static/pagination.js"></script>
|
|
|
25 |
{{>footer}}
|
|
|
1 |
{{>header this.style}}
|
2 |
<main class="results">
|
3 |
+
{{>search_bar this}}
|
4 |
<div class="results_aggregated">
|
5 |
+
{{#if results}} {{#each results}}
|
6 |
<div class="result">
|
7 |
<h1><a href="{{{this.visitingUrl}}}">{{{this.title}}}</a></h1>
|
8 |
<small>{{{this.url}}}</small>
|
|
|
13 |
{{/each}}
|
14 |
</div>
|
15 |
</div>
|
16 |
+
{{/each}} {{else}}
|
17 |
+
<div class="result_not_found">
|
18 |
+
<p>Your search - {{{this.pageQuery}}} - did not match any documents.</p>
|
19 |
+
<p class="suggestions">Suggestions:</p>
|
20 |
+
<ul>
|
21 |
+
<li>Make sure that all words are spelled correctly.</li>
|
22 |
+
<li>Try different keywords.</li>
|
23 |
+
<li>Try more general keywords.</li>
|
24 |
+
</ul>
|
25 |
+
<img src="./images/no_results.gif" alt="Man fishing gif" />
|
26 |
+
</div>
|
27 |
+
{{/if}}
|
28 |
</div>
|
29 |
<div class="page_navigation">
|
30 |
+
<button type="button" onclick="navigate_backward()">
|
31 |
+
← previous
|
32 |
+
</button>
|
33 |
<button type="button" onclick="navigate_forward()">next →</button>
|
34 |
</div>
|
35 |
</main>
|
36 |
<script src="static/index.js"></script>
|
37 |
<script src="static/pagination.js"></script>
|
38 |
+
<script src="static/error_box.js"></script>
|
39 |
{{>footer}}
|
public/templates/search_bar.html
CHANGED
@@ -6,4 +6,20 @@
|
|
6 |
placeholder="Type to search"
|
7 |
/>
|
8 |
<button type="submit" onclick="searchWeb()">search</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
</div>
|
|
|
6 |
placeholder="Type to search"
|
7 |
/>
|
8 |
<button type="submit" onclick="searchWeb()">search</button>
|
9 |
+
<div class="error_box">
|
10 |
+
<button onclick="toggleErrorBox()" class="error_box_dropdown">
|
11 |
+
<img src="./images/info.svg" alt="Info icon for error box" />
|
12 |
+
</button>
|
13 |
+
{{#each engineErrorsInfo}}
|
14 |
+
<div class="error_item">
|
15 |
+
<span class="engine_name">{{{this.engine}}}</span>
|
16 |
+
<span class="engine_name">{{{this.error}}}</span>
|
17 |
+
<span
|
18 |
+
class="severity_color"
|
19 |
+
style="background: {{{this.severity_color}}}; width: 400px; height: 400px"
|
20 |
+
>lsl</span
|
21 |
+
>
|
22 |
+
</div>
|
23 |
+
{{/each}}
|
24 |
+
</div>
|
25 |
</div>
|
src/results/aggregation_models.rs
CHANGED
@@ -116,10 +116,12 @@ impl RawSearchResult {
|
|
116 |
}
|
117 |
}
|
118 |
|
|
|
119 |
#[derive(Serialize, Deserialize)]
|
120 |
pub struct EngineErrorInfo {
|
121 |
pub error: String,
|
122 |
pub engine: String,
|
|
|
123 |
}
|
124 |
|
125 |
impl EngineErrorInfo {
|
@@ -131,6 +133,11 @@ impl EngineErrorInfo {
|
|
131 |
EngineError::UnexpectedError => String::from("UnexpectedError"),
|
132 |
},
|
133 |
engine,
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
}
|
136 |
}
|
|
|
116 |
}
|
117 |
}
|
118 |
|
119 |
+
///
|
120 |
#[derive(Serialize, Deserialize)]
|
121 |
pub struct EngineErrorInfo {
|
122 |
pub error: String,
|
123 |
pub engine: String,
|
124 |
+
pub severity_color: String,
|
125 |
}
|
126 |
|
127 |
impl EngineErrorInfo {
|
|
|
133 |
EngineError::UnexpectedError => String::from("UnexpectedError"),
|
134 |
},
|
135 |
engine,
|
136 |
+
severity_color: match error {
|
137 |
+
EngineError::RequestError => String::from("green"),
|
138 |
+
EngineError::EmptyResultSet => String::from("blue"),
|
139 |
+
EngineError::UnexpectedError => String::from("red"),
|
140 |
+
},
|
141 |
}
|
142 |
}
|
143 |
}
|