feat: add trace tool

This commit is contained in:
Qiuxia Fan 2022-02-21 13:40:13 +08:00
parent 01194b0325
commit 33054d1f0a
5 changed files with 34 additions and 13 deletions

18
src/assets/icons/merge.svg Executable file
View File

@ -0,0 +1,18 @@
<!-- 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. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path d="M5.08964366,4.67738245 C5.53724055,6.35901626 7.61507769,7.75687802 10.2843944,7.97145461 C10.6340823,7.38943035 11.271563,7 12,7 C13.1045695,7 14,7.8954305 14,9 C14,10.1045695 13.1045695,11 12,11 C11.2491882,11 10.5950062,10.5862786 10.2529915,9.97437331 C8.18114287,9.83159096 6.31872952,9.10035115 5,7.98669933 L5,11.2675644 C5.59780137,11.6133738 6,12.2597176 6,13 C6,14.1045695 5.1045695,15 4,15 C2.8954305,15 2,14.1045695 2,13 C2,12.2597176 2.40219863,11.6133738 3,11.2675644 L3,4.73243561 C2.40219863,4.38662619 2,3.74028236 2,3 C2,1.8954305 2.8954305,1 4,1 C5.1045695,1 6,1.8954305 6,3 C6,3.70264175 5.63766215,4.32065497 5.08964366,4.67738245 Z M4,4 C4.55228475,4 5,3.55228475 5,3 C5,2.44771525 4.55228475,2 4,2 C3.44771525,2 3,2.44771525 3,3 C3,3.55228475 3.44771525,4 4,4 Z M4,14 C4.55228475,14 5,13.5522847 5,13 C5,12.4477153 4.55228475,12 4,12 C3.44771525,12 3,12.4477153 3,13 C3,13.5522847 3.44771525,14 4,14 Z M12,10 C12.5522847,10 13,9.55228475 13,9 C13,8.44771525 12.5522847,8 12,8 C11.4477153,8 11,8.44771525 11,9 C11,9.55228475 11.4477153,10 12,10 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -63,7 +63,7 @@ export const dashboardStore = defineStore({
this.layout = data; this.layout = data;
}, },
addControl(type: string) { addControl(type: string) {
const newWidget: LayoutConfig = { const newItem: LayoutConfig = {
...NewControl, ...NewControl,
i: String(this.layout.length), i: String(this.layout.length),
type, type,
@ -71,8 +71,8 @@ export const dashboardStore = defineStore({
metrics: [""], metrics: [""],
}; };
if (type === "Tab") { if (type === "Tab") {
newWidget.h = 24; newItem.h = 24;
newWidget.children = [ newItem.children = [
{ {
name: "Tab1", name: "Tab1",
children: [], children: [],
@ -84,9 +84,9 @@ export const dashboardStore = defineStore({
]; ];
} }
if (type === "Topology") { if (type === "Topology") {
newWidget.w = 4; newItem.w = 4;
newWidget.h = 6; newItem.h = 6;
newWidget.graph = { newItem.graph = {
fontColor: "white", fontColor: "white",
backgroundColor: "green", backgroundColor: "green",
iconTheme: true, iconTheme: true,
@ -95,12 +95,15 @@ export const dashboardStore = defineStore({
showDepth: true, showDepth: true,
}; };
} }
if (type === "Trace") {
newItem.h = 24;
}
this.layout = this.layout.map((d: LayoutConfig) => { this.layout = this.layout.map((d: LayoutConfig) => {
d.y = d.y + newWidget.h; d.y = d.y + newItem.h;
return d; return d;
}); });
this.layout.push(newWidget); this.layout.push(newItem);
this.activedGridItem = newWidget.i; this.activedGridItem = newItem.i;
}, },
addTabItem(item: LayoutConfig) { addTabItem(item: LayoutConfig) {
const idx = this.layout.findIndex((d: LayoutConfig) => d.i === item.i); const idx = this.layout.findIndex((d: LayoutConfig) => d.i === item.i);

View File

View File

@ -165,11 +165,11 @@ export const SortOrder = [
export const ToolIcons = [ export const ToolIcons = [
{ name: "playlist_add", content: "Add Widget", id: "addWidget" }, { name: "playlist_add", content: "Add Widget", id: "addWidget" },
{ name: "all_inbox", content: "Add Tab", id: "addTab" }, { name: "all_inbox", content: "Add Tab", id: "addTab" },
// { name: "insert_image", content: "Add Image", id: "addImage" }, { name: "device_hub", content: "Add Topology", id: "topology" },
{ name: "merge", content: "Add Trace", id: "trace" },
// { name: "save_alt", content: "Export", id: "export" }, // { name: "save_alt", content: "Export", id: "export" },
// { name: "folder_open", content: "Import", id: "import" }, // { name: "folder_open", content: "Import", id: "import" },
// { name: "settings", content: "Settings", id: "settings" }, // { name: "settings", content: "Settings", id: "settings" },
{ name: "device_hub", content: "Add Topology", id: "topology" },
// { name: "save", content: "Apply", id: "apply" }, // { name: "save", content: "Apply", id: "apply" },
]; ];
export const ScopeType = [ export const ScopeType = [

View File

@ -290,8 +290,8 @@ function clickIcons(t: { id: string; content: string; name: string }) {
case "addTab": case "addTab":
dashboardStore.addControl("Tab"); dashboardStore.addControl("Tab");
break; break;
case "addImage": case "trace":
dashboardStore.addControl("Image"); dashboardStore.addControl("Trace");
break; break;
case "topology": case "topology":
dashboardStore.addControl("Topology"); dashboardStore.addControl("Topology");