diff --git a/api/api.swagger3.yaml b/api/api.swagger3.yaml index 1a9a1850e..e7be9d2c1 100644 --- a/api/api.swagger3.yaml +++ b/api/api.swagger3.yaml @@ -5041,14 +5041,14 @@ components: type: string area: $ref: '#/components/schemas/apiArea' - image: - $ref: '#/components/schemas/apiImage' icon: type: string autoLoad: type: boolean parentId: type: string + isLoaded: + type: boolean createdAt: type: string format: date-time @@ -5234,7 +5234,7 @@ components: items: type: array items: - $ref: '#/components/schemas/apiEntity' + $ref: '#/components/schemas/apiEntityShort' meta: $ref: '#/components/schemas/apiMeta' apiGetEntityStorageResult: diff --git a/api/dto/entity.go b/api/dto/entity.go index 5031c38ef..2957e3f27 100644 --- a/api/dto/entity.go +++ b/api/dto/entity.go @@ -21,8 +21,7 @@ package dto import ( "fmt" - stub "github.com/e154/smart-home/api/stub" - + "github.com/e154/smart-home/api/stub" "github.com/e154/smart-home/common" m "github.com/e154/smart-home/models" ) @@ -168,12 +167,12 @@ func (r Entity) ToSearchResult(list []*m.Entity) *stub.ApiSearchEntityResult { } // ToListResult ... -func (r Entity) ToListResult(list []*m.Entity) []*stub.ApiEntity { +func (r Entity) ToListResult(list []*m.Entity) []*stub.ApiEntityShort { - items := make([]*stub.ApiEntity, 0, len(list)) + items := make([]*stub.ApiEntityShort, 0, len(list)) for _, i := range list { - items = append(items, ToEntity(i)) + items = append(items, r.ToEntityShort(i)) } return items @@ -181,7 +180,6 @@ func (r Entity) ToListResult(list []*m.Entity) []*stub.ApiEntity { // ToEntityShort ... func (r Entity) ToEntityShort(entity *m.Entity) (obj *stub.ApiEntityShort) { - imageDto := NewImageDto() obj = &stub.ApiEntityShort{ Id: entity.Id.String(), PluginName: entity.PluginName, @@ -191,6 +189,7 @@ func (r Entity) ToEntityShort(entity *m.Entity) (obj *stub.ApiEntityShort) { CreatedAt: entity.CreatedAt, UpdatedAt: entity.UpdatedAt, ParentId: entity.ParentId.StringPtr(), + IsLoaded: common.Bool(entity.IsLoaded), } // area if entity.Area != nil { @@ -200,10 +199,6 @@ func (r Entity) ToEntityShort(entity *m.Entity) (obj *stub.ApiEntityShort) { Description: entity.Area.Description, } } - // image - if entity.Image != nil { - obj.Image = imageDto.ToImage(entity.Image) - } return } @@ -241,7 +236,7 @@ func ToEntity(entity *m.Entity) (obj *stub.ApiEntity) { } // image if entity.Image != nil { - obj.Image = imageDto.ToImage(entity.Image) + obj.Image = imageDto.ToImageShort(entity.Image) } // parent if entity.ParentId != nil { @@ -263,7 +258,7 @@ func ToEntity(entity *m.Entity) (obj *stub.ApiEntity) { } // script if a.Script != nil { - action.Script = scriptDto.GetStubScript(a.Script) + action.Script = scriptDto.GetStubScriptShort(a.Script) } obj.Actions = append(obj.Actions, action) } @@ -284,7 +279,7 @@ func ToEntity(entity *m.Entity) (obj *stub.ApiEntity) { } // scripts for _, s := range entity.Scripts { - script := scriptDto.GetStubScript(s) + script := scriptDto.GetStubScriptShort(s) obj.Scripts = append(obj.Scripts, *script) obj.ScriptIds = append(obj.ScriptIds, s.Id) } diff --git a/api/dto/image.go b/api/dto/image.go index c8fb2c5eb..0c8c081f2 100644 --- a/api/dto/image.go +++ b/api/dto/image.go @@ -48,6 +48,16 @@ func (i Image) ToImage(image *m.Image) (result *stub.ApiImage) { return } +// ToImageShort ... +func (i Image) ToImageShort(image *m.Image) (result *stub.ApiImage) { + result = &stub.ApiImage{ + Id: image.Id, + Name: image.Name, + Url: image.Url, + } + return +} + // FromNewImageRequest ... func (i Image) FromNewImageRequest(req *stub.ApiNewImageRequest) (image *m.Image) { image = &m.Image{ diff --git a/api/dto/script.go b/api/dto/script.go index fdd641a10..88771bef3 100644 --- a/api/dto/script.go +++ b/api/dto/script.go @@ -72,6 +72,12 @@ func (s Script) GetStubScript(script *m.Script) (result *stub.ApiScript) { return } +// GetStubScriptShort ... +func (s Script) GetStubScriptShort(script *m.Script) (result *stub.ApiScript) { + result = GetStubScriptShort(script) + return +} + // ToSearchResult ... func (s Script) ToSearchResult(list []*m.Script) *stub.ApiSearchScriptListResult { @@ -139,6 +145,18 @@ func GetStubScript(script *m.Script) (result *stub.ApiScript) { return } +// GetStubScriptShort ... +func GetStubScriptShort(script *m.Script) (result *stub.ApiScript) { + if script == nil { + return + } + result = &stub.ApiScript{ + Id: script.Id, + Name: script.Name, + } + return +} + func ImportScript(from *stub.ApiScript) (*int64, *m.Script) { if from == nil { return nil, nil diff --git a/api/stub/types.go b/api/stub/types.go index 35eac177b..f9d1b1642 100644 --- a/api/stub/types.go +++ b/api/stub/types.go @@ -420,7 +420,7 @@ type ApiEntityShort struct { Description string `json:"description"` Icon *string `json:"icon,omitempty"` Id string `json:"id"` - Image *ApiImage `json:"image,omitempty"` + IsLoaded *bool `json:"isLoaded,omitempty"` ParentId *string `json:"parentId,omitempty"` PluginName string `json:"pluginName"` UpdatedAt time.Time `json:"updatedAt"` @@ -533,8 +533,8 @@ type ApiGetDashboardTabListResult struct { // ApiGetEntityListResult defines model for apiGetEntityListResult. type ApiGetEntityListResult struct { - Items []ApiEntity `json:"items"` - Meta *ApiMeta `json:"meta,omitempty"` + Items []ApiEntityShort `json:"items"` + Meta *ApiMeta `json:"meta,omitempty"` } // ApiGetEntityStorageResult defines model for apiGetEntityStorageResult. diff --git a/plugins/alexa/plugin.go b/plugins/alexa/plugin.go index 5f9dfac2f..bcdfbb36b 100644 --- a/plugins/alexa/plugin.go +++ b/plugins/alexa/plugin.go @@ -138,7 +138,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Server ... diff --git a/plugins/cgminer/plugin.go b/plugins/cgminer/plugin.go index ee56f1e8e..1b4a22f4f 100644 --- a/plugins/cgminer/plugin.go +++ b/plugins/cgminer/plugin.go @@ -114,7 +114,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/cpuspeed/plugin.go b/plugins/cpuspeed/plugin.go index f9ce73a56..6ddde0ec1 100644 --- a/plugins/cpuspeed/plugin.go +++ b/plugins/cpuspeed/plugin.go @@ -122,7 +122,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/email/plugin.go b/plugins/email/plugin.go index c2d02829c..1050cfa5c 100644 --- a/plugins/email/plugin.go +++ b/plugins/email/plugin.go @@ -97,7 +97,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/hdd/plugin.go b/plugins/hdd/plugin.go index 40c76d2db..0b2ac9000 100644 --- a/plugins/hdd/plugin.go +++ b/plugins/hdd/plugin.go @@ -119,7 +119,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/html5_notify/plugin.go b/plugins/html5_notify/plugin.go index dcc3a43ed..7bd6412f5 100644 --- a/plugins/html5_notify/plugin.go +++ b/plugins/html5_notify/plugin.go @@ -96,7 +96,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/logs/plugin.go b/plugins/logs/plugin.go index 6dc58e278..5fcbf0ded 100644 --- a/plugins/logs/plugin.go +++ b/plugins/logs/plugin.go @@ -108,7 +108,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/memory/plugin.go b/plugins/memory/plugin.go index 1e5a4187f..b3d8cbbfd 100644 --- a/plugins/memory/plugin.go +++ b/plugins/memory/plugin.go @@ -125,7 +125,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/memory_app/plugin.go b/plugins/memory_app/plugin.go index 6699db3cb..1afd26c2a 100644 --- a/plugins/memory_app/plugin.go +++ b/plugins/memory_app/plugin.go @@ -124,7 +124,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/messagebird/plugin.go b/plugins/messagebird/plugin.go index 532dd3be3..d691279eb 100644 --- a/plugins/messagebird/plugin.go +++ b/plugins/messagebird/plugin.go @@ -96,7 +96,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/modbus_rtu/plugin.go b/plugins/modbus_rtu/plugin.go index 264acab42..3b41f69fa 100644 --- a/plugins/modbus_rtu/plugin.go +++ b/plugins/modbus_rtu/plugin.go @@ -115,7 +115,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/modbus_tcp/plugin.go b/plugins/modbus_tcp/plugin.go index a41238bfa..d76e2af0c 100644 --- a/plugins/modbus_tcp/plugin.go +++ b/plugins/modbus_tcp/plugin.go @@ -113,7 +113,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/moon/plugin.go b/plugins/moon/plugin.go index 7454b999a..f3d9f9ceb 100644 --- a/plugins/moon/plugin.go +++ b/plugins/moon/plugin.go @@ -113,7 +113,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/mqtt/plugin.go b/plugins/mqtt/plugin.go index c3a309196..696f29fed 100644 --- a/plugins/mqtt/plugin.go +++ b/plugins/mqtt/plugin.go @@ -127,7 +127,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/mqtt_bridge/plugin.go b/plugins/mqtt_bridge/plugin.go index be5344273..dfd5904d9 100644 --- a/plugins/mqtt_bridge/plugin.go +++ b/plugins/mqtt_bridge/plugin.go @@ -117,7 +117,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/neural_network/plugin.go b/plugins/neural_network/plugin.go index ad53a3c66..182eea4f6 100644 --- a/plugins/neural_network/plugin.go +++ b/plugins/neural_network/plugin.go @@ -101,7 +101,7 @@ func (p *plugin) Depends() []string { } func (p *plugin) Version() string { - return "0.0.1" + return Version } func (p *plugin) Options() m.PluginOptions { diff --git a/plugins/node/plugin.go b/plugins/node/plugin.go index 52ebb7fe1..d5f003bf3 100644 --- a/plugins/node/plugin.go +++ b/plugins/node/plugin.go @@ -107,7 +107,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } func (p *plugin) pushToNode() { diff --git a/plugins/notify/plugin.go b/plugins/notify/plugin.go index 3a478a94a..e2a6daf74 100644 --- a/plugins/notify/plugin.go +++ b/plugins/notify/plugin.go @@ -95,5 +95,5 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } diff --git a/plugins/onvif/plugin.go b/plugins/onvif/plugin.go index a86a08829..20b7ef551 100644 --- a/plugins/onvif/plugin.go +++ b/plugins/onvif/plugin.go @@ -120,7 +120,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/scene/plugin.go b/plugins/scene/plugin.go index 6eaa7d6b6..a17f71de4 100644 --- a/plugins/scene/plugin.go +++ b/plugins/scene/plugin.go @@ -124,7 +124,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/sensor/plugin.go b/plugins/sensor/plugin.go index 08af320a7..c855b82ab 100644 --- a/plugins/sensor/plugin.go +++ b/plugins/sensor/plugin.go @@ -114,7 +114,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/slack/plugin.go b/plugins/slack/plugin.go index eea0f68ff..9bf4a716c 100644 --- a/plugins/slack/plugin.go +++ b/plugins/slack/plugin.go @@ -94,7 +94,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/sun/plugin.go b/plugins/sun/plugin.go index 775e6b0b6..b4d4346a9 100644 --- a/plugins/sun/plugin.go +++ b/plugins/sun/plugin.go @@ -106,7 +106,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/triggers/plugin.go b/plugins/triggers/plugin.go index 3b8bacf77..860be6177 100644 --- a/plugins/triggers/plugin.go +++ b/plugins/triggers/plugin.go @@ -125,7 +125,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // GetTrigger ... diff --git a/plugins/twilio/plugin.go b/plugins/twilio/plugin.go index 52aa5fcfa..b74f4981a 100644 --- a/plugins/twilio/plugin.go +++ b/plugins/twilio/plugin.go @@ -97,7 +97,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/updater/plugin.go b/plugins/updater/plugin.go index 2e66b6962..c952d94d8 100644 --- a/plugins/updater/plugin.go +++ b/plugins/updater/plugin.go @@ -132,7 +132,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } func (p *plugin) eventHandler(_ string, msg interface{}) { diff --git a/plugins/uptime/plugin.go b/plugins/uptime/plugin.go index 795bc1096..feaa55a40 100644 --- a/plugins/uptime/plugin.go +++ b/plugins/uptime/plugin.go @@ -154,7 +154,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/version/plugin.go b/plugins/version/plugin.go index add620298..d851fb45b 100644 --- a/plugins/version/plugin.go +++ b/plugins/version/plugin.go @@ -118,7 +118,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/weather_met/plugin.go b/plugins/weather_met/plugin.go index 2e31c5511..cda84c502 100644 --- a/plugins/weather_met/plugin.go +++ b/plugins/weather_met/plugin.go @@ -121,7 +121,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/weather_owm/plugin.go b/plugins/weather_owm/plugin.go index 557889d1e..640c9e8ba 100644 --- a/plugins/weather_owm/plugin.go +++ b/plugins/weather_owm/plugin.go @@ -119,7 +119,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/webpush/plugin.go b/plugins/webpush/plugin.go index 633081346..a3f9ea175 100644 --- a/plugins/webpush/plugin.go +++ b/plugins/webpush/plugin.go @@ -137,7 +137,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/plugins/zigbee2mqtt/plugin.go b/plugins/zigbee2mqtt/plugin.go index 7e84c0f07..813f1c3ce 100644 --- a/plugins/zigbee2mqtt/plugin.go +++ b/plugins/zigbee2mqtt/plugin.go @@ -160,7 +160,7 @@ func (p *plugin) Depends() []string { // Version ... func (p *plugin) Version() string { - return "0.0.1" + return Version } // Options ... diff --git a/static_source/admin/src/api/stub.ts b/static_source/admin/src/api/stub.ts index 8ac99f7f6..0599fb492 100644 --- a/static_source/admin/src/api/stub.ts +++ b/static_source/admin/src/api/stub.ts @@ -431,10 +431,10 @@ export interface ApiEntityShort { pluginName: string; description: string; area?: ApiArea; - image?: ApiImage; icon?: string; autoLoad: boolean; parentId?: string; + isLoaded?: boolean; /** @format date-time */ createdAt: string; /** @format date-time */ @@ -533,7 +533,7 @@ export interface ApiGetDashboardTabListResult { } export interface ApiGetEntityListResult { - items: ApiEntity[]; + items: ApiEntityShort[]; meta?: ApiMeta; } diff --git a/static_source/admin/src/components/Echart/src/Echart.vue b/static_source/admin/src/components/Echart/src/Echart.vue index 0b7e791ca..4db1ea0b5 100644 --- a/static_source/admin/src/components/Echart/src/Echart.vue +++ b/static_source/admin/src/components/Echart/src/Echart.vue @@ -92,11 +92,11 @@ const contentResizeHandler = async (e: TransitionEvent) => { onMounted(() => { initChart() - window.addEventListener('resize', resizeHandler) + window.addEventListener('resize', resizeHandler, {passive: true}) contentEl.value = document.getElementsByClassName(`${variables.namespace}-layout-content`)[0] unref(contentEl) && - (unref(contentEl) as Element).addEventListener('transitionend', contentResizeHandler) + (unref(contentEl) as Element).addEventListener('transitionend', contentResizeHandler, {passive: true}) echartRef.on('datazoom', function (evt) { // const option = echartRef.getOption(); diff --git a/static_source/admin/src/layout/components/AppView.vue b/static_source/admin/src/layout/components/AppView.vue index 493dfcf9d..2acd63470 100644 --- a/static_source/admin/src/layout/components/AppView.vue +++ b/static_source/admin/src/layout/components/AppView.vue @@ -32,7 +32,7 @@ const onKeydown = ( event ) => { } onMounted(() => { - document.addEventListener("keydown", onKeydown) + document.addEventListener("keydown", onKeydown, {passive: true}) }) onUnmounted(() => { diff --git a/static_source/admin/src/views/Dashboard/card_items/state/index.vue b/static_source/admin/src/views/Dashboard/card_items/state/index.vue index b50d6ad8d..6f97af05b 100644 --- a/static_source/admin/src/views/Dashboard/card_items/state/index.vue +++ b/static_source/admin/src/views/Dashboard/card_items/state/index.vue @@ -34,7 +34,7 @@ onMounted(() => { // store dom element moveable props.item.setTarget(el.value) - currentImage.value = props.item?.payload.state.default_image || props.item?.payload.state.defaultImage || null; + currentImage.value = props.item?.payload.state.defaultImage || props.item?.payload.state.default_image || null; if (props.item?.payload?.state?.defaultIcon) { currentImage.value = null currentIcon.value = props.item?.payload?.state?.defaultIcon; @@ -88,7 +88,7 @@ const update = debounce(() => { } if (counter == 0) { - currentImage.value = props.item?.payload.state.default_image || props.item?.payload.state.defaultImage || null; + currentImage.value = props.item?.payload.state.defaultImage || props.item?.payload.state.default_image || null; if (props.item?.payload?.state?.defaultIcon) { currentImage.value = null currentIcon.value = props.item?.payload?.state?.defaultIcon; diff --git a/static_source/admin/src/views/Dashboard/card_items/video/VideoMse.vue b/static_source/admin/src/views/Dashboard/card_items/video/VideoMse.vue index d14f6f7ea..6ee9112d3 100644 --- a/static_source/admin/src/views/Dashboard/card_items/video/VideoMse.vue +++ b/static_source/admin/src/views/Dashboard/card_items/video/VideoMse.vue @@ -30,7 +30,7 @@ onMounted(async () => { videoEl.value.currentTime = videoEl.value.buffered.end(videoEl.value.buffered.length - 1) - 0.1 videoEl.value.play() } - }) + }, {passive: true}) startPlay() }) diff --git a/static_source/admin/src/views/Dashboard/core.ts b/static_source/admin/src/views/Dashboard/core.ts index 7568a767c..6a3e99cc5 100644 --- a/static_source/admin/src/views/Dashboard/core.ts +++ b/static_source/admin/src/views/Dashboard/core.ts @@ -320,11 +320,13 @@ export class CardItem { iconSize: action.iconSize, }); } - const payload = btoa(unescape(encodeURIComponent(serializedObject({ + const payload = {}; + payload[this._type] = this.payload[this._type]; + const cardItemPayload = btoa(unescape(encodeURIComponent(serializedObject({ width: this.width, height: this.height, transform: this.transform, - payload: this.payload, + payload: payload, style: style, showOn: this.showOn, hideOn: this.hideOn, @@ -338,7 +340,7 @@ export class CardItem { weight: this.weight, enabled: this.enabled, entityId: this._entityId || null, - payload: payload, + payload: cardItemPayload, hidden: this.hidden, frozen: this.frozen diff --git a/static_source/admin/src/views/Entities/components/EntitiesSearch.vue b/static_source/admin/src/views/Entities/components/EntitiesSearch.vue index ce1187eae..0c9565467 100644 --- a/static_source/admin/src/views/Entities/components/EntitiesSearch.vue +++ b/static_source/admin/src/views/Entities/components/EntitiesSearch.vue @@ -1,11 +1,11 @@