feat: add dialog

This commit is contained in:
Fine 2023-01-31 16:53:16 +08:00
parent c40a98375f
commit 7a331fdde6
6 changed files with 41 additions and 0 deletions

View File

@ -181,6 +181,8 @@ const msg = {
taskTitle: "HTTP request and response collecting rules", taskTitle: "HTTP request and response collecting rules",
iframeWidgetTip: "Add a link to a widget", iframeWidgetTip: "Add a link to a widget",
iframeSrc: "Iframe Link", iframeSrc: "Iframe Link",
generateLink: "Generate Link",
setDuration: "Set Duration",
seconds: "Seconds", seconds: "Seconds",
hourTip: "Select Hour", hourTip: "Select Hour",
minuteTip: "Select Minute", minuteTip: "Select Minute",

View File

@ -164,6 +164,8 @@ const msg = {
legendValues: "Valor de la leyenda", legendValues: "Valor de la leyenda",
iframeWidgetTip: "Añadir enlaces a los gadgets", iframeWidgetTip: "Añadir enlaces a los gadgets",
iframeSrc: "Enlace Iframe", iframeSrc: "Enlace Iframe",
generateLink: "Generar enlaces",
setDuration: "Establecer la duración",
seconds: "Segundos", seconds: "Segundos",
hourTip: "Seleccione Hora", hourTip: "Seleccione Hora",
minuteTip: "Seleccione Minuto", minuteTip: "Seleccione Minuto",

View File

@ -178,6 +178,8 @@ const msg = {
taskTitle: "HTTP请求和响应收集规则", taskTitle: "HTTP请求和响应收集规则",
iframeWidgetTip: "添加widget的链接", iframeWidgetTip: "添加widget的链接",
iframeSrc: "Iframe链接", iframeSrc: "Iframe链接",
generateLink: "生成链接",
setDuration: "设置时间区间",
seconds: "秒", seconds: "秒",
hourTip: "选择小时", hourTip: "选择小时",
minuteTip: "选择分钟", minuteTip: "选择分钟",

View File

@ -40,6 +40,7 @@ interface DashboardState {
currentDashboard: Nullable<DashboardItem>; currentDashboard: Nullable<DashboardItem>;
editMode: boolean; editMode: boolean;
currentTabIndex: number; currentTabIndex: number;
showLinkConfig: boolean;
} }
export const dashboardStore = defineStore({ export const dashboardStore = defineStore({
@ -58,6 +59,7 @@ export const dashboardStore = defineStore({
currentDashboard: null, currentDashboard: null,
editMode: false, editMode: false,
currentTabIndex: 0, currentTabIndex: 0,
showLinkConfig: false,
}), }),
actions: { actions: {
setLayout(data: LayoutConfig[]) { setLayout(data: LayoutConfig[]) {
@ -66,6 +68,9 @@ export const dashboardStore = defineStore({
setMode(mode: boolean) { setMode(mode: boolean) {
this.editMode = mode; this.editMode = mode;
}, },
setWidgetLink(show: boolean) {
this.showLinkConfig = show;
},
resetDashboards(list: DashboardItem[]) { resetDashboards(list: DashboardItem[]) {
this.dashboards = list; this.dashboards = list;
sessionStorage.setItem("dashboards", JSON.stringify(list)); sessionStorage.setItem("dashboards", JSON.stringify(list));

View File

@ -30,6 +30,21 @@ limitations under the License. -->
> >
<component :is="dashboardStore.selectedGrid.type" /> <component :is="dashboardStore.selectedGrid.type" />
</el-dialog> </el-dialog>
<el-dialog
v-model="dashboardStore.showLinkConfig"
:title="t('generateLink')"
:destroy-on-close="true"
@closed="dashboardStore.setWidgetLink(false)"
>
<div>
<label>{{ t("setDuration") }}</label>
<el-switch v-model="hasDuration" />
</div>
<div>
<span class="link">{{ widgetLink }}</span>
<el-button type="primary">{{ t("generateLink") }}</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -52,6 +67,8 @@ limitations under the License. -->
const { t } = useI18n(); const { t } = useI18n();
const p = useRoute().params; const p = useRoute().params;
const layoutKey = ref<string>(`${p.layerId}_${p.entity}_${p.name}`); const layoutKey = ref<string>(`${p.layerId}_${p.entity}_${p.name}`);
const hasDuration = ref<boolean>(false);
const widgetLink = ref<string>("");
setTemplate(); setTemplate();
async function setTemplate() { async function setTemplate() {
await dashboardStore.setDashboards(); await dashboardStore.setDashboards();
@ -108,6 +125,8 @@ limitations under the License. -->
t, t,
handleClick, handleClick,
dashboardStore, dashboardStore,
hasDuration,
widgetLink,
}; };
}, },
}); });
@ -116,4 +135,8 @@ limitations under the License. -->
.ds-main { .ds-main {
overflow: auto; overflow: auto;
} }
.link {
color: #999;
}
</style> </style>

View File

@ -38,6 +38,9 @@ limitations under the License. -->
<div class="tools" @click="removeWidget"> <div class="tools" @click="removeWidget">
<span>{{ t("delete") }}</span> <span>{{ t("delete") }}</span>
</div> </div>
<div class="tools" @click="generateLink">
<span>{{ t("generateLink") }}</span>
</div>
</el-popover> </el-popover>
</div> </div>
</div> </div>
@ -161,6 +164,9 @@ limitations under the License. -->
} }
} }
} }
function generateLink() {
dashboardStore.setWidgetLink(true);
}
watch( watch(
() => [props.data.metricTypes, props.data.metrics], () => [props.data.metricTypes, props.data.metrics],
() => { () => {
@ -227,6 +233,7 @@ limitations under the License. -->
state, state,
appStore, appStore,
removeWidget, removeWidget,
generateLink,
editConfig, editConfig,
data, data,
loading, loading,