model

package
v0.0.0-...-689a9a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownStatisticsFilter is returned if an unknown statistics filter
	// is given.
	ErrUnknownStatisticsFilter = errors.New("unknown statistics filter")
	// ErrUnknownCountFilter is returned if an unknown counting filter
	// is given.
	ErrUnknownCountFilter = errors.New("unknown count filter type")
)

Functions

func AddAlarmCustomer

func AddAlarmCustomer(groupID int64, customer string) (int64, error)

func AddGroup

func AddGroup(params *GroupParameters) (int64, error)

func AddGroup2Alarm

func AddGroup2Alarm(groupID int64, customerID int64) (int64, error)

AddGroup2Alarm adds a grouo to an alarm.

func AddLayer

func AddLayer(groupID, layerID int64) (int64, error)

func AddPerm

func AddPerm(userID int64, groupID int64, roleID int64) error

func AddRole

func AddRole(params *RoleDetailParameters) (int64, error)

func AddUser

func AddUser(user *UserDetails) (int64, error)

func CheckCustomerAlarm

func CheckCustomerAlarm(customerID int64, alarmID int64) (bool, error)

CheckCustomerAlarm checks if there is any customer for a given alarm.

func CheckCustomerArea

func CheckCustomerArea(customerID int64, areaID int64) (bool, error)

CheckCustomerArea checks if there are any customers for an area.

func CheckCustomerParticipant

func CheckCustomerParticipant(customerID int64, participantID int64) (bool, error)

CheckCustomerParticipant checks if there is any customer for a participant.

func CheckGroupAlarmCustomer

func CheckGroupAlarmCustomer(groupID int64, customerID int64) (bool, error)

CheckGroupAlarmCustomer checks if there are any constomers in a group.

func CheckLink(userID int64, hash string) (bool, error)

func CheckUser

func CheckUser(email string) (*int64, error)

func CopyLayer

func CopyLayer(childID, parentID int64) error

func CountAreaInAlarms

func CountAreaInAlarms(areaID int64) (int64, error)

CountAreaInAlarms counts the alarms in a given area.

func CountLoginSuccess

func CountLoginSuccess(logs []*Log) int

CountLoginSuccess counts the successfull logins.

func CountParticipantInAlarms

func CountParticipantInAlarms(participantID int64) (int64, error)

CountParticipantInAlarms counts the alarm participants,

func FindUser

func FindUser(username, password string) (sql.NullInt64, error)

FindUser looks for a user with a password. If they both match the ID of the user is returned.

func GenerateLink(
	https bool, email string,
	userID int64, serverName string,
) (string, error)

func GeomContainsPoint

func GeomContainsPoint(g wkt.Geom, point *wkt.Point) bool

GeomContainsPoint checks if a point is inside a given geometry.

func GetChildren

func GetChildren(id int64) ([]int64, error)

func GetCount

func GetCount(start, stop int64, bound, box *Box, filter CountFilter) (int64, error)

GetCount returns a event count for a given time range between start and stop, an optional bounding box and a count filter.

func GetHomeGroup

func GetHomeGroup(userID int64) (*int64, error)

func GetLiveBlitzgebiet

func GetLiveBlitzgebiet(userID int64) (wkt.Geom, error)

GetLiveBlitzgebiet returns the geometry of a given userID.

func GetMenu

func GetMenu(userID int64) ([]interface{}, error)

GetMenu returns the menu structure for a given user used in the JS client.

func MultiPolygonContainsPoint

func MultiPolygonContainsPoint(poly *wkt.MultiPolygon, point *wkt.Point) bool

MultiPolygonContainsPoint checks if a multi-polygon contains a given point.

func PolygonContainsPoint

func PolygonContainsPoint(poly *wkt.Polygon, point *wkt.Point) bool

PolygonContainsPoint checks if a polygon contains a given point.

func RemoveAlarm

func RemoveAlarm(alarm AlarmIDs) (int64, error)

func RemoveAlarmArea

func RemoveAlarmArea(area AlarmAreaIDs) (int64, error)

func RemoveAlarmParticipant

func RemoveAlarmParticipant(participant *AlarmParticipantIDs) (int64, error)

