Skip to content

Commit c9dcaf7

Browse files
author
Piotr
committed
issue #57 fixed (searchbar crash)
1 parent 9f6ed13 commit c9dcaf7

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/App.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,9 @@ const updateSampleLine = () => {
592592
</div>
593593
<div class="right">
594594
<input type="text" class="searchbar" v-model="store.searchbar" placeholder="Search logs..." />
595+
<br />
596+
<span class="search-error" v-if="store.searchbarValid.length > 0">Invalid search query: {{ store.searchbarValid
597+
}}</span>
595598
</div>
596599
<div class="end">
597600
<TopBar />

src/app.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@
5656
-ms-box-sizing: border-box;
5757
box-sizing: border-box;
5858
}
59+
60+
.search-error {
61+
font-family: 'Roboto mono', sans-serif;
62+
font-size: 12px;
63+
padding: 5px;
64+
background: var(--hl-bg);
65+
margin-left:10px;
66+
-webkit-box-sizing: border-box;
67+
-moz-box-sizing: border-box;
68+
-o-box-sizing: border-box;
69+
-ms-box-sizing: border-box;
70+
box-sizing: border-box;
71+
}
5972
}
6073

6174
.end {

src/store.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,21 @@ export const useMainStore = defineStore("main", () => {
252252
}
253253
}
254254

255+
const searchbarValid = computed(() => {
256+
try {
257+
new RegExp(searchbar.value, 'i')
258+
return ''
259+
} catch (e) {
260+
return (e as any).message
261+
}
262+
})
263+
255264
const displayRows = computed(() => {
265+
266+
if (searchbarValid.value.length > 0) {
267+
return []
268+
}
269+
256270
const selectedFacets: Record<string, string[]> = {}
257271
for (let i in facets.value) {
258272
facets.value[i].items.forEach(el => {
@@ -312,7 +326,6 @@ export const useMainStore = defineStore("main", () => {
312326
if (searchbar.value.length < 3) {
313327
return true
314328
}
315-
316329
return (r.msg.content || "").search(new RegExp(searchbar.value, 'i')) >= 0
317330
})
318331
})
@@ -365,6 +378,7 @@ export const useMainStore = defineStore("main", () => {
365378

366379
facets,
367380
searchbar,
381+
searchbarValid,
368382

369383
toggleRowMark
370384
};

src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ export function formatThousands(x: number): string {
44

55
export function getUrlParam(url: string, param: string): string | null {
66
let params = new URLSearchParams(url)
7-
console.log(params, url)
87
return params.get(param)
98
}

0 commit comments

Comments
 (0)