Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
node_modules
bundle.js
.eslintrc.json
coverage
coverage
NoSQLdata.csv
SQL_images.csv
SQL_listings.csv
193 changes: 192 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,196 @@
# imageCarousel
# Getting start with the image carousel:

1) npm run seed
2) npm run build
3) npm run start

# CRUD API

API Documentation
______________________________________________________________________
GET /galleries
- BEHAVIOR
- Get all the galleries
- INPUT PARAMETERS
- none
- OUTPUT
- an array of objects representing the galleries with listing_id, listing_title, id, caption and url.
- returns an empty array if no galleries are in the database

Example command to pull all the galeries:
```terminal
curl -X GET http://localhost:3000/gallery/
```

Example output:
```javascript
[
{
"listing_id" : 21,
"listing_title" : "Downtown SF Studio Apartment Near Civic Center",
"listing_images" : [
{
"id" : 0,
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/29a3d676-0c64-4df3-8568-ad1e48d25a5e.jpg?t=r:w1200-h720-sfit,e:fjpg-c90",
"caption" : "Beautiful and sunny room"
},
{
"id" : 1,
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/da820318-2f83-41ab-8bc2-b97ac67dd6da.jpg?t=r:w1200-h720-sfit,e:fjpg-c90",
"caption" : "The bathroom is clean and has all the utilities"
}
]
},
{
"listing_id" : 22,
"listing_title" : "Large House Near Market Street",
"listing_images" : [
{
"id" : 0,
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/29a3d676-0c64-4df3-8568-ad1e48d25a5e.jpg?t=r:w1200-h720-sfit,e:fjpg-c20",
"caption" : "Spacious living room"
},
{
"id" : 1,
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/da820318-2f83-41ab-8bc2-b97ac67dd6da.jpg?t=r:w1200-h720-sfit,e:fjpg-c70",
"caption" : "Sunny balcony"
}
]
}
]
```
______________________________________________________________________
GET /gallery/:id
- BEHAVIOR
- retrieves a specific gallery in the database based on an id
- INPUT PARAMETERS
- none (the id is specified in the url)
- OUTPUT
- an object representing the gallery of specified id
- returns an empty array if no gallery match the id in the database

Example command to retrieve all the galeries:
```terminal
curl -X GET 'http://localhost:3000/gallery/21'
```

Example output:
```javascript
{
"listing_id" : 21,
"listing_title" : "Downtown SF Studio Apartment Near Civic Center",
"listing_images" : [
{
"id" : 0,
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/29a3d676-0c64-4df3-8568-ad1e48d25a5e.jpg?t=r:w1200-h720-sfit,e:fjpg-c90",
"caption" : "Beautiful and sunny room"
},
{
"id" : 1,
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/da820318-2f83-41ab-8bc2-b97ac67dd6da.jpg?t=r:w1200-h720-sfit,e:fjpg-c90",
"caption" : "The bathroom is clean and has all the utilities"
}
]
}
```
______________________________________________________________________
POST /gallery
- BEHAVIOR
- stores a new gallery into the database
- INPUT PARAMETERS
- an object with properties:
- listing_id (type NUMBER): unique property identifier
- listing_title (type STRING): name of the property
- listing_images (type OBJECT): array containing the pictures of the property
- id (type NUMBER): unique property image identifier
- url (type STRING): url of the picture
- caption (type STRING): caption of the picture

- OUTPUT
- none

Example command to insert a gallery into the database:
```terminal
curl -X POST 'Content-Type: application/json' '{
"listing_id" : "200000","listing_title" : "xxxx","listing_images" : [
{
"id" : "561554778",
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/29a3d676-0c64-4df3-8568-ad1e48d25a5e.jpg?t=r:w1200-h720-sfit,e:fjpg-c90",
"caption" : ""},
{
"id" : "561554726",
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/da820318-2f83-41ab-8bc2-b97ac67dd6da.jpg?t=r:w1200-h720-sfit,e:fjpg-c90",
"caption" : "beautiful place"
}
]}' 'http://localhost:3000/gallery/21'
```

______________________________________________________________________
PUT /gallery/:id
- BEHAVIOR
- updates the stored record matching the id with specified changes
- INPUT
- object specifying the request changes. The object follows the guidelines of db.collection.update() of mongoDB.
- OUTPUT
- none

Example command to update a gallery:
```terminal
curl -X PUT -H "content-type: application/JSON" -d '{
"$set": {
"listing_title":"bob",
"listing_images.0.caption":"beautiful room"
}
}' http://localhost:3000/gallery/22
```
______________________________________________________________________
DELETE /:id
- BEHAVIOR
- deletes a gallery in the database based on the id
- INPUT
- none. The id is specified in the url.
- OUTPUT
- none

Example command to delete a gallery:
```terminal
Curl -X DELETE 'http://localhost:3000/gallery/21'
```

# Database Schemas

POSTGRESQL:

![Schema Image](https://user-images.githubusercontent.com/56744348/74473709-ebe58e80-4e58-11ea-8c61-eff16c58fcd1.png)

Listing Table:
-listing_id INTEGER PRIMARY KEY
-listing_title TEXT

Images Table:
-id INTEGER
-url TEXT
-caption TEXT
-listing_id INTEGER INTEGER REFERENCES sql_listings(listing_id)

CASSANDRA:

-Sample output:
```json
{
"listing_id" : 21,
"listing_title" : "Downtown SF Studio Apartment Near Civic Center",
"listing_images" : [
{
"id" : 0,
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/29a3d676-0c64-4df3-8568-ad1e48d25a5e.jpg?t=r:w1200-h720-sfit,e:fjpg-c90",
"caption" : "Beautiful and sunny room"
},
{
"id" : 1,
"url" : "https://a0.muscache.com/4ea/air/v2/pictures/da820318-2f83-41ab-8bc2-b97ac67dd6da.jpg?t=r:w1200-h720-sfit,e:fjpg-c90",
"caption" : "The bathroom is clean and has all the utilities"
}
]
}
```
1 change: 1 addition & 0 deletions client/dist/loaderio-da5e3d1a58646d34b2b420819fddf921.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loaderio-da5e3d1a58646d34b2b420819fddf921
13 changes: 9 additions & 4 deletions client/src/components/FiveImages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ import SmallImage from '../elements/ImageHeader/smallImage';
import SmallImageDiv from '../elements/ImageHeader/smallImageDiv';

const FiveImages = ({ viewSelectHandler, clickedImageHandler, listingObj }) => {

const [hoveredImage, setHoveredImage] = useState(null);

const bigImgUrl = `${listingObj.listing_images[0].url.split('?')[0]}?aki_policy=xx_large`;
const smallImgUrl1 = `https://s3.us-west-1.amazonaws.com/draftbnb.gallery/album1/${listingObj.listing_images[1].id}.jpg`;
const smallImgUrl2 = `https://s3.us-west-1.amazonaws.com/draftbnb.gallery/album1/${listingObj.listing_images[2].id}.jpg`;
const smallImgUrl3 = `https://s3.us-west-1.amazonaws.com/draftbnb.gallery/album1/${listingObj.listing_images[3].id}.jpg`;
const smallImgUrl4 = `https://s3.us-west-1.amazonaws.com/draftbnb.gallery/album1/${listingObj.listing_images[4].id}.jpg`;
const smallImgUrl1 = `${listingObj.listing_images[1].url}`;
const smallImgUrl2 = `${listingObj.listing_images[2].url}`;
const smallImgUrl3 = `${listingObj.listing_images[3].url}`;
const smallImgUrl4 = `${listingObj.listing_images[4].url}`;
// const smallImgUrl1 = `https://s3.us-west-1.amazonaws.com/draftbnb.gallery/album1/${listingObj.listing_images[1].id}.jpg`;
// const smallImgUrl2 = `https://s3.us-west-1.amazonaws.com/draftbnb.gallery/album1/${listingObj.listing_images[2].id}.jpg`;
// const smallImgUrl3 = `https://s3.us-west-1.amazonaws.com/draftbnb.gallery/album1/${listingObj.listing_images[3].id}.jpg`;
// const smallImgUrl4 = `https://s3.us-west-1.amazonaws.com/draftbnb.gallery/album1/${listingObj.listing_images[4].id}.jpg`;

const mouseEnterHandler = (e) => {
setHoveredImage(e.target.name);
Expand Down
53 changes: 53 additions & 0 deletions newrelic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict'
/**
* New Relic agent configuration.
*
* See lib/config/default.js in the agent distribution for a more complete
* description of configuration variables and their potential values.
*/
exports.config = {
/**
* Array of application names.
*/
app_name: ['DSC_airbusybeavers'],
/**
* Your New Relic license key.
*/
license_key: '409bfdead5d6b4db8105e85fd62e4533246bNRAL',
logging: {
/**
* Level at which to log. 'trace' is most useful to New Relic when diagnosing
* issues with the agent, 'info' and higher will impose the least overhead on
* production applications.
*/
level: 'info'
},
/**
* When true, all request headers except for those listed in attributes.exclude
* will be captured for all traces, unless otherwise specified in a destination's
* attributes include/exclude lists.
*/
allow_all_headers: true,
attributes: {
/**
* Prefix of attributes to exclude from all destinations. Allows * as wildcard
* at end.
*
* NOTE: If excluding headers, they must be in camelCase form to be filtered.
*
* @env NEW_RELIC_ATTRIBUTES_EXCLUDE
*/
exclude: [
'request.headers.cookie',
'request.headers.authorization',
'request.headers.proxyAuthorization',
'request.headers.setCookie*',
'request.headers.x*',
'response.headers.cookie',
'response.headers.authorization',
'response.headers.proxyAuthorization',
'response.headers.setCookie*',
'response.headers.x*'
]
}
}
Loading