func RemoveGroup

func RemoveGroup(groupID int64) error

func RemoveGroup2Alarm

func RemoveGroup2Alarm(groupID int64, customerID int64) (int64, error)

RemoveGroup2Alarm removes a group from an alarm.

func RemoveGroupLayers

func RemoveGroupLayers(groupID int64) error

func RemoveLayer

func RemoveLayer(id, userID int64) (bool, error)

func RemovePerm

func RemovePerm(userID int64) error

func RemoveRole

func RemoveRole(roleID int64) error

func RemoveUser

func RemoveUser(userID int64) error

func SendTestAlarm

func SendTestAlarm(alarm TestAlarm) (int64, error)

func ThemeIDFromHost

func ThemeIDFromHost(host string, def int64) (int64, error)

func UpdateAlarm

func UpdateAlarm(areaID, participantID int64, alarmID *int64, customerID int64) (int64, error)

func UpdateAlarmArea

func UpdateAlarmArea(area *AlarmArea) (*int64, error)

func UpdateAlarmParticipant

func UpdateAlarmParticipant(participantInfo *ParticipantInfo) (*int64, error)

func UpdateLayer

func UpdateLayer(layer *LayerInfo, groupID int64) error

func UpdatePassword

func UpdatePassword(password string, userID int64, hash string, ip string) error

func UpdatePermission

func UpdatePermission(permission *PermissionParameters) error

func UpdateRole

func UpdateRole(role *RoleDetail) error

func UpdateUser

func UpdateUser(user *UserDetails) error

func UserLogging

func UserLogging(user int64, request string, ip net.IP, session string) error

UserLogging loggs in a user an binds her to the session.

func UserLoggingNoSession

func UserLoggingNoSession(request string, ip net.IP) error

UserLoggingNoSession loggs in a user.

Types

type AlarmArea

type AlarmArea struct {
	AreaName        *string  `json:"gebietname"`
	AreaRadius      *float64 `json:"radius"`
	AreaInnerRadius *float64 `json:"innerradius"`
	AreaGeom        *string  `json:"geometry"`
	AlarmDuration   *int64   `json:"dauer"`
	AlarmThreshold  *int64   `json:"blitzezumalarm"`
	AreaLat         *float64 `json:"breite"`
	AreaLon         *float64 `json:"laenge"`
	CustomerID      *int64   `json:"kundenid"`
	GroupID         *int64   `json:"gruppe"`
	ID              *int64   `json:"id"`
}

AlarmArea are the in-depth informations about an alarm area.

type AlarmAreaGroup

type AlarmAreaGroup struct {
	ID           int64       `json:"id"`
	GroupName    string      `json:"gruppenname"`
	Alarm        *FakeBool   `json:"alarm"`
	Customer     int64       `json:"kunde"`
	CustomerName string      `json:"kundenname"`
	Areas        interface{} `json:"gebiete"`
}

AlarmAreaGroup are the detail passed to the JS client about an alarm area group.

func GetAlarmAreaGroupList

func GetAlarmAreaGroupList(groupID int64) ([]*AlarmAreaGroup, error)

type AlarmAreaIDs

type AlarmAreaIDs struct {
	ID         *int64 `json:"id"`
	CustomerID *int64 `json:"kundeid"`
	GroupID    *int64 `json:"gruppe"`
	Cascade    *bool  `json:"cascade"`
}

AlarmAreaIDs maps an alarm to a customer and a group.

type AlarmAreaInfo

type AlarmAreaInfo struct {
	Name  string `json:"name"`
	Count int64  `json:"count"`
	Geom  string `json:"geom"`
}

AlarmAreaInfo is used as a JSON serialisation of the attributes associated with an alarm area.

func GetAlarmArea

func GetAlarmArea(id int64) (*AlarmAreaInfo, error)

GetAlarmArea return an AlarmAreaInfo for a given userID.

type AlarmAreaList

