Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#103] add markers and highlites parameters to floorplans api #104

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.10.3] - 2024-06-28
### Changed
- Added markers and highlites parameters to floor plans endpoint to allow client to set default state. [#103](https://github.com/rokwire/gateway-building-block/issues/103)

## [2.10.2] - 2024-06-27
### Fixed
- Populate building number in wayfinding building end points [#100](https://github.com/rokwire/gateway-building-block/issues/100)
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Patches for **Gateway Building Block** in this repository will only be applied to the following versions:
| Version | Supported |
| ------- | ------------------ |
| 2.10.2 | :white_check_mark: |
| < 2.10.2 | :x: |
| 2.10.3 | :white_check_mark: |
| < 2.10.3 | :x: |

## Reporting a Bug or Vulnerability

Expand Down
4 changes: 2 additions & 2 deletions core/apis_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ func (a appClient) GetSuccessTeam(uin string, unitid string, accesstoken string)

}

func (a appClient) GetFloorPlan(buildingnumber string, floornumber string) (*model.FloorPlan, int, error) {
func (a appClient) GetFloorPlan(buildingnumber string, floornumber string, markers string, highlites string) (*model.FloorPlan, int, error) {
conf, _ := a.app.GetEnvConfigs()

retData, err := a.LocationAdapter.GetFloorPlan(buildingnumber, floornumber, conf)
retData, err := a.LocationAdapter.GetFloorPlan(buildingnumber, floornumber, markers, highlites, conf)
if err != nil {
return nil, 500, err
}
Expand Down
4 changes: 2 additions & 2 deletions core/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Client interface {
GetSuccessTeam(uin string, unitid string, accessToken string) (*model.SuccessTeam, int, error)
GetPrimaryCareProvider(uin string, accessToken string) (*[]model.SuccessTeamMember, int, error)
GetAcademicAdvisors(uin string, unitid string, accessToken string) (*[]model.SuccessTeamMember, int, error)
GetFloorPlan(buildingnumber string, floornumber string) (*model.FloorPlan, int, error)
GetFloorPlan(buildingnumber string, floornumber string, markers string, highlites string) (*model.FloorPlan, int, error)
SearchBuildings(bldgName string, returnCompact bool) (*map[string]any, error)
}

Expand Down Expand Up @@ -186,7 +186,7 @@ type WayFinding interface {
GetEntrance(bldgID string, adaAccessibleOnly bool, latitude float64, longitude float64, conf *model.EnvConfigData) (*model.Entrance, error)
GetBuildings(conf *model.EnvConfigData) (*[]model.Building, error)
GetBuilding(bldgID string, adaAccessibleOnly bool, latitude float64, longitude float64, conf *model.EnvConfigData) (*model.Building, error)
GetFloorPlan(bldgNum string, floornumber string, conf *model.EnvConfigData) (*model.FloorPlan, error)
GetFloorPlan(bldgNum string, floornumber string, markers string, highlites string, conf *model.EnvConfigData) (*model.FloorPlan, error)
}

// Appointments represents the adapter needed to interace with various appoinment data providers
Expand Down
2 changes: 1 addition & 1 deletion core/model/uiuc/buildingdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func NewFloorPlan(fp CampusFloorPlan) *model.FloorPlan {
}
for j := 0; j < len(fp.Highlites); j++ {
newfp.Highlites = append(newfp.Highlites, model.FloorPlanHighlite{RenderID: fp.Highlites[j].RenderID, Label: fp.Highlites[j].Label, Color: fp.Highlites[j].Color,
Display: fp.Markers[j].Display})
Display: fp.Highlites[j].Display})
}
return &newfp
}
Expand Down
17 changes: 15 additions & 2 deletions driven/uiucadapters/wayfindingadapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,24 @@ func (uwf *UIUCWayFinding) GetBuilding(bldgID string, adaAccessibleOnly bool, la
}

// GetFloorPlan returns the requested floor plan
func (uwf *UIUCWayFinding) GetFloorPlan(bldgNum string, floornumber string, conf *model.EnvConfigData) (*model.FloorPlan, error) {
func (uwf *UIUCWayFinding) GetFloorPlan(bldgNum string, floornumber string, markers string, highlites string, conf *model.EnvConfigData) (*model.FloorPlan, error) {
apiURL := conf.WayFindingURL
apikey := conf.WayFindingKey

reqParams := "?"
url := apiURL + "/floorplans/number/" + bldgNum + "/floor/" + floornumber
if markers != "" {
reqParams += "render_markers=" + markers
if highlites != "" {
reqParams += "&"
}
}

if highlites != "" {
reqParams += "render_highlites=" + highlites
}
if reqParams != "?" {
url += reqParams
}

uiucfp, err := uwf.getFloorPlanData(url, apikey)
if err != nil {
Expand Down
12 changes: 11 additions & 1 deletion driver/web/apis_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ func (h ClientAPIsHandler) searchBuildings(l *logs.Log, r *http.Request, claims
func (h ClientAPIsHandler) getFloorPlan(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse {
bldgid := ""
floor := ""
markers := "on"
highlites := "on"

reqParams := utils.ConstructFilter(r)

for _, v := range reqParams.Items {
Expand All @@ -310,6 +313,13 @@ func (h ClientAPIsHandler) getFloorPlan(l *logs.Log, r *http.Request, claims *to
if v.Field == "floor" {
floor = v.Value[0]
}
if v.Field == "markers" {
markers = v.Value[0]
}

if v.Field == "highlites" {
highlites = v.Value[0]
}
}
if bldgid == "" || bldgid == "nil" {
return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeQueryParam, logutils.StringArgs("bldgid"), nil, http.StatusBadRequest, false)
Expand All @@ -318,7 +328,7 @@ func (h ClientAPIsHandler) getFloorPlan(l *logs.Log, r *http.Request, claims *to
if floor == "" || floor == "nil" {
return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeQueryParam, logutils.StringArgs("floor"), nil, http.StatusBadRequest, false)
}
fp, _, err := h.app.Client.GetFloorPlan(bldgid, floor)
fp, _, err := h.app.Client.GetFloorPlan(bldgid, floor, markers, highlites)

if err != nil {
return l.HTTPResponseErrorAction(logutils.ActionGet, model.TypeFloorPlan, nil, err, http.StatusInternalServerError, true)
Expand Down
2 changes: 1 addition & 1 deletion driver/web/docs/gen/def.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.3
info:
title: Rokwire Gateway Building Block API
description: Gateway Building Block API Documentation
version: 2.10.2
version: 2.10.3
servers:
- url: 'https://api.rokwire.illinois.edu/gateway'
description: Production server
Expand Down
2 changes: 1 addition & 1 deletion driver/web/docs/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.3
info:
title: Rokwire Gateway Building Block API
description: Gateway Building Block API Documentation
version: 2.10.2
version: 2.10.3
servers:
- url: 'https://api.rokwire.illinois.edu/gateway'
description: Production server
Expand Down
Loading