Skip to content

Commit

Permalink
technical debt
Browse files Browse the repository at this point in the history
  • Loading branch information
e154 committed Nov 17, 2023
1 parent 403b5cb commit 3130c60
Show file tree
Hide file tree
Showing 24 changed files with 100 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test:
go test -race $(go list ./... | grep -v /tests/)

install_linter:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.45.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.55.2

lint-todo:
@echo MARK: make lint todo
Expand Down
2 changes: 1 addition & 1 deletion Makefile.local
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ test:
go test -race $(go list ./... | grep -v /tests/)

install_linter:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.45.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.55.2

lint-todo:
@echo MARK: make lint todo
Expand Down
6 changes: 3 additions & 3 deletions adaptors/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ package adaptors
import (
"context"
"encoding/json"
"github.com/e154/smart-home/system/orm"
"time"

"github.com/e154/smart-home/common"
"gorm.io/gorm"

"github.com/e154/smart-home/common"
"github.com/e154/smart-home/db"
m "github.com/e154/smart-home/models"
"gorm.io/gorm"
"github.com/e154/smart-home/system/orm"
)

// ITrigger ...
Expand Down
2 changes: 1 addition & 1 deletion endpoint/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ package endpoint
import (
"context"
"fmt"
"github.com/e154/smart-home/common/events"

"github.com/e154/smart-home/common"
"github.com/e154/smart-home/common/apperr"
"github.com/e154/smart-home/common/events"
m "github.com/e154/smart-home/models"
)

Expand Down
2 changes: 1 addition & 1 deletion endpoint/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ package endpoint
import (
"context"
"fmt"
"github.com/e154/smart-home/common"
"time"

"github.com/e154/smart-home/common"
m "github.com/e154/smart-home/models"
)

Expand Down
5 changes: 2 additions & 3 deletions endpoint/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ package endpoint
import (
"context"
"fmt"
"github.com/e154/smart-home/common/events"

"github.com/e154/smart-home/common/apperr"

"github.com/e154/smart-home/common"
"github.com/e154/smart-home/common/apperr"
"github.com/e154/smart-home/common/events"
m "github.com/e154/smart-home/models"
)

Expand Down
2 changes: 1 addition & 1 deletion endpoint/zigbee2mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ package endpoint
import (
"context"
"fmt"
"github.com/e154/smart-home/common/events"

"github.com/pkg/errors"

"github.com/e154/smart-home/common"
"github.com/e154/smart-home/common/apperr"
"github.com/e154/smart-home/common/events"
m "github.com/e154/smart-home/models"
)

Expand Down
4 changes: 2 additions & 2 deletions models/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func UploadImage(ctx context.Context, reader *bufio.Reader, fileName string) (ne
}
buffer.Write(part[:count])
}
if err == io.EOF {
err = nil
if err != io.EOF {
return
}

contentType := http.DetectContentType(buffer.Bytes())
Expand Down
9 changes: 4 additions & 5 deletions plugins/logs/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import (
"context"
"fmt"

"github.com/e154/smart-home/system/scheduler"
"github.com/e154/smart-home/system/supervisor"

"github.com/e154/smart-home/common"
m "github.com/e154/smart-home/models"
"github.com/e154/smart-home/system/logging"
"github.com/e154/smart-home/system/scheduler"
"github.com/e154/smart-home/system/supervisor"
)

var _ supervisor.Pluggable = (*plugin)(nil)
Expand Down Expand Up @@ -56,7 +55,7 @@ func (p *plugin) Load(ctx context.Context, service supervisor.Service) (err erro
return
}
// every day at 00:00 am
p.entryId, err = p.Service.Scheduler().AddFunc("0 0 0 * * *", func() {
p.entryId, _ = p.Service.Scheduler().AddFunc("0 0 0 * * *", func() {
p.actor.UpdateDay()
})
var entity *m.Entity
Expand All @@ -72,7 +71,7 @@ func (p *plugin) Load(ctx context.Context, service supervisor.Service) (err erro
}

p.actor = NewActor(entity, service)
p.AddActor(p.actor, entity)
_ = p.AddActor(p.actor, entity)

logging.LogsHook = p.actor.LogsHook

Expand Down
2 changes: 1 addition & 1 deletion plugins/moon/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (p *plugin) Load(ctx context.Context, service supervisor.Service) (err erro
// Unload ...
func (p *plugin) Unload(ctx context.Context) (err error) {
p.ticker.Stop()
err = p.Plugin.Unload(ctx)
_ = p.Plugin.Unload(ctx)
return nil
}

Expand Down
6 changes: 2 additions & 4 deletions plugins/version/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ import (
"time"

"github.com/e154/smart-home/common"

"github.com/e154/smart-home/system/supervisor"

m "github.com/e154/smart-home/models"
"github.com/e154/smart-home/system/supervisor"
)

var _ supervisor.Pluggable = (*plugin)(nil)
Expand Down Expand Up @@ -63,7 +61,7 @@ func (p *plugin) Load(ctx context.Context, service supervisor.Service) (err erro
PluginName: Name,
Attributes: NewAttr(),
}
err = p.Service.Adaptors().Entity.Add(context.Background(), entity)
_ = p.Service.Adaptors().Entity.Add(context.Background(), entity)
}

go func() {
Expand Down
11 changes: 11 additions & 0 deletions static_source/admin/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ const setDefaultTheme = () => {
appStore.setIsDark(isDarkTheme)
}
const consoleBanner = () => {
var i, url;
if (window.console && 'undefined' !== typeof console.log) {
url = 'https://github.com/e154/smart-home';
i = `Software package for automation - ${url}`;
console.log('%c Smart home %c Copyright © 2014-%s', 'font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;font-size:62px;color:#303E4D;-webkit-text-fill-color:#303E4D;-webkit-text-stroke: 1px #303E4D;', 'font-size:12px;color:#a9a9a9;', (new Date()).getFullYear());
return console.log('%c ' + i, 'color:#333;');
}
}
setDefaultTheme()
consoleBanner()
</script>

<template>
Expand Down
101 changes: 50 additions & 51 deletions static_source/admin/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,57 +361,6 @@ export const developRouterMap: AppRouteRecordRaw[] = [
},
]
},
{
path: '/zigbee2mqtt',
component: Develop,
redirect: '/zigbee2mqtt/index',
meta: {
title: t('router.Zigbee2mqtt'),
icon: 'simple-icons:zigbee'
},
children: [
{
path: 'index',
name: 'Zigbee2mqtt',
component: () => import('@/views/Zigbee2mqtt/index.vue'),
meta: {
title: t('router.List'),
noTagsView: true,
noCache: true,
hidden: true,
canTo: true,
activeMenu: '/zigbee2mqtt'
}
},
{
path: 'new',
name: 'newZigbee2mqtt',
component: () => import('@/views/Zigbee2mqtt/new.vue'),
meta: {
title: t('router.New'),
noTagsView: true,
noCache: true,
hidden: true,
canTo: true,
activeMenu: '/zigbee2mqtt'
}
},
{
path: 'edit/:id',
name: 'editZigbee2mqtt',
component: () => import('@/views/Zigbee2mqtt/edit.vue'),
props: true,
meta: {
title: t('router.Edit'),
noTagsView: true,
noCache: true,
hidden: true,
canTo: true,
activeMenu: '/zigbee2mqtt'
}
}
]
},
{
path: '/dashboards',
component: Develop,
Expand Down Expand Up @@ -665,6 +614,56 @@ export const developRouterMap: AppRouteRecordRaw[] = [
}
]
},
{
path: 'zigbee2mqtt',
name: 'Zigbee2mqtt',
component: () => import('@/views/zigbee2mqtt/index.vue'),
meta: {
title: t('router.Zigbee2mqtt'),
},
children: [
{
path: 'index',
name: 'Zigbee2mqtt',
component: () => import('@/views/Zigbee2mqtt/index.vue'),
meta: {
title: t('router.List'),
noTagsView: true,
noCache: true,
hidden: true,
canTo: true,
activeMenu: '/etc/zigbee2mqtt'
}
},
{
path: 'new',
name: 'newZigbee2mqtt',
component: () => import('@/views/Zigbee2mqtt/new.vue'),
meta: {
title: t('router.New'),
noTagsView: true,
noCache: true,
hidden: true,
canTo: true,
activeMenu: '/etc/zigbee2mqtt'
}
},
{
path: 'edit/:id',
name: 'editZigbee2mqtt',
component: () => import('@/views/Zigbee2mqtt/edit.vue'),
props: true,
meta: {
title: t('router.Edit'),
noTagsView: true,
noCache: true,
hidden: true,
canTo: true,
activeMenu: '/etc/zigbee2mqtt'
}
}
]
},
{
path: 'users',
name: 'Users',
Expand Down
14 changes: 7 additions & 7 deletions static_source/admin/src/views/Dashboard/card_items/map/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ onMounted(() => {
// store dom element moveable
props.item.setTarget(el.value)
layerList.value.push(jawgLayer.value.tileLayer);
// layerList.value.push(jawgLayer.value.tileLayer);
layerList.value.push(osmLayer.value.tileLayer);
})
Expand Down Expand Up @@ -240,12 +240,12 @@ const getUrl = (image?: ApiImage): string | undefined => {
:layerList="layerList"
/>

<ol-tile-layer ref="jawgLayer" title="JAWG">
<ol-source-xyz
crossOrigin="anonymous"
url="https://c.tile.jawg.io/jawg-dark/{z}/{x}/{y}.png?access-token=87PWIbRaZAGNmYDjlYsLkeTVJpQeCfl2Y61mcHopxXqSdxXExoTLEv7dwqBwSWuJ"
/>
</ol-tile-layer>
<!-- <ol-tile-layer ref="jawgLayer" title="JAWG">-->
<!-- <ol-source-xyz-->
<!-- crossOrigin="anonymous"-->
<!-- url="https://c.tile.jawg.io/jawg-dark/{z}/{x}/{y}.png?access-token=87PWIbRaZAGNmYDjlYsLkeTVJpQeCfl2Y61mcHopxXqSdxXExoTLEv7dwqBwSWuJ"-->
<!-- />-->
<!-- </ol-tile-layer>-->

<ol-tile-layer ref="osmLayer">
<ol-source-osm />
Expand Down
2 changes: 1 addition & 1 deletion static_source/admin/src/views/Zigbee2mqtt/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const save = async () => {
}
const cancel = () => {
push('/zigbee2mqtt')
push('/etc/zigbee2mqtt')
}
const remove = async () => {
Expand Down
4 changes: 2 additions & 2 deletions static_source/admin/src/views/Zigbee2mqtt/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ const sortChange = (data) => {
getList()
const addNew = () => {
push('/zigbee2mqtt/new')
push('/etc/zigbee2mqtt/new')
}
const selectRow = (row) => {
if (!row) {
return
}
const {id} = row
push(`/zigbee2mqtt/edit/${id}`)
push(`/etc/zigbee2mqtt/edit/${id}`)
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions static_source/admin/src/views/Zigbee2mqtt/new.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ const save = async () => {
loading.value = false
})
if (res) {
push(`/zigbee2mqtt/edit/${res.data.id}`)
push(`/etc/zigbee2mqtt/edit/${res.data.id}`)
}
}
}
const cancel = () => {
push('/zigbee2mqtt')
push('/etc/zigbee2mqtt')
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion system/automation/task_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (a *taskManager) Shutdown() {
a.unload()
_ = a.eventBus.Unsubscribe("system/models/tasks/+", a.eventHandler)
_ = a.eventBus.Unsubscribe("system/automation/tasks/+", a.eventHandler)
log.Info("Shutdown")
log.Info("shutdown")
}

func (a *taskManager) load() {
Expand Down
4 changes: 2 additions & 2 deletions system/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ func (b *Backup) UploadBackup(ctx context.Context, reader *bufio.Reader, fileNam
}
buffer.Write(part[:count])
}
if err == io.EOF {
err = nil
if err != io.EOF {
return
}

contentType := http.DetectContentType(buffer.Bytes())
Expand Down
1 change: 1 addition & 0 deletions system/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

// Cache interface contains all behaviors for cache adapter.
// usage:
//
// cache.Register("file",cache.NewFileCache) // this operation is run in init method of file.go.
// c,err := cache.NewCache("file","{....}")
// c.Put("key",value, 3600 * time.Second)
Expand Down
Loading

0 comments on commit 3130c60

Please sign in to comment.