type AlarmAreaList struct {
	ID                 int64        `json:"id"`
	Area               string       `json:"gebiet"`
	Length             float64      `json:"laenge"`
	Wide               float64      `json:"breite"`
	AreasRadius        float64      `json:"radius"`
	AreasInnerRadius   float64      `json:"innerRadius"`
	AreasBlidsAlarm    int64        `json:"blitzezumalarm"`
	Last               string       `json:"letzter"`
	Number             int64        `json:"anzahl"`
	Surface            float64      `json:"flach"`
	AreasAlarmDuration int64        `json:"alarmdauer"`
	CustomerID         int64        `json:"kundenid"`
	Customer           string       `json:"kunde"`
	Geometry           *string      `json:"geometry"`
	GeoJSON            *interface{} `json:"geojson"`
}

AlarmAreaList is an item of a alarm area list in the JS client.

func GetAlarmGebietList

func GetAlarmGebietList(groupID int64, areaID *int64) ([]*AlarmAreaList, error)

type AlarmAreaListSimple

type AlarmAreaListSimple struct {
	ID         int64  `json:"id"`
	Area       string `json:"gebiet"`
	CustomerID int64  `json:"kundenid"`
}

AlarmAreaListSimple binds an alarm area to a customer.

func GetAlarmAreaListSimple

func GetAlarmAreaListSimple(groupID int64) ([]*AlarmAreaListSimple, error)

type AlarmCustomer

type AlarmCustomer struct {
	ID   int64  `json:"id"`
	Name string `json:"alarmkunde"`
}

AlarmCustomer is the ID and the name of a customer.

func GetAlarmCustomerList

func GetAlarmCustomerList(groupID int64) ([]*AlarmCustomer, error)

type AlarmDetail

type AlarmDetail struct {
	AreasBlidsToAlarm      int64     `json:"blitzezumalarm"`
	Duration               int64     `json:"dauer"`
	AreasBlidsNumber       int64     `json:"blitzanzahl"`
	AreasRadius            float64   `json:"radius"`
	AreasAlarm             *FakeBool `json:"alarm"`
	AreasArea              string    `json:"gebiet"`
	AreaID                 int64     `json:"gebietid"`
	ParticipantStartTime   string    `json:"startzeit"`
	ParticipantStopTime    string    `json:"stopzeit"`
	Start                  string    `json:"beginn"`
	End                    string    `json:"ende"`
	ParticipantMon         *FakeBool `json:"mo"`
	ParticipantTue         *FakeBool `json:"di"`
	ParticipantWed         *FakeBool `json:"mi"`
	ParticipantThu         *FakeBool `json:"don"`
	ParticipantFri         *FakeBool `json:"fr"`
	ParticipantSat         *FakeBool `json:"sa"`
	ParticipantSun         *FakeBool `json:"so"`
	ParticipantOnlyLog     *FakeBool `json:"nurlog"`
	ParticipantUTC         *FakeBool `json:"utc"`
	Protocol               *FakeBool `json:"protocol"`
	CSV                    *FakeBool `json:"csv"`
	ParticipantSMS         string    `json:"sms"`
	ParticipantEMail       string    `json:"email"`
	ParticipantFax         string    `json:"fax"`
	ParticipantTel         string    `json:"tel"`
	ParticipantParticipant string    `json:"teilnehmer"`
	ParticipantID          int64     `json:"teilnehmerid"`
	AreaGroupsGroupsName   string    `json:"gruppenname"`
	AlarmID                int64     `json:"alarmid"`
	AlarmCustomerID        int64     `json:"alarmkundeid"`
	CustomerCustomer       string    `json:"kunde"`
	Last                   string    `json:"letzter"`
	Centerx                float64   `json:"centerx"`
	Centery                float64   `json:"centery"`
	Area                   float64   `json:"flach"`
}

AlarmDetail are the in-depth informations of an alarm.

func GetAlarmList

func GetAlarmList(groupID int64) ([]*AlarmDetail, error)

type AlarmIDs

type AlarmIDs struct {
	ID         *int64 `json:"alarmid"`
	CustomerID *int64 `json:"kundeid"`
	GroupID    *int64 `json:"groupid"`
}

AlarmIDs maps an alarm ID to a customer and a group.

type AlarmMessages

type AlarmMessages struct {
	Start    string `json:"anf"`
	End      string `json:"ende"`
	ID       int64  `json:"id"`
	Alarm    int64  `json:"alarm"`
	Entry    string `json:"eintrag"`
	Finished string `json:"finished"`
	Typ      string `json:"typ"`
}

