-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add weather graph and test.
- Loading branch information
Showing
17 changed files
with
189 additions
and
64 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ form { | |
} | ||
|
||
.mat-mdc-card { | ||
background: #2c3338; | ||
background: white; | ||
} | ||
|
||
.data-content { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
3 changes: 3 additions & 0 deletions
3
frontend/src/app/weather/weather-graph/weather-graph.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="chart-container"> | ||
<canvas id="MyChart">{{ chart }}</canvas> | ||
</div> |
62 changes: 62 additions & 0 deletions
62
frontend/src/app/weather/weather-graph/weather-graph.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {Component, OnDestroy, OnInit} from '@angular/core'; | ||
import {ForecastWeatherDetail} from "../model/ForecastWeatherDetal"; | ||
import {Chart, registerables} from 'chart.js'; | ||
import moment from "moment"; | ||
|
||
@Component({ | ||
selector: 'app-weather-graph', | ||
standalone: true, | ||
imports: [], | ||
templateUrl: './weather-graph.component.html', | ||
styleUrl: './weather-graph.component.css' | ||
}) | ||
export class WeatherGraphComponent implements OnInit, OnDestroy { | ||
protected chart: any; | ||
|
||
ngOnInit() { | ||
Chart.register(...registerables); | ||
this.createChart(ForecastWeatherDetail.createDefault()); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
} | ||
|
||
createChart(data: ForecastWeatherDetail) { | ||
if (this.chart != undefined) { | ||
this.chart.destroy(); | ||
} | ||
this.chart = new Chart("MyChart", { | ||
type: "line", //this denotes tha type of chart | ||
|
||
data: {// values on X-Axis | ||
labels: data.time.map(time => moment(time).format("DD/MM")), | ||
datasets: [ | ||
{ | ||
label: "Min Temp", | ||
data: data.minTemperature, | ||
backgroundColor: 'blue' | ||
}, | ||
{ | ||
label: "Max Temp", | ||
data: data.maxTemperature, | ||
backgroundColor: 'red' | ||
}, | ||
{ | ||
label: "Max wind", | ||
data: data.maxWindSpeed, | ||
backgroundColor: 'grey' | ||
} | ||
] | ||
}, | ||
options: { | ||
scales: { | ||
y: { | ||
beginAtZero: true | ||
} | ||
}, | ||
responsive: true, | ||
aspectRatio: 1 | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ describe('LoginComponent', () => { | |
describe('login', () => { | ||
it('should login', () => { | ||
const validFormValue = {email: "[email protected]", password: "password"} as LoginForm | ||
component.formGroup = formBuilder.group(validFormValue) | ||
component['formGroup'] = formBuilder.group(validFormValue) | ||
fixture.detectChanges() | ||
|
||
authService.login = jest.fn().mockReturnValue(of({})); | ||
|
@@ -62,7 +62,7 @@ describe('LoginComponent', () => { | |
|
||
it('invalid password', () => { | ||
const validFormValue = {email: "[email protected]", password: "password"} as LoginForm | ||
component.formGroup = formBuilder.group(validFormValue) | ||
component['formGroup'] = formBuilder.group(validFormValue) | ||
fixture.detectChanges() | ||
|
||
const notificationSpy = jest.spyOn(notificationService, 'errorNotification'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ describe('RegisterComponent', () => { | |
password: "password", | ||
passwordConfirmation: "password" | ||
} as RegistrationForm | ||
component.formGroup = formBuilder.group(validFormValue) | ||
component['formGroup'] = formBuilder.group(validFormValue) | ||
fixture.detectChanges() | ||
|
||
authService.register = jest.fn().mockReturnValue(of({})); | ||
|
@@ -68,7 +68,7 @@ describe('RegisterComponent', () => { | |
|
||
it('should throw error', () => { | ||
const validFormValue = {email: "[email protected]", password: "password"} as LoginForm | ||
component.formGroup = formBuilder.group(validFormValue) | ||
component['formGroup'] = formBuilder.group(validFormValue) | ||
fixture.detectChanges() | ||
|
||
const notificationSpy = jest.spyOn(notificationService, 'errorNotification'); | ||
|
Oops, something went wrong.