mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 15:25:24 +00:00
feat: set conditions for different layers node
This commit is contained in:
parent
b4de2bd230
commit
41ad830ea8
@ -43,7 +43,6 @@ interface Option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*global defineProps, defineEmits*/
|
/*global defineProps, defineEmits*/
|
||||||
|
|
||||||
const emit = defineEmits(["change"]);
|
const emit = defineEmits(["change"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
options: {
|
options: {
|
||||||
@ -54,7 +53,7 @@ const props = defineProps({
|
|||||||
type: [Array, String] as PropType<string[] | string>,
|
type: [Array, String] as PropType<string[] | string>,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
size: { type: [], default: "default" },
|
size: { type: null, default: "default" },
|
||||||
placeholder: { type: String, default: "Select a option" },
|
placeholder: { type: String, default: "Select a option" },
|
||||||
borderRadius: { type: Number, default: 3 },
|
borderRadius: { type: Number, default: 3 },
|
||||||
multiple: { type: Boolean, default: false },
|
multiple: { type: Boolean, default: false },
|
||||||
|
@ -56,8 +56,25 @@ export const topologyStore = defineStore({
|
|||||||
this.call = link;
|
this.call = link;
|
||||||
},
|
},
|
||||||
setTopology(data: { nodes: Node[]; calls: Call[] }) {
|
setTopology(data: { nodes: Node[]; calls: Call[] }) {
|
||||||
this.nodes = data.nodes;
|
this.nodes = data.nodes.map((n: Node) => {
|
||||||
this.calls = data.calls;
|
const service =
|
||||||
|
useSelectorStore().services.filter(
|
||||||
|
(d: Service) => d.id === n.id
|
||||||
|
)[0] || {};
|
||||||
|
n.layer = service.layers ? service.layers[0] : null;
|
||||||
|
return n;
|
||||||
|
});
|
||||||
|
this.calls = data.calls.map((c: Call) => {
|
||||||
|
for (const s of useSelectorStore().services) {
|
||||||
|
if (c.source.id === s.id) {
|
||||||
|
c.source.layer = s.layers[0];
|
||||||
|
}
|
||||||
|
if (c.target.id === s.id) {
|
||||||
|
c.target.layer = s.layers[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
setNodeMetrics(m: { id: string; value: unknown }[]) {
|
setNodeMetrics(m: { id: string; value: unknown }[]) {
|
||||||
this.nodeMetrics = m;
|
this.nodeMetrics = m;
|
||||||
|
18
src/types/topology.d.ts
vendored
18
src/types/topology.d.ts
vendored
@ -15,31 +15,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
export interface Call {
|
export interface Call {
|
||||||
avgResponseTime: number;
|
|
||||||
cpm: number;
|
|
||||||
isAlert: boolean;
|
|
||||||
source: string | any;
|
source: string | any;
|
||||||
target: string | any;
|
target: string | any;
|
||||||
id: string;
|
id: string;
|
||||||
detectPoints: string[];
|
detectPoints: string[];
|
||||||
type?: string;
|
type?: string;
|
||||||
sourceObj?: any;
|
layer?: string;
|
||||||
isGroupActive?: boolean;
|
|
||||||
latency?: number;
|
|
||||||
}
|
}
|
||||||
export interface Node {
|
export interface Node {
|
||||||
apdex: number;
|
|
||||||
avgResponseTime: number;
|
|
||||||
cpm: number;
|
|
||||||
id: string;
|
id: string;
|
||||||
isAlarm: boolean;
|
|
||||||
name: string;
|
name: string;
|
||||||
numOfServer: number;
|
|
||||||
numOfServerAlarm: number;
|
|
||||||
numOfServiceAlarm: number;
|
|
||||||
sla: number;
|
|
||||||
type: string;
|
type: string;
|
||||||
isReal: boolean;
|
isReal: boolean;
|
||||||
isGroupActive?: boolean;
|
layer?: string;
|
||||||
latency?: number;
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="operations-list"
|
class="operations-list"
|
||||||
v-if="topologyStore.node && topologyStore.node.isReal"
|
v-if="topologyStore.node"
|
||||||
:style="{
|
:style="{
|
||||||
top: operationsPos.y + 'px',
|
top: operationsPos.y + 'px',
|
||||||
left: operationsPos.x + 'px',
|
left: operationsPos.x + 'px',
|
||||||
@ -182,8 +182,22 @@ function handleNodeClick(d: Node & { x: number; y: number }) {
|
|||||||
topologyStore.setLink(null);
|
topologyStore.setLink(null);
|
||||||
operationsPos.x = d.x;
|
operationsPos.x = d.x;
|
||||||
operationsPos.y = d.y + 30;
|
operationsPos.y = d.y + 30;
|
||||||
|
console.log(d.layer === String(dashboardStore.layerId));
|
||||||
|
if (d.layer === String(dashboardStore.layerId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
items.value = [
|
||||||
|
{ id: "inspect", title: "Inspect", func: handleInspect },
|
||||||
|
{ id: "alarm", title: "Alarm", func: handleGoAlarm },
|
||||||
|
];
|
||||||
}
|
}
|
||||||
function handleLinkClick(event: any, d: Call) {
|
function handleLinkClick(event: any, d: Call) {
|
||||||
|
if (
|
||||||
|
d.source.layer !== dashboardStore.layerId ||
|
||||||
|
d.target.layer !== dashboardStore.layerId
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
topologyStore.setNode(null);
|
topologyStore.setNode(null);
|
||||||
topologyStore.setLink(d);
|
topologyStore.setLink(d);
|
||||||
@ -305,13 +319,14 @@ function update() {
|
|||||||
}
|
}
|
||||||
async function handleInspect() {
|
async function handleInspect() {
|
||||||
svg.value.selectAll(".topo-svg-graph").remove();
|
svg.value.selectAll(".topo-svg-graph").remove();
|
||||||
const resp = await topologyStore.getServiceTopology(topologyStore.node.id);
|
const id = topologyStore.node.id;
|
||||||
|
topologyStore.setNode(null);
|
||||||
|
topologyStore.setLink(null);
|
||||||
|
const resp = await topologyStore.getServiceTopology(id);
|
||||||
|
|
||||||
if (resp.errors) {
|
if (resp.errors) {
|
||||||
ElMessage.error(resp.errors);
|
ElMessage.error(resp.errors);
|
||||||
}
|
}
|
||||||
topologyStore.setNode(null);
|
|
||||||
topologyStore.setLink(null);
|
|
||||||
await init();
|
await init();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -410,12 +425,6 @@ function updateSettings(config: any) {
|
|||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
window.removeEventListener("resize", resize);
|
window.removeEventListener("resize", resize);
|
||||||
});
|
});
|
||||||
// watch(
|
|
||||||
// () => [topologyStore.nodes, topologyStore.calls],
|
|
||||||
// () => {
|
|
||||||
// update();
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.micro-topo-chart {
|
.micro-topo-chart {
|
||||||
|
Loading…
Reference in New Issue
Block a user