Skip to content

Commit

Permalink
Updated more url to match image
Browse files Browse the repository at this point in the history
  • Loading branch information
gryffindor-coder committed Aug 1, 2023
1 parent d27816e commit d16d0e2
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ public TransactionCallback<List<MealModel>> getPopularMealsTransaction(String em
"WITH m, rand() as random\n" +
"ORDER BY random\n" +
"RETURN m.name AS name, m.instructions AS instructions, m.description AS description, " +
"m.url AS url, m.ingredients AS ingredients, m.cookingTime AS cookingTime",
"m.image AS image, m.ingredients AS ingredients, m.cookingTime AS cookingTime",
Values.parameters("email", email));

while (result.hasNext()) {
org.neo4j.driver.Record record = result.next();
String name = record.get("name").asString();
String instructions = record.get("instructions").asString();
String description = record.get("description").asString();
String url = record.get("url").asString();
String image = record.get("image").asString();
String ingredients = record.get("ingredients").asString();
String cookingTime = record.get("cookingTime").asString();
randomMeals.add(new MealModel(name, instructions, description, url, ingredients, cookingTime));
randomMeals.add(new MealModel(name, instructions, description, image, ingredients, cookingTime));
}

return randomMeals;
Expand Down Expand Up @@ -101,13 +101,13 @@ public TransactionCallback<List<MealModel>> getSearchedMealsTransaction(String m
List<MealModel> matchingPopularMeals = new ArrayList<>();
// org.neo4j.driver.Result result = transaction.run("MATCH (m:Meal {name: $name})\n" +
// "RETURN m.name AS name, m.instructions AS instructions, m.description AS description, " +
// "m.url AS url, m.ingredients AS ingredients, m.cookingTime AS cookingTime",
// "m.image AS image, m.ingredients AS ingredients, m.cookingTime AS cookingTime",
// Values.parameters("email", email));
org.neo4j.driver.Result result = transaction.run(
"MATCH (m:Meal)\n" +
"WHERE m.name =~ $namePattern OR m.ingredients =~ $namePattern OR m.description =~ $namePattern\n" + // Use regular expression matching
"RETURN m.name AS name, m.instructions AS instructions, m.description AS description, " +
"m.url AS url, m.ingredients AS ingredients, m.cookingTime AS cookingTime",
"m.image AS image, m.ingredients AS ingredients, m.cookingTime AS cookingTime",
Values.parameters("namePattern", "(?i).*" + mealName + ".*") // (?i) for case-insensitive
);

Expand All @@ -116,11 +116,11 @@ public TransactionCallback<List<MealModel>> getSearchedMealsTransaction(String m
String name = record.get("name").asString();
String instructions = record.get("instructions").asString();
String description = record.get("description").asString();
String url = record.get("url").asString();
String image = record.get("image").asString();
String ingredients = record.get("ingredients").asString();
String cookingTime = record.get("cookingTime").asString();
// return new MealModel(name, instructions, description, url, ingredients, cookingTime);
matchingPopularMeals.add(new MealModel(name, instructions, description, url, ingredients, cookingTime));
// return new MealModel(name, instructions, description, image, ingredients, cookingTime);
matchingPopularMeals.add(new MealModel(name, instructions, description, image, ingredients, cookingTime));
}

return matchingPopularMeals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<ion-avatar no-padding no-margin>
<img
src="https://images.unsplash.com/photo-1498837167922-ddd27525d352?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80"
src="https://plus.unsplash.com/premium_photo-1675252369719-dd52bc69c3df?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=687&q=80"
alt="https://images.unsplash.com/photo-1498837167922-ddd27525d352?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80"
/>
</ion-avatar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-avatar>
<ion-img [src]="item.image" [alt]="item.name"></ion-img>
</ion-avatar>
<ion-content class="ion-padding">

<div *ngIf="notSaved()">
<ion-button (click)="addRecipe(item)" class="savebutton" fill="outline" shape="round" color="black">
<ion-icon slot="start" name="bookmark-outline"></ion-icon>
Save to Recipe Book
</ion-button>
</div>
<p>{{ item.description }}</p>
<h4>Preparation Time</h4>
<p>{{ item.cookingTime }}</p>
<h4>Ingredients</h4>
<p>{{ item.ingredients }}</p>
<h4>Instructions</h4>
<p>{{ item.instructions }}</p>
</ion-content>
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@
right: 5px;
padding-top: 5px;
text-transform: capitalize;
}

ion-avatar {
height: 20vh;
width: auto;
--border-radius: 2%;
}

p {
padding-left: 5vw;
}

ion-content {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
7 changes: 4 additions & 3 deletions frontend/src/app/pages/recipe-book/recipe-book.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ export class RecipeBookPage implements OnInit {
this.getRecipes();
}

async addRecipe(item: MealI) {
this.recipeService.addRecipe(item).subscribe({
async addRecipe(item: MealI) {
this.recipeService.addRecipe(item).subscribe({
next: (response) => {
if (response.status === 200) {
if (response.body) {
this.items.push(response.body);
this.getRecipes();
this.errorHandlerService.presentSuccessToast(item.name + " added to Recipe Book");
}
}
},
Expand Down
16 changes: 12 additions & 4 deletions frontend/src/app/services/recipe-book/recipe-book-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,26 @@ export class RecipeBookApiService {
this.url+'/addRecipe',
{
"name":item.name,
"image":item.image
"description":item.description,
"image":item.image,
"ingredients":item.ingredients,
"instructions":item.instructions,
"cookingTime":item.cookingTime
},
{observe: 'response'}
);
}

removeRecipe(recipe: MealI): Observable<HttpResponse<void>> {
removeRecipe(item: MealI): Observable<HttpResponse<void>> {
return this.http.post<void>(
this.url+'/removeRecipe',
{
"title": recipe.name,
"image": recipe.image
"name":item.name,
"description":item.description,
"image":item.image,
"ingredients":item.ingredients,
"instructions":item.instructions,
"cookingTime":item.cookingTime
},
{observe: 'response'}
);
Expand Down

0 comments on commit d16d0e2

Please sign in to comment.