AlarmMessages is an item in the the list of alarm messages.

func GetAlarmMessages

func GetAlarmMessages(alarmID int64, startString, endString string) ([]*AlarmMessages, error)

type AlarmParticipantIDs

type AlarmParticipantIDs struct {
	ID         *int64 `json:"id"`
	CustomerID *int64 `json:"kunde"`
	GroupID    *int64 `json:"gruppe"`
	Cascade    *bool  `json:"cascade"`
}

AlarmParticipantIDs are used to pass the customer IDs from the JS client to the server.

type AlarmParticipants

type AlarmParticipants struct {
	ID              int64     `json:"id"`
	Participant     string    `json:"teilnehmer"`
	SMS             string    `json:"sms"`
	EMail           string    `json:"email"`
	Fax             string    `json:"fax"`
	Tel             string    `json:"tel"`
	Alarm           string    `json:"alarmierung"`
	AllClear        string    `json:"entwarnung"`
	Customer        int64     `json:"kunde"`
	StartDate       string    `json:"startdatum"`
	StopDate        string    `json:"stopdatum"`
	StartTime       string    `json:"startzeit"`
	StopTime        string    `json:"stopzeit"`
	Mon             *FakeBool `json:"mo"`
	Tue             *FakeBool `json:"di"`
	Wed             *FakeBool `json:"mi"`
	Thu             *FakeBool `json:"don"`
	Fri             *FakeBool `json:"fr"`
	Sat             *FakeBool `json:"sa"`
	Sun             *FakeBool `json:"so"`
	OnlyLog         *FakeBool `json:"nurlog"`
	UTC             *FakeBool `json:"utc"`
	SubjectAlarm    string    `json:"betreffalarm"`
	SubjectAllClear string    `json:"betreffentwarn"`
	BlidsLog        *FakeBool `json:"blitzprotokoll"`
	BlidsASCSV      *FakeBool `json:"blitzascsv"`
	Begin           string    `json:"anfang"`
	End             string    `json:"ende"`
	Active          *FakeBool `json:"aktiv"`
	CustomerName    string    `json:"kundenname"`
}

AlarmParticipants are the details about an alarm participant.

func GetAlarmParticipantsList

func GetAlarmParticipantsList(groupID int64, participantID *int64) ([]*AlarmParticipants, error)

type AlarmParticipantsListSimple

type AlarmParticipantsListSimple struct {
	ID          int64  `json:"id"`
	Participant string `json:"teilnehmer"`
	Customer    string `json:"kunde"`
}

AlarmParticipantsListSimple binds a participant to a customer.

func GetAlarmParticipantsListSimple

func GetAlarmParticipantsListSimple(groupID int64) ([]*AlarmParticipantsListSimple, error)

type Area

type Area struct {
	ID   int64  `json:"id"`
	Area string `json:"gebiet"`
}

Area is the ID and the name of an area.

func GetAlarmAreaGroup

func GetAlarmAreaGroup(groupListID int64) ([]*Area, error)

type BBox

type BBox struct {
	MinX float64
	MinY float64
	MaxX float64
	MaxY float64
}

BBox is a bounding box of an area.

func CalculateBBox

func CalculateBBox(g wkt.Geom) *BBox

CalculateBBox return the bounding box of given geometry.

func (*BBox) Contains

func (bb *BBox) Contains(p *wkt.Point) bool

Contains checks if a given point is inside these bounding box.

type Box

type Box struct {
	Left         *float64 `json:"left"`
	Right        *float64 `json:"right"`
	Top          *float64 `json:"top"`
	Bottom       *float64 `json:"bottom"`
	StatisticBox *string  `json:"statistikbox"`
	SWindowed    FakeBool `json:"swindow"`
}

Box is used a JSON serialisation of a bounding box with optional fields.

func GetBox

func GetBox(userID int64) (*Box, error)

GetBox returns the bounding box for a given userID.

type CountFilter

type CountFilter int

CountFilter limits counts to certain attributes.

