progress so far with tools section

This commit is contained in:
Peter Olu 2022-05-03 15:46:35 +01:00
parent 2c57337257
commit 36f3adf6de
2 changed files with 116 additions and 29 deletions

View File

@ -13,12 +13,28 @@ 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"> <div class="dashboard-tool flex-h">
<div class="dashboard-tool flex-h"> <div class="dashboard-tool flex-h">
<div class="flex-h"> <div class="flex-h">
<div class="selectors-item" v-if="key !== 10"> <div class="selectors-item" v-if="key !== 10">
<span class="label">$Service</span> <el-tooltip
class="box-item"
effect="dark"
content="Services"
placement="top-start"
>
<el-button
style="margin-left: 4px"
@click="setSelectedSelector('$service')"
type="secondary"
>
<Icon size="sm" iconName="playlist_add" />
</el-button>
</el-tooltip>
<!-- <span class="label">$Service</span> -->
<Selector <Selector
v-if="selectedSelector === '$service'"
style="margin-left: 20px"
v-model="states.currentService" v-model="states.currentService"
:options="selectorStore.services" :options="selectorStore.services"
size="small" size="small"
@ -26,16 +42,41 @@ limitations under the License. -->
@change="changeService" @change="changeService"
class="selectors" class="selectors"
/> />
<el-button
style="margin-left: 4px"
v-if="selectedSelector === '$service'"
class="search-btn"
size="small"
type="danger"
@click="closeSelector"
>
<Icon iconSize="sm" iconName="cancel" />
</el-button>
</div> </div>
<div class="selectors-item" v-if="key === 3 || key === 4"> <div class="selectors-item" v-if="key === 3 || key === 4">
<span class="label"> <el-tooltip
class="box-item"
effect="dark"
content="Endpoint"
placement="top-start"
>
<el-button
style="margin-left: 4px"
@click="setSelectedSelector('$endpoint')"
type="secondary"
>
<Icon size="sm" iconName="view" />
</el-button>
</el-tooltip>
<!-- <span class="label">
{{ {{
["EndpointRelation", "Endpoint"].includes(dashboardStore.entity) ["EndpointRelation", "Endpoint"].includes(dashboardStore.entity)
? "$Endpoint" ? "$Endpoint"
: "$ServiceInstance" : "$ServiceInstance"
}} }}
</span> </span> -->
<Selector <Selector
v-if="selectedSelector === '$endpoint'"
v-model="states.currentPod" v-model="states.currentPod"
:options="selectorStore.pods" :options="selectorStore.pods"
size="small" size="small"
@ -43,8 +84,20 @@ limitations under the License. -->
@change="changePods" @change="changePods"
@query="searchPods" @query="searchPods"
class="selectorPod" class="selectorPod"
:isRemote="['EndpointRelation', 'Endpoint'].includes(dashboardStore.entity)" :isRemote="
['EndpointRelation', 'Endpoint'].includes(dashboardStore.entity)
"
/> />
<!-- <el-button
style="margin-left: 4px"
v-if="selectedSelector === '$endpoint'"
class="search-btn"
size="small"
type="danger"
@click="closeSelector"
>
<Icon iconSize="sm" iconName="cancel" />
</el-button> -->
</div> </div>
<div class="selectors-item" v-if="key === 2 || key === 4"> <div class="selectors-item" v-if="key === 2 || key === 4">
<span class="label">$DestinationService</span> <span class="label">$DestinationService</span>
@ -150,11 +203,11 @@ const dashboardStore = useDashboardStore();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const params = useRoute().params; const params = useRoute().params;
const selectedSelector = ref<string>("");
const showFilter = computed( const showFilter = computed(
() => dashboardStore.layout[0].activedTabIndex === 2 () => dashboardStore.layout[0].activedTabIndex === 2
); );
const { query } = useRoute(); const { query } = useRoute();
dashboardStore.setViewMode(query["fullview"] === "true"); dashboardStore.setViewMode(query["fullview"] === "true");
@ -180,10 +233,18 @@ const states = reactive<{
currentDestPod: "", currentDestPod: "",
}); });
const key = computed(() => { const key = computed(() => {
const type = EntityType.find((d: Option) => d.value === dashboardStore.entity); const type = EntityType.find(
(d: Option) => d.value === dashboardStore.entity
);
return (type && type.key) || 0; return (type && type.key) || 0;
}); });
function setSelectedSelector(selector: string) {
selectedSelector.value = selector;
}
function closeSelector() {
selectedSelector.value = "";
}
setCurrentDashboard(); setCurrentDashboard();
appStore.setEventStack([initSelector]); appStore.setEventStack([initSelector]);
initSelector(); initSelector();
@ -214,7 +275,9 @@ async function setSelector() {
].includes(String(params.entity)) ].includes(String(params.entity))
) { ) {
setSourceSelector(); setSourceSelector();
if ([EntityType[2].value, EntityType[3].value].includes(String(params.entity))) { if (
[EntityType[2].value, EntityType[3].value].includes(String(params.entity))
) {
return; return;
} }
setDestSelector(); setDestSelector();
@ -282,7 +345,11 @@ 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(String(params.entity), selectorStore.currentDestService.id, false); await fetchPods(
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,7 +362,9 @@ async function setDestSelector() {
(d: { label: string }) => d.label === states.currentDestPod (d: { label: string }) => d.label === states.currentDestPod
); );
} else { } else {
currentDestPod = selectorStore.destPods.find((d: { id: string }) => d.id === destPod); currentDestPod = selectorStore.destPods.find(
(d: { id: string }) => d.id === destPod
);
} }
if (currentDestPod) { if (currentDestPod) {
selectorStore.setCurrentDestPod(currentDestPod); selectorStore.setCurrentDestPod(currentDestPod);
@ -324,7 +393,9 @@ async function getServices() {
(d: { label: string }) => d.label === states.currentService (d: { label: string }) => d.label === states.currentService
); );
} else { } else {
s = (selectorStore.services || []).find((d: unknown, index: number) => index === 0); s = (selectorStore.services || []).find(
(d: unknown, index: number) => index === 0
);
} }
selectorStore.setCurrentService(s || null); selectorStore.setCurrentService(s || null);
let d; let d;
@ -333,7 +404,9 @@ async function getServices() {
(d: { label: string }) => d.label === states.currentDestService (d: { label: string }) => d.label === states.currentDestService
); );
} else { } else {
d = (selectorStore.services || []).find((d: unknown, index: number) => index === 1); d = (selectorStore.services || []).find(
(d: unknown, index: number) => index === 1
);
} }
selectorStore.setCurrentDestService(d || null); selectorStore.setCurrentDestService(d || null);
if (!selectorStore.currentService) { if (!selectorStore.currentService) {
@ -341,14 +414,18 @@ 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 ([EntityType[2].value, EntityType[3].value].includes(dashboardStore.entity)) { if (
[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 ([EntityType[5].value, EntityType[6].value].includes(dashboardStore.entity)) { if (
[EntityType[5].value, EntityType[6].value].includes(dashboardStore.entity)
) {
fetchPods(dashboardStore.entity, selectorStore.currentDestService.id, true); fetchPods(dashboardStore.entity, selectorStore.currentDestService.id, true);
} }
} }
@ -403,7 +480,10 @@ async function applyDashboard() {
} }
async function clickIcons(t: { id: string; content: string; name: string }) { async function clickIcons(t: { id: string; content: string; name: string }) {
if (dashboardStore.selectedGrid && dashboardStore.selectedGrid.type === "Tab") { if (
dashboardStore.selectedGrid &&
dashboardStore.selectedGrid.type === "Tab"
) {
setTabControls(t.id); setTabControls(t.id);
return; return;
} }
@ -491,7 +571,9 @@ async function fetchPods(
(d: { label: unknown }) => d.label === states.currentPod (d: { label: unknown }) => d.label === states.currentPod
); );
} else { } else {
p = selectorStore.pods.find((d: unknown, index: number) => index === 0); p = selectorStore.pods.find(
(d: unknown, index: number) => index === 0
);
} }
selectorStore.setCurrentPod(p || null); selectorStore.setCurrentPod(p || null);
states.currentPod = selectorStore.currentPod.label; states.currentPod = selectorStore.currentPod.label;
@ -599,7 +681,12 @@ function searchDestPods(query: string) {
const param = { const param = {
keyword: query, keyword: query,
}; };
fetchPods(EntityType[6].value, selectorStore.currentDestService.id, false, param); fetchPods(
EntityType[6].value,
selectorStore.currentDestService.id,
false,
param
);
} }
watch( watch(
() => dashboardStore.entity, () => dashboardStore.entity,

View File

@ -88,12 +88,7 @@ limitations under the License. -->
</el-tooltip> </el-tooltip>
</div> </div>
<div class="wrap-filters"> <div class="wrap-filters">
<div <div class="filter my-5" v-if="activeFilter === 'service'">
class="filter my-5"
v-if="
activeFilter === 'service'
"
>
<span class="grey mr-5">{{ t("service") }}:</span> <span class="grey mr-5">{{ t("service") }}:</span>
<Selector <Selector
size="small" size="small"
@ -105,7 +100,9 @@ limitations under the License. -->
</div> </div>
<div <div
class="filter my-5" class="filter my-5"
v-if="activeFilter === 'instance' && dashboardStore.entity !== EntityType[3].value" v-if="
activeFilter === 'instance' && dashboardStore.entity !== EntityType[3].value
"
> >
<span class="grey mr-5">{{ t("instance") }}:</span> <span class="grey mr-5">{{ t("instance") }}:</span>
<Selector <Selector
@ -149,7 +146,11 @@ limitations under the License. -->
<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>
<ConditionTags v-if="activeFilter === 'tags'" :type="'TRACE'" @update="updateTags" /> <ConditionTags
v-if="activeFilter === 'tags'"
:type="'TRACE'"
@update="updateTags"
/>
<el-button <el-button
v-if="activeFilter" v-if="activeFilter"
class="search-btn" class="search-btn"
@ -167,7 +168,6 @@ limitations under the License. -->
type="danger" type="danger"
@click="cancelSearch" @click="cancelSearch"
> >
<!-- {{ t("search") }} -->
<Icon iconSize="sm" iconName="cancel" /> <Icon iconSize="sm" iconName="cancel" />
</el-button> </el-button>
</div> </div>
@ -192,7 +192,7 @@ const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const activeFilter = ref<string>(""); const activeFilter = ref<string>("");
const showAllBtns = ref<boolean>(true); // const showAllBtns = ref<boolean>(true);
function setFilter(filter: string) { function setFilter(filter: string) {
activeFilter.value = filter; activeFilter.value = filter;
} }