Skip to content

Commit

Permalink
init loader for logs search
Browse files Browse the repository at this point in the history
  • Loading branch information
LbP22 committed May 2, 2024
1 parent 06c0486 commit 8db1975
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 10 deletions.
1 change: 1 addition & 0 deletions application/frontend/src/Stores/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const urlHash = writable("");
//cancel fetch (for bed connection)

export const isFeatching = writable(false);
export const isSearching = writable(false);

//status for serching logs by status

Expand Down
56 changes: 56 additions & 0 deletions application/frontend/src/Views/Logs/Loader.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<span class="loader"></span>

<style>
.loader {
width: 16px;
height: 16px;
position: relative;
left: -32px;
border-radius: 50%;
color: #fff;
background: currentColor;
box-shadow: 32px 0 , -32px 0 , 64px 0;
}
.loader::after {
content: '';
position: absolute;
left: -32px;
top: 0;
width: 16px;
height: 16px;
border-radius: 10px;
background: #c244db;
animation: move 3s linear infinite alternate;
}
@keyframes move {
0% , 5%{
left: -32px;
width: 16px;
}
15% , 20%{
left: -32px;
width: 48px;
}
30% , 35%{
left: 0px;
width: 16px;
}
45% , 50%{
left: 0px;
width: 48px;
}
60% , 65%{
left: 32px;
width: 16px;
}
75% , 80% {
left: 32px;
width: 48px;
}
95%, 100% {
left: 64px;
width: 16px;
}
}
</style>
34 changes: 24 additions & 10 deletions application/frontend/src/Views/Logs/NewLogsV2.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import LogsViewHeder from "./LogsViewHeder/LogsViewHeder.svelte";
import IntersectionObserver from "svelte-intersection-observer";
import Spiner from "./Spiner.svelte";
import Loader from "./Loader.svelte";
import LogStringHeader from "./LogStringHeader.svelte";
import { fade } from "svelte/transition";
import { handleKeydown, copyCustomText } from "../../utils/functions.js";
Expand All @@ -26,6 +27,7 @@
isPending,
urlHash,
isFeatching,
isSearching,
chosenStatus,
WSisMuted,
manuallyUnmuted,
Expand Down Expand Up @@ -140,6 +142,7 @@
let last_key = "";
let is_all_logs_processed = false;
while (total_logs_amount < limit && !is_all_logs_processed) {
isSearching.set(true);
let data = await api.getLogs({
containerName: $lastChosenService,
hostName: $lastChosenHost,
Expand All @@ -164,6 +167,7 @@
previousLogs = allLogsCopy.splice(0, limit);
}
}
isSearching.set(false);
isPending.set(false);
autoscroll = true;
pauseWS = false;
Expand Down Expand Up @@ -442,15 +446,16 @@
let is_all_logs_processed = false;
let last_key = customStartWith ? customStartWith : customStartWith === 0 ? "" : allLogs.at(0)?.at(0);
while (limit < total_logs_amount && !is_all_logs_processed) {
const data = (await getLogs({
containerName: $lastChosenService,
search: searchText,
limit,
status: $chosenStatus,
caseSens: !$store.caseInSensitive,
startWith: last_key,
hostName: $lastChosenHost,
signal,
isSearching.set(true);
const data = (await getLogs({
containerName: $lastChosenService,
search: searchText,
limit,
status: $chosenStatus,
caseSens: !$store.caseInSensitive,
startWith: last_key,
hostName: $lastChosenHost,
signal,
})).logs.reverse();
total_logs = [...total_logs, ...data];
total_logs_amount += data.length;
Expand Down Expand Up @@ -491,6 +496,7 @@
}
}
isSearching.set(false);
}
lastFetchActionIsFetch = true;
return total_logs;
Expand Down Expand Up @@ -523,6 +529,7 @@
let last_key = customStartWith ? customStartWith : customStartWith === 0 ? "" : allLogs.at(0)?.at(0);
while (limit > total_received_logs_count && !is_all_logs_processed) {
isSearching.set(true);
const data = await getLogs({
containerName: $lastChosenService,
search: searchText,
Expand All @@ -538,6 +545,7 @@
total_received_logs_count += data.logs.length;
total_logs = [...total_logs, ...data.logs.reverse()];
}
isSearching.set(false);
isFeatching.set(false);
if (initialService === $lastChosenService) {
Expand Down Expand Up @@ -567,6 +575,7 @@
let total_received_logs_count = 0;
let is_all_logs_processed = false;
while (total_received_logs_count < limit && !is_all_logs_processed) {
isSearching.set(true);
const data = await getPrevLogs({
containerName: $lastChosenService,
search: searchText,
Expand All @@ -581,6 +590,7 @@
last_key = data.last_processed_key;
total_logs = [...total_logs, ...data.logs];
}
isSearching.set(false);
isFeatching.set(false);
if (initialService === $lastChosenService) {
if (total_logs.length) {
Expand Down Expand Up @@ -772,14 +782,18 @@
<div id="logs" class="logs" bind:this={div}>
<div class="logsTableContainer">
<table class="logsTable {$store.breakLines ? 'breakLines' : ''}">
{#if $isSearching}
<div style="left: 50%; top: 50%; padding-bottom: 10px;" class="flex">
<Loader />
</div>
{/if}
<div id="startOfLogs" />
<IntersectionObserver
element={startOfLogs}
bind:intersecting={startOfLogsIntersect}
>
<div id="startOfLogs" bind:this={startOfLogs} />
</IntersectionObserver>
{#each allLogs as logItem, i}
{#if transformLogStringForTimeBudget(logItem, $store.UTCtime) !== transformLogStringForTimeBudget(allLogs[i - 1], $store.UTCtime) && i - 1 >= 0}
<div class="timeBudgeContainer">
Expand Down

0 comments on commit 8db1975

Please sign in to comment.