implemeted functionlaity to empty taglist internally on cancel

This commit is contained in:
Peter Olu 2022-05-12 10:17:09 +01:00
parent 4645d000d4
commit 91a0c2979b
2 changed files with 25 additions and 8 deletions

View File

@ -16,10 +16,7 @@ limitations under the License. -->
<div class="flex-h" :class="{ light: theme === 'light' }"> <div class="flex-h" :class="{ light: theme === 'light' }">
<div class="flex-h items-center mr-5"> <div class="flex-h items-center mr-5">
<span class="sm grey" v-show="theme === 'dark'">{{ t("tags") }}: </span> <span class="sm grey" v-show="theme === 'dark'">{{ t("tags") }}: </span>
<span <span v-if="tagsList.length" class="trace-tags">
v-if="tagsList.length"
class="trace-tags"
>
<!-- :style="type === 'LOG' ? `min-width: 122px;` : ''" --> <!-- :style="type === 'LOG' ? `min-width: 122px;` : ''" -->
<span class="selected" v-for="(item, index) in tagsList" :key="index"> <span class="selected" v-for="(item, index) in tagsList" :key="index">
<span>{{ item }}</span> <span>{{ item }}</span>
@ -62,11 +59,12 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from "vue"; import { ref, defineExpose } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
/*global defineEmits, defineProps */ /*global defineEmits, defineProps */
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
defineProps({ defineProps({
type: { type: String, default: "TRACE" }, type: { type: String, default: "TRACE" },
}); });
@ -75,6 +73,13 @@ const theme = ref<string>("dark");
const tags = ref<string>(""); const tags = ref<string>("");
const tagsList = ref<string[]>([]); const tagsList = ref<string[]>([]);
defineExpose({
tagsList,
emptyTags
})
function emptyTags (){
tagsList.value = []
}
function removeTags(index: number) { function removeTags(index: number) {
tagsList.value.splice(index, 1); tagsList.value.splice(index, 1);
updateTags(); updateTags();
@ -99,7 +104,7 @@ function updateTags() {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.items-center{ .items-center {
align-items: center; align-items: center;
} }
.trace-tags { .trace-tags {

View File

@ -61,7 +61,13 @@ limitations under the License. -->
@change="changeField('instance', $event)" @change="changeField('instance', $event)"
/> />
</div> </div>
<div class="filter" v-if="dashboardStore.entity !== EntityType[2].value && activeFilter === 'endpoints'"> <div
class="filter"
v-if="
dashboardStore.entity !== EntityType[2].value &&
activeFilter === 'endpoints'
"
>
<span class="grey mr-5">{{ t("endpoint") }}:</span> <span class="grey mr-5">{{ t("endpoint") }}:</span>
<Selector <Selector
size="small" size="small"
@ -93,10 +99,11 @@ limitations under the License. -->
<el-input size="small" class="inputs mr-5" v-model="minTraceDuration" /> <el-input size="small" class="inputs mr-5" v-model="minTraceDuration" />
<span class="grey mr-5">-</span> <span class="grey mr-5">-</span>
<el-input size="small" class="inputs" v-model="maxTraceDuration" /> <el-input size="small" class="inputs" v-model="maxTraceDuration" />
</div> </div>
<keep-alive> <keep-alive>
<ConditionTags <ConditionTags
v-if="activeFilter === 'tags'" v-if="activeFilter === 'tags'"
ref="tagComponent"
:type="'TRACE'" :type="'TRACE'"
@update="updateTags" @update="updateTags"
/> />
@ -202,6 +209,8 @@ const state = reactive<any>({
service: { value: "", label: "" }, service: { value: "", label: "" },
}); });
const tagComponent = ref<InstanceType<typeof ConditionTags> | null>(null)
// const dateTime = computed(() => [ // const dateTime = computed(() => [
// appStore.durationRow.start, // appStore.durationRow.start,
// appStore.durationRow.end, // appStore.durationRow.end,
@ -272,6 +281,8 @@ function cancelSearch() {
case "tags": case "tags":
tagsList.value = []; tagsList.value = [];
tagsMap.value = []; tagsMap.value = [];
updateTags({ tagsMap: [], tagsList: [] });
tagComponent.value?.emptyTags()
break; break;
case "traceId": case "traceId":
traceId.value = ""; traceId.value = "";
@ -353,6 +364,7 @@ function changeField(type: string, opt: any) {
} }
} }
function updateTags(data: { tagsMap: Array<Option>; tagsList: string[] }) { function updateTags(data: { tagsMap: Array<Option>; tagsList: string[] }) {
console.log(data, tagComponent.value)
tagsList.value = data.tagsList; tagsList.value = data.tagsList;
tagsMap.value = data.tagsMap; tagsMap.value = data.tagsMap;
} }