Example #1
0
func (ctl *LogfileController) postEditLogfileAction(c *gin.Context) {

	appId := c.Param("app_id")
	logfileId := c.Param("logfile_id")

	application := ctl.getApplication(c, appId)
	if application == nil {
		return
	}

	logfile := ctl.getLogfile(c, application, logfileId)
	if logfile == nil {
		return
	}

	var form models.LogfileUpdateForm
	if err := c.Bind(&form); err != nil {
		c.AbortWithStatus(http.StatusBadRequest)
		return
	}

	// Workaround for bool field, because http form only send string
	// The value is "on" for true, and "" for false
	form.Enabled = c.PostForm("enabled") == "on"

	if err := form.Validate(); err != nil {
		c.HTML(http.StatusOK, "logfile_edit.html", map[string]interface{}{
			"errors":      err.Errors,
			"application": application,
			"form":        form,
		})
		return
	}

	logfile.Update(&form)

	if err := models.LogfileMapper.Update(logfile); err != nil {
		panic(err)
	}

	c.Redirect(http.StatusFound, "/application/show/"+application.Name)
}
Example #2
0
func (ctl *LogfileController) getEditLogfileAction(c *gin.Context) {

	appId := c.Param("app_id")
	logfileId := c.Param("logfile_id")

	application := ctl.getApplication(c, appId)
	if application == nil {
		return
	}

	logfile := ctl.getLogfile(c, application, logfileId)
	if logfile == nil {
		return
	}

	// Hydrate the form
	var form models.LogfileUpdateForm
	form.Hydrate(logfile)

	c.HTML(http.StatusOK, "logfile_edit.html", map[string]interface{}{
		"application": application,
		"form":        form,
	})
}