Documentation ¶
Index ¶
- func ShowUI(rw http.ResponseWriter, req *http.Request)
- type CalendarItem
- type CalendarRequest
- type CalendarResponse
- type CalendarView
- type ErrorResponse
- type Hub
- type NewsItem
- type NewsReport
- type PollenReport
- type PollenRequest
- type QuakeReport
- type RemoveConfigRequest
- type Service
- func (service Service) GetAllConfig(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetAllEvents(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetCalendar(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetConfig(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetCroppedImage(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetEarthquakes(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetEvent(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetMapImage(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetNews(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetPollen(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetWeather(rw http.ResponseWriter, req *http.Request)
- func (service Service) RemoveConfig(rw http.ResponseWriter, req *http.Request)
- func (service Service) SetConfig(rw http.ResponseWriter, req *http.Request)
- type SetConfigRequest
- type SpaHandler
- type SystemResponse
- type WeatherAlert
- type WeatherDataBlock
- type WeatherDataPoint
- type WeatherReport
- type WeatherRequest
- type WsHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CalendarItem ¶ added in v1.0.46
type CalendarRequest ¶ added in v1.0.46
CalendarRequest represents a request to get calendar information for the given iCal url and timezone
type CalendarResponse ¶ added in v1.0.46
type CalendarResponse []CalendarItem
CalendarResponse represents the response from the calendar service
type CalendarView ¶ added in v1.0.51
type CalendarView struct { Items []CalendarItem `json:"items"` LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
CalendarView represents the data sent to the dashboard for the calendar view
type ErrorResponse ¶ added in v1.0.37
type ErrorResponse struct {
Message string `json:"message"`
}
ErrorResponse represents an API response
type Hub ¶
type Hub struct { // Inbound messages from the connections. Broadcast chan []byte // contains filtered or unexported fields }
Hub is a connection hub for websockets
type NewsItem ¶ added in v1.0.46
type NewsItem struct { ID string `json:"id"` CreateTime int64 `json:"createtime"` Text string `json:"text"` MediaURL string `json:"mediaurl"` StoryURL string `json:"storyurl"` }
NewsItem represents a single news item
type NewsReport ¶ added in v1.0.46
type NewsReport struct { Items []NewsItem `json:"items"` Version string `json:"version"` LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
NewsReport defines a news report
type PollenReport ¶ added in v1.0.43
type PollenReport struct { Location string `json:"location"` // The location for the report Zipcode string `json:"zip"` // The zipcode for the report PredominantPollen string `json:"predominant_pollen"` // The predominant pollen in the report period StartDate time.Time `json:"startdate"` // The start time for this report Data []float64 `json:"data"` // Pollen data indices -- one for today and each future day ReportingService string `json:"service"` // The reporting service Version string `json:"version"` // Service version information LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
PollenReport represents the report of pollen data
type PollenRequest ¶ added in v1.0.43
type PollenRequest struct {
ZipCode string `json:"zipcode"`
}
PollenRequest represents a request to get pollen information for the given zipcode
type QuakeReport ¶ added in v1.0.48
type QuakeReport struct { Type string `json:"type"` Metadata struct { Generated int64 `json:"generated"` URL string `json:"url"` Title string `json:"title"` Status int `json:"status"` API string `json:"api"` Count int `json:"count"` } `json:"metadata"` Features []struct { Type string `json:"type"` Properties struct { Mag float64 `json:"mag"` // The earthquake magnitude Place string `json:"place"` // The earthquake 'place' / name Time int64 `json:"time"` // The time the earthquake event happened, in UTC Updated int64 `json:"updated"` Tz interface{} `json:"tz"` URL string `json:"url"` Detail string `json:"detail"` Felt interface{} `json:"felt"` Cdi interface{} `json:"cdi"` Mmi float64 `json:"mmi"` Alert string `json:"alert"` // The alert color (“green”, “yellow”, “orange”, “red”) this is a summary of the estimate of fatalities and economic losses Status string `json:"status"` Tsunami int `json:"tsunami"` // This flag is set to "1" for large events in oceanic regions and "0" otherwise. The existence or value of this flag does not indicate if a tsunami actually did or will exist. Sig int `json:"sig"` Net string `json:"net"` Code string `json:"code"` Ids string `json:"ids"` Sources string `json:"sources"` Types string `json:"types"` Nst interface{} `json:"nst"` Dmin float64 `json:"dmin"` Rms float64 `json:"rms"` Gap int `json:"gap"` MagType string `json:"magType"` Type string `json:"type"` Title string `json:"title"` } `json:"properties"` Geometry struct { Type string `json:"type"` Coordinates []float64 `json:"coordinates"` // Lat and long of the earthquake origin } `json:"geometry"` ID string `json:"id"` } `json:"features"` Bbox []float64 `json:"bbox"` LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
QuakeReport represents the report of earthquake data For a data dictionary for these fields, please see https://earthquake.usgs.gov/data/comcat/data-eventterms.php
type RemoveConfigRequest ¶ added in v1.0.39
type RemoveConfigRequest struct {
Name string `json:"name"`
}
RemoveConfigRequest represents a 'remove config' request
type Service ¶
type Service struct { DB *data.Manager StartTime time.Time HistoryTTL time.Duration // WsHub is the websocket hub connection for // broadcasting config changes to anybody interested WsHub *Hub }
Service encapsulates API service operations
func (Service) GetAllConfig ¶
func (service Service) GetAllConfig(rw http.ResponseWriter, req *http.Request)
GetAllConfig godoc @Summary Gets all config items @Description Gets all config items @Tags config @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /config [get]
func (Service) GetAllEvents ¶ added in v1.0.36
func (service Service) GetAllEvents(rw http.ResponseWriter, req *http.Request)
GetAllEvents godoc @Summary Gets all events in the system @Description Gets all events in the system @Tags events @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /events [get]
func (Service) GetCalendar ¶ added in v1.0.46
func (service Service) GetCalendar(rw http.ResponseWriter, req *http.Request)
GetCalendar godoc @Summary Gets today's calendar data for the given iCal url and timezone @Description Gets today's calendar data for the given iCal url and timezone @Tags dashboard @Accept json @Produce json @Param zipcode body api.CalendarRequest true "The iCal url and timezone to for calendar data" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/calendar [post]
func (Service) GetConfig ¶
func (service Service) GetConfig(rw http.ResponseWriter, req *http.Request)
GetConfig gets a specfic config item based on config item name
func (Service) GetCroppedImage ¶ added in v1.0.44
func (service Service) GetCroppedImage(rw http.ResponseWriter, req *http.Request)
GetConfig gets a specfic config item based on config item name
func (Service) GetEarthquakes ¶ added in v1.0.48
func (service Service) GetEarthquakes(rw http.ResponseWriter, req *http.Request)
GetEarthquakes godoc @Summary Gets earthquake data for significant quakes in the last month @Description Gets earthquake data for significant quakes in the last month @Tags dashboard @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/earthquakes [get]
func (Service) GetEvent ¶ added in v1.0.36
func (service Service) GetEvent(rw http.ResponseWriter, req *http.Request)
GetEvent godoc @Summary Gets a log event. @Description Gets a log event. @Tags events @Accept json @Produce json @Param id path string true "The event id to get" @Success 200 {object} api.SystemResponse @Failure 404 {object} api.ErrorResponse @Router /event/{id} [get]
func (Service) GetMapImage ¶ added in v1.0.49
func (service Service) GetMapImage(rw http.ResponseWriter, req *http.Request)
GetMapImage godoc @Summary gets a map image for the given coordinates
func (Service) GetNews ¶ added in v1.0.46
func (service Service) GetNews(rw http.ResponseWriter, req *http.Request)
GetNews godoc @Summary Gets current breaking news, photos, and link @Description Gets current breaking news, photos, and link @Tags dashboard @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/news [get]
func (Service) GetPollen ¶ added in v1.0.43
func (service Service) GetPollen(rw http.ResponseWriter, req *http.Request)
GetPollen godoc @Summary Gets pollen data for the given zipcode @Description Gets pollen data for the given zipcode @Tags dashboard @Accept json @Produce json @Param zipcode body api.PollenRequest true "The zipcode to get pollen data for" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/pollen [post]
func (Service) GetWeather ¶ added in v1.0.46
func (service Service) GetWeather(rw http.ResponseWriter, req *http.Request)
GetWeather godoc @Summary Gets weather data for the given coordinates @Description Gets weather data for the given coordinates @Tags dashboard @Accept json @Produce json @Param zipcode body api.WeatherRequest true "The coordinates to get weather data for" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/weather [post]
func (Service) RemoveConfig ¶
func (service Service) RemoveConfig(rw http.ResponseWriter, req *http.Request)
RemoveConfig godoc @Summary Removes a specific config item and broadcasts the change on the websocket @Description Removes a specific config item and broadcasts the change on the websocket @Tags config @Accept json @Produce json @Param config body api.RemoveConfigRequest true "The config item to remove" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /config [delete]
func (Service) SetConfig ¶
func (service Service) SetConfig(rw http.ResponseWriter, req *http.Request)
SetConfig godoc @Summary Sets a specific config item and broadcasts the change on the websocket @Description Sets a specific config item and broadcasts the change on the websocket @Tags config @Accept json @Produce json @Param config body api.SetConfigRequest true "The config item to update" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /config [post]
type SetConfigRequest ¶ added in v1.0.39
SetConfigRequest represents a 'set config' request
type SpaHandler ¶ added in v1.0.41
SpaHandler implements the http.Handler interface, so we can use it to respond to HTTP requests. The path to the static directory and path to the index file within that static directory are used to serve the SPA in the given static directory.
func (SpaHandler) ServeHTTP ¶ added in v1.0.41
func (h SpaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP inspects the URL path to locate a file within the static dir on the SPA handler. If a file is found, it will be served. If not, the file located at the index path on the SPA handler will be served. This is suitable behavior for serving an SPA (single page application).
type SystemResponse ¶
type SystemResponse struct { Message string `json:"message"` Data interface{} `json:"data"` }
SystemResponse is a response for a system request
type WeatherAlert ¶ added in v1.0.46
type WeatherAlert struct { Title string `json:"title,omitempty"` Regions []string `json:"regions,omitempty"` Severity string `json:"severity,omitempty"` Description string `json:"description,omitempty"` Time float64 `json:"time,omitempty"` Expires float64 `json:"expires,omitempty"` URI string `json:"uri,omitempty"` }
WeatherAlert defines an alert for a weather event
type WeatherDataBlock ¶ added in v1.0.46
type WeatherDataBlock struct { Summary string `json:"summary,omitempty"` Icon string `json:"icon,omitempty"` Data []WeatherDataPoint `json:"data,omitempty"` }
WeatherDataBlock defines a group of data points
type WeatherDataPoint ¶ added in v1.0.46
type WeatherDataPoint struct { Time int64 `json:"time,omitempty"` Summary string `json:"summary,omitempty"` Icon string `json:"icon,omitempty"` PrecipIntensity float64 `json:"precipIntensity,omitempty"` PrecipIntensityMax float64 `json:"precipIntensityMax,omitempty"` PrecipProbability float64 `json:"precipProbability"` PrecipType string `json:"precipType,omitempty"` PrecipAccumulation float64 `json:"precipAccumulation"` Temperature float64 `json:"temperature,omitempty"` TemperatureMax float64 `json:"temperatureMax,omitempty"` ApparentTemperature float64 `json:"apparentTemperature,omitempty"` WindSpeed float64 `json:"windSpeed,omitempty"` WindGust float64 `json:"windGust,omitempty"` WindBearing float64 `json:"windBearing,omitempty"` CloudCover float64 `json:"cloudCover,omitempty"` Humidity float64 `json:"humidity,omitempty"` Pressure float64 `json:"pressure,omitempty"` Visibility float64 `json:"visibility,omitempty"` Ozone float64 `json:"ozone,omitempty"` UVIndex float64 `json:"uvindex,omitempty"` }
WeatherDataPoint defines a weather data point
type WeatherReport ¶ added in v1.0.46
type WeatherReport struct { Latitude float64 `json:"latitude,omitempty"` Longitude float64 `json:"longitude,omitempty"` Currently WeatherDataPoint `json:"currently,omitempty"` Daily WeatherDataBlock `json:"daily,omitempty"` Hourly []WeatherDataPoint `json:"hourly,omitempty"` Alerts []WeatherAlert `json:"alerts,omitempty"` APICalls int `json:"apicalls,omitempty"` Code int `json:"code,omitempty"` Version string `json:"version"` LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
WeatherReport defines a weather report
type WeatherRequest ¶ added in v1.0.46
WeatherRequest represents a request to get weather information for the given coordiates