const (
	// CountWithoutFilter does not filter at all.
	CountWithoutFilter CountFilter = iota
	// CountType4Filter only counts type = 4 events.
	CountType4Filter
	// CountType1PosFilter only counts type = 1 and positive events.
	CountType1PosFilter
	// CountType1NegFilter only counts type = 1 and negative events.
	CountType1NegFilter
)

type DependendObjectsError

type DependendObjectsError struct {
	ObjCount int64
	ObjName  string
}

DependendObjectsError models an DB error with a number of depended objects. Used eg. if a deletion fails because there are dependend objects.

func (DependendObjectsError) Error

func (e DependendObjectsError) Error() string

Error fulfill the error interface.

type FakeBool

type FakeBool bool

FakeBool is a bool read/written from/to as "t" and "f" when used in JSON serialisations.

func FakeBoolPointer

func FakeBoolPointer(x bool) *FakeBool

FakeBoolPointer returns a pointer to a FakeBool with the value of the given bool.

func (FakeBool) MarshalJSON

func (fb FakeBool) MarshalJSON() ([]byte, error)

MarshalJSON fulfill the JSON writing part.

func (*FakeBool) UnmarshalJSON

func (fb *FakeBool) UnmarshalJSON(data []byte) error

UnmarshalJSON fulfill the JSON readinng part.

type Group

type Group struct {
	ID        int64  `json:"id"`
	GroupName string `json:"gruppenname"`
}

Group are the essential group informations.

func GetGroupList

func GetGroupList() ([]*Group, error)

type GroupDetail

type GroupDetail struct {
	ID             int64     `json:"id"`
	FatherGroupID  *int64    `json:"vatergruppe,omitempty"`
	GroupName      *string   `json:"gruppenname,omitempty"`
	ThemeID        *int64    `json:"theme_id,omitempty"`
	Area           *string   `json:"blitzgebiet,omitempty"`
	MaxDisplayTime *int64    `json:"max_displayzeit,omitempty"`
	ArchiveDays    *int64    `json:"archiv_tage,omitempty"`
	ArchiveSince   *string   `json:"archiv_ab"`
	MaxZoom        int64     `json:"max_zoom"`
	MinZoom        int64     `json:"min_zoom"`
	Sound          *FakeBool `json:"sound,omitempty"`
	LiveBlids      *FakeBool `json:"liveblids,omitempty"`
	Animation      *FakeBool `json:"animation"`
}

GroupDetail are the in-depth informations about a group.

func GetGroupDetail

func GetGroupDetail(groupID, adminID int64) (*GroupDetail, error)

type GroupDetailSmall

type GroupDetailSmall struct {
	ID             int64        `json:"id"`
	FatherID       *int64       `json:"vatergruppenid"`
	Length         *float64     `json:"laenge"`
	Width          *float64     `json:"breite"`
	Area           *string      `json:"alarmgebiet"`
	GroupName      string       `json:"gruppenname"`
	AlarmCustomers int64        `json:"alarmkunden"`
	Rights         *Permissions `json:"rights"`
}

GroupDetailSmall are the short informations about a group.

func GetGroupDetailSmall

func GetGroupDetailSmall(userID, groupID int64) (*GroupDetailSmall, error)

type GroupNode

type GroupNode struct {
	ID     int64
	Parent *GroupNode
}

GroupNode is a node in the tree of groups users belong to.

type GroupParameters

type GroupParameters struct {
	ID             *int64    `json:"id"`
	GroupName      *string   `json:"gruppenname"`
	ParentID       *int64    `json:"vatergruppe"`
	ArchiveSince   *string   `json:"archiv_ab"`
	ArchiveDays    *int64    `json:"archiv_tage"`
	LatMin         *string   `json:"latmin"`
	LatMax         *string   `json:"latmax"`
	LonMin         *string   `json:"lonmin"`
	LonMax         *string   `json:"lonmax"`
	MinZoom        *int64    `json:"min_zoom"`
	MaxZoom        *int64    `json:"max_zoom"`
	Sound          *FakeBool `json:"sound"`
	ThemeID        *int64    `json:"theme_id"`
	MaxDisplayTime *int64    `json:"max_displayzeit"`
	LiveBlids      *FakeBool `json:"liveblids"`
	Animation      *FakeBool `json:"animation"`
}

