Documentation
¶
Index ¶
- Constants
- Variables
- func AddAlarmToUser(ctx context.Context, conn *sql.Conn, userID int64, alarm Alarm) (alarmID int64, err error)
- func AddAreaToUnit(ctx context.Context, conn *sql.Conn, unitID int64, area AlarmArea) error
- func AlarmHasArea(ctx context.Context, conn *sql.Conn, unitID, areaID int64) bool
- func CreateAlarm(ctx context.Context, conn *sql.Conn, alarm Alarm) (alarmID int64, err error)
- func CreateAlarmArea(ctx context.Context, conn *sql.Conn, unitID int64, area AlarmArea) (areaID int64, err error)
- func CreateAlarmSettings(ctx context.Context, conn *sql.Conn, userID int64) (int64, error)
- func CreateAppSettings(ctx context.Context, conn *sql.Conn, groupID int64, settings AppSettings) (int64, error)
- func CreateGroup(ctx context.Context, conn *sql.Conn, group *Group) (int64, error)
- func CreateGroupMapLayer(ctx context.Context, conn *sql.Conn, groupID int64, layer *LayerForGroup) (layerID int64, err error)
- func CreateMapLayer(ctx context.Context, conn *sql.Conn, layer *Layer) (layerID int64, err error)
- func CreateProfile(ctx context.Context, conn *sql.Conn, userID int64) (int64, error)
- func CreateRole(ctx context.Context, conn *sql.Conn, role *Role) (int64, error)
- func CreateRolePermission(ctx context.Context, conn *sql.Conn, roleID, permissionID int64) error
- func CreateStrokeArea(ctx context.Context, conn *sql.Conn, area *StrokeArea) (int64, error)
- func CreateUser(ctx context.Context, conn *sql.Conn, user *User) (id int64, err error)
- func CreateUserLog(log Logging, userID int64) (logID int64, err error)
- func DeleteAlarm(ctx context.Context, conn *sql.Conn, alarmID, userID int64) error
- func DeleteAlarmByGroupID(ctx context.Context, conn *sql.Conn, alarmID, groupID int64) error
- func DeleteGroup(ctx context.Context, conn *sql.Conn, groupID int64) error
- func DeleteGroupMapLayer(ctx context.Context, conn *sql.Conn, groupID, layerID int64) error
- func DeleteMapLayer(ctx context.Context, conn *sql.Conn, layerID int64) error
- func DeleteRole(ctx context.Context, conn *sql.Conn, roleID int64) error
- func DeleteRolePermission(ctx context.Context, conn *sql.Conn, roleID, permissionID int64) error
- func DeleteUser(ctx context.Context, conn *sql.Conn, userID int64) error
- func GeomContainsPoint(g wkt.Geom, point *wkt.Point) bool
- func HasAlarm(ctx context.Context, conn *sql.Conn, userID, alarmID int64) bool
- func HasAlarmByGroup(ctx context.Context, conn *sql.Conn, groupID, alarmID int64) bool
- func LoadActivities(ctx context.Context, conn *sql.Conn, permissionActivities []PermissionActivity) (map[int64]*Activity, error)
- func LoadPermissions(ctx context.Context, conn *sql.Conn, rolePermissions []RolePermission, ...) error
- func LoadRoles(ctx context.Context, conn *sql.Conn, userRoles []UserRole) (map[int64]*Role, error)
- func LoadRolesForUser(ctx context.Context, conn *sql.Conn, userID int64) (*[]Role, error)
- func LoadStrokeAreaAsWKT(ctx context.Context, conn *sql.Conn, userID int64) (wkt.Geom, error)
- func MultiPolygonContainsPoint(poly *wkt.MultiPolygon, point *wkt.Point) bool
- func PolygonContainsPoint(poly *wkt.Polygon, point *wkt.Point) bool
- func RemoveAreaFromUnit(ctx context.Context, conn *sql.Conn, unitID, areaID int64) error
- func UpdateAlarm(ctx context.Context, conn *sql.Conn, alarm Alarm) (alarmID int64, err error)
- func UpdateAlarmArea(ctx context.Context, conn *sql.Conn, area *AlarmArea) (int64, error)
- func UpdateAlarmSettings(ctx context.Context, conn *sql.Conn, settings AlarmSettings) (int64, error)
- func UpdateAppSettings(ctx context.Context, conn *sql.Conn, groupID int64, settings AppSettings) (int64, error)
- func UpdateGroup(ctx context.Context, conn *sql.Conn, group *Group) (int64, error)
- func UpdateGroupMapLayer(ctx context.Context, conn *sql.Conn, layer *LayerForGroup) (layerID int64, err error)
- func UpdateMapLayer(ctx context.Context, conn *sql.Conn, layer *Layer) (layerID int64, err error)
- func UpdateProfile(ctx context.Context, conn *sql.Conn, userID int64, profile *interface{}) error
- func UpdateRole(ctx context.Context, conn *sql.Conn, role *Role) (int64, error)
- func UpdateStrokeArea(ctx context.Context, conn *sql.Conn, area *StrokeArea) (int64, error)
- func UpdateUser(ctx context.Context, conn *sql.Conn, user *User) (int64, error)
- type Activity
- type Alarm
- func LoadAlarm(ctx context.Context, conn *sql.Conn, unitID int64) (*Alarm, error)
- func LoadAlarmByGroup(ctx context.Context, conn *sql.Conn, groupID int64) ([]Alarm, error)
- func LoadAlarmByGroupByID(ctx context.Context, conn *sql.Conn, groupID, alarmID int64) ([]Alarm, error)
- func LoadAlarms(ctx context.Context, conn *sql.Conn, userID int64) ([]Alarm, error)
- type AlarmArea
- type AlarmSettings
- type AppSettings
- type BBox
- type Date
- type Group
- type HostTheme
- type Layer
- type LayerForGroup
- func LoadGroupMapLayerByID(ctx context.Context, conn *sql.Conn, groupID, layerID int64) (*LayerForGroup, error)
- func LoadGroupMapLayers(ctx context.Context, conn *sql.Conn, groupID int64) ([]LayerForGroup, error)
- func LoadMapLayersUser(ctx context.Context, conn *sql.Conn, userID int64) ([]LayerForGroup, error)
- type Logging
- type PWResetUser
- type Permission
- func LoadPermissionByID(ctx context.Context, conn *sql.Conn, permissionID int64) (*Permission, error)
- func LoadPermissionsByRole(ctx context.Context, conn *sql.Conn, roleID int64) ([]*Permission, error)
- func LoadUserPermissions(ctx context.Context, conn *sql.Conn, userID int64) ([]*Permission, error)
- type PermissionActivity
- type Profile
- type Role
- type RolePermission
- type Statistic
- type StatisticItem
- type StrokeArea
- type Template
- func LoadTemplateFax(ctx context.Context, conn *sql.Conn) ([]Template, error)
- func LoadTemplateMQTT(ctx context.Context, conn *sql.Conn) ([]Template, error)
- func LoadTemplateMail(ctx context.Context, conn *sql.Conn) ([]Template, error)
- func LoadTemplatePhone(ctx context.Context, conn *sql.Conn) ([]Template, error)
- func LoadTemplateSMS(ctx context.Context, conn *sql.Conn) ([]Template, error)
- type Theme
- type Time
- type TimeParser
- type User
- type UserActivities
- type UserRole
Constants ¶
const ( PermissionActivitiesSQL = ` SELECT activity_id FROM users.permission_activity WHERE permission_id = $1` PermissionSQL = ` SELECT name FROM users.permissions WHERE id = $1` ActivitySQL = ` SELECT name, method, destination_url FROM users.activity WHERE id = $1` AllActivitiesSQL = ` SELECT id, name, method, destination_url FROM users.activity` )
const ( // TimeFormat is the default format TimeFormat = time.RFC3339 // TimeFormatMicro includes micro seconds TimeFormatMicro = "2006-01-02T15:04:05.999Z07:00" // TimeFormatMicroLocal is in local time TimeFormatMicroLocal = "2006-01-02T15:04:05.000" // DateFormat is for dates without time. DateFormat = "2006-01-02" )
Variables ¶
var ParseTime = TimeParser{ TimeFormat, TimeFormatMicro, TimeFormatMicroLocal, DateFormat, }.Parse
ParseTime parses the time formats.
Functions ¶
func AddAlarmToUser ¶
func AddAlarmToUser(ctx context.Context, conn *sql.Conn, userID int64, alarm Alarm) (alarmID int64, err error)
AddAlarmToUser connects an existing alarm to the specified user.
func AddAreaToUnit ¶
AddAreaToUnit associates an existing area with an alarm_area_unit.
func AlarmHasArea ¶
func CreateAlarm ¶
CreateAlarm persists the given alarm and connects it to the user.
func CreateAlarmArea ¶
func CreateAlarmArea(ctx context.Context, conn *sql.Conn, unitID int64, area AlarmArea) (areaID int64, err error)
CreateAlarmArea persists a new alarm area for an existing alarm_area_unit.
func CreateAlarmSettings ¶
CreateAlarmSettings persists new and empty alarm settings for a user.
func CreateAppSettings ¶
func CreateAppSettings(ctx context.Context, conn *sql.Conn, groupID int64, settings AppSettings) (int64, error)
CreateAppSettings persists new app settings for the specified group.
func CreateGroup ¶
CreateGroup persists a new group in the database and creates empty app settings.
func CreateGroupMapLayer ¶
func CreateGroupMapLayer(ctx context.Context, conn *sql.Conn, groupID int64, layer *LayerForGroup) (layerID int64, err error)
CreateGroupMapLayer persists the given layer.
func CreateMapLayer ¶
CreateMapLayer persists the given layer.
func CreateProfile ¶
CreateProfile persists a new empty profile for a user.
func CreateRole ¶
CreateRole writes a new role to db.
func CreateRolePermission ¶
CreateRolePermission associates a permission with a role.
func CreateStrokeArea ¶
CreateStrokeArea persists a new stroke area.
func CreateUser ¶
CreateUser writes a new user to db.
func CreateUserLog ¶
CreateUserLog persists the given alarm and connects it to the user.
func DeleteAlarm ¶
DeleteAlarm removes the association between the user and the alarm. Does not remove the alarm itself.
func DeleteAlarmByGroupID ¶
DeleteAlarmByGroupID removes an alarm from the database.
func DeleteGroup ¶
DeleteGroup removes an empty group from the database.
func DeleteGroupMapLayer ¶
DeleteGroupMapLayer removes the the maplayer freom db.
func DeleteMapLayer ¶
DeleteMapLayer removes the the maplayer freom db.
func DeleteRole ¶
DeleteRole removes a role from db.
func DeleteRolePermission ¶
DeleteRolePermission removes the association between a role and a permission.
func DeleteUser ¶
DeleteUser removes a user from db.
func GeomContainsPoint ¶
GeomContainsPoint checks if a point is inside a given geometry.
func HasAlarm ¶
HasAlarm checks if the alarm identified by alarm is associated to a user identified by userID
func HasAlarmByGroup ¶
HasAlarmByGroup checks if the group has the alarm.
func LoadActivities ¶
func LoadPermissions ¶
func LoadPermissions( ctx context.Context, conn *sql.Conn, rolePermissions []RolePermission, permissions map[int64]*Permission, ) error
func LoadRolesForUser ¶
LoadRolesForUser fetches roles for a user from db using the userID parameter
func LoadStrokeAreaAsWKT ¶
LoadStrokeAreaAsWKT returns the geometry of a given userID.
func MultiPolygonContainsPoint ¶
func MultiPolygonContainsPoint(poly *wkt.MultiPolygon, point *wkt.Point) bool
MultiPolygonContainsPoint checks if a multi-polygon contains a given point.
func PolygonContainsPoint ¶
PolygonContainsPoint checks if a polygon contains a given point.
func RemoveAreaFromUnit ¶
RemoveAreaFromUnit deletes the connection between an alarm area and the unit.
func UpdateAlarm ¶
UpdateAlarm persists new attributes in an existing alarm.
func UpdateAlarmArea ¶
UpdateAlarmArea persists changed attributes of a stroke area.
func UpdateAlarmSettings ¶
func UpdateAlarmSettings(ctx context.Context, conn *sql.Conn, settings AlarmSettings) (int64, error)
UpdateAlarmSettings persists changes in alarmsettings.
func UpdateAppSettings ¶
func UpdateAppSettings(ctx context.Context, conn *sql.Conn, groupID int64, settings AppSettings) (int64, error)
UpdateAppSettings persists changes in app settings.
func UpdateGroup ¶
UpdateGroup persists changes for a group.
func UpdateGroupMapLayer ¶
func UpdateGroupMapLayer(ctx context.Context, conn *sql.Conn, layer *LayerForGroup) (layerID int64, err error)
UpdateGroupMapLayer persists new attributes in an existing layer.
func UpdateMapLayer ¶
UpdateMapLayer persists new attributes in an existing layer.
func UpdateProfile ¶
UpdateProfile sets the new profile data for a user.
func UpdateRole ¶
UpdateRole persists changes in role attributes.
func UpdateStrokeArea ¶
UpdateStrokeArea persists changed attributes of a stroke area.
Types ¶
type Activity ¶
type Alarm ¶
type Alarm struct {
ID int64 `json:"id"`
Name string `json:"name"`
GroupID int64 `json:"groupId"`
Alarm bool `json:"alarm"`
AlarmTimestamp *pgtype.Timestamptz `json:"alarmTimestamp"`
IsExtended bool `json:"isExtended"`
IsNotified bool `json:"isNotified"`
}
Alarm represents the datastructure for alarm_area_units in the db.
func LoadAlarmByGroup ¶
LoadAlarmByGroup fetches alarms associated to a group from db using the groupID parameter
type AlarmArea ¶
type AlarmArea struct {
ID int64 `json:"id"`
Geom interface{} `json:"geom"`
AlarmDuration *int64 `json:"alarmDuration"`
Radius *float64 `json:"radius"`
Center *interface{} `json:"center"`
Icon *string `json:"icon"`
Area *float64 `json:"area"`
InnerRadius *float64 `json:"innerRadius"`
StrokeThreshold *int64 `json:"strokeThreshold"`
StrokeCounter *int64 `json:"strokeCounter"`
LastStroke *pgtype.Timestamptz `json:"lastStroke"`
}
AlarmArea represents the persistence layer
func LoadAlarmAreaByID ¶
LoadAlarmAreaByID fetches a single alarm area specified by id.
type AlarmSettings ¶
type AlarmSettings struct {
ID *int64 `json:"id"`
AlarmTemplateMailID *int64 `json:"alarmTemplateMailId"`
AlarmTemplateSmsID *int64 `json:"alarmTemplateSmsId"`
AlarmTemplateMqttID *int64 `json:"alarmTemplateMqttId"`
AlarmTemplateFaxID *int64 `json:"alarmTemplateFaxId"`
Sms *string `json:"sms"`
Email *string `json:"email"`
Phone *string `json:"phone"`
Fax *string `json:"fax"`
StartDate *pgtype.Timestamptz `json:"startDate"`
StopDate *pgtype.Timestamptz `json:"stopDate"`
StartTime *time.Time `json:"startTime"`
StopTime *time.Time `json:"stopTime"`
Monday *bool `json:"monday"`
Tuesday *bool `json:"tuesday"`
Wednesday *bool `json:"wednesday"`
Thursday *bool `json:"thursday"`
Friday *bool `json:"friday"`
Saturday *bool `json:"saturday"`
Sunday *bool `json:"sunday"`
OnlyLog bool `json:"onlyLog"`
StrokeProtocol bool `json:"strokeProtocol"`
StrokeAsCSV bool `json:"strokeAsCSV"`
}
AlarmSettings represents the persistence layer
func LoadAlarmSettings ¶
LoadAlarmSettings fetches alarm settings for a user from db using the userID parameter
type AppSettings ¶
type AppSettings struct {
ID *int64 `json:"id"`
GroupID int64 `json:"groupId"`
MaxDisplayTime *int64 `json:"maxDisplayTime"`
ArchiveDays int64 `json:"archiveDays"`
ArchiveSince pgtype.Timestamptz `json:"archiveSince"`
MaxZoom int64 `json:"maxZoom"`
MinZoom int64 `json:"minZoom"`
LiveBlids bool `json:"liveBlids"`
Animation bool `json:"animation"`
Sound bool `json:"sound"`
Path string `json:"path"`
MaxAlarms int64 `json:"maxAlarms"`
MaxAlarmAreas int64 `json:"maxAlarmAreas"`
MaxAlarmUser int64 `json:"maxAlarmUser"`
StatisticWindowed bool `json:"statisticWindowed"`
}
AppSettings represents the persistence layer
func LoadAppSettings ¶
LoadAppSettings fetches settings for a group from db using the groupID parameter
type BBox ¶
BBox is a bounding box of an area.
func CalculateBBox ¶
CalculateBBox return the bounding box of given geometry.
type Date ¶
Date is a wrapper for time.Time
func (Date) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Date
func (*Date) UnmarshalJSON ¶
UnmarshalJSON parses the JSON encoded Date.
type Group ¶
type Group struct {
ID *int64 `json:"id"`
Name *string `json:"name"`
Parent *int64 `json:"parent"`
RoleID *int64 `json:"roleId"`
ThemeID *int64 `json:"themeId"`
MaxAlarmArea *int64 `json:"maxAlarmArea"`
DataAreaID *int64 `json:"dataAreaId"`
AlarmConfigID *int64 `json:"alarmConfigId"`
ChangeAlarmConfig bool `json:"changeAlarmConfig"`
}
Group represents the persistence layer
func LoadGroupByID ¶
LoadGroupByID fetches the group with the given groupID from the database.
type HostTheme ¶
type Layer ¶
type Layer struct {
ID int64 `json:"id"`
GeoserverName *string `json:"geoserverName"`
Name *string `json:"name"`
Reload bool `json:"reload"`
BaseLayer bool `json:"baseLayer"`
TimeLayer bool `json:"timeLayer"`
TickWidth *int64 `json:"tickWidth"`
LayerType string `json:"layerType"`
SingleTile bool `json:"singleTile"`
DefaultName *string `json:"defaultName"`
ExternalServer *string `json:"externalServer"`
ExternalParameter json.RawMessage `json:"externalParameter"`
}
Layer represents the datastructure for map_layers in the db.
func LoadMapLayerByID ¶
LoadMapLayerByID fetches a layer identified by its id from the database.
type LayerForGroup ¶
type LayerForGroup struct {
ID int64 `json:"id"`
GroupID int64 `json:"groupId"`
LayerID int64 `json:"layerID"`
ReloadTime int64 `json:"reloadTime"`
DisplayName *string `json:"displayName"`
FeatureInfo bool `json:"featureInfo"`
CheckOnLogin bool `json:"checkedOnLogin"`
Permanent bool `json:"permanent"`
CQLFilter json.RawMessage `json:"cqlFilter"`
PopupTemplate *string `json:"popupTemplate"`
ZIndex *int64 `json:"zIndex"`
}
LayerForGroup represents the datastructure for group_map_layers in the db.
func LoadGroupMapLayerByID ¶
func LoadGroupMapLayerByID(ctx context.Context, conn *sql.Conn, groupID, layerID int64) (*LayerForGroup, error)
LoadGroupMapLayerByID fetches a group layer identified by its id from the database.
func LoadGroupMapLayers ¶
func LoadGroupMapLayers(ctx context.Context, conn *sql.Conn, groupID int64) ([]LayerForGroup, error)
LoadGroupMapLayers fetches the map layers from db
func LoadMapLayersUser ¶
LoadMapLayersUser fetches the map layers from db
type Logging ¶
type Logging struct {
ID int64 `json:"id"`
User string `json:"user"`
Text string `json:"text"`
Timestamp *pgtype.Timestamptz `json:"timestamp"`
IP string `json:"ip"`
}
Logging represents the datastructure in the db.
type PWResetUser ¶
type PWResetUser struct {
User string `json:"user"`
}
PWResetUser is send to request a password reset for a user.
type Permission ¶
type Permission struct {
ID int64 `json:"id"`
Name string `json:"name"`
ActivityIDs []int64 `json:"activities,omitempty"`
}
Permission represents the persistence layer.
func LoadPermissionByID ¶
func LoadPermissionByID(ctx context.Context, conn *sql.Conn, permissionID int64) (*Permission, error)
LoadPermissionByID fetches a single permission.
func LoadPermissionsByRole ¶
func LoadPermissionsByRole(ctx context.Context, conn *sql.Conn, roleID int64) ([]*Permission, error)
LoadPermissionsByRole fetches the permissions for a specified user.
func LoadUserPermissions ¶
LoadUserPermissions fetches the permissions for a specified user.
type PermissionActivity ¶
type PermissionActivity struct {
PermissionID int64 `json:"permission_id"`
ActivityID int64 `json:"activity_id"`
}
func LoadPermissionActivities ¶
func LoadPermissionActivities( ctx context.Context, conn *sql.Conn, rolePermissions []RolePermission, ) ([]PermissionActivity, error)
type Role ¶
type Role struct {
ID int64 `json:"id"`
Parent *int64 `json:"parent"`
Name *string `json:"name"`
PermissionIDs []int64 `json:"permissions,omitempty"`
}
Role represents the persitence layer of a role
type RolePermission ¶
type RolePermission struct {
RoleID int64 `json:"role_id"`
PermissionID int64 `json:"permission_id"`
}
func LoadRolePermissions ¶
type Statistic ¶
type Statistic struct {
PEarth []StatisticItem `json:"pEarth"`
NEarth []StatisticItem `json:"nEarth"`
Cloud []StatisticItem `json:"cloud"`
CountTotal int64 `json:"countTotal"`
CountPEarth int64 `json:"countPEarth"`
CountNEarth int64 `json:"countNEarth"`
CountCloud int64 `json:"countCloud"`
}
Statistic represents the summary over stroke statistics in a specific time range and in a specific bbox.
type StatisticItem ¶
StatisticItem represents a single entry in statistics.
type StrokeArea ¶
type StrokeArea struct {
ID *int64 `json:"id"`
GroupID int64 `json:"groupId"`
Geom interface{} `json:"geom"`
}
StrokeArea represents the persistence layer
func LoadStrokeArea ¶
LoadStrokeArea fetches a stroke area for a user from db using the userID parameter
func LoadStrokeAreaByGroup ¶
LoadStrokeAreaByGroup fetches a single stroke area for a group.
type Template ¶
type Template struct {
ID int64 `json:"id"`
AlarmSubject *string `json:"alarmSubject"`
AllClearSubject *string `json:"allClearSubject"`
AlarmText *string `json:"alarmText"`
AllClearText *string `json:"allClearText"`
}
Template represents the persitence layer of all types of templates
func LoadTemplateFax ¶
LoadTemplateFax fetches all templates of type fax.
func LoadTemplateMQTT ¶
LoadTemplateMQTT fetches all templates of type mqtt.
func LoadTemplateMail ¶
LoadTemplateMail fetches all templates of type mail.
func LoadTemplatePhone ¶
LoadTemplatePhone fetches all templates of type phone.
type Theme ¶
type Theme struct {
ID *int64 `json:"id"`
Name *string `json:"name"`
Data *pgtype.JSON `json:"data"`
}
Theme represents the persitence layer of a user
func LoadThemeForUser ¶
LoadThemeForUser fetches a theme for a user from db using the userID parameter
type Time ¶
Time is a wrapper for time.Time
func (Time) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Time
func (*Time) UnmarshalJSON ¶
UnmarshalJSON pases the JSON encodes Time
type User ¶
type User struct {
ID *int64 `json:"id"`
Name *string `json:"name"`
Password *string `json:"password"`
GroupID *int64 `json:"groupId"`
StartDate *sql.NullTime `json:"startDate"`
StopDate *sql.NullTime `json:"stopDate"`
FirstName *string `json:"firstName"`
LastName *string `json:"lastName"`
Company *string `json:"company"`
Division *string `json:"division"`
Street *string `json:"street"`
ZIP *string `json:"zip"`
City *string `json:"city"`
PhoneNumber *string `json:"phonenumber"`
Annotation *string `json:"annotation"`
MobileNumber *string `json:"mobilenumber"`
EMail *string `json:"email"`
}
User represents the persitence layer of a user
type UserActivities ¶
type UserActivities struct {
Roles map[int64]*Role `json:"roles"`
Permissions map[int64]*Permission `json:"permissions"`
Activities map[int64]*Activity `json:"activities"`
}