Skip to content

Commit

Permalink
Merge pull request #116 from COS301-SE-2023/frakno-redoRepo
Browse files Browse the repository at this point in the history
Franko-bugs-fixed
  • Loading branch information
SkulderLock authored Sep 7, 2023
2 parents fa6fc6d + 024b909 commit 03dc68d
Show file tree
Hide file tree
Showing 10 changed files with 1,860 additions and 1,388 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public DaysMealsModel(MealModel breakfast, MealModel lunch, MealModel dinner, Da
this.mealDate = mealDate;
this.user = user;
this.userDateIdentifier = (user.getEmail() + mealDate.toString());
this.meal = "";
}

public MealModel getBreakfast() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MealModel {
private String name;

@NotBlank(message = "An image is required")
private String image;
private String image = "https://images.unsplash.com/photo-1498837167922-ddd27525d352?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80";

@NotBlank(message = "A Description is required")
private String description;
Expand All @@ -32,7 +32,7 @@ public MealModel(String name, String instructions,String description, String ima
this.name = name;
this.instructions = instructions;
this.description = description;
this.image = image;
this.image = "https://images.unsplash.com/photo-1498837167922-ddd27525d352?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80";
this.ingredients = ingredients;
this.cookingTime = cookingTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ public class OpenaiApiService {
private OpenaiPromptBuilder pBuilder = new OpenaiPromptBuilder();

public String fetchMealResponse(String Type) throws JsonMappingException, JsonProcessingException {
// String jsonResponse = getJSONResponse(Type);
// JsonNode jsonNode = jsonMapper.readTree(jsonResponse);
String jsonResponse = getJSONResponse(Type);
JsonNode jsonNode = jsonMapper.readTree(jsonResponse);

// String text = jsonNode.get("choices").get(0).get("text").asText();
// text = text.replace("\\\"", "\"");
// text = text.replace("\n", "");
// text = text.replace("/r/n", "\\r\\n");
// return text;
String text = jsonNode.get("choices").get(0).get("text").asText();
text = text.replace("\\\"", "\"");
text = text.replace("\n", "");
text = text.replace("/r/n", "\\r\\n");
return text;

return "{\"instructions\":\"1. Preheat oven to 375 degrees/r/n2. Grease a baking dish with butter/r/n3. Beat together the eggs, milk, and a pinch of salt/r/n4. Place the bread slices in the baking dish and pour the egg mixture over them/r/n5. Bake in the preheated oven for 25 minutes/r/n6. Serve warm with your favorite toppings\",\"name\":\"Baked French Toast\",\"description\":\"a delicious breakfast dish of egg-soaked bread\",\"ingredients\":\"6 slices of bread/r/n3 eggs/r/n3/4 cup of milk/r/nSalt/r/nButter\",\"cookingTime\":\"30 minutes\"}";
// return "{\"instructions\":\"1. Preheat oven to 375 degrees/r/n2. Grease a baking dish with butter/r/n3. Beat together the eggs, milk, and a pinch of salt/r/n4. Place the bread slices in the baking dish and pour the egg mixture over them/r/n5. Bake in the preheated oven for 25 minutes/r/n6. Serve warm with your favorite toppings\",\"name\":\"Baked French Toast\",\"description\":\"a delicious breakfast dish of egg-soaked bread\",\"ingredients\":\"6 slices of bread/r/n3 eggs/r/n3/4 cup of milk/r/nSalt/r/nButter\",\"cookingTime\":\"30 minutes\"}";
}

public String fetchMealResponse(String Type, String extendedPrompt)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/models/userpreference.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ export interface UserPreferencesI {
goal: string;
shoppingInterval: string;
foodPreferences: string[];
calorieAmount: number;
calorieAmount: number | string;
budgetRange: string;
macroRatio: {protein: number, carbs: number, fat: number};
allergies: string[];
cookingTime: string;
userHeight: number; //consider moving to account
userWeight: number; //consider moving to account
userBMI: number;
userBMI: number | string;

bmiset : boolean;
cookingTimeSet : boolean;
Expand Down
41 changes: 18 additions & 23 deletions frontend/src/app/pages/profile/profile.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

<ion-content>

<ion-card>
<ion-button
(click)="navToProfile()"><ion-icon name="person-circle" size="small"></ion-icon>
</ion-button>

<ion-label>{{this.user.username}}'s Profile</ion-label>
<ion-card class="profile-card">
<ion-card-content class="profile-content">
<ion-button class="profile-button" (click)="navToProfile()">
<ion-icon name="person-circle" class="profile-icon"></ion-icon>
</ion-button>
<ion-label class="profile-label">{{ this.user.username }}'s Profile</ion-label>
</ion-card-content>
</ion-card>

<!-- the Goal -->
<ion-card>
<ion-card-header>
Expand All @@ -31,11 +33,11 @@
<ion-card-subtitle>
<div class="card-toggle">
<div class="toggle-label">Shopping Interval</div>
<div class="toggle-value">{{ userpreferences.shoppingInterval }}</div>
<div class="toggle-value">{{ getDisplayShoppingInterval() }}</div>
<ion-icon name="chevron-forward-outline" size="medium"></ion-icon>
</div>
</ion-card-subtitle>
</ion-card-header>
</ion-card-header>

<ion-modal [isOpen]="isShoppingModalOpen">
<ng-template>
Expand All @@ -46,7 +48,7 @@
<ion-button (click)="setOpenShopping(false)">Cancel</ion-button>
</ion-buttons>
<ion-buttons slot="end">
<ion-button (click)="setOpenShoppingSave(false)" [strong]="true">Confirm</ion-button>
<ion-button [disabled]="disabledConfirmShopping()" (click)="setOpenShoppingSave(false)" [strong]="true">Confirm</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
Expand Down Expand Up @@ -80,7 +82,7 @@
</ion-radio-group>

<ion-item *ngIf="shoppingInterval === 'other'">
<ion-label class="range-label">Every {{ shoppingIntervalOtherValue }} day(s)</ion-label>
<ion-label class="range-label">Every {{ getDisplayOtherShoppingInterval() }} day(s)</ion-label>
</ion-item>

<ion-item *ngIf="shoppingInterval === 'other'">
Expand Down Expand Up @@ -136,7 +138,7 @@
<ion-button (click)="setOpenPreferences(false)">Cancel</ion-button>
</ion-buttons>
<ion-buttons slot="end">
<ion-button (click)="setOpenPreferencesSave(false)" [strong]="true">Confirm</ion-button>
<ion-button [disabled]="disabledConfirmPreference()" (click)="setOpenPreferencesSave(false)" [strong]="true">Confirm</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
Expand Down Expand Up @@ -180,7 +182,6 @@
</ion-card>



<!-- The Calorie Counter -->
<ion-card (click)="setOpenCalorie(true)" class="ion-activatable">
<ion-ripple-effect></ion-ripple-effect>
Expand Down Expand Up @@ -264,7 +265,7 @@
<ion-button (click)="setOpenBudget(false)">Cancel</ion-button>
</ion-buttons>
<ion-buttons slot="end">
<ion-button (click)="setOpenBudgetSave(false)" [strong]="true">Confirm</ion-button>
<ion-button [disabled]="disabledConfirmBudget()" (click)="setOpenBudgetSave(false)" [strong]="true">Confirm</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
Expand All @@ -288,12 +289,6 @@
<ion-item>
<ion-radio [disabled]="!userpreferences.budgetSet" value="high">High Budget</ion-radio>
</ion-item>
<ion-item>
<ion-radio [disabled]="!userpreferences.budgetSet" value="custom">Custom Amount</ion-radio>
</ion-item>
<ion-item *ngIf="selectedPriceRange === 'custom'">
<ion-input type="number" label="Enter Custom Amount:" labelPlacement="floating" [(ngModel)]="userpreferences.budgetRange" step="0.01" min="0" placeholder="Enter amount"></ion-input>
</ion-item>
</ion-radio-group>
</ion-list>
</ion-card-content>
Expand Down Expand Up @@ -460,7 +455,7 @@
<ion-button (click)="setOpenCooking(false)">Cancel</ion-button>
</ion-buttons>
<ion-buttons slot="end">
<ion-button (click)="setOpenCookingSave(false)" [strong]="true">Confirm</ion-button>
<ion-button [disabled]="disabledCalorieCookingTime()" (click)="setOpenCookingSave(false)" [strong]="true">Confirm</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
Expand Down Expand Up @@ -526,7 +521,7 @@
<ion-button (click)="setOpenBMI(false)">Cancel</ion-button>
</ion-buttons>
<ion-buttons slot="end">
<ion-button (click)="setOpenBMISave(false)" (click)="calculateBMI()" [strong]="true">Confirm</ion-button>
<ion-button (click)="setOpenBMISave(false)" [strong]="true">Confirm</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
Expand All @@ -541,10 +536,10 @@
</ion-card-subtitle>
<ion-list>
<ion-item>
<ion-input [disabled]="!userpreferences.bmiset" type="number" [(ngModel)]="userpreferences.userHeight" step="0.01" min="0" placeholder="Enter amount">Height (cm)</ion-input>
<ion-input [disabled]="!userpreferences.bmiset" type="number" (input)="validateBudgetInput($event)" [(ngModel)]="userpreferences.userHeight" step="0.01" min="0" placeholder="Enter amount">Height (cm)</ion-input>
</ion-item>
<ion-item>
<ion-input [disabled]="!userpreferences.bmiset" type="number" [(ngModel)]="userpreferences.userWeight" step="0.01" min="0" placeholder="Enter amount">Weight (kg)</ion-input>
<ion-input [disabled]="!userpreferences.bmiset" type="number" (input)="validateBudgetInput($event)" [(ngModel)]="userpreferences.userWeight" step="0.01" min="0" placeholder="Enter amount">Weight (kg)</ion-input>
</ion-item>
</ion-list>
</ion-card-content>
Expand Down
31 changes: 31 additions & 0 deletions frontend/src/app/pages/profile/profile.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,34 @@
flex: 1;
text-align: left;
}

.profile-card {
display: flex;
justify-content: center;
align-items: center;
padding: 10px;
margin: 10px;
border-radius: 15px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.profile-content {
display: flex;
align-items: center;
}

.profile-button {
margin-right: 10px;
}

.profile-icon {
font-size: 32px;
color: #007bff;
}

.profile-label {
font-size: 18px;
font-weight: 600;
color: #333;
}

3 changes: 1 addition & 2 deletions frontend/src/app/pages/profile/profile.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ describe('ProfilePage', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
//removed ProfilePage from declarations
imports: [IonicModule.forRoot(), HttpClientTestingModule, RouterTestingModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA] // added this line
schemas: [CUSTOM_ELEMENTS_SCHEMA]

}).compileComponents();

Expand Down
Loading

0 comments on commit 03dc68d

Please sign in to comment.