refactored approach

This commit is contained in:
Peter Olu 2022-05-21 19:37:50 +01:00
parent 8f9801daa6
commit f27c5d8b34

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="flex-h log-wrapper"> <div class="flex-h log-wrapper">
<div v-if="currentSearchTerm==='column'" class="flex-h items-center mr-5"> <div v-if="currentSearchTerm === 'column'" class="flex-h items-center mr-5">
<p style="margin-right: 10px">Select visible columns</p> <p style="margin-right: 10px">Select visible columns</p>
<el-select <el-select
v-model="selectedColumns" v-model="selectedColumns"
@ -26,41 +26,42 @@ limitations under the License. -->
style="width: 240px" style="width: 240px"
size="small" size="small"
> >
<!-- <el-option @click="() =>{}" value="">Reset</el-option> -->
<el-option <el-option
v-for="item in logStore.serviceLogColumn" v-for="item in logStore.serviceLogColumn"
: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> <div class="flex-h items-center">
<Icon v-if="item.isVisible" iconSize="sm" iconName="cancel" /> <span class="mr-5">{{ item.value }}</span>
<Icon v-else iconSize="sm" iconName="add" /> <div
style="justify-content: space-between"
class="flex-h items-center"
>
<el-tooltip
class="box-item"
effect="dark"
:content="item.isVisible ? 'Hide column' : 'Show Column'"
placement="right-start"
>
<el-button
v-if="item.isVisible"
class="toggle-btn mx-3"
@click="hideColumns(item)"
>
<Icon iconSize="sm" iconName="cancel" />
</el-button>
<el-button v-else class="toggle-btn mx-3" @click="showColumns(item)">
<Icon iconSize="sm" iconName="add" />
</el-button>
</el-tooltip>
</div>
</div>
</el-option> </el-option>
</el-select> </el-select>
<div class="flex-h items-center" v-if="selectedColumns.length"> <el-button class="toggle-btn mx-3danger" @click="setSearchTerm('')">
<el-tooltip <Icon iconSize="sm" iconName="cancel" />
class="box-item" </el-button>
effect="dark"
content="Add selected columns"
placement="bottom-start"
>
<el-button class="toggle-btn mx-3" @click="showColumns">
<Icon iconSize="sm" iconName="save" />
</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="hideColumns">
<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">
@ -365,26 +366,28 @@ onMounted(() => {
"time", "time",
"contentType", "contentType",
"tags", "tags",
"traceID"]) "traceID",
]);
} }
});
})
init(); init();
function toggleColumSelector() { function toggleColumSelector() {
showColumList.value = !showColumList.value; showColumList.value = !showColumList.value;
setSearchTerm("column"); setSearchTerm("column");
} }
function hideColumns() { function hideColumns(column: any) {
selectedColumns.value.push(column.value);
logStore.hideColumns(selectedColumns.value); logStore.hideColumns(selectedColumns.value);
selectedColumns.value = []; selectedColumns.value = [];
toggleColumSelector(); // toggleColumSelector();
setSearchTerm(""); // setSearchTerm("");
} }
function showColumns() { function showColumns(column: any) {
selectedColumns.value.push(column.value);
logStore.showColumns(selectedColumns.value); logStore.showColumns(selectedColumns.value);
selectedColumns.value = []; selectedColumns.value = [];
toggleColumSelector(); // toggleColumSelector();
setSearchTerm(""); // setSearchTerm("");
} }
async function init() { async function init() {
const resp = await logStore.getLogsByKeywords(); const resp = await logStore.getLogsByKeywords();
@ -712,4 +715,7 @@ watch(
.items-center { .items-center {
align-items: center; align-items: center;
} }
.space-between {
justify-content: space-between !important;
}
</style> </style>