* Add service_log indexer file (ee) * Rename to completed_run * rename to service_logs * Update lib.rs * Make indexing of logs and simple frontend * Add common ee file * Update lib.rs * Make log search global to fix openapi unused path param * Prepare sqlx * Show last indexed also when no jobs are found * Adapt feature flags to service logs indexer * Update api and main * Build service log search page * scope query to the min and max time * Migrate modal, bug fixes * Remove unused import * Make the service logs page take the full screen * improve quick access menu to service_logs, fix date stuff, hide 0 matches --------- Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
39 lines
1.0 KiB
Svelte
39 lines
1.0 KiB
Svelte
<script lang="ts">
|
|
import AnsiUp from 'ansi_up'
|
|
|
|
export let content: string
|
|
export let highlighted: any[]
|
|
|
|
const ansi_up = new AnsiUp()
|
|
ansi_up.use_classes = true
|
|
|
|
function highlightSnippet(snippet: string) {
|
|
const opener = '!-!-!_H_START_WMILL_!-!-!'
|
|
const closer = '!-!-!_H_ENDER_WMILL_!-!-!'
|
|
|
|
let offset = 0
|
|
let ret = snippet
|
|
for (const range of highlighted) {
|
|
ret = ret.slice(0, range.start + offset) + opener + ret.slice(range.start + offset)
|
|
offset += opener.length
|
|
ret = ret.slice(0, range.end + offset) + closer + ret.slice(range.end + offset)
|
|
offset += closer.length
|
|
}
|
|
|
|
let html = ansi_up.ansi_to_html(ret)
|
|
let html2 = html
|
|
.replaceAll(opener, '<span class="bg-amber-400 text-black">')
|
|
.replaceAll(closer, '</span>')
|
|
return html2
|
|
}
|
|
|
|
let html = highlightSnippet(content)
|
|
</script>
|
|
|
|
<button on:click class="font-light !m-0 !p-0">
|
|
<pre
|
|
class="bg-surface-secondary hover:bg-surface px-2 py-1 text-secondary text-xs w-[100%] whitespace-pre border min-w-full text-start" >
|
|
{@html html}
|
|
</pre>
|
|
</button>
|