Skip to content

Commit

Permalink
parent
Browse files Browse the repository at this point in the history
  • Loading branch information
kdudkov committed Mar 30, 2022
1 parent b4f33ce commit 516022f
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 56 deletions.
36 changes: 22 additions & 14 deletions cmd/goatak_server/templates/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,21 @@ <h5 v-on:click="mapToUnit(current_unit)">
<div class="card-body">
<b>UID:</b> {{current_unit.uid}}<br/>
<span v-if="coords != null"></span>
<span v-if="ne(current_unit.team)"><b>Team:</b> {{current_unit.team}}, <b>Role:</b> {{current_unit.role}}<br/></span>
<div v-if="ne(current_unit.team)"><b>Team:</b> {{current_unit.team}}, <b>Role:</b>
{{current_unit.role}}
</div>
<b>Type:</b> {{current_unit.type}} <b>SIDC:</b> {{current_unit.sidc}}<br/>
<b>coords:</b> {{printCoords(current_unit.lat, current_unit.lon)}}
<span class="badge rounded-pill bg-success" style="cursor:default;"
v-on:click="map.setView([current_unit.lat, current_unit.lon])"><i
class="bi bi-geo"></i></span>
<span v-if="coords != null">({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor)</span>
<br/>
<div>
<b>coords:</b> {{printCoords(current_unit.lat, current_unit.lon)}}
<span class="badge rounded-pill bg-success" style="cursor:default;"
v-on:click="map.setView([current_unit.lat, current_unit.lon])"><i
class="bi bi-geo"></i></span>
<span v-if="coords != null">({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor)</span>
</div>
<b>speed:</b> {{sp(current_unit.speed)}} km/h, <b>hae:</b> {{current_unit.hae.toFixed(1)}}<br/>
<span v-if="ne(current_unit.tak_version)"><b>ver:</b> {{current_unit.tak_version}}<br/></span>
<div v-if="ne(current_unit.tak_version)"><b>ver:</b> {{current_unit.tak_version}}</div>
<div v-if="current_unit.parent_callsign !== ''"><b>parent:</b> {{current_unit.parent_callsign}}
</div>
<b>time:</b> {{dt(current_unit.start_time)}} <b>stale:</b> {{dt(current_unit.stale_time)}}<br/>
<b>last seen</b>: {{dt(current_unit.last_seen)}}<br/>
{{current_unit.text}}
Expand All @@ -139,12 +144,15 @@ <h5 v-on:click="mapToUnit(current_unit)">
<b>UID:</b> {{current_unit.uid}}<br/>
<span v-if="coords != null"></span>
<b>Type:</b> {{current_unit.type}} <b>SIDC:</b> {{current_unit.sidc}}<br/>
<b>coords:</b> {{printCoords(current_unit.lat, current_unit.lon)}}
<span class="badge rounded-pill bg-success" style="cursor:default;"
v-on:click="map.setView([current_unit.lat, current_unit.lon])"><i
class="bi bi-geo"></i></span>
<span v-if="coords != null">({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor)</span>
<br/>
<div>
<b>coords:</b> {{printCoords(current_unit.lat, current_unit.lon)}}
<span class="badge rounded-pill bg-success" style="cursor:default;"
v-on:click="map.setView([current_unit.lat, current_unit.lon])"><i
class="bi bi-geo"></i></span>
<span v-if="coords != null">({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor)</span>
</div>
<div v-if="current_unit.parent_callsign !== ''"><b>parent:</b> {{current_unit.parent_callsign}}
</div>
{{current_unit.text}}
</div>
</div>
Expand Down
36 changes: 22 additions & 14 deletions cmd/webclient/templates/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,21 @@ <h5 v-on:click="mapToUnit(current_unit)">
<div class="card-body">
<b>UID:</b> {{current_unit.uid}}<br/>
<span v-if="coords != null"></span>
<span v-if="ne(current_unit.team)"><b>Team:</b> {{current_unit.team}}, <b>Role:</b> {{current_unit.role}}<br/></span>
<div v-if="ne(current_unit.team)"><b>Team:</b> {{current_unit.team}}, <b>Role:</b>
{{current_unit.role}}
</div>
<b>Type:</b> {{current_unit.type}} <b>SIDC:</b> {{current_unit.sidc}}<br/>
<b>coords:</b> {{printCoords(current_unit.lat, current_unit.lon)}}
<span class="badge rounded-pill bg-success" style="cursor:default;"
v-on:click="map.setView([current_unit.lat, current_unit.lon])"><i
class="bi bi-geo"></i></span>
<span v-if="coords != null">({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor)</span>
<br/>
<div>
<b>coords:</b> {{printCoords(current_unit.lat, current_unit.lon)}}
<span class="badge rounded-pill bg-success" style="cursor:default;"
v-on:click="map.setView([current_unit.lat, current_unit.lon])"><i
class="bi bi-geo"></i></span>
<span v-if="coords != null">({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor)</span>
</div>
<b>speed:</b> {{sp(current_unit.speed)}} km/h, <b>hae:</b> {{current_unit.hae.toFixed(1)}}<br/>
<span v-if="ne(current_unit.tak_version)"><b>ver:</b> {{current_unit.tak_version}}<br/></span>
<div v-if="ne(current_unit.tak_version)"><b>ver:</b> {{current_unit.tak_version}}</div>
<div v-if="current_unit.parent_callsign !== ''"><b>parent:</b> {{current_unit.parent_callsign}}
</div>
<b>time:</b> {{dt(current_unit.start_time)}} <b>stale:</b> {{dt(current_unit.stale_time)}}<br/>
<b>last seen</b>: {{dt(current_unit.last_seen)}}<br/>
{{current_unit.text}}
Expand All @@ -139,12 +144,15 @@ <h5 v-on:click="mapToUnit(current_unit)">
<b>UID:</b> {{current_unit.uid}}<br/>
<span v-if="coords != null"></span>
<b>Type:</b> {{current_unit.type}} <b>SIDC:</b> {{current_unit.sidc}}<br/>
<b>coords:</b> {{printCoords(current_unit.lat, current_unit.lon)}}
<span class="badge rounded-pill bg-success" style="cursor:default;"
v-on:click="map.setView([current_unit.lat, current_unit.lon])"><i
class="bi bi-geo"></i></span>
<span v-if="coords != null">({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor)</span>
<br/>
<div>
<b>coords:</b> {{printCoords(current_unit.lat, current_unit.lon)}}
<span class="badge rounded-pill bg-success" style="cursor:default;"
v-on:click="map.setView([current_unit.lat, current_unit.lon])"><i
class="bi bi-geo"></i></span>
<span v-if="coords != null">({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor)</span>
</div>
<div v-if="current_unit.parent_callsign !== ''"><b>parent:</b> {{current_unit.parent_callsign}}
</div>
{{current_unit.text}}
</div>
</div>
Expand Down
49 changes: 27 additions & 22 deletions model/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@ import (
)

type WebUnit struct {
Uid string `json:"uid"`
Callsign string `json:"callsign"`
Category string `json:"category"`
Team string `json:"team"`
Role string `json:"role"`
Time time.Time `json:"time"`
LastSeen time.Time `json:"last_seen"`
StaleTime time.Time `json:"stale_time"`
StartTime time.Time `json:"start_time"`
SendTime time.Time `json:"send_time"`
Type string `json:"type"`
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
Hae float64 `json:"hae"`
Speed float64 `json:"speed"`
Course float64 `json:"course"`
Sidc string `json:"sidc"`
TakVersion string `json:"tak_version"`
Status string `json:"status"`
Text string `json:"text"`
Color string `json:"color"`
Uid string `json:"uid"`
Callsign string `json:"callsign"`
Category string `json:"category"`
Team string `json:"team"`
Role string `json:"role"`
Time time.Time `json:"time"`
LastSeen time.Time `json:"last_seen"`
StaleTime time.Time `json:"stale_time"`
StartTime time.Time `json:"start_time"`
SendTime time.Time `json:"send_time"`
Type string `json:"type"`
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
Hae float64 `json:"hae"`
Speed float64 `json:"speed"`
Course float64 `json:"course"`
Sidc string `json:"sidc"`
TakVersion string `json:"tak_version"`
Status string `json:"status"`
Text string `json:"text"`
Color string `json:"color"`
ParentCallsign string `json:"parent_callsign"`
ParentUid string `json:"parent_uid"`
}

type DigitalPointer struct {
Expand Down Expand Up @@ -62,13 +64,16 @@ func (c *Contact) ToWeb() *WebUnit {
func (u *Unit) ToWeb() *WebUnit {
w := u.Item.ToWeb()
w.Category = "unit"
w.ParentUid = u.parentUid
w.ParentCallsign = u.parentCallsign
return w
}

func (p *Point) ToWeb() *WebUnit {
w := p.Item.ToWeb()
w.Category = "point"

w.ParentUid = p.parentUid
w.ParentCallsign = p.parentCallsign
return w
}

Expand Down
35 changes: 29 additions & 6 deletions model/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ type Item struct {

type Unit struct {
Item
mx sync.RWMutex
track []*Pos
parentCallsign string
parentUid string
mx sync.RWMutex
track []*Pos
}

type Contact struct {
Expand All @@ -46,8 +48,8 @@ type Contact struct {

type Point struct {
Item
authorCallsign string
authorUid string
parentCallsign string
parentUid string
}

func (c *Contact) String() string {
Expand Down Expand Up @@ -140,17 +142,32 @@ func UnitFromMsg(msg *cot.Msg) *Unit {
speed: msg.TakMessage.GetCotEvent().GetDetail().GetTrack().GetSpeed(),
}

return &Unit{
u := &Unit{
Item: ItemFromMsg(msg),
mx: sync.RWMutex{},
track: []*Pos{pos},
}

link := msg.Detail.GetFirstChild("link")
if link.GetAttr("relation") == "p-p" {
u.parentCallsign = link.GetAttr("parent_callsign")
u.parentUid = link.GetAttr("uid")
}
return u
}

func PointFromEvent(msg *cot.Msg) *Point {
return &Point{
p := &Point{
Item: ItemFromMsg(msg),
}

link := msg.Detail.GetFirstChild("link")
if link.GetAttr("relation") == "p-p" {
p.parentCallsign = link.GetAttr("parent_callsign")
p.parentUid = link.GetAttr("uid")
}

return p
}

func ItemFromMsg(msg *cot.Msg) Item {
Expand Down Expand Up @@ -200,6 +217,12 @@ func (u *Unit) Update(msg *cot.Msg) {
pos := getPos(u.msg, msg)
u.msg = msg

link := msg.Detail.GetFirstChild("link")
if link.GetAttr("relation") == "p-p" {
u.parentCallsign = link.GetAttr("parent_callsign")
u.parentUid = link.GetAttr("uid")
}

if pos != nil {
u.track = append(u.track, pos)

Expand Down

0 comments on commit 516022f

Please sign in to comment.