wire shelters and animals to backend and fix cors issue
7 files added
13 files modified
| | |
| | | */target |
| | | */.classpath |
| | | */.project |
| | | .idea* |
| | |
| | | notificationService.host=http://notification-service:8080 |
| | | spring.data.mongodb.host=mongodb |
| | | spring.data.mongodb.host=localhost |
| | | spring.data.mongodb.port=27018 |
| | | spring.data.mongodb.database=adopt-a-pup |
| | | spring.data.mongodb.password=developer |
| | | spring.data.mongodb.username=developer |
| | |
| | | - match: { prefix: "/email/" } |
| | | route: { cluster: email-service, timeout: { seconds: 60 } } |
| | | cors: |
| | | allow_origin_string_match: |
| | | - prefix: "*" |
| | | allow_methods: GET, PUT, DELETE, POST, OPTIONS |
| | | allow_headers: access-control-allow-origin,access-control-request-header,access-control-request-method,authorization,keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent |
| | | max_age: "1728000" |
| | | expose_headers: x-total-pages,x-total-count |
| | | filter_enabled: |
| | | default_value: {numerator: 100, denominator: HUNDRED} |
| | | runtime_key: cors.www.enabled |
| | | http_filters: |
| | | - name: envoy.cors |
| | | - name: envoy.router |
| | |
| | | route: { cluster: animal-service, timeout: { seconds: 60 } } |
| | | - match: { prefix: "/adoption/" } |
| | | route: { cluster: adoption-service, timeout: { seconds: 60 } } |
| | | - match: { prefix: "/shelter/" } |
| | | - match: { prefix: "/shelters/" } |
| | | route: { cluster: shelter-service, timeout: { seconds: 60 } } |
| | | - match: { prefix: "/email/" } |
| | | route: { cluster: email-service, timeout: { seconds: 60 } } |
| | | cors: |
| | | allow_origin_string_match: |
| | | - prefix: "*" |
| | | allow_methods: GET, PUT, DELETE, POST, OPTIONS |
| | | allow_headers: access-control-request-header,access-control-request-method,authorization,keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent |
| | | allow_headers: access-control-allow-origin,access-control-request-header,access-control-request-method,authorization,keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent |
| | | max_age: "1728000" |
| | | expose_headers: x-total-pages,x-total-count |
| | | filter_enabled: |
| | | default_value: {numerator: 100, denominator: HUNDRED} |
| | | runtime_key: cors.www.enabled |
| | | http_filters: |
| | | - name: envoy.cors |
| | | - name: envoy.router |
| | |
| | | import { AnimalService } from "./Services/AnimalService"; |
| | | import { AdoptionService } from "./Services/AdoptionService"; |
| | | import { ShelterService } from "./Services/ShelterService"; |
| | | import AnimalDetailsView from "./Views/AnimalDetailsView"; |
| | | import AnimalDetails from "./Components/AnimalDetails"; |
| | | // import ShelterRESTService from "./Services/ShelterRESTService"; |
| | | |
| | | // Services to connect to backends |
| | |
| | | <NewsView newsService={newsService} /> |
| | | </Route> |
| | | } |
| | | <Route path={`/animals/:animalId`} component={AnimalDetails}> |
| | | {/* <AnimalDetailsView |
| | | // animalId={this.pro} |
| | | animalService={animalService} |
| | | adoptionService={adoptionService}/> */} |
| | | </Route> |
| | | </Structure> |
| | | </Switch> |
| | | </Router> |
| | |
| | | import { Animal } from "../Models/Animal"; |
| | | import { AdoptionService } from "../Services/AdoptionService"; |
| | | import { Residency } from "../Models/Residency"; |
| | | import AnimalDetailsView from "../Views/AnimalDetailsView"; |
| | | import { Link, useHistory } from "react-router-dom"; |
| | | |
| | | |
| | | type AnimalListProps = { |
| | |
| | | showAdoptSucessAlert: boolean, |
| | | showAdoptErrorAlert: boolean |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Card list to show adoptable animals and apply for adoption |
| | |
| | | const adoptionApplication = { |
| | | username: "todo", |
| | | residency: Residency.HOUSE, |
| | | animalId: animal.id, |
| | | animalId: animal.animalId, |
| | | squareFootageOfHome: 100, |
| | | occupation: "todo", |
| | | ownOtherAnimals: false, |
| | |
| | | |
| | | |
| | | private renderAnimalCard(animal: Animal) { |
| | | const pictureSrc = `/photos/${animal.id}.jpeg`; |
| | | const pictureSrc = `/photos/${animal.animalId}.jpeg`; |
| | | |
| | | return ( |
| | | <GalleryItem key={animal.id}> |
| | | <GalleryItem key={animal.animalId}> |
| | | <Card> |
| | | <CardHeader> |
| | | {animal.name} |
| | | {animal.animalName} |
| | | </CardHeader> |
| | | <CardBody> |
| | | <img src={pictureSrc} alt={animal.name}></img> |
| | | <img src={pictureSrc} alt={animal.animalName}></img> |
| | | <CardActions> |
| | | <Button onClick={() => this.handleAdoptButtonClick(animal)}> |
| | | {/* <Button onClick={() => this.handleAdoptButtonClick(animal)}> |
| | | Adopt |
| | | </Button> |
| | | </Button> */} |
| | | <Link to={`/animals/${animal.animalId}`}> |
| | | <Button> |
| | | Details |
| | | </Button> |
| | | </Link> |
| | | </CardActions> |
| | | </CardBody> |
| | | </Card> |
| | |
| | | ); |
| | | |
| | | } |
| | | |
| | | |
| | | private renderAdoptErrorAlert(): React.ReactNode | null { |
| | | if (this.state.showAdoptErrorAlert) { |
New file |
| | |
| | | import React from "react"; |
| | | import { |
| | | Gallery, GalleryItem, Card, CardBody, CardHeader, CardActions, Button, Alert |
| | | } from "@patternfly/react-core"; |
| | | import { AnimalService } from "../Services/AnimalService"; |
| | | import { Animal } from "../Models/Animal"; |
| | | import { AdoptionService } from "../Services/AdoptionService"; |
| | | import { Residency } from "../Models/Residency"; |
| | | import AnimalDetailsView from "../Views/AnimalDetailsView"; |
| | | import { Link, useHistory } from "react-router-dom"; |
| | | |
| | | type AnimalDetailsProps = { |
| | | animalService: AnimalService; |
| | | adoptionService: AdoptionService; |
| | | } |
| | | |
| | | type AnimalDetailsState = { |
| | | animal: Animal; |
| | | } |
| | | |
| | | export default class AnimalDetails extends React.Component<AnimalDetailsProps, AnimalDetailsState> { |
| | | |
| | | constructor(props: AnimalDetailsProps) { |
| | | super(props); |
| | | |
| | | } |
| | | |
| | | public async componentDidMount() { |
| | | // We need the animal Id or somehow have the animal |
| | | // that was selected in AdoptableAnimalsList to be passed.. |
| | | // not sure how to do that |
| | | const animalId = window.location.pathname; |
| | | console.log(animalId); |
| | | |
| | | } |
| | | |
| | | public render() { |
| | | return( |
| | | <React.Fragment> |
| | | hello |
| | | </React.Fragment> |
| | | ) |
| | | } |
| | | } |
| | |
| | | |
| | | return ( |
| | | <List> |
| | | {shelters.map(shelter => <ListItem key={shelter.id}>{shelter.name}</ListItem>)} |
| | | {shelters.map(shelter => <ListItem key={shelter.shelterId}>{shelter.shelterName}</ListItem>)} |
| | | </List> |
| | | ); |
| | | } |
| | |
| | | export interface Animal { |
| | | id: string; |
| | | name: string; |
| | | animalId: string; |
| | | animalName: string; |
| | | shelterId: string; |
| | | breed: string; |
| | | adoptable: boolean; |
| | | approximateSize: string; |
| | | residencyRequired: string; |
| | | weight: number; |
| | | squareFootageOfHome: number; |
| | | childSafe: boolean; |
| | | otherDogSafe: boolean; |
| | | } |
New file |
| | |
| | | export interface Shelter { |
| | | shelterId: string; |
| | | shelterName: string; |
| | | state: string; |
| | | country: string; |
| | | address: string; |
| | | email: string; |
| | | phoneNumber: string; |
| | | } |
| | |
| | | public async getAdoptableByShelter(): Promise<Animal[]> { |
| | | return [ |
| | | { |
| | | id: "a1", |
| | | name: "Dog 1", |
| | | animalId: "a1", |
| | | animalName: "Dog 1", |
| | | breed: "Shepherd", |
| | | shelterId: "s1", |
| | | adoptable: true |
| | | adoptable: true, |
| | | weight: 100, |
| | | approximateSize: "L", |
| | | residencyRequired: "HOUSE", |
| | | squareFootageOfHome: 800, |
| | | childSafe: true, |
| | | otherDogSafe: true |
| | | } |
| | | ]; |
| | | } |
| | |
| | | public async getAllAdoptable(): Promise<Animal[]> { |
| | | return [ |
| | | { |
| | | id: "a1", |
| | | name: "Dog 1", |
| | | animalId: "a1", |
| | | animalName: "Dog 1", |
| | | breed: "Shepherd", |
| | | shelterId: "s1", |
| | | adoptable: true |
| | | adoptable: true, |
| | | weight: 100, |
| | | approximateSize: "L", |
| | | residencyRequired: "HOUSE", |
| | | squareFootageOfHome: 800, |
| | | childSafe: true, |
| | | otherDogSafe: true |
| | | } |
| | | ]; |
| | | } |
| | | |
| | | public async getById(id: string): Promise<Animal> { |
| | | return { |
| | | id: id, |
| | | name: "Dog 1", |
| | | return { |
| | | animalId: "a1", |
| | | animalName: "Dog 1", |
| | | breed: "Shepherd", |
| | | shelterId: "s1", |
| | | adoptable: true |
| | | adoptable: true, |
| | | weight: 100, |
| | | approximateSize: "L", |
| | | residencyRequired: "HOUSE", |
| | | squareFootageOfHome: 800, |
| | | childSafe: true, |
| | | otherDogSafe: true |
| | | }; |
| | | } |
| | | |
| | |
| | | super(baseUrl, "shelter-service"); |
| | | } |
| | | public async create(animal: Animal): Promise<void> { |
| | | await this.post(`/${animal.shelterId}/create`, animal); |
| | | await this.post(`/animals/${animal.shelterId}/create`, animal); |
| | | } |
| | | |
| | | public getAllAdoptable(): Promise<Animal[]> { |
| | | throw new Error("Method not implemented."); |
| | | return this.get("/animals/getAllAdoptable") |
| | | } |
| | | |
| | | public getById(id: string): Promise<Animal> { |
| | | throw new Error("Method not implemented."); |
| | | return this.get(`/animals/${id}/getAnimalById`); |
| | | } |
| | | |
| | | public getAdoptableByShelter(): Promise<Animal[]> { |
| | | return this.get("/getAllAdoptableByShelter"); |
| | | return this.get("/animals/getAllAdoptableByShelter"); |
| | | } |
| | | |
| | | public async applyForAdoption(adoptionApplication: AdoptionApplication): Promise<void> { |
| | | await this.post("/applyForAdoption", adoptionApplication); |
| | | await this.post("/animals/applyForAdoption", adoptionApplication); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | public async getAll(): Promise<any[]> { |
| | | return [ |
| | | { id: "s1", name: "Shelter 1" }, |
| | | { id: "s2", name: "Shelter 2" } |
| | | { shelterId: "s1", shelterName: "Shelter 1" }, |
| | | { shelterId: "s2", shelterName: "Shelter 2" } |
| | | ]; |
| | | } |
| | | } |
| | |
| | | import { ShelterService, ShelterParams } from "./ShelterService"; |
| | | import { RESTService } from "./RESTService"; |
| | | import { Shelter } from "../Models/Shelter"; |
| | | |
| | | |
| | | export default class ShelterRESTService extends RESTService implements ShelterService { |
| | |
| | | return this.post("/create", params); |
| | | } |
| | | |
| | | public getAll(): Promise<Array<any>> { |
| | | return this.get<Array<any>>("/shelters/getAll"); |
| | | public getAll(): Promise<Array<Shelter>> { |
| | | return this.get<Array<Shelter>>("/shelters/getAll"); |
| | | } |
| | | } |
New file |
| | |
| | | import React from "react"; |
| | | import { PageSection, PageSectionVariants, Text, TextContent } from "@patternfly/react-core"; |
| | | import { AdoptionService } from "../Services/AdoptionService"; |
| | | import { AnimalService } from "../Services/AnimalService"; |
| | | |
| | | type AnimalDetailsViewProps = { |
| | | adoptionService: AdoptionService; |
| | | animalService: AnimalService; |
| | | } |
| | | |
| | | export default class AnimalDetailsView extends React.Component<AnimalDetailsViewProps, AnimalService> { |
| | | public render() { |
| | | return ( |
| | | <PageSection variant={PageSectionVariants.light}> |
| | | |
| | | </PageSection> |
| | | ) |
| | | } |
| | | } |