├── src ├── assets │ ├── .gitkeep │ ├── cold-c.png │ ├── high-c.png │ ├── wind.png │ ├── humidity.png │ ├── cold-image.jpg │ ├── hot-image.jpg │ └── weather-background.jpg ├── app │ ├── app.component.css │ ├── app-routing.module.ts │ ├── app.module.ts │ ├── app.component.ts │ ├── services │ │ └── weather.service.ts │ ├── models │ │ └── weather.model.ts │ ├── app.component.spec.ts │ └── app.component.html ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── test.ts ├── polyfills.ts └── styles.css ├── .vscode ├── extensions.json ├── launch.json └── tasks.json ├── .editorconfig ├── tsconfig.app.json ├── tsconfig.spec.json ├── tsconfig.json ├── .browserslistrc ├── .gitignore ├── README.md ├── package.json ├── karma.conf.js └── angular.json /src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jaffer-Ali-Abubakker/Weather-app-Angular/HEAD/src/favicon.ico -------------------------------------------------------------------------------- /src/assets/cold-c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jaffer-Ali-Abubakker/Weather-app-Angular/HEAD/src/assets/cold-c.png -------------------------------------------------------------------------------- /src/assets/high-c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jaffer-Ali-Abubakker/Weather-app-Angular/HEAD/src/assets/high-c.png -------------------------------------------------------------------------------- /src/assets/wind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jaffer-Ali-Abubakker/Weather-app-Angular/HEAD/src/assets/wind.png -------------------------------------------------------------------------------- /src/assets/humidity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jaffer-Ali-Abubakker/Weather-app-Angular/HEAD/src/assets/humidity.png -------------------------------------------------------------------------------- /src/assets/cold-image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jaffer-Ali-Abubakker/Weather-app-Angular/HEAD/src/assets/cold-image.jpg -------------------------------------------------------------------------------- /src/assets/hot-image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jaffer-Ali-Abubakker/Weather-app-Angular/HEAD/src/assets/hot-image.jpg -------------------------------------------------------------------------------- /src/assets/weather-background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jaffer-Ali-Abubakker/Weather-app-Angular/HEAD/src/assets/weather-background.jpg -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | 4 | const routes: Routes = []; 5 | 6 | @NgModule({ 7 | imports: [RouterModule.forRoot(routes)], 8 | exports: [RouterModule] 9 | }) 10 | export class AppRoutingModule { } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WeatherApp 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "pwa-chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import { HttpClientModule } from "@angular/common/http"; 7 | import { FormsModule } from '@angular/forms'; 8 | 9 | @NgModule({ 10 | declarations: [ 11 | AppComponent 12 | ], 13 | imports: [ 14 | BrowserModule, 15 | AppRoutingModule, 16 | HttpClientModule, 17 | FormsModule 18 | ], 19 | providers: [], 20 | bootstrap: [AppComponent] 21 | }) 22 | export class AppModule { } 23 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "sourceMap": true, 8 | "declaration": false, 9 | "downlevelIteration": true, 10 | "experimentalDecorators": true, 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2020", 14 | "module": "es2020", 15 | "lib": [ 16 | "es2020", 17 | "dom" 18 | ] 19 | }, 20 | "angularCompilerOptions": { 21 | "enableI18nLegacyMessageIdFormat": false 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | (id: string): T; 13 | keys(): string[]; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | ); 22 | 23 | // Then we find all the tests. 24 | const context = require.context('./', true, /\.spec\.ts$/); 25 | // And load the modules. 26 | context.keys().forEach(context); 27 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { weatherData } from './models/weather.model'; 3 | import { WeatherService } from './services/weather.service'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | templateUrl: './app.component.html', 8 | styleUrls: ['./app.component.css'] 9 | }) 10 | export class AppComponent implements OnInit { 11 | 12 | constructor(private weatherService: WeatherService){ 13 | 14 | 15 | } 16 | cityName:string = 'manchester' 17 | weatherData?: weatherData; 18 | 19 | ngOnInit(): void { 20 | this.getWeatherData(this.cityName); 21 | this.cityName = ''; 22 | } 23 | 24 | onSubmit() { 25 | this.getWeatherData(this.cityName); 26 | this.cityName = ''; 27 | 28 | } 29 | private getWeatherData(cityName: string){ 30 | this.weatherService.getWeatherData(cityName) 31 | .subscribe({ 32 | next: (response)=>{ 33 | this.weatherData = response; 34 | console.log(response); 35 | } 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/app/services/weather.service.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; 2 | import { Injectable } from '@angular/core'; 3 | import { Observable } from 'rxjs'; 4 | import { environment } from 'src/environments/environment'; 5 | import { weatherData } from '../models/weather.model'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class WeatherService { 11 | 12 | constructor(private http: HttpClient) { } 13 | 14 | getWeatherData(cityName: string):Observable{ 15 | return this.http.get(environment.weatherApiBaseurl, { 16 | headers: new HttpHeaders() 17 | .set(environment.XRapidAPIHostHeaderName, 18 | environment.XRapidAPIHostHeaderValue) 19 | .set(environment.XRapidAPIKeyHeaderName, 20 | environment.XRapidAPIKeyHeadervalue), 21 | params: new HttpParams() 22 | .set('q', cityName) 23 | .set('units', 'metric') 24 | .set('mode', 'json') 25 | }) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false, 7 | weatherApiBaseurl:'https://community-open-weather-map.p.rapidapi.com/weather', 8 | XRapidAPIHostHeaderName: 'X-RapidAPI-Key', 9 | XRapidAPIHostHeaderValue: 'community-open-weather-map.p.rapidapi.com', 10 | XRapidAPIKeyHeaderName: 'X-RapidAPI-Key', 11 | XRapidAPIKeyHeadervalue: 'b7967da63cmshdac5b5c572cea27p162043jsn7efa738013ba' 12 | }; 13 | 14 | /* 15 | * For easier debugging in development mode, you can import the following file 16 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 17 | * 18 | * This import should be commented out in production mode because it will have a negative impact 19 | * on performance if an error is thrown. 20 | */ 21 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 22 | -------------------------------------------------------------------------------- /src/app/models/weather.model.ts: -------------------------------------------------------------------------------- 1 | export interface weatherData { 2 | coord: Coord 3 | weather: Weather[] 4 | base: string 5 | main: Main 6 | visibility: number 7 | wind: Wind 8 | clouds: Clouds 9 | dt: number 10 | sys: Sys 11 | timezone: number 12 | id: number 13 | name: string 14 | cod: number 15 | } 16 | 17 | export interface Coord { 18 | lon: number 19 | lat: number 20 | } 21 | 22 | export interface Weather { 23 | id: number 24 | main: string 25 | description: string 26 | icon: string 27 | } 28 | 29 | export interface Main { 30 | temp: number 31 | feelslike: number 32 | temp_min: number 33 | temp_max: number 34 | pressure: number 35 | humidity: number 36 | } 37 | 38 | export interface Wind { 39 | speed: number 40 | deg: number 41 | } 42 | 43 | export interface Clouds { 44 | all: number 45 | } 46 | 47 | export interface Sys { 48 | type: number 49 | id: number 50 | country: string 51 | sunrise: number 52 | sunset: number 53 | } 54 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WeatherApp 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.0.2. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weather-app", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "^14.0.0", 14 | "@angular/common": "^14.0.0", 15 | "@angular/compiler": "^14.0.0", 16 | "@angular/core": "^14.0.0", 17 | "@angular/forms": "^14.0.0", 18 | "@angular/platform-browser": "^14.0.0", 19 | "@angular/platform-browser-dynamic": "^14.0.0", 20 | "@angular/router": "^14.0.0", 21 | "rxjs": "~7.5.0", 22 | "tslib": "^2.3.0", 23 | "zone.js": "~0.11.4" 24 | }, 25 | "devDependencies": { 26 | "@angular-devkit/build-angular": "^14.0.2", 27 | "@angular/cli": "~14.0.2", 28 | "@angular/compiler-cli": "^14.0.0", 29 | "@types/jasmine": "~4.0.0", 30 | "jasmine-core": "~4.1.0", 31 | "karma": "~6.3.0", 32 | "karma-chrome-launcher": "~3.1.0", 33 | "karma-coverage": "~2.2.0", 34 | "karma-jasmine": "~5.0.0", 35 | "karma-jasmine-html-reporter": "~1.7.0", 36 | "typescript": "~4.7.2" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async () => { 7 | await TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | }); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'Weather-app'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('Weather-app'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement as HTMLElement; 33 | expect(compiled.querySelector('.content span')?.textContent).toContain('Weather-app app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/weather-app'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes recent versions of Safari, Chrome (including 12 | * Opera), Edge on the desktop, and iOS and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * By default, zone.js will patch all possible macroTask and DomEvents 23 | * user can disable parts of macroTask/DomEvents patch by setting following flags 24 | * because those flags need to be set before `zone.js` being loaded, and webpack 25 | * will put import in the top of bundle, so user need to create a separate file 26 | * in this directory (for example: zone-flags.ts), and put the following flags 27 | * into that file, and then add the following code before importing zone.js. 28 | * import './zone-flags'; 29 | * 30 | * The flags allowed in zone-flags.ts are listed here. 31 | * 32 | * The following flags will work for all browsers. 33 | * 34 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 35 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 36 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 37 | * 38 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 39 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 40 | * 41 | * (window as any).__Zone_enable_cross_context_check = true; 42 | * 43 | */ 44 | 45 | /*************************************************************************************************** 46 | * Zone JS is required by default for Angular itself. 47 | */ 48 | import 'zone.js'; // Included with Angular CLI. 49 | 50 | 51 | /*************************************************************************************************** 52 | * APPLICATION IMPORTS 53 | */ 54 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | :root { 3 | 4 | --blue-1: #503273; 5 | --blue-2: #5055a1; 6 | --yellow-1: #e9a700; 7 | --white: #FFF; 8 | --grey-1: #EDEDED; 9 | --shadow-dark: rgba(0,0,0,0.3); 10 | --shadow-light: rgba(255,255,255,0.1); 11 | } 12 | *{ 13 | margin: 0; 14 | padding: 0; 15 | box-sizing: border-box; 16 | } 17 | 18 | body { 19 | font-family: Verdana, Geneva, Tahoma, sans-serif; 20 | font-size: 16px; 21 | width: 100%; 22 | height: 100vh; 23 | background-color: var(--blue-1); 24 | 25 | 26 | display: flex; 27 | justify-content: center; 28 | align-items: center; 29 | } 30 | 31 | .container { 32 | width: 400px; 33 | height: 80vh; 34 | background-color: var(--blue-2); 35 | border-radius: 20px; 36 | box-shadow: 10px 10px 10px var(--shadow-dark); 37 | 38 | } 39 | 40 | .upper-data { 41 | position: relative; 42 | overflow: hidden; 43 | width: 100%; 44 | height: 50%; 45 | border-top-left-radius: 20px ; 46 | border-top-right-radius: 20px; 47 | } 48 | .lower-data { 49 | position: relative; 50 | overflow: hidden; 51 | width: 100%; 52 | height: 50%; 53 | border-bottom-left-radius: 20px; 54 | border-bottom-right-radius: 20px; 55 | padding: 1em; 56 | display: flex; 57 | flex-direction: column; 58 | } 59 | 60 | .upper-data img { 61 | position: absolute; 62 | top: 0; 63 | left: 0; 64 | width: 100%; 65 | height: 100%; 66 | 67 | } 68 | 69 | .weather-data{ 70 | position: relative; 71 | z-index: 1; 72 | width: 100%; 73 | height: 100%; 74 | background-color: var(--shadow-dark); 75 | display: flex; 76 | flex-direction: column; 77 | align-items: center; 78 | justify-content: center; 79 | } 80 | 81 | .location { 82 | color: var(--white); 83 | text-align: center; 84 | font-size: 1.2em; 85 | } 86 | 87 | .temperature { 88 | color: var(--white); 89 | font-size: 4em; 90 | text-align: center; 91 | font-weight: 900; 92 | } 93 | 94 | .more-info-label { 95 | color: var(--white); 96 | } 97 | 98 | .more-info-container { 99 | flex: 1; 100 | background-color: var(--shadow-light); 101 | border-bottom-left-radius: 20px ; 102 | border-bottom-right-radius: 20px; 103 | margin-top: 1em; 104 | 105 | 106 | display: flex; 107 | flex-direction: row; 108 | flex-wrap: wrap; 109 | } 110 | 111 | .info-block { 112 | width: 50%; 113 | display: flex; 114 | flex-direction:column ; 115 | justify-content: center; 116 | align-items: center; 117 | } 118 | 119 | .info-block-label img { 120 | width: 1.5em; 121 | } 122 | .info-block-label span { 123 | color: var(--white); 124 | font-size: 0.8em; 125 | } 126 | .info-block-value { 127 | width: 50%; 128 | display: flex; 129 | justify-content: flex-start; 130 | align-items: center; 131 | color: var(--white); 132 | } 133 | 134 | .search { 135 | margin-bottom: 1em; 136 | text-align: center; 137 | } 138 | 139 | .search input { 140 | 141 | background-color: var(--shadow-light); 142 | outline: none; 143 | border: none; 144 | border-radius: 20px; 145 | padding: 1em; 146 | color: var(--grey-1); 147 | font-size: .8em; 148 | text-align: center; 149 | 150 | } 151 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "Weather-app": { 7 | "projectType": "application", 8 | "schematics": {}, 9 | "root": "", 10 | "sourceRoot": "src", 11 | "prefix": "app", 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/weather-app", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "tsconfig.app.json", 21 | "assets": [ 22 | "src/favicon.ico", 23 | "src/assets" 24 | ], 25 | "styles": [ 26 | "src/styles.css" 27 | ], 28 | "scripts": [] 29 | }, 30 | "configurations": { 31 | "production": { 32 | "budgets": [ 33 | { 34 | "type": "initial", 35 | "maximumWarning": "2mb", 36 | "maximumError": "5mb" 37 | }, 38 | { 39 | "type": "anyComponentStyle", 40 | "maximumWarning": "6kb", 41 | "maximumError": "10kb" 42 | } 43 | ], 44 | "fileReplacements": [ 45 | { 46 | "replace": "src/environments/environment.ts", 47 | "with": "src/environments/environment.prod.ts" 48 | } 49 | ], 50 | "outputHashing": "all" 51 | }, 52 | "development": { 53 | "buildOptimizer": false, 54 | "optimization": false, 55 | "vendorChunk": true, 56 | "extractLicenses": false, 57 | "sourceMap": true, 58 | "namedChunks": true 59 | } 60 | }, 61 | "defaultConfiguration": "production" 62 | }, 63 | "serve": { 64 | "builder": "@angular-devkit/build-angular:dev-server", 65 | "configurations": { 66 | "production": { 67 | "browserTarget": "Weather-app:build:production" 68 | }, 69 | "development": { 70 | "browserTarget": "Weather-app:build:development" 71 | } 72 | }, 73 | "defaultConfiguration": "development" 74 | }, 75 | "extract-i18n": { 76 | "builder": "@angular-devkit/build-angular:extract-i18n", 77 | "options": { 78 | "browserTarget": "Weather-app:build" 79 | } 80 | }, 81 | "test": { 82 | "builder": "@angular-devkit/build-angular:karma", 83 | "options": { 84 | "main": "src/test.ts", 85 | "polyfills": "src/polyfills.ts", 86 | "tsConfig": "tsconfig.spec.json", 87 | "karmaConfig": "karma.conf.js", 88 | "assets": [ 89 | "src/favicon.ico", 90 | "src/assets" 91 | ], 92 | "styles": [ 93 | "src/styles.css" 94 | ], 95 | "scripts": [] 96 | } 97 | } 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 |
9 |
10 | 11 | 12 | 13 |
14 |
{{ weatherData.name}}
15 |
{{ weatherData.main.temp | number: '1.0-0' }}°C
16 |
17 | 18 | 19 |
20 |
21 |
22 | More Information 23 |
24 |
25 |
26 |
27 | 28 | min 29 |
30 |
31 | {{ weatherData.main.temp_min | number: '1.0-0' }}°C 32 |
33 |
34 | 35 |
36 |
37 | 38 | max 39 |
40 |
41 | {{ weatherData.main.temp_max | number: '1.0-0' }}°C 42 |
43 |
44 | 45 |
46 |
47 | 48 | humidity 49 |
50 |
51 | {{ weatherData.main.humidity }}% 52 |
53 |
54 | 55 |
56 |
57 | 58 | wind 59 |
60 |
61 | {{ weatherData.wind.speed }} km/h 62 |
63 |
64 |
65 |
66 |
67 | 68 | 127 | 128 | --------------------------------------------------------------------------------