-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
268 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
static_source/admin/src/views/Dashboard/card_items/icon/editor.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<script setup lang="ts"> | ||
import {computed, onMounted, PropType, ref, unref, watch} from "vue"; | ||
import {Card, CardItem, comparisonType, Core, requestCurrentState, Tab} from "@/views/Dashboard/core"; | ||
import ViewCard from "@/views/Dashboard/editor/ViewCard.vue"; | ||
import {ElDivider, ElCollapse, ElCollapseItem, ElCard, ElForm, ElFormItem, ElPopconfirm, ElSwitch, | ||
ElRow, ElCol, ElSelect, ElOption, ElInput, ElTag, ElButton, ElColorPicker, ElInputNumber } from 'element-plus' | ||
import CommonEditor from "@/views/Dashboard/card_items/common/editor.vue"; | ||
import {useI18n} from "@/hooks/web/useI18n"; | ||
import {Cache, GetTokens} from "@/views/Dashboard/render"; | ||
import Viewer from "@/components/JsonViewer/JsonViewer.vue"; | ||
const {t} = useI18n() | ||
// --------------------------------- | ||
// common | ||
// --------------------------------- | ||
const _cache: Cache = new Cache(); | ||
const props = defineProps({ | ||
core: { | ||
type: Object as PropType<Core>, | ||
}, | ||
item: { | ||
type: Object as PropType<Nullable<CardItem>>, | ||
default: () => null | ||
}, | ||
}) | ||
const currentItem = computed({ | ||
get(): CardItem { | ||
return props.item as CardItem | ||
}, | ||
set(val: CardItem) {} | ||
}) | ||
// --------------------------------- | ||
// component methods | ||
// --------------------------------- | ||
const updateCurrentState = () => { | ||
if (currentItem.value.entityId) { | ||
requestCurrentState(currentItem.value?.entityId) | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
|
||
<CommonEditor :item="currentItem" :core="core"/> | ||
|
||
<ElDivider content-position="left">{{ $t('dashboard.editor.iconOptions') }}</ElDivider> | ||
|
||
<ElRow :gutter="24"> | ||
<ElCol :span="8" :xs="8"> | ||
<ElFormItem :label="$t('dashboard.editor.icon')" prop="icon"> | ||
<ElInput v-model="currentItem.payload.icon.value" /> | ||
</ElFormItem> | ||
</ElCol> | ||
<ElCol :span="8" :xs="8"> | ||
<ElFormItem :label="$t('dashboard.editor.iconColor')" prop="iconColor"> | ||
<ElColorPicker show-alpha v-model="currentItem.payload.icon.iconColor"/> | ||
</ElFormItem> | ||
</ElCol> | ||
<ElCol :span="8" :xs="8"> | ||
<ElFormItem :label="$t('dashboard.editor.iconSize')" prop="iconSize"> | ||
<ElInputNumber size="small" v-model="currentItem.payload.icon.iconSize" :min="1" :value-on-clear="12"/> | ||
</ElFormItem> | ||
</ElCol> | ||
</ElRow> | ||
|
||
<ElFormItem :label="$t('dashboard.editor.attrField')" prop="text"> | ||
<ElInput size="small" v-model="currentItem.payload.icon.attrField"/> | ||
</ElFormItem> | ||
|
||
<ElRow style="padding-bottom: 20px" v-if="currentItem.entity"> | ||
<ElCol> | ||
<ElCollapse> | ||
<ElCollapseItem :title="$t('dashboard.editor.eventstateJSONobject')"> | ||
<ElButton type="default" @click.prevent.stop="updateCurrentState()" style="margin-bottom: 20px"> | ||
<Icon icon="ep:refresh" class="mr-5px"/> | ||
{{ $t('dashboard.editor.getEvent') }} | ||
</ElButton> | ||
|
||
<Viewer v-model="currentItem.lastEvent"/> | ||
|
||
</ElCollapseItem> | ||
</ElCollapse> | ||
</ElCol> | ||
</ElRow> | ||
|
||
</template> | ||
|
||
<style lang="less" > | ||
</style> |
95 changes: 95 additions & 0 deletions
95
static_source/admin/src/views/Dashboard/card_items/icon/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<script setup lang="ts"> | ||
import {computed, onMounted, onUnmounted, PropType, ref, unref, watch} from "vue"; | ||
import {ButtonAction, Card, CardItem, Core, requestCurrentState, Tab} from "@/views/Dashboard/core"; | ||
import {Cache, Compare, GetTokens, RenderText, Resolve} from "@/views/Dashboard/render"; | ||
import {ElImage, ElIcon} from "element-plus"; | ||
import { Picture as IconPicture } from '@element-plus/icons-vue' | ||
import {Attribute, GetAttrValue} from "@/api/stream_types"; | ||
import {debounce} from "lodash-es"; | ||
// --------------------------------- | ||
// common | ||
// --------------------------------- | ||
const props = defineProps({ | ||
item: { | ||
type: Object as PropType<Nullable<CardItem>>, | ||
default: () => null | ||
}, | ||
}) | ||
const el = ref(null) | ||
onMounted(() => { | ||
// store dom element moveable | ||
props.item.setTarget(el.value) | ||
}) | ||
onUnmounted(() => { | ||
}) | ||
// --------------------------------- | ||
// component methods | ||
// --------------------------------- | ||
const reloadKey = ref(0) | ||
const icon = ref<Nullable<string>>(null) | ||
const iconSize = ref<Nullable<number>>(null) | ||
const iconColor = ref<Nullable<string>>(null) | ||
const reload = () => { | ||
reloadKey.value += 1 | ||
} | ||
const update = debounce(() => { | ||
if (!props.item?.payload?.icon) { | ||
return; | ||
} | ||
iconColor.value = props.item?.payload?.icon?.iconColor || '#000000'; | ||
iconSize.value = props.item?.payload?.icon?.iconSize || 14; | ||
if (props.item?.payload.icon.attrField) { | ||
icon.value = RenderText([props.item?.payload.icon.attrField], '[' + props.item?.payload.icon.attrField + ']', props.item?.lastEvent); | ||
return | ||
} | ||
icon.value = props.item?.payload.icon?.value || ''; | ||
return; | ||
}, 100) | ||
watch( | ||
() => props.item, | ||
(val?: CardItem) => { | ||
if (!val) return; | ||
update() | ||
}, | ||
{ | ||
deep: true, | ||
immediate: true | ||
} | ||
) | ||
update(); | ||
</script> | ||
|
||
<template> | ||
<div ref="el" :class="[{'hidden': item.hidden}]" style="width: 100%; height: 100%"> | ||
<Icon | ||
style="width: 100%; height: 100%" | ||
:key="reloadKey" | ||
:icon="icon" | ||
:color="iconColor" | ||
:size="iconSize" /> | ||
</div> | ||
|
||
</template> | ||
|
||
<style lang="less" > | ||
.el-image__error, .el-image__placeholder, .el-image__inner { | ||
height: auto; | ||
} | ||
.el-image.item-element { | ||
overflow: visible; | ||
} | ||
</style> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.