GroupParameters are used to create or update a group.

type GroupTree

type GroupTree map[int64]*GroupNode

GroupTree maps user IDs to the trees of groups the users belong to.

func BuildGroupTree

func BuildGroupTree() (GroupTree, error)

BuildGroupTree loads the complete tree of groups into memory allowing a fast lookup of which groups a user is in.

func (GroupTree) InGroup

func (gt GroupTree) InGroup(homeGroupID, groupID int64) bool

InGroup checks if a given user is in a given group.

type GroupUpdateResult

type GroupUpdateResult struct {
	ID        int64   `json:"id"`
	GroupName *string `json:"gruppenname"`
	Box       *string `json:"box"`
}

GroupUpdateResult represents the update result of a group.

func UpdateGroup

func UpdateGroup(in *GroupParameters) (*GroupUpdateResult, error)

type Layer

type Layer struct {
	GeoName           string      `json:"geoname"`
	DisplayName       string      `json:"displayname"`
	Filter            interface{} `json:"filter"`
	PopupTemplate     string      `json:"popup_template"`
	ReloadTime        int64       `json:"reload_time"`
	FeatureInfo       FakeBool    `json:"feature_info"`
	CheckedOnLogin    FakeBool    `json:"checked_onlogin"`
	Permanent         FakeBool    `json:"permanent"`
	SingleTile        FakeBool    `json:"single_tile"`
	TimeDependent     FakeBool    `json:"timedependent"`
	ExternerServer    string      `json:"externer_server"`
	ExternerParameter string      `json:"externer_parameter"`
}

Layer is used to send JSON encoded data about a layer to the JS client.

func LoadLayers

func LoadLayers(id int64) ([]*Layer, error)

LoadLayers returns the list of layers belonging to a given user.

type LayerInfo

type LayerInfo struct {
	ID             int64    `json:"id"`
	LayerID        *int64   `json:"ebenen_id"`
	ReloadTime     int64    `json:"reload_time"`
	DisplayName    string   `json:"anzeige_name"`
	FeatureInfo    FakeBool `json:"feature_info"`
	CheckedOnLogin FakeBool `json:"checked_onlogin"`
	Permanent      FakeBool `json:"permanent"`
	StandardName   *string  `json:"standardname"`
}

LayerInfo is used to represents the details of a layer.

func GetLayerList

func GetLayerList(groupID int64) ([]*LayerInfo, error)

type Log

type Log struct {
	ID       int64  `json:"id"`
	UserName string `json:"benutzer"`
	Date     string `json:"datum"`
	Request  string `json:"request"`
	IP       string `json:"ip"`
	Session  string `json:"session"`
}

Log is used as a JSON serialisation send containing a logging data set.

func ShowLog

func ShowLog(slp *ShowLogParameters) ([]*Log, error)

ShowLog is used to fetch logging informations for given ShowLogParameters.

type ParticipantInfo

type ParticipantInfo struct {
	ID               *int64        `json:"id"`
	GroupID          int64         `json:"gruppe"`
	GroupName        string        `json:"gruppenname"`
	CustomerID       int64         `json:"kundenid"`
	Participant      string        `json:"teilnehmer"`
	SelectedCustomer AlarmCustomer `json:"selectedkunde"`
	Start            string        `json:"anfang"`
	End              string        `json:"ende"`
	StartTime        string        `json:"startzeit"`
	StopTime         string        `json:"stopzeit"`
	Typ              string        `json:"typ"`
	UTC              string        `json:"utc"`
	BlitzASCSV       FakeBool      `json:"blitzascsv"`
	BlidsLog         FakeBool      `json:"blitzprotokoll"`
	OnlyLog          FakeBool      `json:"nurlog"`
	Mon              FakeBool      `json:"mo"`
	Tue              FakeBool      `json:"di"`
	Wed              FakeBool      `json:"mi"`
	Thu              FakeBool      `json:"don"`
	Fri              FakeBool      `json:"fr"`
	Sat              FakeBool      `json:"sa"`
	Sun              FakeBool      `json:"so"`
	EMail            string        `json:"email"`
	SMS              string        `json:"sms"`
	Fax              string        `json:"fax"`
	Tel              string        `json:"tel"`
	Alarming         string        `json:"alarmierung"`
	AllClear         string        `json:"entwarnung"`
	Default          *FakeBool     `json:"default"`
}

