| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <template>
- <dashboard-cards ref="dashboardCards" useLocalPanels :extraParams="extraParams" :localPanels="localPanels" />
- </template>
- <script>
- import WindowsMixin from '@/mixins/windows'
- import DashboardCards from '@Monitor/components/MonitorCard/DashboardCards'
- import { WIRE_MONITOR_OPTS } from '../constants'
- export default {
- name: 'WireMonitorSidepage',
- components: {
- DashboardCards,
- },
- mixins: [WindowsMixin],
- props: {
- data: { // listItemData
- type: Object,
- required: true,
- },
- },
- data () {
- return {
- singleActions: [
- ],
- }
- },
- computed: {
- monitorConstants () {
- return WIRE_MONITOR_OPTS
- },
- wireId () {
- return this.data.id
- },
- localPanels () {
- return this.monitorConstants.map(item => {
- return {
- panel_name: `${item.label}${item.metric ? `(${item.metric})` : `(${item.fromItem}.${item.seleteItem})`}`,
- constants: item,
- queryData: this.genQueryData(item),
- }
- })
- },
- },
- created () {
- },
- methods: {
- genQueryData (val) {
- const opt = val
- let select = []
- if (val.as) {
- const asItems = val.as.split(',')
- select = val.seleteItem.split(',').map((val, i) => {
- return [
- {
- type: 'field',
- params: [val],
- },
- { // 对应 mean(val.seleteItem)
- type: opt.groupFunc || 'mean',
- params: [],
- },
- { // 确保后端返回columns有 val.label 的别名
- type: 'alias',
- params: [asItems[i]],
- },
- ]
- })
- } else {
- select = val.seleteItem.split(',').map((val, i) => {
- return [
- {
- type: 'field',
- params: [val],
- },
- { // 对应 mean(val.seleteItem)
- type: opt.groupFunc || 'mean',
- params: [],
- },
- { // 确保后端返回columns有 val.label 的别名
- type: 'alias',
- params: [val],
- },
- ]
- })
- }
- const data = {
- metric_query: [
- {
- model: {
- measurement: val.fromItem,
- select,
- group_by: [
- { type: 'tag', params: ['id'] },
- ],
- tags: [
- {
- key: 'id',
- value: this.wireId,
- operator: '=',
- },
- ],
- },
- },
- ],
- scope: this.$store.getters.scope,
- unit: true,
- }
- return data
- },
- },
- }
- </script>
|