Documentation ¶
Overview ¶
Package browser is the root package for the browser web application and contains all domain types.
Index ¶
- Constants
- Variables
- func AppendStringIfMissing(slice []string, s string) []string
- func Int64(v int64) *int64
- type Database
- type Group
- type GroupType
- type Measurement
- type Point
- type Role
- type SeriesFilter
- type Station
- type StationService
- type Stations
- type Stmt
- type TimeSeries
- type User
- type UserService
Constants ¶
const DefaultCollectionInterval = 15 * time.Minute
DefaultCollectionInterval is the default interval with which LTER stations aggregate measured points.
const UserContextKey userContextKey = "BrowserLTER"
UserContextKey is the context key for retrieving the user off of context.
Variables ¶
var ( ErrAuthentication = errors.New("user not authenticated") ErrDataNotFound = errors.New("no data points") ErrInvalidRequest = errors.New("invalid request") ErrInternal = errors.New("internal error") ErrInvalidToken = errors.New("invalid token") ErrUserNotFound = errors.New("user not found") ErrUserNotValid = errors.New("user is not valid") ErrUserAlreadyExists = errors.New("user already exists") ErrGroupsNotFound = errors.New("no groups found") // Location denotes the time location of the LTER stations, which is UTC+1. Location = time.FixedZone("+0100", 60*60) // Build version & commit SHA. Version string Commit string )
var Roles = []Role{Public, External, FullAccess}
Roles is a list of all supported Roles.
Functions ¶
func AppendStringIfMissing ¶
AppendStringIfMissing will append the given string to the given slice if it is missing.
Types ¶
type Database ¶
type Database interface { // Series returns a TimeSeries filtered with the given SeriesFilter. Points // in a TimeSeries should always have a continuous time range as for // https://gitlab.inf.unibz.it/lter/browser/issues/10 Series(context.Context, *SeriesFilter) (TimeSeries, error) // GroupsByStation will return a slice of groupped measurements stored in // the Database for the given station. GroupsByStation(context.Context, int64) ([]Group, error) // Maintenance will return a list of measurement names which correspond to // maintenance observations. Maintenance(context.Context) ([]string, error) // Query returns a query Stmt for the given SeriesFilter. Query(context.Context, *SeriesFilter) *Stmt }
Database represents a backend for retrieving time series data.
type Group ¶
type Group uint8
Group combines multiple measurements to a single entity.
const ( AirTemperature Group = iota RelativeHumidity SoilTemperature SoilTemperatureDepth00 SoilTemperatureDepth02 SoilTemperatureDepth05 SoilTemperatureDepth10 SoilTemperatureDepth20 SoilTemperatureDepth40 SoilTemperatureDepth50 SoilWaterContent SoilWaterContentDepth02 SoilWaterContentDepth05 SoilWaterContentDepth20 SoilWaterContentDepth40 SoilWaterContentDepth50 SoilElectricalConductivity SoilElectricalConductivityDepth02 SoilElectricalConductivityDepth05 SoilElectricalConductivityDepth20 SoilElectricalConductivityDepth40 SoilElectricalConductivityDepth50 SoilDielectricPermittivity SoilDielectricPermittivityDepth02 SoilDielectricPermittivityDepth05 SoilDielectricPermittivityDepth20 SoilDielectricPermittivityDepth40 SoilDielectricPermittivityDepth50 SoilWaterPotential SoilWaterPotentialDepth05 SoilWaterPotentialDepth20 SoilWaterPotentialDepth40 SoilWaterPotentialDepth50 SoilHeatFlux SoilSurfaceTemperature Wind WindSpeed WindDirection WindGust Precipitation PrecipitationTotal PrecipitationIntensity SnowHeight LeafWetnessDuration SunshineDuration PhotosyntheticallyActiveRadiation PhotosyntheticallyActiveRadiationTotal PhotosyntheticallyActiveRadiationDiffuse PhotosyntheticallyActiveRadiationAtSoilLevel NDVIRadiations PRIRadiations ShortWaveRadiation ShortWaveRadiationIncoming ShortWaveRadiationOutgoing LongWaveRadiation LongWaveRadiationIncoming LongWaveRadiationOutgoing AtmosphericPressure NoGroup )
func AppendGroupIfMissing ¶
AppendGroupIfMissing will append the given to group to the given slice if it is missing.
func FilterGroupsByRole ¶
FilterGroupsByRole will filter the give groups by the given role returning only groups the role is allowed to access.
func GroupsByRole ¶
GroupsByRole will return a list of groups for the given role.
func GroupsByType ¶
type Measurement ¶
type Measurement struct { Label string Aggregation string Unit string Depth *int64 Station *Station Points []*Point }
Measurement represents a single measurements with metadata and its points.
type Role ¶
type Role string
Role represents a role a User is part of.
func NewRole ¶
NewRole returns a new role from the given string. If the string cannot be parsed to a role the default role will be returned.
func (*Role) UnmarshalJSON ¶
type SeriesFilter ¶
type SeriesFilter struct { Groups []Group Stations []string Landuse []string Start time.Time End time.Time // WithSTD determines if the Series should contain standard deviations. WithSTD bool // Maintenance is a list of raw label names corresponding to measurements // used for maintenance technicians. Maintenance []string }
SeriesFilter represents a filter for filtering TimeSeries.
func ParseSeriesFilterFromRequest ¶
func ParseSeriesFilterFromRequest(r *http.Request) (*SeriesFilter, error)
ParseSeriesFilterFromRequest parses form values from the given http.Request and returns a a valid SeriesFilter or an error. It performs basic validation for the given dates.
type Station ¶
type Station struct { ID int64 Name string Landuse string Elevation int64 Latitude float64 Longitude float64 Image string Dashboard string }
Station represents a meteorological station of the LTER project.
type StationService ¶
type StationService interface { // Station returns the station by the given id or an error. Station(ctx context.Context, id int64) (*Station, error) // Stations retrieves metadata about all stations. Stations(ctx context.Context) (Stations, error) }
StationService represents a service for retriving stations.
type Stations ¶
type Stations []*Station
Stations represents a group of meteorological stations.
type Stmt ¶
Stmt is a query statement composed of the actual query and the database it is performed on.
type User ¶
User represents an authenticated user.
func UserFromContext ¶
UserFromContext reads user information from the given context. If the context has no user information a default user will be returned.
type UserService ¶
type UserService interface { // Get retrieves a user if it exists Get(context.Context, *User) (*User, error) // Create a new User in the UsersStore Create(context.Context, *User) error // Delete the user from the UsersStore Delete(context.Context, *User) error // Update updates the given user Update(context.Context, *User) error }
UserService is the storage and retrieval of authentication information.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
encoding/csv
Package csv writes comma-separated values (CSV) files using the LTER default CSV format.
|
Package csv writes comma-separated values (CSV) files using the LTER default CSV format. |
encoding/csvf
Package csvf writes comma-separated values (CSV) files using the LTER friendly format.
|
Package csvf writes comma-separated values (CSV) files using the LTER friendly format. |
http
Package http handles everything related to HTTP.
|
Package http handles everything related to HTTP. |
influx
Package influx provides the implementation of the browser.Database interface using InfluxDB as backend.
|
Package influx provides the implementation of the browser.Database interface using InfluxDB as backend. |
middleware
Package middleware implements a simple middleware pattern for HTTP handlers, along with implementation for some common middleware.
|
Package middleware implements a simple middleware pattern for HTTP handlers, along with implementation for some common middleware. |
mock
Package mock provides mock implementations of various interfaces used only for testing.
|
Package mock provides mock implementations of various interfaces used only for testing. |
oauth2
Package oauth2 provides an handler for handling OAuth2 authentication flows and the implementation of several OAuth2 providers.
|
Package oauth2 provides an handler for handling OAuth2 authentication flows and the implementation of several OAuth2 providers. |
ql
Package ql provides an API for building InfluxQL queries.
|
Package ql provides an API for building InfluxQL queries. |
snipeit
Package snipeit provides a service for retriving information stored in SnipeIT.
|
Package snipeit provides a service for retriving information stored in SnipeIT. |