From 05882ee66897ead046ce89ee3fad0fae530e7b3c Mon Sep 17 00:00:00 2001 From: Andreas Visagie u21430901 Date: Mon, 9 Oct 2023 01:05:03 +0200 Subject: [PATCH 1/3] No loadshedding stage --- .../src/app/tab-schedule/tab-schedule.page.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/WhereIsThePower/src/app/tab-schedule/tab-schedule.page.html b/app/WhereIsThePower/src/app/tab-schedule/tab-schedule.page.html index 995cfc76..2a5d465f 100644 --- a/app/WhereIsThePower/src/app/tab-schedule/tab-schedule.page.html +++ b/app/WhereIsThePower/src/app/tab-schedule/tab-schedule.page.html @@ -32,9 +32,12 @@

{{ result.name }}

{{ suburbName }}

- + Current Stage: {{ loadsheddingStage }} + + No Loadshedding + From 8a1e298ff83dcc3dd7886b26f8743663823c4960 Mon Sep 17 00:00:00 2001 From: Andreas Visagie u21430901 Date: Thu, 26 Oct 2023 14:31:32 +0200 Subject: [PATCH 2/3] Added confirm password --- .../components/signup/signup.component.html | 9 +++++ .../components/signup/signup.component.ts | 33 +++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/app/WhereIsThePower/src/app/shared/components/signup/signup.component.html b/app/WhereIsThePower/src/app/shared/components/signup/signup.component.html index fc9d921e..d8add49b 100644 --- a/app/WhereIsThePower/src/app/shared/components/signup/signup.component.html +++ b/app/WhereIsThePower/src/app/shared/components/signup/signup.component.html @@ -50,6 +50,15 @@

Where Is the Power? Password must be at least 8 characters + + + Confirm Password + + + + Passwords do not match + +
Signup
diff --git a/app/WhereIsThePower/src/app/shared/components/signup/signup.component.ts b/app/WhereIsThePower/src/app/shared/components/signup/signup.component.ts index 4c2757f0..53ec7732 100644 --- a/app/WhereIsThePower/src/app/shared/components/signup/signup.component.ts +++ b/app/WhereIsThePower/src/app/shared/components/signup/signup.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; import { ToastController } from '@ionic/angular'; import { RegisterUser } from '../../models/register-user'; @@ -27,8 +27,10 @@ export class SignupComponent implements OnInit { lastName: ['', [Validators.required]], email: ['', [Validators.required, Validators.email]], password: ['', [Validators.required, Validators.minLength(8)]], + confirmPassword: ['', Validators.required], }); + constructor( private router: Router, private formBuilder: FormBuilder, @@ -36,7 +38,17 @@ export class SignupComponent implements OnInit { private authService: AuthService, public modalController: ModalController, private loadingController: LoadingController - ) { } + ) { + this.signupForm.addValidators( + this.comparePasswordValidator( + this.signupForm.controls['password'], + this.signupForm.controls['confirmPassword'] + ) + ); + } + + + ngOnInit() { } @@ -45,7 +57,24 @@ export class SignupComponent implements OnInit { this.modalController.dismiss(); } + + comparePasswordValidator(passwordOne: AbstractControl, passwordTwo: AbstractControl) { + return () => { + if (passwordOne.value !== passwordTwo.value) { + console.log("Passwords do not match") + return { match_error: 'matchingErr' }; + } + + return null; + }; + } + signup() { + if(this.signupForm.value.password !== this.signupForm.value.confirmPassword) { + this.failToast('Passwords do not match'); + return; + } + if (this.signupForm.valid) { this.newUser.firstName = this.signupForm.value.firstName; this.newUser.lastName = this.signupForm.value.lastName; From dc67e355bab04d5a28f9b6a9a5e68ccee0398717 Mon Sep 17 00:00:00 2001 From: AmberLz Date: Thu, 26 Oct 2023 14:44:57 +0200 Subject: [PATCH 3/3] Update tab-statistics.page.ts --- .../app/tab-statistics/tab-statistics.page.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/WhereIsThePower/src/app/tab-statistics/tab-statistics.page.ts b/app/WhereIsThePower/src/app/tab-statistics/tab-statistics.page.ts index 077bea93..7b421f6c 100644 --- a/app/WhereIsThePower/src/app/tab-statistics/tab-statistics.page.ts +++ b/app/WhereIsThePower/src/app/tab-statistics/tab-statistics.page.ts @@ -83,15 +83,23 @@ export class TabStatisticsPage implements OnInit { processDoughnutChart(data: any) { // Get today's day name (e.g., "Mon", "Tue", etc.) + const today = new Date().toLocaleDateString('en-US', { weekday: 'short' }); + //const today = "Wed"; + //console.log("WEDNESDAY", data.result.perDayTimes["Wed"]); // Get the on and off values for today's day from the data - const todayOnValue = data.result.perDayTimes[today]?.on || 0; - const todayOffValue = data.result.perDayTimes[today]?.off || 0; + let uptimeToday = 24; + let downtimeToday = 0; + if (data.result.perDayTimes[today] != undefined) { + const todayOnValue = data.result.perDayTimes[today]?.on || 0; + const todayOffValue = data.result.perDayTimes[today]?.off || 0; + + // Convert total uptime and downtime to hours + uptimeToday = Math.floor(todayOnValue / 60); + downtimeToday = Math.floor(todayOffValue / 60); + } - // Convert total uptime and downtime to hours - const uptimeToday = Math.floor(todayOnValue / 60); - const downtimeToday = Math.floor(todayOffValue / 60); // Data for Doughnut Chart (Uptime/Downtime for Today) const doughnutData = {