Fix bug on teleinfo.

This commit is contained in:
chteufleur 2016-12-16 22:49:06 +01:00
parent 8ed7eafbe6
commit 1df76ee4e2
3 changed files with 13 additions and 5 deletions

View File

@ -101,9 +101,8 @@ func (c *SensorsController) PostCompteur() {
teleinfo.UpdateCompteur(adresse, description) teleinfo.UpdateCompteur(adresse, description)
c.Redirect("/sensors", 302) c.Redirect("/sensors", 302)
} else if isDelete != "" { } else if isDelete != "" {
cpt := teleinfo.GetCompteurByAdresse(adresse) teleinfo.DeleteCompteurByAdresse(adresse)
teleinfo.DeleteCompteur(cpt.Id) teleinfo.DeleteDataCompteur(adresse)
teleinfo.DeleteDataCompteur(cpt.AdresseCompteur)
c.Redirect("/sensors", 302) c.Redirect("/sensors", 302)
} else { } else {
c.Redirect("/404", 404) c.Redirect("/404", 404)

View File

@ -18,6 +18,11 @@ type AddTeleinfoController struct {
} }
func (c *AddTeleinfoController) Prepare() { func (c *AddTeleinfoController) Prepare() {
sess := c.GetSession(variables.SessionName)
if sess != nil {
c.Data["IsAuthentificated"] = true
}
c.Data["version"] = variables.Version c.Data["version"] = variables.Version
} }
@ -47,6 +52,11 @@ type ViewTeleinfoController struct {
} }
func (c *ViewTeleinfoController) Prepare() { func (c *ViewTeleinfoController) Prepare() {
sess := c.GetSession(variables.SessionName)
if sess != nil {
c.Data["IsAuthentificated"] = true
}
c.Data["IsViewTeleinfo"] = true c.Data["IsViewTeleinfo"] = true
c.Data["version"] = variables.Version c.Data["version"] = variables.Version
} }
@ -79,7 +89,6 @@ func formatDataSensorTeleInfo(values []teleinfo.TeleinfoTable) string {
if i > 0 { if i > 0 {
ret += "," ret += ","
} }
// TODO faire la dérivé de la puissance pour avoir les variations plutot que l'évolution de la puissance
horodate := strconv.FormatInt((values[i].HorodateGMT.Unix()+int64(timezoneOffset))*1000, 10) horodate := strconv.FormatInt((values[i].HorodateGMT.Unix()+int64(timezoneOffset))*1000, 10)
value := strconv.FormatInt(values[i].PuissanceApparente, 10) value := strconv.FormatInt(values[i].PuissanceApparente, 10)
ret += "[" + horodate + "," + value + "]" ret += "[" + horodate + "," + value + "]"

View File

@ -1,7 +1,7 @@
package variables package variables
const ( const (
Version = "0.1.4" Version = "0.1.5-dev"
SessionName = "Session_Data_House" SessionName = "Session_Data_House"