diff --git a/CHANGELOG.md b/CHANGELOG.md index ad50750d..fe53615b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ 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.4] - 2024-08-26 +### Changed +- Based on data coming back from LaundryView, uiuc laundry adapter now reutrns unknown as a status when the machine is offline and the out for service flag is 0. [#107]https://github.com/rokwire/gateway-building-block/issues/107 + +## [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) diff --git a/SECURITY.md b/SECURITY.md index 2402c7de..f45e0e79 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -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.4 | :white_check_mark: | +| < 2.10.4 | :x: | ## Reporting a Bug or Vulnerability diff --git a/core/apis_client.go b/core/apis_client.go index a86d64b0..e44568d9 100644 --- a/core/apis_client.go +++ b/core/apis_client.go @@ -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 } diff --git a/core/interfaces.go b/core/interfaces.go index e938d8ab..de670d21 100644 --- a/core/interfaces.go +++ b/core/interfaces.go @@ -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) } @@ -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 diff --git a/core/model/uiuc/buildingdata.go b/core/model/uiuc/buildingdata.go index 7565b9bb..480db710 100644 --- a/core/model/uiuc/buildingdata.go +++ b/core/model/uiuc/buildingdata.go @@ -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 } diff --git a/core/model/uiuc/laundryview.go b/core/model/uiuc/laundryview.go index 4b4d2f89..9cd9b264 100644 --- a/core/model/uiuc/laundryview.go +++ b/core/model/uiuc/laundryview.go @@ -93,7 +93,7 @@ func NewLaundryRoom(id int, name string, status string, location *model.LaundryD } // NewAppliance returns an app formatted appliance ojbect from campus data -func NewAppliance(id string, appliancetype string, cycletime int, status string, timeremaining string, label string) *model.Appliance { +func NewAppliance(id string, appliancetype string, cycletime int, status string, timeremaining string, label string, outofserviceflag string) *model.Appliance { var finalStatus string switch status { @@ -101,11 +101,17 @@ func NewAppliance(id string, appliancetype string, cycletime int, status string, finalStatus = "available" case "In Use": finalStatus = "in_use" + case "Offline": + if outofserviceflag == "1" { + finalStatus = "out_of_service" + } else { + finalStatus = "unknown" + } default: - finalStatus = "out_of_service" + finalStatus = "unknown" } - if finalStatus == "available" || finalStatus == "out_of_service" { + if finalStatus == "available" || finalStatus == "out_of_service" || finalStatus == "unknown" { appl := model.Appliance{ID: id, ApplianceType: appliancetype, AverageCycleTime: cycletime, Status: finalStatus, Label: label} return &appl } diff --git a/driven/uiucadapters/laundryadapter.go b/driven/uiucadapters/laundryadapter.go index 418dd125..b17867a5 100644 --- a/driven/uiucadapters/laundryadapter.go +++ b/driven/uiucadapters/laundryadapter.go @@ -111,7 +111,7 @@ func (lv *CSCLaundryView) GetLaundryRoom(roomid string, conf *model.EnvConfigDat for i, appl := range lr.Appliances { avgCycle, _ := strconv.Atoi(appl.AvgCycleTime) - rd.Appliances[i] = uiuc.NewAppliance(appl.ApplianceKey, appl.ApplianceType, avgCycle, appl.Status, appl.TimeRemaining, appl.Label) + rd.Appliances[i] = uiuc.NewAppliance(appl.ApplianceKey, appl.ApplianceType, avgCycle, appl.Status, appl.TimeRemaining, appl.Label, appl.OutOfService) } if len(lv.laundryAssets) > 0 { diff --git a/driven/uiucadapters/wayfindingadapter.go b/driven/uiucadapters/wayfindingadapter.go index 8256ae8a..66ff4008 100644 --- a/driven/uiucadapters/wayfindingadapter.go +++ b/driven/uiucadapters/wayfindingadapter.go @@ -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 { diff --git a/driver/web/apis_client.go b/driver/web/apis_client.go index 6945214d..38d20dd2 100644 --- a/driver/web/apis_client.go +++ b/driver/web/apis_client.go @@ -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 { @@ -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) @@ -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) diff --git a/driver/web/docs/gen/def.yaml b/driver/web/docs/gen/def.yaml index bcfc1c60..c7807606 100644 --- a/driver/web/docs/gen/def.yaml +++ b/driver/web/docs/gen/def.yaml @@ -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.4 servers: - url: 'https://api.rokwire.illinois.edu/gateway' description: Production server diff --git a/driver/web/docs/index.yaml b/driver/web/docs/index.yaml index 59cd1435..7569f20d 100644 --- a/driver/web/docs/index.yaml +++ b/driver/web/docs/index.yaml @@ -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.4 servers: - url: 'https://api.rokwire.illinois.edu/gateway' description: Production server