ParticipantInfo are the in-depth informations about an alarm participant.

type Permission

type Permission string

Permission models a permission.

func LoadAdminRights

func LoadAdminRights(userID int64) (Permission, error)

func (Permission) Any

func (p Permission) Any(vs ...string) bool

Any checks if the permission is any from the given arguments.

type PermissionList

type PermissionList struct {
	UserName  string `json:"benutzername"`
	UserID    int64  `json:"benutzer_id"`
	GroupName string `json:"gruppenname"`
	GroupID   int64  `json:"gruppen_id"`
	RoleName  string `json:"rollenname"`
	RoleID    int64  `json:"rollen_id"`
}

PermissionList models the permission of user in respect to a group and a role.

func GetPermissionList

func GetPermissionList() ([]*PermissionList, error)

type PermissionParameters

type PermissionParameters struct {
	GroupID    *int64 `json:"groupid"`
	OldGroupID *int64 `json:"oldgroupid"`
	RoleID     *int64 `json:"roleid"`
	OldRoleID  *int64 `json:"oldroleid"`
	UserID     *int64 `json:"userid"`
}

PermissionParameters is used to update the role permissions.

type Permissions

type Permissions struct {
	Rolename         string     `json:"-"`
	AllowLogin       bool       `json:"-"`
	AlarmAdmin       Permission `json:"alarm_admin"`
	AlarmAreas       Permission `json:"alarm_gebiete"`
	AlarmAreaGroup   Permission `json:"alarm_gebietgruppen"`
	AlarmParticipant Permission `json:"alarm_teilnehmer"`
	AlarmAlarms      Permission `json:"alarm_alarme"`
	UserAdmin        Permission `json:"user_admin"`
	GroupAdmin       Permission `json:"gruppen_admin"`
	// Arifical permission
	AlarmSuperAdmin Permission `json:"alarm_super_admin"`
}

Permissions is the typical set of permissions of a logged in user.

func GetUserPermission

func GetUserPermission(userID, groupID int64) (*Permissions, error)

GetUserPermission fetches the permissions of a user in respect of a given group.

type RoleDetail

type RoleDetail struct {
	ID                int64     `json:"id"`
	RoleName          string    `json:"rollenname"`
	CanLogIn          *FakeBool `json:"kann_einloggen"`
	AlarmAdmin        string    `json:"alarm_admin"`
	AlarmArea         string    `json:"alarm_gebiete"`
	AlarmAreaGroups   string    `json:"alarm_gebietgruppen"`
	AlarmParticipants string    `json:"alarm_teilnehmer"`
	AlarmAlarms       string    `json:"alarm_alarme"`
	UserAdmin         string    `json:"user_admin"`
	GroupsAdmin       string    `json:"gruppen_admin"`
	BlidsCounter      string    `json:"blids_counter"`
}

RoleDetail is used the represents the in-depth details of a role.

func GetRoleDetail

func GetRoleDetail(roleID int64) (*RoleDetail, error)

func GetRoleList

func GetRoleList() ([]*RoleDetail, error)

type RoleDetailParameters

type RoleDetailParameters struct {
	ID                *int64    `json:"id"`
	RoleName          *string   `json:"rollenname"`
	CanLogIn          *FakeBool `json:"kann_einloggen"`
	AlarmAdmin        *string   `json:"alarm_admin"`
	AlarmArea         *string   `json:"alarm_gebiete"`
	AlarmAreaGroups   *string   `json:"alarm_gebietgruppen"`
	AlarmParticipants *string   `json:"alarm_teilnehmer"`
	AlarmAlarms       *string   `json:"alarm_alarme"`
	UserAdmin         *string   `json:"user_admin"`
	GroupsAdmin       *string   `json:"gruppen_admin"`
}

RoleDetailParameters are used to update or create a role.

type ShowLogParameters

type ShowLogParameters struct {
	GroupID   *int64  `json:"group"`
	StartTime *string `json:"start"`
	StopTime  *string `json:"stop"`
}

