Skip to content

Commit

Permalink
technical debt
Browse files Browse the repository at this point in the history
  • Loading branch information
e154 committed Jan 12, 2024
1 parent 763617c commit ef4adc5
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 14 deletions.
9 changes: 4 additions & 5 deletions api/dto/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -241,7 +240,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 {
Expand All @@ -263,7 +262,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)
}
Expand All @@ -284,7 +283,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)
}
Expand Down
10 changes: 10 additions & 0 deletions api/dto/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
18 changes: 18 additions & 0 deletions api/dto/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions static_source/admin/src/components/Echart/src/Echart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion static_source/admin/src/layout/components/AppView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const onKeydown = ( event ) => {
}
onMounted(() => {
document.addEventListener("keydown", onKeydown)
document.addEventListener("keydown", onKeydown, {passive: true})
})
onUnmounted(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
8 changes: 5 additions & 3 deletions static_source/admin/src/views/Dashboard/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down
9 changes: 9 additions & 0 deletions system/access_list/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -754,5 +754,14 @@
"description": "",
"method": "delete"
}
},
"stream": {
"watch": {
"actions": [
"/stream/*"
],
"description": "",
"method": "get"
}
}
}

0 comments on commit ef4adc5

Please sign in to comment.