diff --git a/package-lock.json b/package-lock.json index 49fe0447..ebf1e905 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,6 +49,7 @@ "husky": "^8.0.2", "jsdom": "^20.0.3", "lint-staged": "^12.1.3", + "mockjs": "^1.1.0", "node-sass": "^8.0.0", "npm-run-all": "^4.1.5", "postcss-html": "^1.3.0", @@ -10168,6 +10169,18 @@ "node": ">=10" } }, + "node_modules/mockjs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mockjs/-/mockjs-1.1.0.tgz", + "integrity": "sha512-eQsKcWzIaZzEZ07NuEyO4Nw65g0hdWAyurVol1IPl1gahRwY+svqzfgfey8U8dahLwG44d6/RwEzuK52rSa/JQ==", + "dev": true, + "dependencies": { + "commander": "*" + }, + "bin": { + "random": "bin/random" + } + }, "node_modules/moment": { "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", @@ -23559,6 +23572,15 @@ "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", "dev": true }, + "mockjs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mockjs/-/mockjs-1.1.0.tgz", + "integrity": "sha512-eQsKcWzIaZzEZ07NuEyO4Nw65g0hdWAyurVol1IPl1gahRwY+svqzfgfey8U8dahLwG44d6/RwEzuK52rSa/JQ==", + "dev": true, + "requires": { + "commander": "*" + } + }, "moment": { "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", diff --git a/package.json b/package.json index b15fa537..87fb1477 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "husky": "^8.0.2", "jsdom": "^20.0.3", "lint-staged": "^12.1.3", + "mockjs": "^1.1.0", "node-sass": "^8.0.0", "npm-run-all": "^4.1.5", "postcss-html": "^1.3.0", diff --git a/src/mock/index.ts b/src/mock/index.ts new file mode 100644 index 00000000..34818673 --- /dev/null +++ b/src/mock/index.ts @@ -0,0 +1,50 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Mock from "mockjs"; + +const Random = Mock.Random; +const nodes = Mock.mock({ + "nodes|500": [ + { + //id + id: "@guid", + name: "@name", + "type|1": ["ActiveMQ", "activemq-consumer", "H2", "APISIX", "Express", "USER", "Flash"], + "isReal|1": [true, false], + }, + ], +}); +const calls = Mock.mock({ + "links|500": [ + { + //id + id: "@guid", + detectPoints: ["SERVER", "CLIENT"], + source: function () { + const d = Random.integer(0, 250); + return nodes.nodes[d].id; + }, + target: function () { + const d = Random.integer(250, 499); + return nodes.nodes[d].id; + }, + }, + ], +}); +const callsMock = calls.links; +const nodesMock = nodes.nodes; +export { callsMock, nodesMock }; diff --git a/src/types/mock.d.ts b/src/types/mock.d.ts new file mode 100644 index 00000000..c5756794 --- /dev/null +++ b/src/types/mock.d.ts @@ -0,0 +1,17 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +declare module "mockjs"; diff --git a/src/types/topology.d.ts b/src/types/topology.d.ts index bacce261..91df9452 100644 --- a/src/types/topology.d.ts +++ b/src/types/topology.d.ts @@ -26,6 +26,10 @@ export interface Call { lowerArc?: boolean; sourceComponents: string[]; targetComponents: string[]; + sourceX?: number; + sourceY?: number; + targetY?: number; + targetX?: number; } export interface Node { id: string; @@ -34,4 +38,8 @@ export interface Node { isReal: boolean; layer?: string; serviceName?: string; + height?: number; + x?: number; + y?: number; + level?: number; } diff --git a/src/views/dashboard/controls/Topology.vue b/src/views/dashboard/controls/Topology.vue index 594d01b9..9766ab1e 100644 --- a/src/views/dashboard/controls/Topology.vue +++ b/src/views/dashboard/controls/Topology.vue @@ -59,7 +59,7 @@ limitations under the License. --> diff --git a/src/views/dashboard/related/topology/components/Settings.vue b/src/views/dashboard/related/topology/components/Settings.vue index ce9d9157..e0c9d4c1 100644 --- a/src/views/dashboard/related/topology/components/Settings.vue +++ b/src/views/dashboard/related/topology/components/Settings.vue @@ -27,7 +27,7 @@ limitations under the License. --> />
{{ t("linkServerMetrics") }} - +