Commit a1eb4673 authored by isurugunarathna's avatar isurugunarathna

adding generated exercise plan UI

parent 6b6b8eb1
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { GenerateExercisePlanPage } from './generate-exercise-plan.page';
const routes: Routes = [
{
path: '',
component: GenerateExercisePlanPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class GenerateExercisePlanPageRoutingModule {}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { GenerateExercisePlanPageRoutingModule } from './generate-exercise-plan-routing.module';
import { GenerateExercisePlanPage } from './generate-exercise-plan.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
GenerateExercisePlanPageRoutingModule
],
declarations: [GenerateExercisePlanPage]
})
export class GenerateExercisePlanPageModule {}
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<div class="container-fluid" style="background-color: #E9F0FB">
<div class="row ion-justify-content-center" style="height: 100vh">
<div class="col-11">
<div class="row ion-justify-content-center">
<div class="col">
<h1 class="fw-bolder">Charlie's Exercise Plan</h1>
</div>
</div>
<div class="row mt-4">
<div class="col px-2 py-5 bg-secondary shadow-lg rounded-3 text-light">
<div class="row">
<div class="col">Breed: </div>
<div class="col">
<span *ngIf="breed === 0">Boxer</span>
<span *ngIf="breed === 1">Doberman</span>
<span *ngIf="breed === 2">German splitz</span>
<span *ngIf="breed === 3">Great dane</span>
<span *ngIf="breed === 4">Labrador</span>
<span *ngIf="breed === 5">Pomenarian</span>
</div>
</div>
<div class="row">
<div class="col">Health: </div>
<div class="col text-warning">{{prediction}}</div>
</div>
<p class="ion-text-center mt-4"><u>How to give exercise</u></p>
<h5 *ngIf="prediction == 'Over weight'" class="ion-text-center mt-4 fw-bold text-warning">Your dog is overweight, please consider following exercise plans</h5>
<h6 *ngIf="prediction == 'Over weight'" class="ion-text-center mt-4 fw-bold text-warning">Recommended exercise is to walk your dog for 30 minutes five times a day. For a more organized plan, please follow these steps</h6>
<h5 *ngIf="prediction == 'Normal weight' || prediction == 'Under weight'" class="ion-text-center mt-4 fw-bold text-warning">Your dog is not obese</h5>
<h5 *ngIf="prediction == 'Under weight'" class="ion-text-center mt-4 fw-bold text-warning">Since your dog is underweight exercise is not mandatory, but with proper meal plans please follow the instructions.</h5>
<h5 *ngIf="breed === 0 && (prediction == 'Normal weight' || prediction == 'Under weight')" class="ion-text-center mt-4 fw-bold text-warning">
Walk your dog more than 2 hours a day
</h5>
<h5 *ngIf="breed === 1 && (prediction == 'Normal weight' || prediction == 'Under weight')" class="ion-text-center mt-4 fw-bold text-warning">
Walk your dog more than 2 hours a day
</h5>
<h5 *ngIf="breed === 2 && (prediction == 'Normal weight' || prediction == 'Under weight')" class="ion-text-center mt-4 fw-bold text-warning">
Walk your dog upto 1 hour a day
</h5>
<h5 *ngIf="breed === 3 && (prediction == 'Normal weight' || prediction == 'Under weight')" class="ion-text-center mt-4 fw-bold text-warning">
Walk your dog more than 2 hours a day
</h5>
<h5 *ngIf="breed === 4 && (prediction == 'Normal weight' || prediction == 'Under weight')" class="ion-text-center mt-4 fw-bold text-warning">
Walk your dog more than 2 hours a day
</h5>
<h5 *ngIf="breed === 5 && (prediction == 'Normal weight' || prediction == 'Under weight')" class="ion-text-center mt-4 fw-bold text-warning">
Walk your dog upto 30 minutes
</h5>
<ul *ngIf="prediction == 'Over weight'" class="list-group">
<li class="list-group-item">Week 1: 30 minutes per day 10 minutes brisk followed by 20 minutes casual pace.</li>
<li class="list-group-item">Week 2: 30 minutes per day 15 minutes brisk followed by 15 minutes casual pace.</li>
<li class="list-group-item">Week 3: 30 minutes per day 20 minutes brisk followed by 10 minutes casual pace.</li>
<li class="list-group-item">Week 4: 35-40 minutes per day 30 minutes brisk followed by 5-10 minutes casual pace.</li>
<li class="list-group-item">Week 5+: 35-60 minutes per day try to do two 20-30 minutes: 15-25 minutes brisk followed by 5 minutes casual pace.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</ion-content>
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { GenerateExercisePlanPage } from './generate-exercise-plan.page';
describe('GenerateExercisePlanPage', () => {
let component: GenerateExercisePlanPage;
let fixture: ComponentFixture<GenerateExercisePlanPage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ GenerateExercisePlanPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(GenerateExercisePlanPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {PythonBackendService} from '../core/python-backend.service';
@Component({
selector: 'app-generate-exercise-plan',
templateUrl: './generate-exercise-plan.page.html',
styleUrls: ['./generate-exercise-plan.page.scss'],
})
export class GenerateExercisePlanPage implements OnInit {
breed: number;
weight: number;
height: number;
public prediction: string;
constructor(
private route: ActivatedRoute,
private pythonBackendService: PythonBackendService
) { }
ngOnInit() {
this.breed = Number(this.route.snapshot.paramMap.get('breed'));
this.weight = Number(this.route.snapshot.paramMap.get('weight'));
this.height = Number(this.route.snapshot.paramMap.get('height'));
this.pythonBackendService.predictWeight([[this.breed, this.height, this.weight]])
.subscribe(res => {
console.log(res);
if (res.pred === '0') {
this.prediction = 'Normal weight';
}
if (res.pred === '1') {
this.prediction = 'Over weight';
}
if (res.pred === '-1') {
this.prediction = 'Under weight';
}
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment