Make it go getable
This commit is contained in:
parent
d33e5f312f
commit
c363e309c1
|
|
@ -6,10 +6,10 @@ import (
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
|
||||||
"datahouse/models/sensor"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/sensor"
|
||||||
"datahouse/models/temperature"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/temperature"
|
||||||
temperatureTmp "datahouse/models/temperature/temp"
|
temperatureTmp "git.kingpenguin.tk/chteufleur/datahouse.git/models/temperature/temp"
|
||||||
"datahouse/models/variables"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AddTempController struct {
|
type AddTempController struct {
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ package controllers
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
|
||||||
"datahouse/models/sensor"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/sensor"
|
||||||
temperatureTmp "datahouse/models/temperature/temp"
|
temperatureTmp "git.kingpenguin.tk/chteufleur/datahouse.git/models/temperature/temp"
|
||||||
"datahouse/models/variables"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||||
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package controllers
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
|
||||||
"datahouse/models/user"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/user"
|
||||||
"datahouse/models/variables"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LoginController struct {
|
type LoginController struct {
|
||||||
|
|
|
||||||
|
|
@ -4,21 +4,16 @@ import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/astaxie/beego/httplib"
|
"github.com/astaxie/beego/httplib"
|
||||||
|
|
||||||
"datahouse/models/variables"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/relay"
|
||||||
"datahouse/models/relay"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
type ViewRelayController struct {
|
type ViewRelayController struct {
|
||||||
beego.Controller
|
beego.Controller
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +26,7 @@ func (c *ViewRelayController) Prepare() {
|
||||||
c.Data["IsAuthentificated"] = true
|
c.Data["IsAuthentificated"] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Data["IsViewRelay"] = true;
|
c.Data["IsViewRelay"] = true
|
||||||
c.Data["version"] = variables.Version
|
c.Data["version"] = variables.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,7 +48,6 @@ func (c *ViewRelayController) Get() {
|
||||||
c.TplNames = "relay.tpl"
|
c.TplNames = "relay.tpl"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *ViewRelayController) Post() {
|
func (c *ViewRelayController) Post() {
|
||||||
mac := c.Ctx.Input.Param(":sensor")
|
mac := c.Ctx.Input.Param(":sensor")
|
||||||
r := relay.GetRelayByMac(mac)
|
r := relay.GetRelayByMac(mac)
|
||||||
|
|
@ -72,9 +66,6 @@ func (c *ViewRelayController) Post() {
|
||||||
c.Ctx.Output.Body([]byte(ret))
|
c.Ctx.Output.Body([]byte(ret))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
@ -83,7 +74,6 @@ type AddRelayController struct {
|
||||||
beego.Controller
|
beego.Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *AddRelayController) Get() {
|
func (c *AddRelayController) Get() {
|
||||||
ip := strings.Split(c.Ctx.Request.RemoteAddr, ":")[0]
|
ip := strings.Split(c.Ctx.Request.RemoteAddr, ":")[0]
|
||||||
mac := c.Ctx.Input.Param(":sensor")
|
mac := c.Ctx.Input.Param(":sensor")
|
||||||
|
|
@ -92,9 +82,6 @@ func (c *AddRelayController) Get() {
|
||||||
c.Ctx.Output.Body([]byte("OK"))
|
c.Ctx.Output.Body([]byte("OK"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ package controllers
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
|
||||||
"datahouse/models/relay"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/relay"
|
||||||
"datahouse/models/sensor"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/sensor"
|
||||||
"datahouse/models/temperature"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/temperature"
|
||||||
"datahouse/models/variables"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -48,8 +48,6 @@ func (c *SensorsController) Post() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func (c *SensorsController) PostTempSensors() {
|
func (c *SensorsController) PostTempSensors() {
|
||||||
description := c.Input().Get("description")
|
description := c.Input().Get("description")
|
||||||
mac := c.Input().Get("mac")
|
mac := c.Input().Get("mac")
|
||||||
|
|
@ -73,8 +71,6 @@ func (c *SensorsController) PostTempSensors() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func (c *SensorsController) PostRelay() {
|
func (c *SensorsController) PostRelay() {
|
||||||
description := c.Input().Get("description")
|
description := c.Input().Get("description")
|
||||||
mac := c.Input().Get("mac")
|
mac := c.Input().Get("mac")
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package controllers
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
|
||||||
"datahouse/models/user"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/user"
|
||||||
"datahouse/models/variables"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserController struct {
|
type UserController struct {
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ package controllers
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
|
||||||
"datahouse/models/sensor"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/sensor"
|
||||||
"datahouse/models/temperature"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/temperature"
|
||||||
"datahouse/models/variables"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||||
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
|
||||||
8
main.go
8
main.go
|
|
@ -1,10 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"datahouse/models/database"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/database"
|
||||||
_ "datahouse/models/temperature"
|
_ "git.kingpenguin.tk/chteufleur/datahouse.git/models/temperature"
|
||||||
"datahouse/models/user"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/user"
|
||||||
_ "datahouse/routers"
|
_ "git.kingpenguin.tk/chteufleur/datahouse.git/routers"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,10 @@ package relay
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
|
||||||
"datahouse/models/database"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/database"
|
||||||
"datahouse/models/utils"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type RelayTable struct {
|
type RelayTable struct {
|
||||||
Id int64
|
Id int64
|
||||||
Mac string
|
Mac string
|
||||||
|
|
@ -20,8 +18,6 @@ func init() {
|
||||||
orm.RegisterModel(new(RelayTable))
|
orm.RegisterModel(new(RelayTable))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func GetRelayByMac(relayMac string) *RelayTable {
|
func GetRelayByMac(relayMac string) *RelayTable {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package sensor
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
|
||||||
"datahouse/models/database"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/database"
|
||||||
"datahouse/models/utils"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SensorTable struct {
|
type SensorTable struct {
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package temp
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
|
||||||
"datahouse/models/database"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/database"
|
||||||
"datahouse/models/utils"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/utils"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package temperature
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
|
||||||
"datahouse/models/database"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/database"
|
||||||
"datahouse/models/utils"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/utils"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
|
|
||||||
"datahouse/models/database"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/database"
|
||||||
"datahouse/models/utils"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package routers
|
package routers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"datahouse/controllers"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/controllers"
|
||||||
"datahouse/models/variables"
|
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ $("#toggleButton").click(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/command/relay/"+$(".jumbotron img").attr("id"),
|
url: "/command/relay/"+$(".jumbotron img").attr("id"),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
timeout: 1000,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue