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