From 178c9c354e368257a45d79a8767855686b4f971b Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 06:25:16 -0700 Subject: [PATCH 01/28] implement imperial units in UI --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 1bff9d280e2ad288e2f0c55396491a985e21d278 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 06:42:49 -0700 Subject: [PATCH 02/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 78ed87b66effdbd5f42125e1211657c2665d010d Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 06:45:46 -0700 Subject: [PATCH 03/28] add imperial units --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 05669180481c014079f036803a6b4c983e046412 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 07:00:11 -0700 Subject: [PATCH 04/28] handle mongodb connection --- Bikes/server.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Bikes/server.js b/Bikes/server.js index 276d407..3548939 100644 --- a/Bikes/server.js +++ b/Bikes/server.js @@ -15,8 +15,10 @@ var async = require('async'); // var mongoDBCollection = process.env.mongo_collection; var mongoDBCollection = "bikes"; -// var mongoDBConnStr = "mongodb://databases-mongo"; -var mongoDBConnStr = "mongodb://" + process.env.mongo_connectionstring + ":" + process.env.mongo_port; +var mongoDBConnStr = "mongodb://databases-mongo"; +if (process.env.mongo_port) { + mongoDBConnStr = "mongodb://" + process.env.mongo_connectionstring + ":" + process.env.mongo_port; +} console.log("Collection: " + mongoDBCollection); console.log("MongoDB connection string: " + mongoDBConnStr); From fa08d69ca28f22ed8f3b91f0799a305cb06c61ba Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 07:03:26 -0700 Subject: [PATCH 05/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 6b1ae61dbc6e6fb284c7a7d0cd87e2b5113a0380 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 07:13:14 -0700 Subject: [PATCH 06/28] add imperial units --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 47fa840e10775fc9ad71629d431e2a2d35c3275f Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 07:16:20 -0700 Subject: [PATCH 07/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From d1b8186979dc021b311c0f0c1bbfa1e29f867c0d Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 07:18:27 -0700 Subject: [PATCH 08/28] add imperial units support in UI --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 12c4bdf7ee07c68ca017400711d9b6bc7baceedd Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 07:36:15 -0700 Subject: [PATCH 09/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From f5e387cd67b7dfa8915fe27f5909de200d821e5f Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 09:41:48 -0700 Subject: [PATCH 10/28] add imperial units in frontend UI --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From faf39b3871c28959694479b94288050dae0e8c3a Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 10:01:43 -0700 Subject: [PATCH 11/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From fb813e13c82b3124311dfe57915f20c893b8d635 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 10:25:45 -0700 Subject: [PATCH 12/28] client-side work for imperial units --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 86468f79d70a8d2d32d5070d6c2819cf754368a1 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 10:29:12 -0700 Subject: [PATCH 13/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From e774839bbc1f258f9237f93f58e1d09dbd1f6daa Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 10:33:51 -0700 Subject: [PATCH 14/28] test --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From edb9dd94da286551f82af62bce7f01648c7e4e2f Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 10:38:08 -0700 Subject: [PATCH 15/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From e1360c4e0fefff9665ef66e289985ece341ffb01 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 10:46:25 -0700 Subject: [PATCH 16/28] my part --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 22bb6e865e22c9a0ee756998d92c3823ade74b15 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 10:49:59 -0700 Subject: [PATCH 17/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 04185a862ad03c25730756aa301a185a1072f694 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Fri, 19 Apr 2019 11:42:12 -0700 Subject: [PATCH 18/28] this web ui work --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 510e5d0ce92014452ed7676c451c6c56c3e23ace Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 09:46:20 -0700 Subject: [PATCH 19/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Bikes/server.js | 8 +++--- Gateway/Controllers/BikeController.cs | 4 +-- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Bikes/server.js b/Bikes/server.js index 3548939..9b77ebf 100644 --- a/Bikes/server.js +++ b/Bikes/server.js @@ -244,10 +244,10 @@ app.get('/api/bikes/:bikeId', function(req, res) { theBike.id = theBike._id; delete theBike._id; - // if (req.query["unitType"] == "imperial") { - // theBike.suitableHeightInMeters = theBike.suitableHeightInMeters * 300; // 3.28084; - // theBike.maximumWeightInKg = theBike.maximumWeightInKg * 300; // 2.204623; - // } + if (req.query["unitType"] == "imperial") { + theBike.suitableHeightInMeters = theBike.suitableHeightInMeters * 300; // 3.28084; + theBike.maximumWeightInKg = theBike.maximumWeightInKg * 300; // 2.204623; + } res.send(theBike); }); diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From ca6194d072d8c784f55373f7bff875db6f267687 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 10:13:13 -0700 Subject: [PATCH 20/28] web ui work --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 86b611218f3be5c951c7f622aef2a72b2c3f15d5 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 10:18:10 -0700 Subject: [PATCH 21/28] default to local dns --- Bikes/service.env | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 Bikes/service.env diff --git a/Bikes/service.env b/Bikes/service.env deleted file mode 100644 index d4b1cb0..0000000 --- a/Bikes/service.env +++ /dev/null @@ -1,2 +0,0 @@ -mongo_connectionstring=${services.databases-mongo} -mongo_port=${services.databases-mongo.port} \ No newline at end of file From f9ab6a2550b971c66d163480ec4cab1878da79bf Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 10:20:09 -0700 Subject: [PATCH 22/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From a354a6a54df5dd06a0d08e418db9e3875c03f92d Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 10:22:54 -0700 Subject: [PATCH 23/28] reset values --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Bikes/server.js | 8 +++--- Gateway/Controllers/BikeController.cs | 4 +-- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Bikes/server.js b/Bikes/server.js index 9b77ebf..3548939 100644 --- a/Bikes/server.js +++ b/Bikes/server.js @@ -244,10 +244,10 @@ app.get('/api/bikes/:bikeId', function(req, res) { theBike.id = theBike._id; delete theBike._id; - if (req.query["unitType"] == "imperial") { - theBike.suitableHeightInMeters = theBike.suitableHeightInMeters * 300; // 3.28084; - theBike.maximumWeightInKg = theBike.maximumWeightInKg * 300; // 2.204623; - } + // if (req.query["unitType"] == "imperial") { + // theBike.suitableHeightInMeters = theBike.suitableHeightInMeters * 300; // 3.28084; + // theBike.maximumWeightInKg = theBike.maximumWeightInKg * 300; // 2.204623; + // } res.send(theBike); }); diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 4a4fd071ed0045fe1b05e7e1c3ae603ad3141534 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 10:27:31 -0700 Subject: [PATCH 24/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From 75f0f42721022c3753237b1cffade69e76ce337b Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 10:33:36 -0700 Subject: [PATCH 25/28] my part --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From d833cd09183875112e2bf2f22a8af7cebd95d083 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 10:37:03 -0700 Subject: [PATCH 26/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From ab2d09e7e3c6e3445126efde2d6279d290832c52 Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 11:19:44 -0700 Subject: [PATCH 27/28] my part --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 +++++++++++++++++---------- Gateway/Controllers/BikeController.cs | 4 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 2b4d78f..3e38d36 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost) { + getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = apiHost + '/api/bike/' + bikeId; + const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index fded4ac..1dbc813 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,6 +24,7 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, + unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -46,10 +47,17 @@ class PreviewBase extends Component { return; } + const unitType = "imperial"; + this.setState({ + userId: user.id, + userName: user.name, + unitType: unitType + }); + let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); } catch (error) { console.error(error); @@ -57,6 +65,10 @@ class PreviewBase extends Component { return; } + this.setState({ + bike: bikeData + }); + let vendorData = null; try { // get vendor @@ -68,15 +80,11 @@ class PreviewBase extends Component { return; } - // set state this.setState({ - userId: user.id, - userName: user.name, - bike: bikeData, vendor: vendorData - }) + }); } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -124,19 +132,22 @@ class PreviewBase extends Component {
-
- photo of bike + {this.state.bike.imageUrl != null && + photo of bike + }
-
{this.state.bike.model}
-
Owned by {this.state.vendor.name}
- +
{this.state.bike.model}
+ {this.state.vendor.name != null && +
Owned by {this.state.vendor.name}
+ } + - - + + diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 0457002..577b6c9 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId) + public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) { From e0d808747e2587c96fc2680e0cdc15b1d8744adf Mon Sep 17 00:00:00 2001 From: John Stallo Date: Mon, 29 Apr 2019 12:31:03 -0700 Subject: [PATCH 28/28] reset --- BikeSharingWeb/pages/helpers.js | 4 +-- BikeSharingWeb/pages/preview.js | 39 ++++++++++----------------- Bikes/server.js | 8 +++--- Gateway/Controllers/BikeController.cs | 4 +-- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/BikeSharingWeb/pages/helpers.js b/BikeSharingWeb/pages/helpers.js index 3e38d36..2b4d78f 100644 --- a/BikeSharingWeb/pages/helpers.js +++ b/BikeSharingWeb/pages/helpers.js @@ -53,11 +53,11 @@ const helpers = { } return await res.json(); }, - getBikeAsync: async function(bikeId, apiHost, unitType = "metric") { + getBikeAsync: async function(bikeId, apiHost) { if (!apiHost) { apiHost = await this.getApiHostAsync(); } - const url = `${apiHost}/api/bike/${bikeId}?unitType=${unitType}`; + const url = apiHost + '/api/bike/' + bikeId; const res = await fetch(url); if (!res.ok) { throw new Error(await res.text()); diff --git a/BikeSharingWeb/pages/preview.js b/BikeSharingWeb/pages/preview.js index 1dbc813..fded4ac 100644 --- a/BikeSharingWeb/pages/preview.js +++ b/BikeSharingWeb/pages/preview.js @@ -24,7 +24,6 @@ class PreviewBase extends Component { this.state = { userId: undefined, userName: undefined, - unitType: undefined, bike: {}, vendor: {}, errorMessage: undefined @@ -47,17 +46,10 @@ class PreviewBase extends Component { return; } - const unitType = "imperial"; - this.setState({ - userId: user.id, - userName: user.name, - unitType: unitType - }); - let bikeData = null; try { // get bike - bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost, unitType); + bikeData = await helpers.getBikeAsync(this.props.bikeId, this.apiHost); } catch (error) { console.error(error); @@ -65,10 +57,6 @@ class PreviewBase extends Component { return; } - this.setState({ - bike: bikeData - }); - let vendorData = null; try { // get vendor @@ -80,11 +68,15 @@ class PreviewBase extends Component { return; } + // set state this.setState({ + userId: user.id, + userName: user.name, + bike: bikeData, vendor: vendorData - }); + }) } - + static async getInitialProps(context) { return { bikeId: context.query.id @@ -132,22 +124,19 @@ class PreviewBase extends Component {
+
- {this.state.bike.imageUrl != null && - photo of bike - } + photo of bike
-
{this.state.bike.model}
- {this.state.vendor.name != null && -
Owned by {this.state.vendor.name}
- } - +
{this.state.bike.model}
+
Owned by {this.state.vendor.name}
+ - - + + diff --git a/Bikes/server.js b/Bikes/server.js index 3548939..1602c80 100644 --- a/Bikes/server.js +++ b/Bikes/server.js @@ -244,10 +244,10 @@ app.get('/api/bikes/:bikeId', function(req, res) { theBike.id = theBike._id; delete theBike._id; - // if (req.query["unitType"] == "imperial") { - // theBike.suitableHeightInMeters = theBike.suitableHeightInMeters * 300; // 3.28084; - // theBike.maximumWeightInKg = theBike.maximumWeightInKg * 300; // 2.204623; - // } + if (req.query["unitType"] == "imperial") { + theBike.suitableHeightInMeters = theBike.suitableHeightInMeters * 3.28084; + theBike.maximumWeightInKg = theBike.maximumWeightInKg * 2.204623; + } res.send(theBike); }); diff --git a/Gateway/Controllers/BikeController.cs b/Gateway/Controllers/BikeController.cs index 577b6c9..0457002 100644 --- a/Gateway/Controllers/BikeController.cs +++ b/Gateway/Controllers/BikeController.cs @@ -33,9 +33,9 @@ public BikeController(IOptions customConfiguration) // GET: api/bike/1 [HttpGet("{bikeId}")] - public async Task GetBike(string bikeId, [FromQuery(Name = "unitType")] string unitType = null) + public async Task GetBike(string bikeId) { - string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}?unitType={unitType}"; + string getBikeUrl = $"http://{_bikesService}/api/bikes/{bikeId}"; var response = await HttpHelper.GetAsync(getBikeUrl, this.Request); if (response.IsSuccessStatusCode) {