Merge pull request #4145 from dataease/pr@dev@feat_view-refresh

feat(视图): 视图可以单独设置刷新频率
This commit is contained in:
王嘉豪 2022-12-21 12:08:32 +08:00 committed by GitHub
commit 4cb5752f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 652 additions and 504 deletions

View File

@ -9,13 +9,10 @@
</resultMap>
<select id="findByPanelId" resultMap="BaseResultMapDTO">
SELECT
chart_view.*
FROM
chart_view
SELECT chart_view.*
FROM chart_view
LEFT JOIN panel_view ON chart_view.id = panel_view.chart_view_id
WHERE
panel_view.panel_id = #{panelId}
WHERE panel_view.panel_id = #{panelId}
</select>
<select id="searchOneWithPrivileges" resultMap="BaseResultMapDTO">
@ -25,14 +22,13 @@
</select>
<select id="searchOne" resultMap="BaseResultMapDTO">
select
chart_view.*
from chart_view where id = #{id}
select chart_view.*
from chart_view
where id = #{id}
</select>
<insert id="copyToCache">
INSERT INTO chart_view_cache (
id,
INSERT INTO chart_view_cache (id,
`name`,
title,
scene_id,
@ -59,9 +55,11 @@
drill_fields,
senior,
SNAPSHOT,
data_from
) SELECT
id,
data_from,
refresh_view_enable,
refresh_unit,
refresh_time)
SELECT id,
`name`,
title,
scene_id,
@ -88,14 +86,16 @@
drill_fields,
senior,
SNAPSHOT,
data_from from chart_view
WHERE
chart_view.id = #{id}
data_from,
refresh_view_enable,
refresh_unit,
refresh_time
from chart_view
WHERE chart_view.id = #{id}
</insert>
<insert id="copyCache">
INSERT INTO chart_view_cache (
id,
INSERT INTO chart_view_cache (id,
`name`,
title,
scene_id,
@ -122,9 +122,11 @@
drill_fields,
senior,
SNAPSHOT,
data_from
) SELECT
#{newViewId} as id,
data_from,
refresh_view_enable,
refresh_unit,
refresh_time)
SELECT #{newViewId} as id,
`name`,
title,
scene_id,
@ -151,14 +153,16 @@
drill_fields,
senior,
SNAPSHOT,
data_from from chart_view_cache
WHERE
chart_view_cache.id = #{sourceViewId}
data_from,
refresh_view_enable,
refresh_unit,
refresh_time
from chart_view_cache
WHERE chart_view_cache.id = #{sourceViewId}
</insert>
<insert id="initPanelChartViewCache">
INSERT INTO chart_view_cache (
id,
INSERT INTO chart_view_cache (id,
`name`,
title,
scene_id,
@ -185,9 +189,11 @@
drill_fields,
senior,
SNAPSHOT,
data_from
) SELECT
id,
data_from,
refresh_view_enable,
refresh_unit,
refresh_time)
SELECT id,
`name`,
title,
scene_id,
@ -214,9 +220,12 @@
drill_fields,
senior,
SNAPSHOT,
data_from from chart_view
WHERE
chart_view.scene_id = #{panelId}
data_from,
refresh_view_enable,
refresh_unit,
refresh_time
from chart_view
WHERE chart_view.scene_id = #{panelId}
</insert>
<select id="search" resultMap="BaseResultMapDTO">
@ -405,13 +414,11 @@
SNAPSHOT,
senior,
data_from
FROM (
SELECT panel_id,
FROM (SELECT panel_id,
copy_from_view,
chart_view_id
FROM panel_view
WHERE copy_id = #{copyId}
) pv_copy
WHERE copy_id = #{copyId}) pv_copy
INNER JOIN chart_view ON chart_view.id = pv_copy.copy_from_view
</insert>
@ -459,16 +466,11 @@
<select id="searchViewsWithPanelId" resultMap="BaseResultMapDTO">
SELECT * FROM chart_view
WHERE
id IN (
SELECT
chart_view_id
FROM
panel_view
WHERE
panel_id = #{panelId}
)
SELECT *
FROM chart_view
WHERE id IN (SELECT chart_view_id
FROM panel_view
WHERE panel_id = #{panelId})
</select>
<delete id="deleteCacheWithPanel">
@ -482,7 +484,9 @@
</if>
</delete>
<delete id="deleteViewCache">
delete from chart_view_cache where id = #{viewId}
delete
from chart_view_cache
where id = #{viewId}
</delete>
<update id="copyCacheToView">
@ -514,7 +518,10 @@
cv.drill_fields = cve.drill_fields,
cv.senior = cve.senior,
cv.SNAPSHOT = cve.SNAPSHOT,
cv.data_from = cve.data_from
cv.data_from = cve.data_from,
cv.refresh_view_enable = cve.refresh_view_enable,
cv.refresh_unit = cve.refresh_unit,
cv.refresh_time = cve.refresh_time
where cve.id = cv.id and cv.id in
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
#{viewId}
@ -550,7 +557,10 @@
cv.drill_fields = cve.drill_fields,
cv.senior = cve.senior,
cv.SNAPSHOT = cve.SNAPSHOT,
cv.data_from = cve.data_from
cv.data_from = cve.data_from,
cv.refresh_view_enable = cve.refresh_view_enable,
cv.refresh_unit = cve.refresh_unit,
cv.refresh_time = cve.refresh_time
where cve.id = cv.id and cv.id =#{viewId}
</update>
@ -584,7 +594,10 @@
cv.drill_fields = cve.drill_fields,
cv.senior = cve.senior,
cv.SNAPSHOT = cve.SNAPSHOT,
cv.data_from = cve.data_from
cv.data_from = cve.data_from,
cv.refresh_view_enable = cve.refresh_view_enable,
cv.refresh_unit = cve.refresh_unit,
cv.refresh_time = cve.refresh_time
where cve.id = cv.id and cv.id =#{viewId}
</update>
@ -600,12 +613,13 @@
</delete>
<select id="chartOptions" resultType="io.dataease.dto.chart.ViewOption">
select id, title as name from chart_view where scene_id = #{panelId}
select id, title as name
from chart_view
where scene_id = #{panelId}
</select>
<insert id='chartFiledCopyWithPanel'>
INSERT INTO chart_view_field (
id,
INSERT INTO chart_view_field (id,
table_id,
chart_id,
origin_name,
@ -620,9 +634,8 @@
ext_field,
`checked`,
column_index,
last_sync_time
) SELECT
uuid() AS id,
last_sync_time)
SELECT uuid() AS id,
chart_view_field.table_id,
chart_view_field.pv_copy.chart_view_id AS chart_id,
chart_view_field.origin_name,
@ -638,17 +651,11 @@
chart_view_field.`checked`,
chart_view_field.column_index,
chart_view_field.last_sync_time
FROM
(
SELECT
panel_id,
FROM (SELECT panel_id,
copy_from_view,
chart_view_id
FROM
panel_view
WHERE
copy_id = #{copyId}
) pv_copy
FROM panel_view
WHERE copy_id = #{copyId}) pv_copy
INNER JOIN chart_view_field ON chart_view_field.chart_id = pv_copy.copy_from_view
</insert>
</mapper>

View File

@ -10,8 +10,25 @@ ALTER TABLE `sys_task`
ADD COLUMN `status` tinyint(1) NULL DEFAULT 1 COMMENT '运行状态' AFTER `create_time`;
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`) VALUES (1100, 1, 0, 1, '血缘关系', 'sys-relationship', 'system/relationship/index', 1002, 'sys-relationship', 'relationship', 0, 0, 0, 'relationship:read');
INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`,
`path`, `i_frame`, `cache`, `hidden`, `permission`)
VALUES (1100, 1, 0, 1, '血缘关系', 'sys-relationship', 'system/relationship/index', 1002, 'sys-relationship',
'relationship', 0, 0, 0, 'relationship:read');
UPDATE `sys_menu` SET `menu_sort` = 1003 WHERE (`menu_id` = 101);
UPDATE `sys_menu`
SET `menu_sort` = 1003
WHERE (`menu_id` = 101);
UPDATE `my_plugin` SET `version` = '1.18.0' where `plugin_id` > 0;
UPDATE `my_plugin`
SET `version` = '1.18.0'
where `plugin_id` > 0;
ALTER TABLE `chart_view`
ADD COLUMN `refresh_view_enable` tinyint(1) NULL DEFAULT 0 COMMENT '是否开启刷新' AFTER `view_fields`,
ADD COLUMN `refresh_unit` varchar(255) NULL DEFAULT 'minute' COMMENT '刷新时间单位' AFTER `refresh_view_enable`,
ADD COLUMN `refresh_time` int(13) NULL DEFAULT 5 COMMENT '刷新时间' AFTER `refresh_unit`;
ALTER TABLE `chart_view_cache`
ADD COLUMN `refresh_view_enable` tinyint(1) NULL DEFAULT 0 COMMENT '是否开启刷新' AFTER `view_fields`,
ADD COLUMN `refresh_unit` varchar(255) NULL DEFAULT 'minute' COMMENT '刷新时间单位' AFTER `refresh_view_enable`,
ADD COLUMN `refresh_time` int(13) NULL DEFAULT 5 COMMENT '刷新时间' AFTER `refresh_unit`;

View File

@ -496,19 +496,7 @@ export default {
},
// sourceViewId
clearLinkage() {
this.componentData.forEach(item => {
if (item.linkageFilters && item.linkageFilters.length > 0) {
const newList = item.linkageFilters.filter(linkage => linkage.sourceViewId !== this.element.propValue.viewId)
item.linkageFilters.splice(0, item.linkageFilters.length)
// push watch
if (newList.length > 0) {
newList.forEach(newLinkage => {
item.linkageFilters.push(newLinkage)
})
}
}
})
bus.$emit('clear_panel_linkage', { viewId: this.element.propValue.viewId })
this.$store.commit('clearViewLinkage', this.element.propValue.viewId)
},
goFile() {
this.$refs.files.click()

View File

@ -305,6 +305,7 @@ export default {
},
data() {
return {
innerRefreshTimer: null,
mobileChartDetailsVisible: false,
chartDetailsVisible: false,
showChartInfo: {},
@ -393,7 +394,7 @@ export default {
return this.httpRequest.status && this.chart.type && this.chart.type === 'label'
},
loadingFlag() {
return (this.canvasStyleData.refreshViewLoading || this.searchCount === 0) && this.requestStatus === 'waiting'
return (this.canvasStyleData.refreshViewLoading || (!this.innerRefreshTimer && this.searchCount === 0)) && this.requestStatus === 'waiting'
},
panelInfo() {
return this.$store.state.panel.panelInfo
@ -520,7 +521,8 @@ export default {
},
//
searchCount: function(val1) {
if (val1 > 0 && this.requestStatus !== 'waiting') {
//
if (val1 > 0 && this.requestStatus !== 'waiting' && !this.innerRefreshTimer) {
this.getData(this.element.propValue.viewId)
}
},
@ -547,6 +549,7 @@ export default {
},
beforeDestroy() {
this.innerRefreshTimer && clearInterval(this.innerRefreshTimer)
bus.$off('plugin-chart-click', this.pluginChartClick)
bus.$off('plugin-jump-click', this.pluginJumpClick)
bus.$off('plugin-add-view-track-filter', this.pluginAddViewTrackFilter)
@ -566,6 +569,20 @@ export default {
}
},
methods: {
//
buildInnerRefreshTimer(refreshViewEnable = false, refreshUnit = 'minute', refreshTime = 5) {
if (this.editMode === 'preview' && !this.innerRefreshTimer && refreshViewEnable) {
this.innerRefreshTimer && clearInterval(this.innerRefreshTimer)
const timerRefreshTime = refreshUnit === 'second' ? refreshTime * 1000 : refreshTime * 60000
this.innerRefreshTimer = setInterval(() => {
this.clearViewLinkage()
this.getData(this.element.propValue.viewId)
}, timerRefreshTime)
}
},
clearViewLinkage() {
this.$store.commit('clearViewLinkage', this.element.propValue.viewId)
},
responseResetButton() {
if (!this.cfilters?.length) {
this.getData(this.element.propValue.viewId, false)
@ -741,6 +758,7 @@ export default {
if (response.success) {
this.chart = response.data
this.view = response.data
this.buildInnerRefreshTimer(this.chart.refreshViewEnable, this.chart.refreshUnit, this.chart.refreshTime)
this.$emit('fill-chart-2-parent', this.chart)
this.getDataOnly(response.data, dataBroadcast)
this.chart['position'] = this.inTab ? 'tab' : 'panel'

View File

@ -931,6 +931,7 @@ export default {
password_input_error: 'Original password input error'
},
chart: {
chart_refresh_tips: 'View refresh setting takes precedence over panel refresh setting',
'1-trend': 'trend',
'2-state': 'State',
'3-rank': 'Rank',

View File

@ -930,6 +930,7 @@ export default {
password_input_error: '原始密碼輸入錯誤'
},
chart: {
chart_refresh_tips: '視圖刷新設置優先於儀表板刷新設置',
'1-trend': '趨勢',
'2-state': '狀態',
'3-rank': '排名',

View File

@ -929,6 +929,7 @@ export default {
password_input_error: '原始密码输入错误'
},
chart: {
chart_refresh_tips: '视图刷新设置优先于仪表板刷新设置',
'1-trend': '趋势',
'2-state': '状态',
'3-rank': '排名',

View File

@ -824,6 +824,23 @@ const data = {
}
}
}
},
// 清除相同sourceViewId 的 联动条件
clearViewLinkage(state, viewId) {
state.componentData.forEach(item => {
if (item.linkageFilters && item.linkageFilters.length > 0) {
const newList = item.linkageFilters.filter(linkage => linkage.sourceViewId !== viewId)
item.linkageFilters.splice(0, item.linkageFilters.length)
// 重新push 可保证数组指针不变 可以watch到
if (newList.length > 0) {
newList.forEach(newLinkage => {
item.linkageFilters.push(newLinkage)
})
}
}
})
bus.$emit('clear_panel_linkage', { viewId: viewId })
}
},
modules: {

View File

@ -235,12 +235,14 @@
<el-button
size="mini"
@click="close()"
>{{ $t('chart.cancel') }}</el-button>
>{{ $t('chart.cancel') }}
</el-button>
<el-button
type="primary"
size="mini"
@click="saveGroup(groupForm)"
>{{ $t('chart.confirm') }}</el-button>
>{{ $t('chart.confirm') }}
</el-button>
</div>
</el-dialog>
</el-col>
@ -274,12 +276,14 @@
<el-button
size="mini"
@click="closeTable()"
>{{ $t('chart.cancel') }}</el-button>
>{{ $t('chart.cancel') }}
</el-button>
<el-button
type="primary"
size="mini"
@click="saveTable(tableForm)"
>{{ $t('chart.confirm') }}</el-button>
>{{ $t('chart.confirm') }}
</el-button>
</div>
</el-dialog>
@ -385,13 +389,15 @@
<el-button
size="mini"
@click="closeCreateChart"
>{{ $t('chart.cancel') }}</el-button>
>{{ $t('chart.cancel') }}
</el-button>
<el-button
v-if="createActive === 2"
type="primary"
size="mini"
@click="createPreview"
>{{ $t('chart.preview')
>{{
$t('chart.preview')
}}
</el-button>
<el-button
@ -433,14 +439,16 @@
<el-button
size="mini"
@click="closeMoveGroup()"
>{{ $t('dataset.cancel') }}</el-button>
>{{ $t('dataset.cancel') }}
</el-button>
<el-button
:disabled="groupMoveConfirmDisabled"
type="primary"
size="mini"
@click="saveMoveGroup(tGroup)"
>{{
$t('dataset.confirm') }}
$t('dataset.confirm')
}}
</el-button>
</div>
</el-dialog>
@ -465,14 +473,16 @@
<el-button
size="mini"
@click="closeMoveDs()"
>{{ $t('dataset.cancel') }}</el-button>
>{{ $t('dataset.cancel') }}
</el-button>
<el-button
:disabled="dsMoveConfirmDisabled"
type="primary"
size="mini"
@click="saveMoveDs(tDs)"
>{{
$t('dataset.confirm') }}
$t('dataset.confirm')
}}
</el-button>
</div>
</el-dialog>
@ -480,27 +490,26 @@
</template>
<script>
import { post, chartGroupTree } from '@/api/chart/chart'
import { chartGroupTree, pluginTypes, post } from '@/api/chart/chart'
import { queryAuthModel } from '@/api/authModel/authModel'
import TableSelector from '../view/TableSelector'
import GroupMoveSelector from '../components/treeSelector/GroupMoveSelector'
import ChartMoveSelector from '../components/treeSelector/ChartMoveSelector'
import ChartType from '@/views/chart/view/ChartType'
import { pluginTypes } from '@/api/chart/chart'
import {
DEFAULT_COLOR_CASE,
DEFAULT_FUNCTION_CFG,
DEFAULT_LABEL,
DEFAULT_LEGEND_STYLE,
DEFAULT_SIZE,
DEFAULT_SPLIT,
DEFAULT_THRESHOLD,
DEFAULT_TITLE_STYLE,
DEFAULT_TOOLTIP,
DEFAULT_TOTAL,
DEFAULT_XAXIS_STYLE,
DEFAULT_YAXIS_STYLE,
DEFAULT_YAXIS_EXT_STYLE,
DEFAULT_SPLIT,
DEFAULT_FUNCTION_CFG,
DEFAULT_THRESHOLD,
DEFAULT_TOTAL
DEFAULT_YAXIS_STYLE
} from '../chart/chart'
import { checkViewTitle } from '@/components/canvas/utils/utils'
import { adaptCurTheme } from '@/components/canvas/utils/style'
@ -977,6 +986,9 @@ export default {
view.render = this.view.render
view.resultMode = 'custom'
view.resultCount = 1000
view.refreshViewEnable = false
view.refreshUnit = 'minute'
view.refreshTime = 5
const customAttr = {
color: DEFAULT_COLOR_CASE,
tableColor: DEFAULT_COLOR_CASE,

View File

@ -406,6 +406,68 @@
</el-radio-group>
</el-row>
</el-row>
<el-row class="padding-lr">
<!-- <span-->
<!-- style="color: #909399; font-size: 8px;width: 80px;text-align: right;"-->
<!-- >-->
<!-- Tips:{{ $t('chart.rich_text_view_result_tips') }}-->
<!-- </span>-->
<span
style="width: 80px;text-align: right;"
>
{{ $t('panel.refresh_frequency') }}
</span>
<el-tooltip
class="item"
effect="dark"
placement="bottom"
>
<div slot="content">
{{ $t('chart.chart_refresh_tips') }}
</div>
<i
class="el-icon-info"
style="cursor: pointer;color: #606266;font-size: 12px"
/>
</el-tooltip>
<span class="padding-lr">
<el-checkbox
v-model="view.refreshViewEnable"
class="el-input-refresh-loading"
@change="refreshAttrChange"
></el-checkbox>
{{ $t('panel.enable_refresh_view') }}
</span>
<el-row>
<el-input
v-model="view.refreshTime"
class="el-input-refresh-time"
type="number"
size="mini"
controls-position="right"
:min="1"
:max="3600"
:disabled="!view.refreshViewEnable"
@change="refreshAttrChange"
/>
<el-select
v-model="view.refreshUnit"
class="el-input-refresh-unit margin-left8"
size="mini"
:disabled="!view.refreshViewEnable"
@change="refreshAttrChange"
>
<el-option
:label="$t('panel.minute')"
:value="'minute'"
/>
<el-option
:label="$t('panel.second')"
:value="'second'"
/>
</el-select>
</el-row>
</el-row>
<plugin-com
v-if="view.isPlugin"
@ -1622,8 +1684,8 @@ import {
pluginTypes,
post,
resetViewCacheCallBack,
viewEditSave,
tableField
tableField,
viewEditSave
} from '@/api/chart/chart'
import DimensionItem from '../components/dragItem/DimensionItem'
import QuotaItem from '../components/dragItem/QuotaItem'
@ -1683,6 +1745,7 @@ import CalcChartFieldEdit from '@/views/chart/view/CalcChartFieldEdit'
import { equalsAny } from '@/utils/StringUtils'
import PositionAdjust from '@/views/chart/view/PositionAdjust'
import MarkMapDataEditor from '@/views/chart/components/map/MarkMapDataEditor'
export default {
name: 'ChartEdit',
components: {
@ -1759,6 +1822,9 @@ export default {
show: true,
type: 'bar',
title: '',
refreshViewEnable: false,
refreshUnit: 'minute',
refreshTime: 5,
customAttr: {
color: DEFAULT_COLOR_CASE,
size: DEFAULT_SIZE,
@ -2291,6 +2357,12 @@ export default {
delete view.data
return view
},
refreshAttrChange(switchType = false, switchRender = false) {
this.changeEditStatus(true)
const view = this.buildParam(true, 'chart', false, switchType, switchRender)
if (!view) return
viewEditSave(this.panelInfo.id, view)
},
calcData(getData, trigger, needRefreshGroup = false, switchType = false, switchRender = false) {
this.changeEditStatus(true)
const view = this.buildParam(true, 'chart', false, switchType, switchRender)
@ -3834,4 +3906,19 @@ span {
cursor: pointer;
z-index: 1;
}
.el-input-refresh-time {
width: calc(50% - 4px) !important;
}
.el-input-refresh-unit {
margin-left: 8px;
width: calc(50% - 4px) !important;
}
.el-input-refresh-loading {
margin-left: 4px;
font-size: 12px !important;
}
</style>

View File

@ -49,7 +49,6 @@
<el-checkbox
v-model="overallSettingForm.refreshViewLoading"
class="el-input-refresh-loading"
:disabled="!overallSettingForm.refreshViewEnable"
@change="themeChange"
>{{ $t('panel.enable_view_loading') }}</el-checkbox>
</span>