reload dashboards

This commit is contained in:
Qiuxia Fan 2022-03-22 16:31:47 +08:00
parent 99aefea739
commit ecd046c663
6 changed files with 47 additions and 7 deletions

View File

@ -122,6 +122,7 @@ const msg = {
editWarning: "You are entering edit mode", editWarning: "You are entering edit mode",
viewWarning: "You are entering view mode", viewWarning: "You are entering view mode",
virtualDatabase: "Virtual Database", virtualDatabase: "Virtual Database",
reloadDashboards: "Reload dashboards",
hourTip: "Select Hour", hourTip: "Select Hour",
minuteTip: "Select Minute", minuteTip: "Select Minute",
secondTip: "Select Second", secondTip: "Select Second",

View File

@ -122,6 +122,7 @@ const msg = {
editWarning: "你正在进入编辑模式", editWarning: "你正在进入编辑模式",
viewWarning: "你正在进入预览模式", viewWarning: "你正在进入预览模式",
virtualDatabase: "虚拟数据库", virtualDatabase: "虚拟数据库",
reloadDashboards: "重新加载仪表盘",
hourTip: "选择小时", hourTip: "选择小时",
minuteTip: "选择分钟", minuteTip: "选择分钟",
secondTip: "选择秒数", secondTip: "选择秒数",

View File

@ -326,6 +326,17 @@ export const dashboardStore = defineStore({
sessionStorage.getItem("dashboards") || "[]" sessionStorage.getItem("dashboards") || "[]"
); );
}, },
async resetTemplates() {
const res = await this.fetchTemplates();
if (res.errors) {
this.dashboards = [];
ElMessage.error(res.errors);
return;
}
this.dashboards = JSON.parse(
sessionStorage.getItem("dashboards") || "[]"
);
},
async updateDashboard(setting: { id: string; configuration: string }) { async updateDashboard(setting: { id: string; configuration: string }) {
const res: AxiosResponse = await graphql.query("updateTemplate").params({ const res: AxiosResponse = await graphql.query("updateTemplate").params({
setting, setting,

View File

@ -18,7 +18,7 @@ limitations under the License. -->
<el-input <el-input
v-model="searchText" v-model="searchText"
placeholder="Please input name" placeholder="Please input name"
class="input-with-search" class="input-with-search ml-10"
size="small" size="small"
@change="searchDashboards" @change="searchDashboards"
> >
@ -28,6 +28,10 @@ limitations under the License. -->
</el-button> </el-button>
</template> </template>
</el-input> </el-input>
<el-button class="ml-10" size="small" @click="reloadTemplates">
<Icon size="sm" iconName="retry" class="reload" />
{{ t("reloadDashboards") }}
</el-button>
<router-link to="/dashboard/new"> <router-link to="/dashboard/new">
<el-button size="small" type="primary"> <el-button size="small" type="primary">
+ {{ t("newDashboard") }} + {{ t("newDashboard") }}
@ -37,7 +41,7 @@ limitations under the License. -->
<div class="table"> <div class="table">
<el-table <el-table
:data="dashboards" :data="dashboards"
:style="{ width: '100%', fontSize: '13px' }" :style="{ fontSize: '13px', width: '100%' }"
v-loading="loading" v-loading="loading"
ref="multipleTableRef" ref="multipleTableRef"
:default-sort="{ prop: 'name' }" :default-sort="{ prop: 'name' }"
@ -46,21 +50,21 @@ limitations under the License. -->
<el-table-column type="selection" width="55" /> <el-table-column type="selection" width="55" />
<el-table-column prop="name" label="Name"> <el-table-column prop="name" label="Name">
<template #default="scope"> <template #default="scope">
<span class="cp" @click="handleView(scope.row)">{{ <span class="cp name" @click="handleView(scope.row)">{{
scope.row.name scope.row.name
}}</span> }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="layer" label="Layer" width="200" /> <el-table-column prop="layer" label="Layer" width="200" />
<el-table-column prop="entity" label="Entity" width="200" /> <el-table-column prop="entity" label="Entity" width="200" />
<el-table-column prop="isRoot" label="Root" width="100"> <el-table-column prop="isRoot" label="Root" width="60">
<template #default="scope"> <template #default="scope">
<span> <span>
{{ scope.row.isRoot ? t("yes") : t("no") }} {{ scope.row.isRoot ? t("yes") : t("no") }}
</span> </span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="Operations"> <el-table-column label="Operations" width="350">
<template #default="scope"> <template #default="scope">
<el-button size="small" @click="handleEdit(scope.row)"> <el-button size="small" @click="handleEdit(scope.row)">
{{ t("edit") }} {{ t("edit") }}
@ -365,6 +369,10 @@ function searchDashboards() {
d.name.includes(searchText.value) d.name.includes(searchText.value)
); );
} }
function reloadTemplates() {
dashboardStore.resetTemplates();
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.header { .header {
@ -373,11 +381,12 @@ function searchDashboards() {
.dashboard-list { .dashboard-list {
padding: 20px; padding: 20px;
width: 100%;
overflow: hidden;
} }
.input-with-search { .input-with-search {
width: 300px; width: 250px;
margin-left: 20px;
} }
.table { .table {
@ -385,6 +394,8 @@ function searchDashboards() {
background-color: #fff; background-color: #fff;
box-shadow: 0px 1px 4px 0px #00000029; box-shadow: 0px 1px 4px 0px #00000029;
border-radius: 5px; border-radius: 5px;
width: 100%;
overflow: hidden;
} }
.toggle-selection { .toggle-selection {
@ -407,4 +418,12 @@ function searchDashboards() {
width: 220px; width: 220px;
cursor: pointer; cursor: pointer;
} }
.name {
color: #409eff;
}
.reload {
margin-right: 3px;
}
</style> </style>

View File

@ -168,6 +168,10 @@ function clickInstance(scope: any) {
layer: dashboardStore.layerId, layer: dashboardStore.layerId,
entity: EntityType[3].value, entity: EntityType[3].value,
}); });
if (!d) {
ElMessage.error("No this dashboard");
return;
}
dashboardStore.setCurrentDashboard(d); dashboardStore.setCurrentDashboard(d);
dashboardStore.setEntity(d.entity); dashboardStore.setEntity(d.entity);
router.push( router.push(

View File

@ -179,6 +179,10 @@ function clickService(scope: any) {
layer: dashboardStore.layerId, layer: dashboardStore.layerId,
entity: EntityType[0].value, entity: EntityType[0].value,
}); });
if (!d) {
ElMessage.error("No this dashboard");
return;
}
dashboardStore.setCurrentDashboard(d); dashboardStore.setCurrentDashboard(d);
dashboardStore.setEntity(d.entity); dashboardStore.setEntity(d.entity);
const path = `/dashboard/${d.layer}/${d.entity}/${scope.row.id}/${d.name const path = `/dashboard/${d.layer}/${d.entity}/${scope.row.id}/${d.name