feat: set dashboard name

This commit is contained in:
Qiuxia Fan 2022-02-12 15:52:08 +08:00
parent 078f1bc042
commit 79d4312f7c
3 changed files with 35 additions and 4 deletions

View File

@ -134,12 +134,21 @@ function initSelector() {
} }
async function setSelector() { async function setSelector() {
if (params.podId) { if (
params.entity === EntityType[2].value ||
params.entity === EntityType[3].value
) {
await selectorStore.getService(String(params.serviceId)); await selectorStore.getService(String(params.serviceId));
states.currentService = selectorStore.currentService.value; states.currentService = selectorStore.currentService.value;
await fetchPods(String(params.entity), false); await fetchPods(String(params.entity), false);
if (!(selectorStore.pods.length && selectorStore.pods[0])) {
selectorStore.setCurrentPod(null);
states.currentPod = "";
return;
}
const pod = params.podId || selectorStore.pods[0].id;
const currentPod = selectorStore.pods.filter( const currentPod = selectorStore.pods.filter(
(d: { id: string }) => d.id === String(params.podId) (d: { id: string }) => d.id === pod
)[0]; )[0];
selectorStore.setCurrentPod(currentPod); selectorStore.setCurrentPod(currentPod);
states.currentPod = currentPod.label; states.currentPod = currentPod.label;

View File

@ -244,14 +244,14 @@ function update() {
} }
function handleGoEndpoint() { function handleGoEndpoint() {
const node = topologyStore.node; const node = topologyStore.node;
const path = `/dashboard/${dashboardStore.layerId}/Endpoint/${node.id}/${settings.value.nodeDashboard}`; const path = `/dashboard/${dashboardStore.layerId}/Endpoint/${node.id}/${settings.value.endpointDashboard}`;
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");
} }
function handleGoInstance() { function handleGoInstance() {
const node = topologyStore.node; const node = topologyStore.node;
const path = `/dashboard/${dashboardStore.layerId}/ServiceInstance/${node.id}/${settings.value.nodeDashboard}`; const path = `/dashboard/${dashboardStore.layerId}/ServiceInstance/${node.id}/${settings.value.instanceDashboard}`;
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");

View File

@ -44,6 +44,22 @@ limitations under the License. -->
size="small" size="small"
class="inputs" class="inputs"
/> />
<div class="label">{{ t("dashboards") }}</div>
<el-input
v-model="states.instanceDashboard"
placeholder="Please input a dashboard name for service instances"
@change="updateSettings"
size="small"
class="inputs"
/>
<div class="label">{{ t("dashboards") }}</div>
<el-input
v-model="states.endpointDashboard"
placeholder="Please input a dashboard name for endpoints"
@change="updateSettings"
size="small"
class="inputs"
/>
<div class="label">{{ t("metrics") }}</div> <div class="label">{{ t("metrics") }}</div>
<Selector <Selector
class="inputs" class="inputs"
@ -71,6 +87,8 @@ const dashboardStore = useDashboardStore();
const states = reactive<{ const states = reactive<{
linkDashboard: string; linkDashboard: string;
nodeDashboard: string; nodeDashboard: string;
instanceDashboard: string;
endpointDashboard: string;
linkMetrics: string[]; linkMetrics: string[];
nodeMetrics: string[]; nodeMetrics: string[];
nodeMetricList: Option[]; nodeMetricList: Option[];
@ -78,6 +96,8 @@ const states = reactive<{
}>({ }>({
linkDashboard: "", linkDashboard: "",
nodeDashboard: "", nodeDashboard: "",
instanceDashboard: "",
endpointDashboard: "",
linkMetrics: [], linkMetrics: [],
nodeMetrics: [], nodeMetrics: [],
nodeMetricList: [], nodeMetricList: [],
@ -104,6 +124,8 @@ function updateSettings() {
emit("update", { emit("update", {
linkDashboard: states.linkDashboard, linkDashboard: states.linkDashboard,
nodeDashboard: states.nodeDashboard, nodeDashboard: states.nodeDashboard,
endpointDashboard: states.endpointDashboard,
instanceDashboard: states.instanceDashboard,
linkMetrics: states.linkMetrics, linkMetrics: states.linkMetrics,
nodeMetrics: states.nodeMetrics, nodeMetrics: states.nodeMetrics,
}); });