mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-12 07:36:14 +00:00
feat: update
This commit is contained in:
parent
82229aca7c
commit
0bda346422
29
src/utils/debounce.ts
Normal file
29
src/utils/debounce.ts
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export function debounce(callback: Function, dur: number) {
|
||||
let timer: any;
|
||||
|
||||
return function () {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
timer = setTimeout(function () {
|
||||
callback();
|
||||
}, dur);
|
||||
};
|
||||
}
|
@ -81,7 +81,7 @@ limitations under the License. -->
|
||||
padding: 10px;
|
||||
font-size: $font-size-smaller;
|
||||
border-bottom: 1px solid $border-color;
|
||||
min-width: 1200px;
|
||||
min-width: 1000px;
|
||||
}
|
||||
|
||||
.tools {
|
||||
@ -101,6 +101,6 @@ limitations under the License. -->
|
||||
min-height: calc(100% - 150px);
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
min-width: 1200px;
|
||||
min-width: 1000px;
|
||||
}
|
||||
</style>
|
||||
|
@ -172,9 +172,8 @@ limitations under the License. -->
|
||||
}
|
||||
|
||||
.trace-chart {
|
||||
height: calc(100% - 100px);
|
||||
height: calc(100% - 95px);
|
||||
overflow: auto;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.trace-detail-wrapper {
|
||||
|
@ -29,6 +29,7 @@ limitations under the License. -->
|
||||
import type { Span, Ref } from "@/types/trace";
|
||||
import SpanDetail from "./SpanDetail.vue";
|
||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||
import { debounce } from "@/utils/debounce";
|
||||
|
||||
/* global defineProps, Nullable, defineExpose,Recordable*/
|
||||
const props = defineProps({
|
||||
@ -45,6 +46,8 @@ limitations under the License. -->
|
||||
const refSpans = ref<Array<Ref>>([]);
|
||||
const tree = ref<Nullable<any>>(null);
|
||||
const traceGraph = ref<Nullable<HTMLDivElement>>(null);
|
||||
const debounceFunc = debounce(draw, 500);
|
||||
|
||||
defineExpose({
|
||||
tree,
|
||||
});
|
||||
@ -55,6 +58,17 @@ limitations under the License. -->
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
draw();
|
||||
loading.value = false;
|
||||
window.addEventListener("resize", resize);
|
||||
});
|
||||
function resize() {
|
||||
debounceFunc();
|
||||
}
|
||||
function draw() {
|
||||
if (!traceGraph.value) {
|
||||
return;
|
||||
}
|
||||
if (props.type === "List") {
|
||||
tree.value = new ListGraph(traceGraph.value, handleSelectSpan);
|
||||
tree.value.init({ label: "TRACE_ROOT", children: segmentId.value }, props.data, fixSpansSize.value);
|
||||
@ -63,11 +77,6 @@ limitations under the License. -->
|
||||
tree.value = new TreeGraph(traceGraph.value, handleSelectSpan);
|
||||
tree.value.init({ label: `${props.traceId}`, children: segmentId.value }, props.data);
|
||||
}
|
||||
loading.value = false;
|
||||
window.addEventListener("resize", resize);
|
||||
});
|
||||
function resize() {
|
||||
tree.value.resize();
|
||||
}
|
||||
function handleSelectSpan(i: Recordable) {
|
||||
currentSpan.value = i.data;
|
||||
|
@ -48,6 +48,7 @@ export default class ListGraph {
|
||||
this.el = el;
|
||||
this.width = el.getBoundingClientRect().width - 10;
|
||||
this.height = el.getBoundingClientRect().height - 10;
|
||||
d3.select(".trace-list-dowanload").remove();
|
||||
this.svg = d3
|
||||
.select(this.el)
|
||||
.append("svg")
|
||||
@ -386,10 +387,4 @@ export default class ListGraph {
|
||||
visDate(date: number, pattern = "YYYY-MM-DD HH:mm:ss:SSS") {
|
||||
return dayjs(date).format(pattern);
|
||||
}
|
||||
resize() {
|
||||
if (!this.el) {
|
||||
return;
|
||||
}
|
||||
this.init(this.data, this.row, this.fixSpansSize);
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ export default class TraceMap {
|
||||
this.topChild = [];
|
||||
this.width = el.clientWidth - 20;
|
||||
this.height = el.clientHeight - 30;
|
||||
d3.select(".d3-trace-tree").remove();
|
||||
this.body = d3
|
||||
.select(this.el)
|
||||
.append("svg")
|
||||
@ -78,12 +79,6 @@ export default class TraceMap {
|
||||
this.svg = this.body.append("g").attr("transform", () => `translate(120, 0)`);
|
||||
this.svg.call(this.tip);
|
||||
}
|
||||
resize() {
|
||||
if (!this.el) {
|
||||
return;
|
||||
}
|
||||
this.init(this.data, this.row);
|
||||
}
|
||||
init(data: Recordable, row: Recordable) {
|
||||
this.treemap = d3.tree().size([row.length * 35, this.width]);
|
||||
this.row = row;
|
||||
|
Loading…
Reference in New Issue
Block a user