feat: add router for dashboard

This commit is contained in:
Qiuxia Fan 2021-12-16 11:26:34 +08:00
parent f4c1c81c09
commit 54f80fddb3
7 changed files with 61 additions and 15 deletions

View File

@ -44,6 +44,7 @@ const msg = {
databasePanel: "Database Panel", databasePanel: "Database Panel",
meshServicePanel: "Service Panel", meshServicePanel: "Service Panel",
newDashboard: "New a dashboard", newDashboard: "New a dashboard",
dashboardEdit: "Edit the dashboard",
hourTip: "Select Hour", hourTip: "Select Hour",
minuteTip: "Select Minute", minuteTip: "Select Minute",
secondTip: "Select Second", secondTip: "Select Second",

View File

@ -44,6 +44,7 @@ const msg = {
databasePanel: "数据库面板", databasePanel: "数据库面板",
meshServicePanel: "服务面板", meshServicePanel: "服务面板",
newDashboard: "新增仪表盘", newDashboard: "新增仪表盘",
dashboardEdit: "编辑仪表盘",
hourTip: "选择小时", hourTip: "选择小时",
minuteTip: "选择分钟", minuteTip: "选择分钟",
secondTip: "选择秒数", secondTip: "选择秒数",

View File

@ -47,6 +47,36 @@ export const routesDashboard: Array<RouteRecordRaw> = [
exact: false, exact: false,
}, },
}, },
{
path: "/dashboard/edit/service/:serviceId",
component: () => import("@/views/dashboard/Edit.vue"),
name: "serviceEdit",
meta: {
title: "dashboardEdit",
exact: false,
notShow: true,
},
},
{
path: "/dashboard/edit/endpoint/:serviceId/:endpointId",
component: () => import("@/views/dashboard/Edit.vue"),
name: "endpointEdit",
meta: {
title: "dashboardEdit",
exact: false,
notShow: true,
},
},
{
path: "/dashboard/edit/instance/:serviceId/:instanceId",
component: () => import("@/views/dashboard/Edit.vue"),
name: "instanceEdit",
meta: {
title: "dashboardEdit",
exact: false,
notShow: true,
},
},
], ],
}, },
]; ];

View File

@ -46,7 +46,7 @@ const router = createRouter({
(window as any).axiosCancel = []; (window as any).axiosCancel = [];
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const token = window.localStorage.getItem("skywalking-authority"); // const token = window.localStorage.getItem("skywalking-authority");
if ((window as any).axiosCancel.length !== 0) { if ((window as any).axiosCancel.length !== 0) {
for (const func of (window as any).axiosCancel) { for (const func of (window as any).axiosCancel) {
setTimeout(func(), 0); setTimeout(func(), 0);

View File

@ -0,0 +1 @@
<template>dashboard edit</template>

View File

@ -57,7 +57,7 @@ limitations under the License. -->
</el-option> </el-option>
</el-select> </el-select>
</div> </div>
<div class="item" v-show="state.entity === 'Service'"> <div class="item" v-show="state.entity === EntityType[0].value">
<div class="label">Service</div> <div class="label">Service</div>
<el-select <el-select
size="small" size="small"
@ -74,7 +74,7 @@ limitations under the License. -->
</el-option> </el-option>
</el-select> </el-select>
</div> </div>
<div class="item" v-show="state.entity === 'Endpoint'"> <div class="item" v-show="state.entity === EntityType[2].value">
<div class="label">Service / Endpoint</div> <div class="label">Service / Endpoint</div>
<el-cascader <el-cascader
v-model="state.serviceEndpoint" v-model="state.serviceEndpoint"
@ -85,7 +85,7 @@ limitations under the License. -->
:style="{ width: '600px' }" :style="{ width: '600px' }"
></el-cascader> ></el-cascader>
</div> </div>
<div class="item" v-show="state.entity === 'ServiceInstance'"> <div class="item" v-show="state.entity === EntityType[3].value">
<div class="label">Service / Instance</div> <div class="label">Service / Instance</div>
<el-cascader <el-cascader
v-model="state.serviceInstance" v-model="state.serviceInstance"
@ -96,7 +96,7 @@ limitations under the License. -->
:style="{ width: '600px' }" :style="{ width: '600px' }"
></el-cascader> ></el-cascader>
</div> </div>
<div class="item" v-show="state.entity === 'ServiceRelation'"> <div class="item" v-show="state.entity === EntityType[4].value">
<div class="label">Destination Service</div> <div class="label">Destination Service</div>
<el-select <el-select
size="small" size="small"
@ -113,7 +113,7 @@ limitations under the License. -->
</el-option> </el-option>
</el-select> </el-select>
</div> </div>
<div class="item" v-show="state.entity === 'EndpointRelation'"> <div class="item" v-show="state.entity === EntityType[5].value">
<span class="label">Destination Service / Endpoint</span> <span class="label">Destination Service / Endpoint</span>
<el-cascader <el-cascader
v-model="state.destServiceEndpoint" v-model="state.destServiceEndpoint"
@ -123,7 +123,7 @@ limitations under the License. -->
:style="{ width: '600px' }" :style="{ width: '600px' }"
></el-cascader> ></el-cascader>
</div> </div>
<div class="item" v-show="state.entity === 'ServiceInstanceRelation'"> <div class="item" v-show="state.entity === EntityType[6].value">
<span class="label">Destination Service / Instance</span> <span class="label">Destination Service / Instance</span>
<el-cascader <el-cascader
v-model="state.destServiceInstance" v-model="state.destServiceInstance"
@ -142,6 +142,7 @@ limitations under the License. -->
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive } from "vue"; import { reactive } from "vue";
import router from "@/router";
import { import {
ElSelect, ElSelect,
ElOption, ElOption,
@ -171,7 +172,19 @@ const handleChange = (value: any) => {
console.log(value); console.log(value);
}; };
const onCreate = () => { const onCreate = () => {
console.log(state); let path = `/dashboard/edit/${state.entity}/`;
switch (state.entity) {
case EntityType[0].value:
path += state.service;
break;
case EntityType[2].value:
path += `${state.service}/${state.serviceEndpoint}`;
break;
case EntityType[3].value:
path += `${state.service}/${state.serviceInstance}`;
break;
}
router.push(path);
}; };
selectorStore.fetchServices("general"); selectorStore.fetchServices("general");
</script> </script>

View File

@ -15,13 +15,13 @@
* limitations under the License. * limitations under the License.
*/ */
export const EntityType = [ export const EntityType = [
{ value: "Service", label: "Service" }, { value: "service", label: "Service" },
{ value: "All", label: "All" }, { value: "all", label: "All" },
{ value: "Endpoint", label: "Service Endpoint" }, { value: "endpoint", label: "Service Endpoint" },
{ value: "ServiceInstance", label: "Service Instance" }, { value: "serviceInstance", label: "Service Instance" },
{ value: "ServiceRelation", label: "Service Relation" }, { value: "serviceRelation", label: "Service Relation" },
{ value: "ServiceInstanceRelation", label: "Service Instance Relation" }, { value: "serviceInstanceRelation", label: "Service Instance Relation" },
{ value: "EndpointRelation", label: "Endpoint Relation" }, { value: "endpointRelation", label: "Endpoint Relation" },
]; ];
export const SelectOpt = [ export const SelectOpt = [
{ {