update sankey

This commit is contained in:
Qiuxia Fan 2022-03-20 16:33:34 +08:00
parent 8404da29a3
commit 2aa63f0746
3 changed files with 42 additions and 30 deletions

View File

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="topology flex-v"> <div class="topology flex-v">
<div class="operation">
<el-popover <el-popover
placement="bottom" placement="bottom"
trigger="click" trigger="click"
@ -21,14 +22,18 @@ limitations under the License. -->
v-if="routeParams.entity" v-if="routeParams.entity"
> >
<template #reference> <template #reference>
<span class="delete cp"> <span>
<Icon iconName="ellipsis_v" size="middle" class="operation" /> <Icon iconName="ellipsis_v" size="middle" />
</span> </span>
</template> </template>
<div class="tools" @click="editConfig">
<span>{{ t("edit") }}</span>
</div>
<div class="tools" @click="removeTopo"> <div class="tools" @click="removeTopo">
<span>{{ t("delete") }}</span> <span>{{ t("delete") }}</span>
</div> </div>
</el-popover> </el-popover>
</div>
<Topology /> <Topology />
</div> </div>
</template> </template>
@ -54,6 +59,10 @@ const dashboardStore = useDashboardStore();
function removeTopo() { function removeTopo() {
dashboardStore.removeControls(props.data); dashboardStore.removeControls(props.data);
} }
function editConfig() {
dashboardStore.setConfigPanel(true);
dashboardStore.selectWidget(props.data);
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.topology { .topology {
@ -64,16 +73,11 @@ function removeTopo() {
position: relative; position: relative;
} }
.delete { .operation {
position: absolute; position: absolute;
top: 5px; top: 5px;
right: 3px; right: 3px;
} cursor: pointer;
.header {
padding: 10px;
font-size: 12px;
border-bottom: 1px solid #dcdfe6;
} }
.tools { .tools {

View File

@ -123,7 +123,7 @@ onMounted(async () => {
height: 0, height: 0,
width: 0, width: 0,
}; };
height.value = dom.height; height.value = dom.height - 40;
width.value = dom.width; width.value = dom.width;
window.addEventListener("resize", resize); window.addEventListener("resize", resize);
svg.value = d3.select(chart.value).append("svg").attr("class", "topo-svg"); svg.value = d3.select(chart.value).append("svg").attr("class", "topo-svg");
@ -475,8 +475,9 @@ onBeforeUnmount(() => {
.micro-topo-chart { .micro-topo-chart {
position: relative; position: relative;
height: 100%; height: calc(100% - 30px);
overflow: auto; overflow: auto;
margin-top: 30px;
.setting { .setting {
position: absolute; position: absolute;

View File

@ -89,8 +89,8 @@ const dashboardStore = useDashboardStore();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const topologyStore = useTopologyStore(); const topologyStore = useTopologyStore();
const loading = ref<boolean>(false); const loading = ref<boolean>(false);
const height = ref<number>(document.body.clientHeight - 150); const height = ref<number>(document.body.clientHeight);
const width = ref<number>(document.body.clientWidth - 40); const width = ref<number>(document.body.clientWidth);
const showSettings = ref<boolean>(false); const showSettings = ref<boolean>(false);
const settings = ref<any>({}); const settings = ref<any>({});
const operationsPos = reactive<{ x: number; y: number }>({ x: NaN, y: NaN }); const operationsPos = reactive<{ x: number; y: number }>({ x: NaN, y: NaN });
@ -112,6 +112,12 @@ async function loadTopology(id: string) {
if (resp && resp.errors) { if (resp && resp.errors) {
ElMessage.error(resp.errors); ElMessage.error(resp.errors);
} }
const dom = document.querySelector(".topology")?.getBoundingClientRect() || {
height: 0,
width: 0,
};
height.value = dom.height - 40;
width.value = dom.width;
} }
function inspect() { function inspect() {
@ -176,7 +182,7 @@ function selectNodeLink(d: any) {
operationsPos.y = d.event.event.clientY; operationsPos.y = d.event.event.clientY;
} }
async function changeDepth(opt: Option[]) { async function changeDepth(opt: Option[] | any) {
depth.value = opt[0].value; depth.value = opt[0].value;
loadTopology(selectorStore.currentPod.id); loadTopology(selectorStore.currentPod.id);
} }
@ -212,8 +218,8 @@ function handleClick(event: any) {
.settings { .settings {
position: absolute; position: absolute;
top: 40px; top: 60px;
right: 0; right: 10px;
width: 400px; width: 400px;
height: 700px; height: 700px;
background-color: #2b3037; background-color: #2b3037;
@ -228,7 +234,8 @@ function handleClick(event: any) {
.tool { .tool {
text-align: right; text-align: right;
margin-top: 10px; margin-top: 40px;
margin-right: 10px;
position: relative; position: relative;
} }