ShowLogParameters are used as JSON serialisation to request logging data.

type StatisticsFilter

type StatisticsFilter int

StatisticsFilter is a filter to extract special statistical features.

const (
	// StatisticsWithoutFilter does not filter at all.
	StatisticsWithoutFilter StatisticsFilter = iota
	// StatisticsType1Filter only shows statistics where type = 1.
	StatisticsType1Filter
)

type StatisticsItem

type StatisticsItem struct {
	Date  string  `json:"date"`
	Count float64 `json:"count"`
}

StatisticsItem is a pair of a date and a count. Used for JSON serialisation.

func GetStatistics

func GetStatistics(
	start, stop int64,
	bound, box *Box,
	filter StatisticsFilter) ([]*StatisticsItem, error)

GetStatistics creates time series for a given time range, an area, an optional bounding box and a filter.

type TestAlarm

type TestAlarm struct {
	ID         *int64 `json:"alarmid"`
	CustomerID *int64 `json:"kundeid"`
	GroupID    *int64 `json:"groupid"`
	Typ        *int32 `json:"alarmtyp"`
}

TestAlarm is used to pass the test alarm parameters to the server.

type Theme

type Theme struct {
	Name   string `json:"name"`
	Header string `json:"header"`
	Footer string `json:"footer"`
	Style  string `json:"style"`
	Title  string `json:"title"`
}

Theme is used send JSON encoded information about a theme to be applied.

func LoadTheme

func LoadTheme(id int64) (*Theme, error)

LoadTheme returns a theme for a given id.

type User

type User struct {
	ID                int64    `json:"id"`
	UserName          string   `json:"username"`
	Start             string   `json:"start"`
	Stop              string   `json:"stop"`
	Bounds            string   `json:"bounds"`
	MaxDisplayZeit    int64    `json:"max_displayzeit"`
	ArchivTage        int64    `json:"archiv_tage"`
	ArchivAb          string   `json:"archiv_ab"`
	MaxZoom           int64    `json:"max_zoom"`
	MinZoom           int64    `json:"min_zoom"`
	LoginAllowed      FakeBool `json:"loginallowed"`
	LiveBlids         FakeBool `json:"liveblids"`
	Animation         FakeBool `json:"animation"`
	Sound             FakeBool `json:"sound"`
	ThemeID           int64    `json:"theme_id"`
	StatistikWindowed FakeBool `json:"statistik_windowed"`
	Statistikgebiet   FakeBool `json:"statistikgebiet"`
}

User is used to send JSON encoded data about the logged in user to the JS client.

func ValidateUser

func ValidateUser(username, password string) (*User, error)

ValidateUser loggs a user and extracts the relevant user data to be return to the JS client.

func (*User) Check

func (u *User) Check() string

Check checks if the user is allowed to logg in. Returns an empty string if everything is alright.

type UserDetails

type UserDetails struct {
	ID          *int64  `json:"id"`
	UserName    string  `json:"benutzername"`
	HomeGroupID int64   `json:"home_gruppen_id"`
	GroupName   *string `json:"gruppenname"`
	StartDate   string  `json:"startdatum"`
	StopDatum   string  `json:"stopdatum"`
	FirstName   *string `json:"firstname"`
	LastName    string  `json:"lastname"`
	Company     string  `json:"company"`
	Division    *string `json:"division"`
	// The DB is using streetadress w/o second 'd'.
	StreetAddress *string `json:"streetaddress"`
	ZIP           *string `json:"zip"`
	City          *string `json:"city"`
	PhoneNumber   *string `json:"phonenumber"`
	Annotation    *string `json:"annotation"`
	Password      *string `json:"passwort"`
}

UserDetails are the in-depth informations about a user.

func GetUserDetails

func GetUserDetails(userID, adminID int64) (*UserDetails, error)

type UserShort

type UserShort struct {
	ID        int64  `json:"id"`
	UserName  string `json:"benutzername"`
	LastName  string `json:"lastname"`
	FirstName string `json:"firstname"`
}

UserShort are the short informations about a user.

func GetUsers

func GetUsers(groupID int64) ([]*UserShort, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL