Esempio n. 1
0
// Region handles the higher level business processing for this API Call
func Region(controller *bc.BaseController, region string) {
	defer bc.CatchPanic(controller, "Region")

	tracelog.STARTEDf(controller.UserId, "Region", "Region[%s]", region)

	buoyStations, err := buoyService.FindRegion(&controller.Service, region)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, controller.UserId, "Region", "Region[%s]", region)
		controller.ServeError(err)
		return
	}

	controller.Data["json"] = &buoyStations
	controller.ServeJson()

	tracelog.COMPLETED(controller.UserId, "Region")
}
Esempio n. 2
0
// Station handles the higher level business processing for this API Call
func Station(controller *bc.BaseController, stationId string) {
	defer bc.CatchPanic(controller, "Station")

	tracelog.STARTEDf(controller.UserId, "Station", "StationId[%s]", stationId)

	buoyStation, err := buoyService.FindStation(&controller.Service, stationId)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, controller.UserId, "Station", "StationId[%s]", stationId)
		controller.ServeError(err)
		return
	}

	controller.Data["json"] = &buoyStation
	controller.ServeJson()

	tracelog.COMPLETED(controller.UserId, "Station")
}
Esempio n. 3
0
// Stations handles the example 3 tab
// http://localhost:9003/buoy/station/42002
func (controller *BuoyController) RetrieveStationJson() {
	params := struct {
		StationId string `form:":stationId" valid:"Required; MinSize(4)" error:"invalid_station_id"`
	}{}

	if controller.ParseAndValidate(&params) == false {
		return
	}

	buoyStation, err := buoyService.FindStation(&controller.Service, params.StationId)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, controller.UserId, "Station", "StationId[%s]", params.StationId)
		controller.ServeError(err)
		return
	}

	controller.Data["json"] = &buoyStation
	controller.ServeJson()
}
Esempio n. 4
0
// Index is the initial view for the buoy system
func (controller *BuoyController) Index() {
	region := "Gulf Of Mexico"
	tracelog.STARTEDf(controller.UserId, "BuoyController.Index", "Region[%s]", region)

	buoyStations, err := buoyService.FindRegion(&controller.Service, region)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, controller.UserId, "BuoyController.Index", "Region[%s]", region)
		controller.ServeError(err)
		return
	}

	controller.Data["Stations"] = buoyStations
	controller.Layout = "shared/basic-layout.html"
	controller.TplNames = "buoy/content.html"
	controller.LayoutSections = map[string]string{}
	controller.LayoutSections["PageHead"] = "buoy/page-head.html"
	controller.LayoutSections["Header"] = "shared/header.html"
	controller.LayoutSections["Modal"] = "shared/modal.html"
}
Esempio n. 5
0
// RetrieveStation handles the example 2 tab
func (controller *BuoyController) RetrieveStation() {
	params := struct {
		StationId string `form:"stationId" valid:"Required; MinSize(4)" error:"invalid_station_id"`
	}{}

	if controller.ParseAndValidate(&params) == false {
		return
	}

	buoyStation, err := buoyService.FindStation(&controller.Service, params.StationId)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, controller.UserId, "BuoyController.RetrieveStation", "StationId[%s]", params.StationId)
		controller.ServeError(err)
		return
	}

	controller.Data["Station"] = buoyStation
	controller.Layout = ""
	controller.TplNames = "buoy/modal/pv_station-detail.html"
	view, _ := controller.RenderString()

	controller.AjaxResponse(0, "SUCCESS", view)
}
Esempio n. 6
0
// LoadJSON takes a json document of translations and manually
// loads them into the system
func LoadJSON(userLocale string, translationDocument string) error {
	tracelog.STARTEDf("localize", "LoadJSON", "UserLocale[%s] Length[%d]", userLocale, len(translationDocument))

	tranDocuments := []map[string]interface{}{}
	err := json.Unmarshal([]byte(translationDocument), &tranDocuments)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, "localize", "LoadJSON", "**************>")
		return err
	}

	for _, tranDocument := range tranDocuments {
		tran, err := translation.NewTranslation(tranDocument)
		if err != nil {
			tracelog.COMPLETED_ERROR(err, "localize", "LoadJSON")
			return err
		}

		i18n.AddTranslation(locale.MustNew(userLocale), tran)
	}

	tracelog.COMPLETED("localize", "LoadJSON")
	return nil
}