toggle trace filters

This commit is contained in:
Peter Olu 2022-05-03 12:12:05 +01:00
parent 7cf5648042
commit b1fd8923ca
3 changed files with 131 additions and 142 deletions

View File

@ -279,6 +279,7 @@ export default defineComponent({
dashboardStore.layout[l].children[activeTabIndex.value].children dashboardStore.layout[l].children[activeTabIndex.value].children
); );
needQuery.value = true; needQuery.value = true;
console.log(dashboardStore.layout[0])
} }
function removeTab(e: Event) { function removeTab(e: Event) {
e.stopPropagation(); e.stopPropagation();

View File

@ -13,112 +13,116 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="dashboard-tool flex-h"> <div class="dashboard-tool">
<div class="flex-h"> <div class="dashboard-tool flex-h">
<div class="selectors-item" v-if="key !== 10"> <div class="flex-h">
<span class="label">$Service</span> <div class="selectors-item" v-if="key !== 10">
<Selector <span class="label">$Service</span>
v-model="states.currentService" <Selector
:options="selectorStore.services" v-model="states.currentService"
size="small" :options="selectorStore.services"
placeholder="Select a service" size="small"
@change="changeService" placeholder="Select a service"
class="selectors" @change="changeService"
/> class="selectors"
/>
</div>
<div class="selectors-item" v-if="key === 3 || key === 4">
<span class="label">
{{
["EndpointRelation", "Endpoint"].includes(dashboardStore.entity)
? "$Endpoint"
: "$ServiceInstance"
}}
</span>
<Selector
v-model="states.currentPod"
:options="selectorStore.pods"
size="small"
placeholder="Select a data"
@change="changePods"
@query="searchPods"
class="selectorPod"
:isRemote="['EndpointRelation', 'Endpoint'].includes(dashboardStore.entity)"
/>
</div>
<div class="selectors-item" v-if="key === 2 || key === 4">
<span class="label">$DestinationService</span>
<Selector
v-model="states.currentDestService"
:options="selectorStore.destServices"
size="small"
placeholder="Select a service"
@change="changeDestService"
class="selectors"
/>
</div>
<div class="selectors-item" v-if="key === 4">
<span class="label">
{{
dashboardStore.entity === "EndpointRelation"
? "$DestinationEndpoint"
: "$DestinationServiceInstance"
}}
</span>
<Selector
v-model="states.currentDestPod"
:options="selectorStore.destPods"
size="small"
placeholder="Select a data"
@change="changeDestPods"
class="selectorPod"
@query="searchDestPods"
:isRemote="dashboardStore.entity === 'EndpointRelation'"
/>
</div>
</div> </div>
<div class="selectors-item" v-if="key === 3 || key === 4"> <div
<span class="label"> class="flex-h tools"
{{ v-loading="loading"
["EndpointRelation", "Endpoint"].includes(dashboardStore.entity) v-if="$route.query['portal'] !== 'true'"
? "$Endpoint" >
: "$ServiceInstance" <div class="tool-icons flex-h" v-if="dashboardStore.editMode">
}} <el-dropdown content="Controls" placement="bottom">
</span> <i>
<Selector <Icon class="icon-btn" size="sm" iconName="control" />
v-model="states.currentPod" </i>
:options="selectorStore.pods" <template #dropdown>
size="small" <el-dropdown-menu>
placeholder="Select a data" <el-dropdown-item
@change="changePods" @click="clickIcons(t)"
@query="searchPods" v-for="(t, index) in toolIcons"
class="selectorPod" :key="index"
:isRemote=" :title="t.content"
['EndpointRelation', 'Endpoint'].includes(dashboardStore.entity) >
" <Icon class="mr-5" size="middle" :iconName="t.name" />
/> <span>{{ t.content }}</span>
</div> </el-dropdown-item>
<div class="selectors-item" v-if="key === 2 || key === 4"> </el-dropdown-menu>
<span class="label">$DestinationService</span> </template>
<Selector </el-dropdown>
v-model="states.currentDestService" <el-tooltip content="Apply" placement="bottom" effect="light">
:options="selectorStore.destServices" <i @click="applyDashboard">
size="small" <Icon class="icon-btn" size="sm" iconName="save" />
placeholder="Select a service" </i>
@change="changeDestService" </el-tooltip>
class="selectors" </div>
/> <div class="switch">
</div> <el-switch
<div class="selectors-item" v-if="key === 4"> v-model="dashboardStore.editMode"
<span class="label"> active-text="Edit"
{{ inactive-text="View"
dashboardStore.entity === "EndpointRelation" size="small"
? "$DestinationEndpoint" inline-prompt
: "$DestinationServiceInstance" active-color="#409eff"
}} inactive-color="#999"
</span> @change="changeMode"
<Selector />
v-model="states.currentDestPod" </div>
:options="selectorStore.destPods"
size="small"
placeholder="Select a data"
@change="changeDestPods"
class="selectorPod"
@query="searchDestPods"
:isRemote="dashboardStore.entity === 'EndpointRelation'"
/>
</div>
</div>
<div class="flex-h tools" v-loading="loading" v-if="$route.query['portal'] !== 'true'">
<div class="tool-icons flex-h" v-if="dashboardStore.editMode">
<el-dropdown content="Controls" placement="bottom">
<i>
<Icon class="icon-btn" size="sm" iconName="control" />
</i>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
@click="clickIcons(t)"
v-for="(t, index) in toolIcons"
:key="index"
:title="t.content"
>
<Icon class="mr-5" size="middle" :iconName="t.name" />
<span>{{ t.content }}</span>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-tooltip content="Apply" placement="bottom" effect="light">
<i @click="applyDashboard">
<Icon class="icon-btn" size="sm" iconName="save" />
</i>
</el-tooltip>
</div>
<div class="switch">
<el-switch
v-model="dashboardStore.editMode"
active-text="Edit"
inactive-text="View"
size="small"
inline-prompt
active-color="#409eff"
inactive-color="#999"
@change="changeMode"
/>
</div> </div>
</div> </div>
<Filter v-if="showFilter" />
</div> </div>
<Filter />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import Filter from "../related/trace/Filter.vue"; import Filter from "../related/trace/Filter.vue";
@ -146,6 +150,10 @@ const dashboardStore = useDashboardStore();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const params = useRoute().params; const params = useRoute().params;
const showFilter = computed(
() => dashboardStore.layout[0].activedTabIndex === 2
);
const { query } = useRoute(); const { query } = useRoute();
dashboardStore.setViewMode(query["fullview"] === "true"); dashboardStore.setViewMode(query["fullview"] === "true");
@ -172,9 +180,7 @@ const states = reactive<{
currentDestPod: "", currentDestPod: "",
}); });
const key = computed(() => { const key = computed(() => {
const type = EntityType.find( const type = EntityType.find((d: Option) => d.value === dashboardStore.entity);
(d: Option) => d.value === dashboardStore.entity
);
return (type && type.key) || 0; return (type && type.key) || 0;
}); });
@ -208,9 +214,7 @@ async function setSelector() {
].includes(String(params.entity)) ].includes(String(params.entity))
) { ) {
setSourceSelector(); setSourceSelector();
if ( if ([EntityType[2].value, EntityType[3].value].includes(String(params.entity))) {
[EntityType[2].value, EntityType[3].value].includes(String(params.entity))
) {
return; return;
} }
setDestSelector(); setDestSelector();
@ -278,11 +282,7 @@ async function setSourceSelector() {
async function setDestSelector() { async function setDestSelector() {
await selectorStore.getService(String(params.destServiceId), true); await selectorStore.getService(String(params.destServiceId), true);
states.currentDestService = selectorStore.currentDestService.value; states.currentDestService = selectorStore.currentDestService.value;
await fetchPods( await fetchPods(String(params.entity), selectorStore.currentDestService.id, false);
String(params.entity),
selectorStore.currentDestService.id,
false
);
if (!(selectorStore.destPods.length && selectorStore.destPods[0])) { if (!(selectorStore.destPods.length && selectorStore.destPods[0])) {
selectorStore.setCurrentDestPod(null); selectorStore.setCurrentDestPod(null);
states.currentDestPod = ""; states.currentDestPod = "";
@ -295,9 +295,7 @@ async function setDestSelector() {
(d: { label: string }) => d.label === states.currentDestPod (d: { label: string }) => d.label === states.currentDestPod
); );
} else { } else {
currentDestPod = selectorStore.destPods.find( currentDestPod = selectorStore.destPods.find((d: { id: string }) => d.id === destPod);
(d: { id: string }) => d.id === destPod
);
} }
if (currentDestPod) { if (currentDestPod) {
selectorStore.setCurrentDestPod(currentDestPod); selectorStore.setCurrentDestPod(currentDestPod);
@ -326,9 +324,7 @@ async function getServices() {
(d: { label: string }) => d.label === states.currentService (d: { label: string }) => d.label === states.currentService
); );
} else { } else {
s = (selectorStore.services || []).find( s = (selectorStore.services || []).find((d: unknown, index: number) => index === 0);
(d: unknown, index: number) => index === 0
);
} }
selectorStore.setCurrentService(s || null); selectorStore.setCurrentService(s || null);
let d; let d;
@ -337,9 +333,7 @@ async function getServices() {
(d: { label: string }) => d.label === states.currentDestService (d: { label: string }) => d.label === states.currentDestService
); );
} else { } else {
d = (selectorStore.services || []).find( d = (selectorStore.services || []).find((d: unknown, index: number) => index === 1);
(d: unknown, index: number) => index === 1
);
} }
selectorStore.setCurrentDestService(d || null); selectorStore.setCurrentDestService(d || null);
if (!selectorStore.currentService) { if (!selectorStore.currentService) {
@ -347,18 +341,14 @@ async function getServices() {
} }
states.currentService = selectorStore.currentService.value; states.currentService = selectorStore.currentService.value;
const e = dashboardStore.entity.split("Relation")[0]; const e = dashboardStore.entity.split("Relation")[0];
if ( if ([EntityType[2].value, EntityType[3].value].includes(dashboardStore.entity)) {
[EntityType[2].value, EntityType[3].value].includes(dashboardStore.entity)
) {
fetchPods(e, selectorStore.currentService.id, true); fetchPods(e, selectorStore.currentService.id, true);
} }
if (!selectorStore.currentDestService) { if (!selectorStore.currentDestService) {
return; return;
} }
states.currentDestService = selectorStore.currentDestService.value; states.currentDestService = selectorStore.currentDestService.value;
if ( if ([EntityType[5].value, EntityType[6].value].includes(dashboardStore.entity)) {
[EntityType[5].value, EntityType[6].value].includes(dashboardStore.entity)
) {
fetchPods(dashboardStore.entity, selectorStore.currentDestService.id, true); fetchPods(dashboardStore.entity, selectorStore.currentDestService.id, true);
} }
} }
@ -413,10 +403,7 @@ async function applyDashboard() {
} }
async function clickIcons(t: { id: string; content: string; name: string }) { async function clickIcons(t: { id: string; content: string; name: string }) {
if ( if (dashboardStore.selectedGrid && dashboardStore.selectedGrid.type === "Tab") {
dashboardStore.selectedGrid &&
dashboardStore.selectedGrid.type === "Tab"
) {
setTabControls(t.id); setTabControls(t.id);
return; return;
} }
@ -504,9 +491,7 @@ async function fetchPods(
(d: { label: unknown }) => d.label === states.currentPod (d: { label: unknown }) => d.label === states.currentPod
); );
} else { } else {
p = selectorStore.pods.find( p = selectorStore.pods.find((d: unknown, index: number) => index === 0);
(d: unknown, index: number) => index === 0
);
} }
selectorStore.setCurrentPod(p || null); selectorStore.setCurrentPod(p || null);
states.currentPod = selectorStore.currentPod.label; states.currentPod = selectorStore.currentPod.label;
@ -614,12 +599,7 @@ function searchDestPods(query: string) {
const param = { const param = {
keyword: query, keyword: query,
}; };
fetchPods( fetchPods(EntityType[6].value, selectorStore.currentDestService.id, false, param);
EntityType[6].value,
selectorStore.currentDestService.id,
false,
param
);
} }
watch( watch(
() => dashboardStore.entity, () => dashboardStore.entity,

View File

@ -14,6 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="flex-h row"> <div class="flex-h row">
<div class="flex-h">
<el-button type="secondary"> Instance </el-button>
<el-button type="secondary"> Status </el-button>
<el-button type="secondary">
<!-- <Icon size="sm" iconName="duration" /> -->
Duration
</el-button>
</div>
<div class="mr-5" v-if="dashboardStore.entity === EntityType[1].value"> <div class="mr-5" v-if="dashboardStore.entity === EntityType[1].value">
<span class="grey mr-5">{{ t("service") }}:</span> <span class="grey mr-5">{{ t("service") }}:</span>
<Selector <Selector