refactored logs header search terms logic and the handling of active buttons

This commit is contained in:
Peter Olu 2022-05-12 07:56:57 +01:00
parent aa7485391b
commit 59a9bc15ea
2 changed files with 41 additions and 13 deletions

View File

@ -108,12 +108,13 @@ limitations under the License. -->
<el-input v-model="traceId" class="inputs-max" size="small" /> <el-input v-model="traceId" class="inputs-max" size="small" />
</div> </div>
</div> </div>
<keep-alive>
<ConditionTags <ConditionTags
v-if="currentSearchTerm === 'tags'" v-if="currentSearchTerm === 'tags'"
:type="'LOG'" :type="'LOG'"
@update="updateTags" @update="updateTags"
/> />
</keep-alive>
</div> </div>
<div class="flex-h items-center" v-show="!isBrowser"> <div class="flex-h items-center" v-show="!isBrowser">
@ -348,8 +349,37 @@ function removeFromActiveTerms() {
(term) => term !== currentSearchTerm.value (term) => term !== currentSearchTerm.value
); );
} }
function searchLogs() { function handleActiveSearchTerms() {
switch (currentSearchTerm.value) {
case "traceId":
if (!traceId.value.length) return;
addToActiveTerms(); addToActiveTerms();
break;
case "tags":
if (!tagsList.value.length) return;
addToActiveTerms();
break;
case "keywords":
if (!keywordsOfContent.value.length) return;
addToActiveTerms();
break;
case "exclude":
if (!excludingKeywordsOfContent.value.length) return;
addToActiveTerms();
break;
case "instance":
addToActiveTerms();
break;
case "service":
addToActiveTerms();
break;
case "endpoint":
addToActiveTerms();
break;
}
}
function searchLogs() {
handleActiveSearchTerms();
currentSearchTerm.value = ""; currentSearchTerm.value = "";
let endpoint = "", let endpoint = "",
instance = ""; instance = "";
@ -434,9 +464,7 @@ function removeExcludeContent(index: number) {
excludingContentStr.value = ""; excludingContentStr.value = "";
} }
function setSearchTerm(term: string) { function setSearchTerm(term: string) {
// if (!term) return;
currentSearchTerm.value = term; currentSearchTerm.value = term;
console.log(currentSearchTerm.value);
} }
function cancelSearchTerm() { function cancelSearchTerm() {
switch (currentSearchTerm.value) { switch (currentSearchTerm.value) {
@ -465,7 +493,7 @@ function cancelSearchTerm() {
} }
removeFromActiveTerms(); removeFromActiveTerms();
currentSearchTerm.value = ""; currentSearchTerm.value = "";
init() init();
} }
watch( watch(
() => selectorStore.currentService, () => selectorStore.currentService,