feat: Implement Text control and update Topology (#37)

This commit is contained in:
Fine0830
2022-03-25 15:51:06 +08:00
committed by GitHub
parent 4380a874de
commit 99e23c33dc
20 changed files with 454 additions and 74 deletions

View File

@@ -121,6 +121,7 @@ import Widget from "./Widget.vue";
import Trace from "./Trace.vue";
import Profile from "./Profile.vue";
import Log from "./Log.vue";
import Text from "./Text.vue";
const props = {
data: {
@@ -131,7 +132,7 @@ const props = {
};
export default defineComponent({
name: "Tab",
components: { Topology, Widget, Trace, Profile, Log },
components: { Topology, Widget, Trace, Profile, Log, Text },
props,
setup(props) {
const { t } = useI18n();
@@ -149,6 +150,7 @@ export default defineComponent({
dashboardStore.setCurrentTabItems(
dashboardStore.layout[l].children[activeTabIndex.value].children
);
dashboardStore.setActiveTabIndex(activeTabIndex.value, props.data.i);
}
function clickTabs(e: Event, idx: number) {

View File

@@ -0,0 +1,129 @@
<!-- 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. -->
<template>
<div class="topology">
<div class="header">
<el-popover
placement="bottom"
trigger="click"
:width="100"
v-if="dashboardStore.editMode"
>
<template #reference>
<span>
<Icon iconName="ellipsis_v" size="middle" class="operation" />
</span>
</template>
<div class="tools" @click="editConfig">
<span>{{ t("edit") }}</span>
</div>
<div class="tools" @click="removeTopo">
<span>{{ t("delete") }}</span>
</div>
</el-popover>
</div>
<div
class="body"
:style="{ backgroundColor: TextColors[data.graph.backgroundColor] }"
>
<div
:style="{
color: TextColors[data.graph.fontColor],
fontSize: data.graph.fontSize + 'px',
}"
>
<a :href="data.graph.url" target="_blank">
{{ data.graph.content }}
</a>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import type { PropType } from "vue";
import { useI18n } from "vue-i18n";
import { useDashboardStore } from "@/store/modules/dashboard";
import { TextColors } from "@/views/dashboard/data";
/*global defineProps */
const props = defineProps({
data: {
type: Object as PropType<any>,
default: () => ({ graph: {} }),
},
activeIndex: { type: String, default: "" },
});
const { t } = useI18n();
const dashboardStore = useDashboardStore();
function removeTopo() {
dashboardStore.removeControls(props.data);
}
function editConfig() {
dashboardStore.setConfigPanel(true);
dashboardStore.selectWidget(props.data);
}
function viewText() {
const path = props.data.graph.url;
console.log(path);
if (!path) {
return;
}
window.open(path, "_blank");
}
</script>
<style lang="scss" scoped>
.topology {
font-size: 12px;
height: 100%;
position: relative;
}
.operation {
cursor: pointer;
}
.header {
position: absolute;
top: 10px;
right: 10px;
}
.body {
text-align: center;
width: 100%;
height: 100%;
cursor: pointer;
box-sizing: border-box;
color: #333;
display: -webkit-box;
-webkit-box-orient: horizontal;
-webkit-box-pack: center;
-webkit-box-align: center;
}
.tools {
padding: 5px 0;
color: #999;
cursor: pointer;
position: relative;
text-align: center;
&:hover {
color: #409eff;
background-color: #eee;
}
}
</style>

View File

@@ -20,5 +20,6 @@ import Widget from "./Widget.vue";
import Trace from "./Trace.vue";
import Profile from "./Profile.vue";
import Log from "./Log.vue";
import Text from "./Text.vue";
export default { Tab, Widget, Trace, Topology, Profile, Log };
export default { Tab, Widget, Trace, Topology, Profile, Log, Text };