can hide columns from selected input

This commit is contained in:
Peter Olu 2022-05-21 15:00:47 +01:00
parent bcf15a6274
commit 9d3c417a49
3 changed files with 41 additions and 10 deletions

View File

@ -1,4 +1,3 @@
import { serviceLogColumn } from '@/types/log-column';
/** /**
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -63,10 +62,9 @@ export const logStore = defineStore({
}), }),
actions: { actions: {
hideColumns(columnsLabel: string[]) { hideColumns(columnsLabel: string[]) {
console.log(columnsLabel, this.serviceLogColumn)
// TODO: add a parameter column type too // TODO: add a parameter column type too
this.serviceLogColumn.map((col: any) => { this.serviceLogColumn.forEach((col: any) => {
if (columnsLabel.includes(col.label)) { if (columnsLabel.includes(col.value)) {
col.isVisible = false col.isVisible = false
} }
}) })

View File

@ -91,7 +91,11 @@ const showDetail = ref<boolean>(false);
const dragger = ref<Nullable<HTMLSpanElement>>(null); const dragger = ref<Nullable<HTMLSpanElement>>(null);
// const method = ref<number>(380); // const method = ref<number>(380);
// props.type === "browser" ? BrowserLogConstants : ServiceLogConstants; // props.type === "browser" ? BrowserLogConstants : ServiceLogConstants;
const columns = ref<any[]> (useLogStore.serviceLogColumn); const columns = ref<any[]>(
props.type === "browser"
? useLogStore.browserLogColumn
: useLogStore.serviceLogColumn
);
// const portalVisibleDefaultCols:string[] = ['Service', 'Instance','Content'] // const portalVisibleDefaultCols:string[] = ['Service', 'Instance','Content']
const visibleColumns = computed(() => const visibleColumns = computed(() =>

View File

@ -15,7 +15,7 @@ limitations under the License. -->
<template> <template>
<div class="flex-h log-wrapper"> <div class="flex-h log-wrapper">
<div class="flex-h items-center mr-5"> <div class="flex-h items-center mr-5">
<p style="margin-left: 10px">Select visible columns</p> <p style="margin-right: 10px">Select visible columns</p>
<el-select <el-select
v-model="selectedColumns" v-model="selectedColumns"
multiple multiple
@ -29,11 +29,36 @@ limitations under the License. -->
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
/> >
<span class="mr-5">{{ item.value }}</span>
<Icon v-if="item.isVisible" iconSize="sm" iconName="cancel" />
<Icon v-else iconSize="sm" iconName="add" />
</el-option>
</el-select> </el-select>
<div class="flex-h items-center" v-if="selectedColumns.length">
<el-tooltip
class="box-item"
effect="dark"
content="Add selected columns"
placement="bottom-start"
>
<el-button class="toggle-btn mx-3" @click="setVisbleColumn"> <el-button class="toggle-btn mx-3" @click="setVisbleColumn">
<Icon iconSize="sm" iconName="timeline" /> <Icon iconSize="sm" iconName="save" />
</el-button> </el-button>
</el-tooltip>
<el-tooltip
class="box-item"
effect="dark"
content="Remove selected columns"
placement="bottom-start"
>
<el-button class="toggle-btn mx-3" @click="hideColumn">
<Icon iconSize="sm" iconName="cancel" />
</el-button>
</el-tooltip>
</div>
</div> </div>
<div v-if="!currentSearchTerm.length" class="flex-h items-center"> <div v-if="!currentSearchTerm.length" class="flex-h items-center">
<div v-for="(item, index) in arrayOfFilters" :key="index"> <div v-for="(item, index) in arrayOfFilters" :key="index">
@ -316,6 +341,10 @@ function setVisbleColumn() {
}); });
console.log(cols, [...logStore.serviceLogColumn]); console.log(cols, [...logStore.serviceLogColumn]);
} }
function hideColumn() {
logStore.hideColumns(selectedColumns.value)
selectedColumns.value = []
}
async function init() { async function init() {
const resp = await logStore.getLogsByKeywords(); const resp = await logStore.getLogsByKeywords();