├── .browserslistrc
├── .editorconfig
├── .firebaserc
├── .gitignore
├── LICENSE
├── README.md
├── angular.json
├── e2e
├── protractor.conf.js
├── src
│ ├── app.e2e-spec.ts
│ └── app.po.ts
└── tsconfig.json
├── firebase.json
├── karma.conf.js
├── ngsw-config.json
├── package-lock.json
├── package.json
├── src
├── app
│ ├── app-routing.module.ts
│ ├── app.component.html
│ ├── app.component.scss
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── core
│ │ ├── api
│ │ │ ├── openweather-api.model.ts
│ │ │ ├── openweather-api.service.ts
│ │ │ └── openweather-mock.data.ts
│ │ ├── core.module.ts
│ │ ├── dialog
│ │ │ ├── agreement-dialog
│ │ │ │ ├── agreement-dialog.component.html
│ │ │ │ ├── agreement-dialog.component.scss
│ │ │ │ ├── agreement-dialog.component.ts
│ │ │ │ └── agreement-dialog.service.ts
│ │ │ ├── app-update-dialog
│ │ │ │ ├── app-update-dialog.component.html
│ │ │ │ ├── app-update-dialog.component.scss
│ │ │ │ ├── app-update-dialog.component.ts
│ │ │ │ └── app-update-dialog.service.ts
│ │ │ ├── dialog.module.ts
│ │ │ ├── error-dialog
│ │ │ │ ├── error-dialog.component.html
│ │ │ │ ├── error-dialog.component.scss
│ │ │ │ ├── error-dialog.component.ts
│ │ │ │ └── error-dialog.service.ts
│ │ │ └── loading-dialog
│ │ │ │ ├── loading-dialog.component.html
│ │ │ │ ├── loading-dialog.component.scss
│ │ │ │ ├── loading-dialog.component.ts
│ │ │ │ └── loading-dialog.service.ts
│ │ ├── errors
│ │ │ ├── error-handler.module.ts
│ │ │ ├── global-error-handler.ts
│ │ │ └── http-error.interceptor.ts
│ │ ├── navbar
│ │ │ ├── navbar.component.html
│ │ │ ├── navbar.component.scss
│ │ │ └── navbar.component.ts
│ │ ├── services
│ │ │ ├── empty-state.service.ts
│ │ │ ├── geolocation-api.service.ts
│ │ │ └── web-storage-api.service.ts
│ │ ├── snackbar
│ │ │ ├── snackbar.component.html
│ │ │ ├── snackbar.component.scss
│ │ │ └── snackbar.component.ts
│ │ └── toolbar
│ │ │ ├── toolbar.component.html
│ │ │ ├── toolbar.component.scss
│ │ │ └── toolbar.component.ts
│ ├── dashboard
│ │ ├── aside-section
│ │ │ ├── aside-section.component.html
│ │ │ ├── aside-section.component.scss
│ │ │ └── aside-section.component.ts
│ │ ├── bottom-section
│ │ │ ├── bottom-section.component.html
│ │ │ ├── bottom-section.component.scss
│ │ │ └── bottom-section.component.ts
│ │ ├── dashboard.component.html
│ │ ├── dashboard.component.scss
│ │ ├── dashboard.component.ts
│ │ ├── dashboard.module.ts
│ │ ├── dashboard.service.ts
│ │ ├── middle-section
│ │ │ ├── middle-section.component.html
│ │ │ ├── middle-section.component.scss
│ │ │ └── middle-section.component.ts
│ │ ├── resolvers
│ │ │ ├── air-pollution.resolver.ts
│ │ │ ├── reverse-geocoder.resolver.ts
│ │ │ └── weather.resolver.ts
│ │ └── top-section
│ │ │ ├── top-section.component.html
│ │ │ ├── top-section.component.scss
│ │ │ └── top-section.component.ts
│ ├── locations
│ │ ├── locations.component.html
│ │ ├── locations.component.scss
│ │ ├── locations.component.ts
│ │ └── locations.module.ts
│ ├── map
│ │ ├── map.component.html
│ │ ├── map.component.scss
│ │ ├── map.component.ts
│ │ └── map.module.ts
│ ├── settings
│ │ ├── settings.component.html
│ │ ├── settings.component.scss
│ │ ├── settings.component.ts
│ │ └── settings.module.ts
│ └── shared
│ │ ├── constants
│ │ └── empty-states.assets.ts
│ │ ├── directives
│ │ ├── air-pollution.directive.ts
│ │ ├── index.ts
│ │ └── uv-index.directive.ts
│ │ ├── enums
│ │ ├── empty-states.enum.ts
│ │ └── units-measurement.enum.ts
│ │ ├── models
│ │ ├── empty-state.model.ts
│ │ └── geolocation-position.model.ts
│ │ ├── pipes
│ │ ├── air-pollution.pipe.ts
│ │ ├── custom-date.pipe.ts
│ │ ├── humidity-range.pipe.ts
│ │ ├── index.ts
│ │ ├── to-integer.pipe.ts
│ │ ├── uv-index.pipe.ts
│ │ └── wind-direction.pipe.ts
│ │ ├── shared.module.ts
│ │ └── widgets
│ │ └── empty-state
│ │ ├── empty-state.component.html
│ │ ├── empty-state.component.scss
│ │ └── empty-state.component.ts
├── assets
│ ├── .gitkeep
│ ├── icons
│ │ ├── dashboard
│ │ │ ├── drops.svg
│ │ │ ├── search-icon.svg
│ │ │ ├── sunrise.svg
│ │ │ ├── sunset.svg
│ │ │ └── wind.svg
│ │ ├── global
│ │ │ ├── global-error.svg
│ │ │ ├── gps-connection-illustration.svg
│ │ │ ├── location-illustration.svg
│ │ │ └── not-implemented.svg
│ │ ├── navbar
│ │ │ ├── dashboard.svg
│ │ │ ├── location-icon.svg
│ │ │ ├── map-icon.svg
│ │ │ └── settings-icon.svg
│ │ ├── pwa
│ │ │ ├── apple-touch-icon.png
│ │ │ ├── shortcut_location_icon_x192.png
│ │ │ ├── shortcut_map_icon_x192.png
│ │ │ ├── shortcut_settings_icon_x192.png
│ │ │ ├── weather_icon_x128.png
│ │ │ ├── weather_icon_x192.png
│ │ │ ├── weather_icon_x384.png
│ │ │ ├── weather_icon_x512.png
│ │ │ ├── weather_icon_x72.png
│ │ │ └── weather_icon_x96.png
│ │ └── weather-conditions
│ │ │ ├── 01d.svg
│ │ │ ├── 01n.svg
│ │ │ ├── 02d.svg
│ │ │ ├── 02n.svg
│ │ │ ├── 03d.svg
│ │ │ ├── 03n.svg
│ │ │ ├── 04d.svg
│ │ │ ├── 04n.svg
│ │ │ ├── 09d.svg
│ │ │ ├── 09n.svg
│ │ │ ├── 10d.svg
│ │ │ ├── 10n.svg
│ │ │ ├── 11d.svg
│ │ │ ├── 11n.svg
│ │ │ ├── 13d.svg
│ │ │ ├── 13n.svg
│ │ │ ├── 50d.svg
│ │ │ └── 50n.svg
│ └── images
│ │ └── profile-picture.png
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.d.ts
├── index.html
├── main.ts
├── manifest.webmanifest
├── polyfills.ts
├── styles.scss
└── test.ts
├── tsconfig.app.json
├── tsconfig.json
├── tsconfig.spec.json
└── tslint.json
/.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 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
18 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.firebaserc:
--------------------------------------------------------------------------------
1 | {
2 | "projects": {
3 | "default": "angular-weather-pwa"
4 | },
5 | "targets": {
6 | "angular-weather-pwa": {
7 | "hosting": {
8 | "weather-app": [
9 | "angular-weather-pwa"
10 | ]
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/.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 | # Only exists if Bazel was run
8 | /bazel-out
9 |
10 | # dependencies
11 | /node_modules
12 |
13 | # profiling files
14 | chrome-profiler-events*.json
15 | speed-measure-plugin*.json
16 |
17 | # IDEs and editors
18 | /.idea
19 | .project
20 | .classpath
21 | .c9/
22 | *.launch
23 | .settings/
24 | *.sublime-workspace
25 |
26 | # IDE - VSCode
27 | .vscode/*
28 | !.vscode/settings.json
29 | !.vscode/tasks.json
30 | !.vscode/launch.json
31 | !.vscode/extensions.json
32 | .history/*
33 |
34 | # misc
35 | /.sass-cache
36 | /connect.lock
37 | /coverage
38 | /libpeerconnection.log
39 | npm-debug.log
40 | yarn-error.log
41 | testem.log
42 | /typings
43 |
44 | # System Files
45 | .DS_Store
46 | Thumbs.db
47 |
48 | # Firebase
49 | /.firebase
50 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Sergio Lopez Diaz
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
Angular Weather App
2 |
3 | Angular Weather App is a Progressive Web Application (PWA) to get weather forecast.
4 | > **[Progressive Web Apps](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)** are web apps that use emerging web browser APIs and features along with traditional progressive enhancement strategy to bring a > native app-like user experience to cross-platform web applications.
5 |
6 | > **[Progressive Web Apps](https://web.dev/what-are-pwas/)** are built and enhanced with modern APIs to deliver enhanced capabilities, reliability, and installability while reaching anyone, anywhere, on any device with a single codebase.
7 |
8 |
9 | ## Demo
10 | Check out the **live application** -> [https://angular-weather-pwa.web.app](https://angular-weather-pwa.web.app)
11 |
12 | 
13 |
14 |
15 | ## Installation ⚙️
16 | | Android (Chrome) | iOS (Safari) |
17 | |-------- | --- |
18 | | | |
19 |
20 | | Computer (Chrome \| Microsoft Edge) |
21 | | -- |
22 | |  |
23 |
24 |
25 | ## Features 🚀
26 | - Get weather forecast by user location.
27 | - Get the weather forecast by searching for a place.
28 | - Can be installed on your mobile phone, tablet and computer.
29 | - Displays the following information:
30 | - Temperature
31 | - Weather description
32 | - Feels like temperature
33 | - Humidity
34 | - Wind speed
35 | - Pollution
36 | - UV index
37 | - Hourly and weekly forecast
38 | - Sunrise and sunset times
39 | - Visibility
40 | - Air quality
41 | - The temperature units can be switched between Celsius and Fahrenheit.
42 | - Notify Internet connection status.
43 | - Works offline after first use.
44 | - Notify when an app update is available.
45 |
46 |
47 | ## Built with 🛠️
48 | 
49 | - [Angular](https://angular.io/) - An Application Design Framework and Development Platform for creating efficient and sophisticated single-page apps.
50 | - [Angular Material](https://material.angular.io/) - Material Design components for Angular.
51 | - [OpenWeather API](https://openweathermap.org/) - Fast and easy-to-work weather APIs.
52 | - [Figma](https://www.figma.com/) - Figma is the only platform that brings together powerful design features you already love and a more efficient workflow to boot.
53 | - [Places API](https://developers.google.com/maps/documentation/places/web-service/overview?hl=en_US) - Get detailed information about 100 million places.
54 | - [Geocoding API](https://developers.google.com/maps/documentation/geocoding/overview?hl=en_US) - Convert between addresses and geographic coordinates.
55 | - [Web APIs for Angular](https://ng-web-apis.github.io/) - High quality lightweight wrappers for native Web APIs for idiomatic use with Angular.
56 | - [RxJS](https://rxjs.dev/) - A javascript library for reactive programming using Observables, to make it easier to compose asynchronous or callback-based code.
57 | - [TypeScript](https://www.typescriptlang.org/) - TypeScript is an open-source language which builds on JavaScript, one of the world’s most used tools, by adding static type definitions.
58 | - [ng-connection-service](https://github.com/ultrasonicsoft/ng-connection-service) - Detects whether browser has an active internet connection or not in Angular application.
59 | - [PWACompat](https://github.com/GoogleChromeLabs/pwacompat) - A library for creating splash screens and icons for Mobile Safari, as well as supporting IE/Edge's Pinned Sites feature.
60 |
61 |
62 | ## Getting started 🏁
63 | To clone and run this application, you'll need [Git](https://git-scm.com) and [Node.js](https://nodejs.org/en/download/) (which comes with [npm](http://npmjs.com)) installed on your computer.
64 |
65 | From your command line:
66 | - `git clone https://github.com/sldiaz04us/angular-weather-app.git`
67 | - `cd angular-weather-app/`
68 | - `npm install` to install all dependencies.
69 |
70 | Before you run the application, you'll also need:
71 | - Create a [Google API Key](https://developers.google.com/maps/documentation/javascript/get-api-key) to use Google Maps Platform products.
72 | - Enable [Places and Geocoding APIs](https://console.cloud.google.com/apis/library).
73 | - Add in the index.html file the below script with your Google API Key.
74 | ```html
75 |
76 |
77 |
78 |
79 | ...
80 |
81 | ...
82 |
83 |
84 | ...
85 |
86 |
87 | ```
88 | - Create an [OpenWeather API Key](https://openweathermap.org/api).
89 | - Add your OpenWeather API Key to the `environment.ts` and `environment.prod.ts` files.
90 | ```typescript
91 | // environment.ts
92 | export const environment = {
93 | production: true,
94 | openWeatherApiKey: '{YOUR_API_KEY}'
95 | };
96 | ```
97 | - Run `ng serve`, this command runs the application.
98 | - Navigate to `http://localhost:4200/`
99 |
100 |
101 | ## What's missing❓
102 | ### Favorite locations
103 | A location module where the users can add their favorite places and be able to see a detail of the weather forecast for each place on the same page.
104 |
105 | ### Radar map
106 | A map module where the users can see a snapshot of the radar map showing information such as rain, snow, storm, etc.
107 |
108 | ### Settings
109 | A settings module where the users can store their preferred location, temperature unit, etc.
110 |
111 | ### Unit/Integration tests 🧪
112 | I skipped writing test for this project.
113 |
114 | ### Accessibility ♿
115 | Not all components have properly defined [aria attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA), visual focus indicators, etc.
116 |
117 |
118 | ## Author: Sergio López Díaz ✍️
119 | You can find out more about me and my projects on:
120 | - [](https://www.linkedin.com/in/sldiaz04us "Sergio Lopez Diaz")
121 | - [](https://twitter.com/sldiaz04us "Sergio Lopez Diaz")
122 |
123 |
124 | ## Support 🤝
125 | Give a ⭐️ if you like this project!
126 |
127 | Thanks a lot for stopping by and supporting me!
128 |
129 |
130 | ## You may also like ⁉️
131 | - [Kanban Project Management](https://github.com/sldiaz04us/kanban-project-management "
132 | Project Management") - A web application to manage software development projects using Kanban.
133 |
134 |
135 | ## Credits
136 | Design inspired by [Diana Malewicz - Weather App UI illustrations](https://uxdesign.cc/create-a-weather-app-ui-with-3d-like-illustrations-4a6a5686c5ea)
137 |
138 |
139 | ## License 📝
140 | Feel free to use my code on your project. Please put a reference to this repository.
141 |
142 | This project is under the MIT license. See the [LICENSE](https://github.com/sldiaz04us/angular-weather-app/blob/master/LICENSE) for more information.
143 |
--------------------------------------------------------------------------------
/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 | "@schematics/angular:component": {
10 | "style": "scss",
11 | "skipTests": true
12 | },
13 | "@schematics/angular:class": {
14 | "skipTests": true
15 | },
16 | "@schematics/angular:directive": {
17 | "skipTests": true
18 | },
19 | "@schematics/angular:guard": {
20 | "skipTests": true
21 | },
22 | "@schematics/angular:interceptor": {
23 | "skipTests": true
24 | },
25 | "@schematics/angular:module": {
26 | "skipTests": true
27 | },
28 | "@schematics/angular:pipe": {
29 | "skipTests": true
30 | },
31 | "@schematics/angular:service": {
32 | "skipTests": true
33 | }
34 | },
35 | "root": "",
36 | "sourceRoot": "src",
37 | "prefix": "app",
38 | "architect": {
39 | "build": {
40 | "builder": "@angular-devkit/build-angular:browser",
41 | "options": {
42 | "outputPath": "dist/weather-app",
43 | "index": "src/index.html",
44 | "main": "src/main.ts",
45 | "polyfills": "src/polyfills.ts",
46 | "tsConfig": "tsconfig.app.json",
47 | "aot": true,
48 | "assets": [
49 | "src/favicon.ico",
50 | "src/assets",
51 | "src/manifest.webmanifest"
52 | ],
53 | "styles": [
54 | "src/styles.scss"
55 | ],
56 | "scripts": []
57 | },
58 | "configurations": {
59 | "production": {
60 | "fileReplacements": [
61 | {
62 | "replace": "src/environments/environment.ts",
63 | "with": "src/environments/environment.prod.ts"
64 | }
65 | ],
66 | "optimization": true,
67 | "outputHashing": "all",
68 | "sourceMap": false,
69 | "namedChunks": false,
70 | "extractLicenses": true,
71 | "vendorChunk": false,
72 | "buildOptimizer": true,
73 | "budgets": [
74 | {
75 | "type": "initial",
76 | "maximumWarning": "2mb",
77 | "maximumError": "5mb"
78 | },
79 | {
80 | "type": "anyComponentStyle",
81 | "maximumWarning": "6kb",
82 | "maximumError": "10kb"
83 | }
84 | ],
85 | "serviceWorker": true,
86 | "ngswConfigPath": "ngsw-config.json"
87 | }
88 | }
89 | },
90 | "serve": {
91 | "builder": "@angular-devkit/build-angular:dev-server",
92 | "options": {
93 | "browserTarget": "weather-app:build"
94 | },
95 | "configurations": {
96 | "production": {
97 | "browserTarget": "weather-app:build:production"
98 | }
99 | }
100 | },
101 | "extract-i18n": {
102 | "builder": "@angular-devkit/build-angular:extract-i18n",
103 | "options": {
104 | "browserTarget": "weather-app:build"
105 | }
106 | },
107 | "test": {
108 | "builder": "@angular-devkit/build-angular:karma",
109 | "options": {
110 | "main": "src/test.ts",
111 | "polyfills": "src/polyfills.ts",
112 | "tsConfig": "tsconfig.spec.json",
113 | "karmaConfig": "karma.conf.js",
114 | "assets": [
115 | "src/favicon.ico",
116 | "src/assets",
117 | "src/manifest.webmanifest"
118 | ],
119 | "styles": [
120 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
121 | "src/styles.scss"
122 | ],
123 | "scripts": []
124 | }
125 | },
126 | "lint": {
127 | "builder": "@angular-devkit/build-angular:tslint",
128 | "options": {
129 | "tsConfig": [
130 | "tsconfig.app.json",
131 | "tsconfig.spec.json",
132 | "e2e/tsconfig.json"
133 | ],
134 | "exclude": [
135 | "**/node_modules/**"
136 | ]
137 | }
138 | },
139 | "e2e": {
140 | "builder": "@angular-devkit/build-angular:protractor",
141 | "options": {
142 | "protractorConfig": "e2e/protractor.conf.js",
143 | "devServerTarget": "weather-app:serve"
144 | },
145 | "configurations": {
146 | "production": {
147 | "devServerTarget": "weather-app:serve:production"
148 | }
149 | }
150 | },
151 | "deploy": {
152 | "builder": "@angular/fire:deploy",
153 | "options": {}
154 | }
155 | }
156 | }
157 | },
158 | "defaultProject": "weather-app"
159 | }
--------------------------------------------------------------------------------
/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // @ts-check
2 | // Protractor configuration file, see link for more information
3 | // https://github.com/angular/protractor/blob/master/lib/config.ts
4 |
5 | const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
6 |
7 | /**
8 | * @type { import("protractor").Config }
9 | */
10 | exports.config = {
11 | allScriptsTimeout: 11000,
12 | specs: [
13 | './src/**/*.e2e-spec.ts'
14 | ],
15 | capabilities: {
16 | browserName: 'chrome'
17 | },
18 | directConnect: true,
19 | SELENIUM_PROMISE_MANAGER: false,
20 | baseUrl: 'http://localhost:4200/',
21 | framework: 'jasmine',
22 | jasmineNodeOpts: {
23 | showColors: true,
24 | defaultTimeoutInterval: 30000,
25 | print: function() {}
26 | },
27 | onPrepare() {
28 | require('ts-node').register({
29 | project: require('path').join(__dirname, './tsconfig.json')
30 | });
31 | jasmine.getEnv().addReporter(new SpecReporter({
32 | spec: {
33 | displayStacktrace: StacktraceOption.PRETTY
34 | }
35 | }));
36 | }
37 | };
--------------------------------------------------------------------------------
/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 | import { browser, logging } from 'protractor';
3 |
4 | describe('workspace-project App', () => {
5 | let page: AppPage;
6 |
7 | beforeEach(() => {
8 | page = new AppPage();
9 | });
10 |
11 | it('should display welcome message', async () => {
12 | await page.navigateTo();
13 | expect(await page.getTitleText()).toEqual('weather-app app is running!');
14 | });
15 |
16 | afterEach(async () => {
17 | // Assert that there are no errors emitted from the browser
18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19 | expect(logs).not.toContain(jasmine.objectContaining({
20 | level: logging.Level.SEVERE,
21 | } as logging.Entry));
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | async navigateTo(): Promise {
5 | return browser.get(browser.baseUrl);
6 | }
7 |
8 | async getTitleText(): Promise {
9 | return element(by.css('app-root .content span')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.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/e2e",
6 | "module": "commonjs",
7 | "target": "es2018",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/firebase.json:
--------------------------------------------------------------------------------
1 | {
2 | "hosting": [
3 | {
4 | "target": "weather-app",
5 | "public": "dist/weather-app",
6 | "ignore": [
7 | "firebase.json",
8 | "**/.*",
9 | "**/node_modules/**"
10 | ],
11 | "rewrites": [
12 | {
13 | "source": "**",
14 | "destination": "/index.html"
15 | }
16 | ],
17 | "headers": [
18 | {
19 | "source": "**/*.@(jpg|jpeg|gif|png|svg)",
20 | "headers": [
21 | {
22 | "key": "Cache-Control",
23 | "value": "max-age=31536000"
24 | }
25 | ]
26 | },
27 | {
28 | "source": "**/*.@(css|js)",
29 | "headers": [
30 | {
31 | "key": "Cache-Control",
32 | "value": "max-age=31536000"
33 | }
34 | ]
35 | }
36 | ]
37 | }
38 | ]
39 | }
40 |
--------------------------------------------------------------------------------
/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 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | jasmineHtmlReporter: {
19 | suppressAll: true // removes the duplicated traces
20 | },
21 | coverageReporter: {
22 | dir: require('path').join(__dirname, './coverage/weather-app'),
23 | subdir: '.',
24 | reporters: [
25 | { type: 'html' },
26 | { type: 'text-summary' }
27 | ]
28 | },
29 | reporters: ['progress', 'kjhtml'],
30 | port: 9876,
31 | colors: true,
32 | logLevel: config.LOG_INFO,
33 | autoWatch: true,
34 | browsers: ['Chrome'],
35 | singleRun: false,
36 | restartOnFileChange: true
37 | });
38 | };
39 |
--------------------------------------------------------------------------------
/ngsw-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/service-worker/config/schema.json",
3 | "index": "/index.html",
4 | "assetGroups": [
5 | {
6 | "name": "app",
7 | "installMode": "prefetch",
8 | "resources": {
9 | "files": [
10 | "/favicon.ico",
11 | "/index.html",
12 | "/manifest.webmanifest",
13 | "/*.css",
14 | "/*.js"
15 | ]
16 | }
17 | },
18 | {
19 | "name": "assets",
20 | "installMode": "lazy",
21 | "updateMode": "prefetch",
22 | "resources": {
23 | "files": [
24 | "/assets/**",
25 | "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
26 | ]
27 | }
28 | }
29 | ],
30 | "dataGroups": [
31 | {
32 | "name": "openweather-api",
33 | "urls": [
34 | "https://api.openweathermap.org/data/2.5/onecall?*",
35 | "https://api.openweathermap.org/data/2.5/air_pollution?*"
36 | ],
37 | "version": 2,
38 | "cacheConfig": {
39 | "maxSize": 6,
40 | "maxAge": "10m",
41 | "timeout": "6s",
42 | "strategy": "freshness"
43 | }
44 | }
45 | ]
46 | }
47 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "weather-app",
3 | "version": "1.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "~11.0.1",
15 | "@angular/cdk": "^11.0.3",
16 | "@angular/common": "~11.0.1",
17 | "@angular/compiler": "~11.0.1",
18 | "@angular/core": "~11.0.1",
19 | "@angular/fire": "^6.1.5",
20 | "@angular/forms": "~11.0.1",
21 | "@angular/material": "^11.0.3",
22 | "@angular/platform-browser": "~11.0.1",
23 | "@angular/platform-browser-dynamic": "~11.0.1",
24 | "@angular/router": "~11.0.1",
25 | "@angular/service-worker": "~11.0.1",
26 | "@ng-web-apis/common": "^1.9.0",
27 | "@ng-web-apis/geolocation": "^1.0.3",
28 | "@ng-web-apis/permissions": "^1.0.0",
29 | "ng-connection-service": "^1.0.4",
30 | "rxjs": "^6.6.3",
31 | "tslib": "^2.0.0",
32 | "zone.js": "~0.10.2",
33 | "firebase": "^7.0 || ^8.0"
34 | },
35 | "devDependencies": {
36 | "@angular-devkit/build-angular": "~0.1100.2",
37 | "@angular/cli": "~11.0.2",
38 | "@angular/compiler-cli": "~11.0.1",
39 | "@types/googlemaps": "^3.43.2",
40 | "@types/jasmine": "~3.6.0",
41 | "@types/node": "^12.11.1",
42 | "codelyzer": "^6.0.0",
43 | "jasmine-core": "~3.6.0",
44 | "jasmine-spec-reporter": "~5.0.0",
45 | "karma": "~5.1.0",
46 | "karma-chrome-launcher": "~3.1.0",
47 | "karma-coverage": "~2.0.3",
48 | "karma-jasmine": "~4.0.0",
49 | "karma-jasmine-html-reporter": "^1.5.0",
50 | "protractor": "~7.0.0",
51 | "ts-node": "~8.3.0",
52 | "tslint": "~6.1.0",
53 | "typescript": "~4.0.2",
54 | "@angular-devkit/architect": ">= 0.900 < 0.1300",
55 | "firebase-tools": "^8.0.0 || ^9.0.0",
56 | "fuzzy": "^0.1.3",
57 | "inquirer": "^6.2.2",
58 | "inquirer-autocomplete-prompt": "^1.0.1",
59 | "open": "^7.0.3",
60 | "jsonc-parser": "^3.0.0"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 |
4 | const routes: Routes = [
5 | { path: '', pathMatch: 'full', redirectTo: 'dashboard' },
6 | {
7 | path: 'dashboard',
8 | loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule)
9 | },
10 | {
11 | path: 'locations',
12 | loadChildren: () => import('./locations/locations.module').then(m => m.LocationsModule)
13 | },
14 | {
15 | path: 'map',
16 | loadChildren: () => import('./map/map.module').then(m => m.MapModule)
17 | },
18 | {
19 | path: 'settings',
20 | loadChildren: () => import('./settings/settings.module').then(m => m.SettingsModule)
21 | },
22 | { path: '**', pathMatch: 'full', redirectTo: 'dashboard' }
23 | ];
24 |
25 | @NgModule({
26 | imports: [RouterModule.forRoot(routes)],
27 | exports: [RouterModule]
28 | })
29 | export class AppRoutingModule { }
30 |
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/app/app.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | width: 100%;
3 | height: 100%;
4 |
5 | display: grid;
6 | grid-template-areas:
7 | "toolbar"
8 | "body";
9 | }
10 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Inject } from '@angular/core';
2 | import { MatSnackBar } from '@angular/material/snack-bar';
3 | import { SwUpdate } from '@angular/service-worker';
4 |
5 | import { LOCATION } from '@ng-web-apis/common';
6 |
7 | import { ConnectionService } from 'ng-connection-service';
8 |
9 | import { AppUpdateDialogService } from './core/dialog/app-update-dialog/app-update-dialog.service';
10 | import { ErrorDialogService } from './core/dialog/error-dialog/error-dialog.service';
11 | import { SnackbarComponent } from './core/snackbar/snackbar.component';
12 |
13 | @Component({
14 | selector: 'app-root',
15 | templateUrl: './app.component.html',
16 | styleUrls: ['./app.component.scss']
17 | })
18 | export class AppComponent {
19 |
20 | constructor(
21 | private swUpdate: SwUpdate,
22 | private appUpdateDialog: AppUpdateDialogService,
23 | @Inject(LOCATION) private location: Location,
24 | private errorDialogService: ErrorDialogService,
25 | private connectionService: ConnectionService,
26 | private snackBar: MatSnackBar
27 | ) {
28 | this.handleSwUpdateAvailable();
29 | this.handleSwUnrecoverableState();
30 | this.notifyConnectionStatus();
31 | }
32 |
33 | private handleSwUpdateAvailable(): void {
34 | this.swUpdate.available.subscribe(event => {
35 | this.appUpdateDialog.openDialog().afterClosed().subscribe(agree => {
36 | if (agree) {
37 | this.swUpdate.activateUpdate().then(() => this.location.reload());
38 | }
39 | });
40 | });
41 | }
42 |
43 | private handleSwUnrecoverableState(): void {
44 | this.swUpdate.unrecoverable.subscribe(event => {
45 | this.errorDialogService.openDialog(`An error occurred that we cannot recover from: ${event.reason}. The App will be reloaded.`)
46 | .afterClosed()
47 | .subscribe(() => {
48 | this.location.reload();
49 | });
50 | });
51 | }
52 |
53 | private notifyConnectionStatus(): void {
54 | this.connectionService.monitor().subscribe(isConnected => {
55 | this.snackBar.openFromComponent(SnackbarComponent, {
56 | data: isConnected
57 | });
58 | });
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { APP_INITIALIZER, NgModule } from '@angular/core';
3 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
4 | import { ServiceWorkerModule } from '@angular/service-worker';
5 | import { MatSnackBarModule, MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar';
6 | import { AngularFireModule } from '@angular/fire';
7 | import { AngularFireAnalyticsModule } from '@angular/fire/analytics';
8 |
9 | import { POSITION_OPTIONS } from '@ng-web-apis/geolocation';
10 |
11 | import { AppRoutingModule } from './app-routing.module';
12 | import { AppComponent } from './app.component';
13 | import { CoreModule } from './core/core.module';
14 | import { GeolocationApiService } from './core/services/geolocation-api.service';
15 | import { environment } from '../environments/environment';
16 |
17 | export function geoLocationFactory(geoLocationService: GeolocationApiService
18 | ): () => Promise {
19 | return () => geoLocationService.load();
20 | }
21 | @NgModule({
22 | declarations: [
23 | AppComponent
24 | ],
25 | imports: [
26 | BrowserModule,
27 | AppRoutingModule,
28 | BrowserAnimationsModule,
29 | CoreModule,
30 | ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
31 | MatSnackBarModule,
32 | environment.production ? AngularFireModule.initializeApp(environment.firebase) : [],
33 | environment.production ? AngularFireAnalyticsModule : []
34 | ],
35 | providers: [
36 | {
37 | provide: POSITION_OPTIONS,
38 | useValue: { enableHighAccuracy: false, timeout: 4000, maximumAge: 600000 /* 10 minutes */ },
39 | },
40 | {
41 | provide: APP_INITIALIZER,
42 | useFactory: geoLocationFactory,
43 | deps: [GeolocationApiService],
44 | multi: true
45 | },
46 | { provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: { duration: 4000 } }
47 | ],
48 | bootstrap: [AppComponent]
49 | })
50 | export class AppModule { }
51 |
--------------------------------------------------------------------------------
/src/app/core/api/openweather-api.model.ts:
--------------------------------------------------------------------------------
1 | // Generated by https://quicktype.io
2 |
3 | export interface OpenWeatherApiResponse {
4 | lat: number;
5 | lon: number;
6 | timezone: string;
7 | timezone_offset: number;
8 | current: Current;
9 | hourly: Current[];
10 | daily: Daily[];
11 | }
12 |
13 | export interface Current {
14 | dt: number;
15 | sunrise?: number;
16 | sunset?: number;
17 | temp: number;
18 | feels_like: number;
19 | pressure: number;
20 | humidity: number;
21 | dew_point: number;
22 | uvi: number;
23 | clouds: number;
24 | visibility: number;
25 | wind_speed: number;
26 | wind_deg: number;
27 | weather: Weather[];
28 | snow?: Snow;
29 | pop?: number;
30 | rain?: Rain;
31 | }
32 |
33 | export interface Snow {
34 | '1h': number;
35 | }
36 | export interface Rain {
37 | '1h': number;
38 | }
39 |
40 | export interface Weather {
41 | id: number;
42 | main: string;
43 | description: string;
44 | icon: string;
45 | }
46 |
47 | export interface Daily {
48 | dt: number;
49 | sunrise: number;
50 | sunset: number;
51 | temp: Temp;
52 | feels_like: FeelsLike;
53 | pressure: number;
54 | humidity: number;
55 | dew_point: number;
56 | wind_speed: number;
57 | wind_deg: number;
58 | weather: Weather[];
59 | clouds: number;
60 | pop: number;
61 | rain?: number;
62 | snow?: number;
63 | uvi: number;
64 | }
65 |
66 | export interface FeelsLike {
67 | day: number;
68 | night: number;
69 | eve: number;
70 | morn: number;
71 | }
72 |
73 | export interface Temp {
74 | day: number;
75 | min: number;
76 | max: number;
77 | night: number;
78 | eve: number;
79 | morn: number;
80 | }
81 |
82 | // Generated by https://quicktype.io
83 |
84 | export interface AirPollutionApiResponse {
85 | coord: Coord;
86 | list: List[];
87 | }
88 |
89 | export interface Coord {
90 | lon: number;
91 | lat: number;
92 | }
93 |
94 | export interface List {
95 | main: Main;
96 | components: { [key: string]: number };
97 | dt: number;
98 | }
99 |
100 | export interface Main {
101 | aqi: number;
102 | }
103 |
104 | // Generated by https://quicktype.io
105 |
106 | export interface ReverseGeocoderApiResponse {
107 | name: string;
108 | local_names: { [key: string]: string };
109 | lat: number;
110 | lon: number;
111 | country: string;
112 | state?: string;
113 | }
114 |
115 |
116 |
--------------------------------------------------------------------------------
/src/app/core/api/openweather-api.service.ts:
--------------------------------------------------------------------------------
1 | import { HttpClient } from '@angular/common/http';
2 | import { Injectable } from '@angular/core';
3 |
4 | import { Observable, of } from 'rxjs';
5 |
6 | import { environment } from 'src/environments/environment';
7 |
8 | import { OpenWeatherApiResponse, AirPollutionApiResponse, ReverseGeocoderApiResponse } from './openweather-api.model';
9 | import { UnitsMeasurement } from '../../shared/enums/units-measurement.enum';
10 | import {
11 | staticWeatherDataInCelsius,
12 | staticWeatherDataInFahrenheit,
13 | staticAirPollutionData
14 | } from './openweather-mock.data';
15 |
16 | @Injectable({
17 | providedIn: 'root'
18 | })
19 | export class OpenWeatherApiService {
20 |
21 | private currentWeatherApiUrl = 'https://api.openweathermap.org/data/2.5/onecall?';
22 | private airPollutionApiUrl = 'https://api.openweathermap.org/data/2.5/air_pollution?';
23 | private reverseGeocoderUrl = 'https://api.openweathermap.org/geo/1.0/reverse?';
24 |
25 | constructor(private http: HttpClient) { }
26 |
27 | getCurrentAndForecastWeather(lat: number, lon: number, units: UnitsMeasurement = UnitsMeasurement.imperial)
28 | : Observable {
29 | return this.http.get(`${this.currentWeatherApiUrl}lat=${lat}&lon=${lon}&exclude=minutely,alerts&units=${units}&appid=${environment.openWeatherApiKey}`);
30 | }
31 | getStaticCurrentAndForecastWeather(units: UnitsMeasurement = UnitsMeasurement.imperial): Observable {
32 | if (units === UnitsMeasurement.imperial) {
33 | return of(staticWeatherDataInFahrenheit);
34 | }
35 | return of(staticWeatherDataInCelsius);
36 | }
37 |
38 | getAirPollutionInfo(lat: number, lon: number): Observable {
39 | return this.http.get(`${this.airPollutionApiUrl}lat=${lat}&lon=${lon}&appid=${environment.openWeatherApiKey}`);
40 | }
41 | getStaticAirPollutionInfo(): Observable {
42 | return of(staticAirPollutionData);
43 | }
44 |
45 | getLocationNameByCoords(lat: number, lon: number): Observable {
46 | return this.http.get(`${this.reverseGeocoderUrl}lat=${lat}&lon=${lon}&appid=${environment.openWeatherApiKey}`);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/app/core/core.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { HttpClientModule } from '@angular/common/http';
4 | import { RouterModule } from '@angular/router';
5 | import { FormsModule, ReactiveFormsModule } from '@angular/forms';
6 |
7 | import { MatFormFieldModule } from '@angular/material/form-field';
8 | import { MatInputModule } from '@angular/material/input';
9 | import { MatButtonModule } from '@angular/material/button';
10 | import { MatIconModule } from '@angular/material/icon';
11 | import { MatAutocompleteModule } from '@angular/material/autocomplete';
12 | import { MatProgressBarModule } from '@angular/material/progress-bar';
13 | import { MatDividerModule } from '@angular/material/divider';
14 |
15 | import { NavbarComponent } from './navbar/navbar.component';
16 | import { ToolbarComponent } from '../core/toolbar/toolbar.component';
17 | import { ErrorHandlerModule } from './errors/error-handler.module';
18 | import { DialogModule } from './dialog/dialog.module';
19 | import { SnackbarComponent } from './snackbar/snackbar.component';
20 |
21 |
22 | @NgModule({
23 | declarations: [NavbarComponent, ToolbarComponent, SnackbarComponent],
24 | imports: [
25 | CommonModule,
26 | HttpClientModule,
27 | RouterModule,
28 | ErrorHandlerModule,
29 | DialogModule,
30 | FormsModule,
31 | ReactiveFormsModule,
32 | MatFormFieldModule,
33 | MatInputModule,
34 | MatIconModule,
35 | MatButtonModule,
36 | MatAutocompleteModule,
37 | MatProgressBarModule,
38 | MatDividerModule
39 | ],
40 | exports: [NavbarComponent, ToolbarComponent]
41 | })
42 | export class CoreModule { }
43 |
--------------------------------------------------------------------------------
/src/app/core/dialog/agreement-dialog/agreement-dialog.component.html:
--------------------------------------------------------------------------------
1 | Location
2 |
3 |
4 | Location access allows us to serve you with more accurate local forecasts.
5 |
6 |
7 |
8 | Regardless of whether or not you allow location access, you can always
9 | receive accurate local forecasts by manually entering a location.
10 |
11 |
17 |
18 |
19 |
22 |
30 |
31 |
--------------------------------------------------------------------------------
/src/app/core/dialog/agreement-dialog/agreement-dialog.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | color: var(--dashboard-dark) !important;
3 |
4 | h2 {
5 | text-align: center;
6 | }
7 |
8 | p {
9 | text-align: justify;
10 | }
11 |
12 | img {
13 | width: 100%;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/core/dialog/agreement-dialog/agreement-dialog.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-agreement-dialog',
5 | templateUrl: './agreement-dialog.component.html',
6 | styleUrls: ['./agreement-dialog.component.scss']
7 | })
8 | export class AgreementDialogComponent { }
9 |
--------------------------------------------------------------------------------
/src/app/core/dialog/agreement-dialog/agreement-dialog.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { MatDialogRef, MatDialog } from '@angular/material/dialog';
3 |
4 | import { AgreementDialogComponent } from './agreement-dialog.component';
5 |
6 | @Injectable({
7 | providedIn: 'root'
8 | })
9 | export class AgreementDialogService {
10 |
11 | private dialogRef: MatDialogRef;
12 |
13 | constructor(private dialog: MatDialog) { }
14 |
15 | get dialogReference(): MatDialogRef {
16 | return this.dialogRef;
17 | }
18 |
19 | openDialog(): void {
20 | this.dialogRef = this.dialog.open(AgreementDialogComponent, {
21 | data: undefined,
22 | maxHeight: '100vh',
23 | width: '540px',
24 | maxWidth: '100vw',
25 | disableClose: true,
26 | hasBackdrop: false
27 | });
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/core/dialog/app-update-dialog/app-update-dialog.component.html:
--------------------------------------------------------------------------------
1 | Update Available
2 |
3 | Do you want to update the application with the latest version?
4 |
5 |
6 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/src/app/core/dialog/app-update-dialog/app-update-dialog.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | color: var(--dashboard-dark) !important;
3 |
4 | h2 {
5 | text-align: center;
6 | }
7 |
8 | p {
9 | text-align: justify;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/core/dialog/app-update-dialog/app-update-dialog.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-app-update-dialog',
5 | templateUrl: './app-update-dialog.component.html',
6 | styleUrls: ['./app-update-dialog.component.scss']
7 | })
8 | export class AppUpdateDialogComponent { }
9 |
--------------------------------------------------------------------------------
/src/app/core/dialog/app-update-dialog/app-update-dialog.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { MatDialogRef, MatDialog } from '@angular/material/dialog';
3 |
4 | import { AppUpdateDialogComponent } from './app-update-dialog.component';
5 |
6 | @Injectable({
7 | providedIn: 'root'
8 | })
9 | export class AppUpdateDialogService {
10 |
11 | constructor(private dialog: MatDialog) { }
12 |
13 | openDialog(): MatDialogRef {
14 | return this.dialog.open(AppUpdateDialogComponent, {
15 | disableClose: true,
16 | hasBackdrop: true
17 | });
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/app/core/dialog/dialog.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { MatDialogModule } from '@angular/material/dialog';
5 | import { MatButtonModule } from '@angular/material/button';
6 | import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
7 | import { A11yModule } from '@angular/cdk/a11y';
8 |
9 | import { LoadingDialogComponent } from './loading-dialog/loading-dialog.component';
10 | import { ErrorDialogComponent } from './error-dialog/error-dialog.component';
11 | import { AgreementDialogComponent } from './agreement-dialog/agreement-dialog.component';
12 | import { AppUpdateDialogComponent } from './app-update-dialog/app-update-dialog.component';
13 |
14 | @NgModule({
15 | declarations: [LoadingDialogComponent, ErrorDialogComponent, AgreementDialogComponent, AppUpdateDialogComponent],
16 | imports: [
17 | CommonModule,
18 | MatDialogModule,
19 | MatButtonModule,
20 | MatProgressSpinnerModule,
21 | A11yModule
22 | ],
23 | })
24 | export class DialogModule { }
25 |
--------------------------------------------------------------------------------
/src/app/core/dialog/error-dialog/error-dialog.component.html:
--------------------------------------------------------------------------------
1 |
2 |

8 |
9 |
Oops!
10 |
Something went wrong, please try again
11 |
12 | Status Code: {{ data.status }}
13 |
14 |
{{ data?.message }}
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/app/core/dialog/error-dialog/error-dialog.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | display: flex;
3 | flex-direction: column;
4 | justify-content: center;
5 | align-items: center;
6 |
7 | color: var(--dashboard-dark) !important;
8 |
9 | .mat-dialog-content {
10 | display: flex;
11 | flex-direction: column;
12 | justify-content: center;
13 | align-items: center;
14 |
15 | img {
16 | width: 80%;
17 | height: auto;
18 | margin: 1em 0;
19 | }
20 |
21 | .error-message {
22 | background: var(--light-yellow);
23 | margin-top: 1em;
24 | padding: 1rem;
25 | font-family: monospace;
26 | word-break: break-all;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/core/dialog/error-dialog/error-dialog.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Inject } from '@angular/core';
2 |
3 | import { MAT_DIALOG_DATA } from '@angular/material/dialog';
4 |
5 | @Component({
6 | selector: 'app-error-dialog',
7 | templateUrl: './error-dialog.component.html',
8 | styleUrls: ['./error-dialog.component.scss']
9 | })
10 | export class ErrorDialogComponent {
11 |
12 | constructor(@Inject(MAT_DIALOG_DATA) public data: { message: string, status?: number }) { }
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/core/dialog/error-dialog/error-dialog.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { MatDialog, MatDialogRef } from '@angular/material/dialog';
3 |
4 | import { ErrorDialogComponent } from './error-dialog.component';
5 |
6 | @Injectable({
7 | providedIn: 'root'
8 | })
9 | export class ErrorDialogService {
10 | private opened = false;
11 |
12 | constructor(private dialog: MatDialog) { }
13 |
14 | openDialog(message: string, status?: number): MatDialogRef {
15 | if (!this.opened) {
16 | this.opened = true;
17 | const dialogRef = this.dialog.open(ErrorDialogComponent, {
18 | data: { message, status },
19 | maxHeight: '100vh',
20 | width: '540px',
21 | maxWidth: '100vw',
22 | disableClose: true,
23 | hasBackdrop: true
24 | });
25 |
26 | dialogRef.afterClosed().subscribe(() => {
27 | this.opened = false;
28 | });
29 |
30 | return dialogRef;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/app/core/dialog/loading-dialog/loading-dialog.component.html:
--------------------------------------------------------------------------------
1 | Loading data
2 | Please have a moment of patience
3 |
8 |
--------------------------------------------------------------------------------
/src/app/core/dialog/loading-dialog/loading-dialog.component.scss:
--------------------------------------------------------------------------------
1 | .mat-dialog-actions {
2 | margin-top: -2rem !important;
3 | padding-top: 2rem !important;
4 | }
5 |
6 | .loading-spinner {
7 | text-align: center;
8 | margin: 3rem auto;
9 | }
10 |
--------------------------------------------------------------------------------
/src/app/core/dialog/loading-dialog/loading-dialog.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-loading-dialog',
5 | templateUrl: './loading-dialog.component.html',
6 | styleUrls: ['./loading-dialog.component.scss']
7 | })
8 | export class LoadingDialogComponent { }
9 |
--------------------------------------------------------------------------------
/src/app/core/dialog/loading-dialog/loading-dialog.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { MatDialog, MatDialogRef } from '@angular/material/dialog';
3 |
4 | import { LoadingDialogComponent } from './loading-dialog.component';
5 |
6 | @Injectable({
7 | providedIn: 'root'
8 | })
9 | export class LoadingDialogService {
10 | private opened = false;
11 | private dialogRef: MatDialogRef;
12 |
13 | constructor(private dialog: MatDialog) { }
14 |
15 | openDialog(): void {
16 | if (!this.opened) {
17 | this.opened = true;
18 | this.dialogRef = this.dialog.open(LoadingDialogComponent, {
19 | data: undefined,
20 | maxHeight: '100vh',
21 | width: '400px',
22 | maxWidth: '100vw',
23 | disableClose: true,
24 | hasBackdrop: true
25 | });
26 |
27 | this.dialogRef.afterClosed().subscribe(() => {
28 | this.opened = false;
29 | });
30 | }
31 | }
32 |
33 | hideDialog(): void {
34 | this.dialogRef.close();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/app/core/errors/error-handler.module.ts:
--------------------------------------------------------------------------------
1 | import { ErrorHandler, NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { HTTP_INTERCEPTORS } from '@angular/common/http';
4 |
5 | import { GlobalErrorHandler } from './global-error-handler';
6 | import { HttpErrorInterceptor } from './http-error.interceptor';
7 |
8 | @NgModule({
9 | declarations: [],
10 | imports: [
11 | CommonModule
12 | ],
13 | providers: [
14 | {
15 | provide: ErrorHandler,
16 | useClass: GlobalErrorHandler
17 | },
18 | {
19 | provide: HTTP_INTERCEPTORS,
20 | useClass: HttpErrorInterceptor,
21 | multi: true
22 | }
23 | ]
24 | })
25 | export class ErrorHandlerModule { }
26 |
--------------------------------------------------------------------------------
/src/app/core/errors/global-error-handler.ts:
--------------------------------------------------------------------------------
1 | import { ErrorHandler, Injectable, NgZone } from '@angular/core';
2 |
3 | import { ErrorDialogService } from '../dialog/error-dialog/error-dialog.service';
4 |
5 | @Injectable()
6 | export class GlobalErrorHandler implements ErrorHandler {
7 | constructor(
8 | private errorDialogService: ErrorDialogService,
9 | private zone: NgZone
10 | ) { }
11 |
12 | handleError(error: Error): void {
13 | this.zone.run(() =>
14 | this.errorDialogService.openDialog(
15 | error.message || 'Undefined client error'
16 | ));
17 |
18 | console.error('Error from global error handler', error);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/core/errors/http-error.interceptor.ts:
--------------------------------------------------------------------------------
1 | import {
2 | HttpErrorResponse,
3 | HttpEvent,
4 | HttpHandler,
5 | HttpInterceptor,
6 | HttpRequest
7 | } from '@angular/common/http';
8 | import { Injectable } from '@angular/core';
9 |
10 | import { Observable, throwError } from 'rxjs';
11 | import { catchError, finalize } from 'rxjs/operators';
12 |
13 | import { ErrorDialogService } from '../dialog/error-dialog/error-dialog.service';
14 | import { LoadingDialogService } from '../dialog/loading-dialog/loading-dialog.service';
15 |
16 |
17 | @Injectable({
18 | providedIn: 'root'
19 | })
20 | export class HttpErrorInterceptor implements HttpInterceptor {
21 | constructor(
22 | private errorDialogService: ErrorDialogService,
23 | private loadingDialogService: LoadingDialogService
24 | ) { }
25 |
26 | intercept(req: HttpRequest, next: HttpHandler): Observable> {
27 | this.loadingDialogService.openDialog();
28 | return next.handle(req).pipe(
29 | catchError((error: HttpErrorResponse) => {
30 | this.errorDialogService.openDialog(error.message ?? JSON.stringify(error), error.status);
31 | return throwError(() => error);
32 | }),
33 | finalize(() => {
34 | this.loadingDialogService.hideDialog();
35 | })
36 | );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/app/core/navbar/navbar.component.html:
--------------------------------------------------------------------------------
1 |
148 |
--------------------------------------------------------------------------------
/src/app/core/navbar/navbar.component.scss:
--------------------------------------------------------------------------------
1 | .navbar {
2 | position: fixed;
3 | bottom: 0; //
4 | width: 100vw; //
5 | height: 4rem; //
6 | background-color: var(--light-blue);
7 | transition: width 200ms ease;
8 | overflow: auto;
9 | z-index: 1000;
10 |
11 | .navbar-nav {
12 | list-style: none;
13 | padding: 0;
14 | margin: 0;
15 | height: 100%;
16 | display: flex;
17 |
18 | .logo {
19 | display: none;
20 | font-weight: bold;
21 | text-transform: uppercase;
22 | margin-bottom: 1rem;
23 | text-align: center;
24 | color: var(--dashboard-dark);
25 | background: var(--blue);
26 | font-size: 1.5rem;
27 | letter-spacing: 0.3ch;
28 | width: 100%;
29 |
30 | svg {
31 | transform: rotate(0deg);
32 | transition: transform var(--transition-speed);
33 | }
34 | }
35 |
36 | .nav-item {
37 | width: 100%;
38 |
39 | &:last-child {
40 | margin-top: 0;
41 | }
42 |
43 | &.router-link-active {
44 | background-color: var(--blue);
45 | border-bottom: 0.2em solid var(--dashboard-dark);
46 | border-left: none;
47 | }
48 | }
49 | }
50 | }
51 |
52 | .nav-link {
53 | display: flex;
54 | justify-content: center;
55 | align-items: center;
56 | height: 4rem;
57 | color: var(--dashboard-dark);
58 | text-decoration: none;
59 | filter: grayscale(100%) opacity(0.7);
60 | transition: color var(--transition-speed);
61 |
62 | svg {
63 | width: 2rem;
64 | min-width: 2rem;
65 | margin: 0 1.5rem;
66 | cursor: pointer;
67 | }
68 |
69 | .link-text {
70 | display: none;
71 | margin-left: 1rem;
72 | }
73 | }
74 |
75 | .fa-primary {
76 | color: var(--vivid-yellow);
77 | }
78 | .fa-secondary {
79 | color: var(--yellow);
80 | }
81 | .fa-primary,
82 | .fa-secondary {
83 | transition: color var(--transition-speed);
84 | }
85 |
86 | /* large screens */
87 | @media only screen and (min-width: 600px) {
88 | .navbar {
89 | top: 0;
90 | width: 5rem;
91 | height: 100vh;
92 |
93 | &.open {
94 | width: 16rem;
95 | z-index: 1100;
96 |
97 | .link-text {
98 | display: block;
99 | transition: opacity var(--transition-speed);
100 | }
101 | .logo div svg {
102 | transform: rotate(-180deg);
103 | }
104 | }
105 |
106 | .navbar-nav {
107 | flex-direction: column;
108 |
109 | .logo {
110 | display: block;
111 | }
112 |
113 | .nav-item {
114 | &:last-child {
115 | margin-top: auto;
116 | }
117 | &.router-link-active {
118 | border-left: 0.2em solid var(--dashboard-dark);
119 | border-bottom: none;
120 | }
121 | }
122 | }
123 | }
124 |
125 | .nav-link {
126 | justify-content: flex-start;
127 | height: 5rem;
128 |
129 | &:hover {
130 | filter: grayscale(0%) opacity(1);
131 | background: var(--blue);
132 | color: var(--dashboard-dark);
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/src/app/core/navbar/navbar.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-navbar',
5 | templateUrl: './navbar.component.html',
6 | styleUrls: ['./navbar.component.scss']
7 | })
8 | export class NavbarComponent {
9 | isOpen = false;
10 |
11 | close(): void {
12 | if (this.isOpen) { this.isOpen = !this.isOpen; }
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/core/services/empty-state.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | import { EmptyStateTypes } from 'src/app/shared/enums/empty-states.enum';
4 | import { EmptyState } from 'src/app/shared/models/empty-state.model';
5 | import { emptyStates } from 'src/app/shared/constants/empty-states.assets';
6 | @Injectable({
7 | providedIn: 'root'
8 | })
9 | export class EmptyStateService {
10 |
11 | getEmptyState(emptyStateType: EmptyStateTypes): EmptyState {
12 | return emptyStates.find(state => state.id === emptyStateType);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/core/services/web-storage-api.service.ts:
--------------------------------------------------------------------------------
1 | import { Inject, Injectable } from '@angular/core';
2 |
3 | import { LOCAL_STORAGE } from '@ng-web-apis/common';
4 |
5 | interface WeatherData {
6 | geolocationStatus: string;
7 | geolocationName: string;
8 | coords: { lat: number, lng: number };
9 | }
10 |
11 | @Injectable({
12 | providedIn: 'root'
13 | })
14 | export class WebStorageApiService {
15 | private readonly WEATHER_DATA = 'WEATHER_APP_DATA';
16 |
17 | constructor(@Inject(LOCAL_STORAGE) private readonly localStorage: Storage) {
18 | }
19 |
20 | getLocalStorageItem(): WeatherData {
21 | return JSON.parse(this.localStorage.getItem(this.WEATHER_DATA));
22 | }
23 |
24 | setLocalStorageItem(value: WeatherData): void {
25 | this.localStorage.setItem(this.WEATHER_DATA, JSON.stringify({ ...value }));
26 | }
27 |
28 | updateLocalStorageItem(value: Partial): void {
29 | const weatherDataParse = this.getLocalStorageItem();
30 | this.setLocalStorageItem({ ...weatherDataParse, ...value });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/app/core/snackbar/snackbar.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Back Online! The App will
4 | work as usual.
5 |
6 |
7 |
8 |
9 | You are Offline! Some
10 | features of the App may not work.
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/app/core/snackbar/snackbar.component.scss:
--------------------------------------------------------------------------------
1 | .online {
2 | color: #013301;
3 | }
4 | .offline {
5 | color: #5c0101;
6 | }
7 |
--------------------------------------------------------------------------------
/src/app/core/snackbar/snackbar.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Inject } from '@angular/core';
2 | import { MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
3 |
4 | @Component({
5 | selector: 'app-snackbar',
6 | templateUrl: './snackbar.component.html',
7 | styleUrls: ['./snackbar.component.scss']
8 | })
9 | export class SnackbarComponent {
10 |
11 | constructor(@Inject(MAT_SNACK_BAR_DATA) public isConnected: boolean) { }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/core/toolbar/toolbar.component.html:
--------------------------------------------------------------------------------
1 |
43 |
--------------------------------------------------------------------------------
/src/app/core/toolbar/toolbar.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | display: grid;
3 | grid-area: toolbar;
4 | grid-template-columns: 1fr;
5 |
6 | padding: 1rem;
7 | max-height: 6em;
8 |
9 | section .mat-form-field {
10 | width: 100%;
11 | }
12 |
13 | /* large screens */
14 | @media only screen and (min-width: 600px) {
15 | margin-left: 5rem;
16 |
17 | section .mat-form-field {
18 | max-width: 20em;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/core/toolbar/toolbar.component.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Component,
3 | ViewChild,
4 | ElementRef,
5 | AfterViewInit,
6 | NgZone
7 | } from '@angular/core';
8 | import { FormControl } from '@angular/forms';
9 |
10 | import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
11 |
12 | import { } from 'googlemaps';
13 |
14 | import { debounceTime, distinctUntilChanged, filter, tap } from 'rxjs/operators';
15 |
16 | import { ErrorDialogService } from '../dialog/error-dialog/error-dialog.service';
17 | import { GeolocationApiService } from '../services/geolocation-api.service';
18 |
19 | @Component({
20 | selector: 'app-toolbar',
21 | templateUrl: './toolbar.component.html',
22 | styleUrls: ['./toolbar.component.scss']
23 | })
24 | export class ToolbarComponent implements AfterViewInit {
25 | @ViewChild('autocomplete') autocompleteRef: ElementRef;
26 |
27 | private placesService: google.maps.places.PlacesService;
28 | private autocompleteService: google.maps.places.AutocompleteService;
29 | private placeDescriptionSelected: string;
30 |
31 | searchPredictions: google.maps.places.AutocompletePrediction[];
32 | searchControl = new FormControl();
33 | isLoading = false;
34 |
35 | readonly gpsPrediction = {
36 | description: 'GPS',
37 | matched_substrings: undefined,
38 | place_id: undefined,
39 | reference: undefined,
40 | structured_formatting: undefined,
41 | terms: undefined,
42 | types: undefined,
43 | };
44 |
45 | constructor(
46 | private ngZone: NgZone,
47 | private geolocationApiService: GeolocationApiService,
48 | private errorDialogService: ErrorDialogService,
49 | ) { }
50 |
51 | ngAfterViewInit(): void {
52 | this.placesService = new google.maps.places.PlacesService(this.autocompleteRef.nativeElement);
53 | this.autocompleteService = new google.maps.places.AutocompleteService();
54 |
55 | this.searchControl.valueChanges.pipe(
56 | debounceTime(400),
57 | tap(value => {
58 | if (value.length <= 2) { this.searchPredictions = []; }
59 | }),
60 | filter(value => value.length > 2),
61 | distinctUntilChanged(),
62 | ).subscribe(value => {
63 | this.isLoading = true;
64 | this.autocompleteService.getPlacePredictions({ input: value }, this.placePredictionsCallback.bind(this));
65 | });
66 | }
67 |
68 | private placePredictionsCallback(
69 | results: google.maps.places.AutocompletePrediction[],
70 | status: google.maps.places.PlacesServiceStatus): void {
71 | /*
72 | * Google API run outside NgZone because Angular can't detect changes
73 | * made by async callbacks of third-party libraries
74 | */
75 | this.ngZone.run(() => {
76 | this.isLoading = false;
77 |
78 | if (status === google.maps.places.PlacesServiceStatus.OK) {
79 | this.searchPredictions = results;
80 | } else {
81 | this.searchPredictions = [{
82 | description: 'No records found',
83 | matched_substrings: undefined,
84 | place_id: undefined,
85 | reference: undefined,
86 | structured_formatting: undefined,
87 | terms: undefined,
88 | types: undefined,
89 | }];
90 | }
91 | });
92 | }
93 |
94 | onSelectedOption(selected: MatAutocompleteSelectedEvent): void {
95 | if (selected.option.value.description === 'GPS') {
96 | this.geolocationApiService.requestGeolocation();
97 | } else if (selected.option.value.place_id) {
98 | this.placeDescriptionSelected = selected.option.value.description;
99 | const placeRequest = {
100 | placeId: selected.option.value.place_id,
101 | fields: ['geometry.location']
102 | };
103 |
104 | this.placesService.getDetails(placeRequest, this.placeDetailsCallback.bind(this));
105 | }
106 |
107 | this.searchPredictions = [];
108 | this.autocompleteRef.nativeElement.value = '';
109 | this.autocompleteRef.nativeElement.blur(); // remove focus
110 | }
111 |
112 | private placeDetailsCallback(
113 | result: google.maps.places.PlaceResult,
114 | status: google.maps.places.PlacesServiceStatus): void {
115 | this.ngZone.run(() => {
116 | if (status === google.maps.places.PlacesServiceStatus.OK) {
117 | this.geolocationApiService.setGeolocationName(this.placeDescriptionSelected);
118 | this.geolocationApiService.setGeolocationPosition(
119 | result.geometry.location.toJSON().lat,
120 | result.geometry.location.toJSON().lng
121 | );
122 | } else {
123 | this.errorDialogService.openDialog('There was an error getting the location details');
124 | }
125 | });
126 | }
127 |
128 | displayFn(prediction: google.maps.places.AutocompletePrediction): string {
129 | return prediction && prediction.description ? prediction.description : '';
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/src/app/dashboard/aside-section/aside-section.component.html:
--------------------------------------------------------------------------------
1 |
2 | Sunrise & Sunset
3 |
4 |

10 |
11 | {{ current?.sunrise | customDate: "shortTime" }}
12 |
13 |
14 |
15 |

21 |
22 | {{ current?.sunset | customDate: "shortTime" }}
23 |
24 |
25 |
26 |
27 |
34 |
41 |
48 |
53 |
58 |
59 |
--------------------------------------------------------------------------------
/src/app/dashboard/aside-section/aside-section.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | display: grid;
3 | grid-area: aside;
4 | grid-template-areas:
5 | "aside-top"
6 | "aside-bottom";
7 | grid-auto-rows: min-content;
8 | grid-gap: 1em;
9 | margin-bottom: 5rem;
10 |
11 | .top {
12 | display: grid;
13 | grid-area: aside-top;
14 | grid-template-rows: auto 1fr 1fr;
15 | grid-row-gap: 1em;
16 | border-radius: 20px;
17 | box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.25);
18 | padding: 1em 2em;
19 | max-height: 316px;
20 | background-color: white;
21 |
22 | h2 {
23 | text-align: center;
24 | color: var(--dark-gray);
25 | }
26 | .sunrise,
27 | .sunset {
28 | display: flex;
29 | justify-content: flex-start;
30 | align-items: center;
31 |
32 | img {
33 | margin-right: 2em;
34 | }
35 | }
36 | }
37 |
38 | .bottom {
39 | display: grid;
40 | grid-area: aside-bottom;
41 | gap: 0.5em;
42 | grid-template-columns: repeat(auto-fit, minmax(150px, 158px));
43 |
44 | .forecast-widget {
45 | width: 150px;
46 | height: 150px;
47 | border-radius: 20px;
48 | box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.25);
49 | padding: 1em;
50 | h2 {
51 | color: var(--dark-gray);
52 | }
53 |
54 | display: flex;
55 | flex-direction: column;
56 | justify-content: space-between;
57 | align-items: flex-start;
58 | background-color: white;
59 | }
60 | }
61 |
62 | @media only screen and (min-width: 600px) {
63 | margin-bottom: 0;
64 | }
65 |
66 | @media only screen and (min-width: 720px) {
67 | grid-template-areas: "aside-top aside-bottom aside-bottom aside-bottom";
68 | }
69 |
70 | @media only screen and (min-width: 1440px) {
71 | grid-template-areas:
72 | "aside-top"
73 | "aside-bottom";
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/app/dashboard/aside-section/aside-section.component.ts:
--------------------------------------------------------------------------------
1 | import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2 |
3 | import { Current } from '../../core/api/openweather-api.model';
4 |
5 | @Component({
6 | selector: 'dashboard-aside-section',
7 | templateUrl: './aside-section.component.html',
8 | styleUrls: ['./aside-section.component.scss'],
9 | changeDetection: ChangeDetectionStrategy.OnPush
10 | })
11 | export class AsideSectionComponent {
12 | @Input() current: Current;
13 | @Input() airPollutionIndex: number;
14 | @Input() unitSymbol: string;
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/dashboard/bottom-section/bottom-section.component.html:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
28 |
29 |
30 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/src/app/dashboard/bottom-section/bottom-section.component.scss:
--------------------------------------------------------------------------------
1 | .today-forecast {
2 | display: grid;
3 | gap: .5em;
4 | grid-template-columns: repeat(auto-fit, minmax(90px, 100px));
5 |
6 | padding: 1em 0;
7 |
8 | .widget {
9 | width: 100px;
10 | height: 150px;
11 | background: #ffffff;
12 | box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
13 | border-radius: 10px;
14 |
15 | display: flex;
16 | flex-direction: column;
17 | justify-content: center;
18 | align-items: center;
19 | }
20 | }
21 |
22 | .week-forecast {
23 | display: grid;
24 | gap: .5em;
25 | row-gap: 1em;
26 | grid-template-columns: repeat(auto-fit, minmax(146px, 156px));
27 |
28 | padding: 1.5em 0;
29 |
30 | .widget {
31 | display: grid;
32 | gap: 1em;
33 | grid-template-rows: 2fr 1fr;
34 |
35 | position: relative;
36 | width: 146px;
37 | height: auto;
38 | padding: 1em;
39 | background: #ffffff;
40 | box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
41 | border-radius: 10px;
42 |
43 | .main{
44 | display: flex;
45 | justify-content: space-between;
46 |
47 | img {
48 | position: absolute;
49 | top: -1em;
50 | right: -1em;
51 | }
52 | }
53 | .temp{
54 | display: flex;
55 | justify-content: space-evenly;
56 |
57 | .min, span{
58 | color: var(--dark-gray);
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/app/dashboard/bottom-section/bottom-section.component.ts:
--------------------------------------------------------------------------------
1 | import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2 |
3 | import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
4 |
5 | import { Observable } from 'rxjs';
6 |
7 | import { Current, Daily } from '../../core/api/openweather-api.model';
8 |
9 | @Component({
10 | selector: 'dashboard-bottom-section',
11 | templateUrl: './bottom-section.component.html',
12 | styleUrls: ['./bottom-section.component.scss'],
13 | changeDetection: ChangeDetectionStrategy.OnPush
14 | })
15 | export class BottomSectionComponent {
16 | @Input() hourlyWeather: Current[];
17 | @Input() dailyWeather: Daily[];
18 | @Input() tempSymbol: string;
19 | readonly webBreakpoints: Observable;
20 |
21 | constructor(breakpointObserver: BreakpointObserver) {
22 | this.webBreakpoints = breakpointObserver.observe([Breakpoints.Web]);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.html:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
19 |
20 |
26 |
27 |
28 |
35 | {{ geolocationState.title }}
36 | {{ geolocationState.content }}
37 |
46 |
47 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | display: grid;
3 | grid-area: body;
4 | grid-gap: 2em;
5 | grid-template-areas:
6 | "main"
7 | "aside";
8 | padding: 1rem;
9 |
10 | #main-content {
11 | display: grid;
12 | grid-area: main;
13 | grid-template-areas:
14 | "main-top"
15 | "main-middle"
16 | "main-bottom";
17 | }
18 |
19 | @media only screen and (min-width: 600px) {
20 | margin-left: 5rem;
21 | }
22 |
23 | @media only screen and (min-width: 1440px) {
24 | grid-template-areas: "main main aside";
25 | }
26 |
27 | @media only screen and (min-width: 1920px) {
28 | grid-template-areas: "main main main aside";
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnDestroy, OnInit } from '@angular/core';
2 | import { ActivatedRoute } from '@angular/router';
3 | import { Title } from '@angular/platform-browser';
4 |
5 | import { Subject } from 'rxjs';
6 | import { takeUntil } from 'rxjs/operators';
7 |
8 | import { DashboardService } from './dashboard.service';
9 | import {
10 | Current,
11 | Daily,
12 | OpenWeatherApiResponse,
13 | AirPollutionApiResponse
14 | } from '../core/api/openweather-api.model';
15 | import { UnitsMeasurement } from '../shared/enums/units-measurement.enum';
16 | import { EmptyState } from '../shared/models/empty-state.model';
17 | import { EmptyStateTypes } from '../shared/enums/empty-states.enum';
18 | import { EmptyStateService } from '../core/services/empty-state.service';
19 |
20 | @Component({
21 | selector: 'app-dashboard',
22 | templateUrl: './dashboard.component.html',
23 | styleUrls: ['./dashboard.component.scss']
24 | })
25 | export class DashboardComponent implements OnInit, OnDestroy {
26 | currentWeather: Current;
27 | hourlyWeather: Current[];
28 | dailyWeather: Daily[];
29 | airPollutionIndex: number;
30 | geolocationName: string;
31 | unitSymbol: string;
32 | temperatureSymbol: string;
33 | unitMeasurement: UnitsMeasurement;
34 | geolocationState: EmptyState;
35 |
36 | private subsNotifier = new Subject();
37 |
38 | constructor(
39 | private dashboardService: DashboardService,
40 | private route: ActivatedRoute,
41 | private emptyStateService: EmptyStateService,
42 | title: Title
43 | ) {
44 | title.setTitle('Dashboard - Weather App');
45 | }
46 |
47 | ngOnInit(): void {
48 | /* Using Resolvers */
49 | this.route.data.subscribe((data: {
50 | weather: OpenWeatherApiResponse,
51 | airPollution: AirPollutionApiResponse
52 | }) => {
53 | if (data.weather) {
54 | this.currentWeather = data.weather.current;
55 | this.hourlyWeather = data.weather.hourly.slice(0, 8);
56 | this.dailyWeather = data.weather.daily;
57 | this.airPollutionIndex = data.airPollution.list[0].main.aqi;
58 | } else if (this.dashboardService.isGeolocationBlocked()) {
59 | this.geolocationState = this.emptyStateService.getEmptyState(EmptyStateTypes.GPS_BLOCKED);
60 | } else {
61 | this.geolocationState = this.emptyStateService.getEmptyState(EmptyStateTypes.GPS);
62 | }
63 | });
64 |
65 | this.dashboardService.geolocationStatusChanged$.pipe(takeUntil(this.subsNotifier)).subscribe(geolocationStatus => {
66 | if (geolocationStatus === 'granted') {
67 | this.geolocationGranted();
68 | } else if (geolocationStatus === 'denied') {
69 | this.currentWeather = undefined;
70 | this.airPollutionIndex = undefined;
71 | this.geolocationState = this.emptyStateService.getEmptyState(EmptyStateTypes.GPS_BLOCKED);
72 | } else { // geolocationStatus === prompt
73 | this.currentWeather = undefined;
74 | this.airPollutionIndex = undefined;
75 | this.geolocationState = this.emptyStateService.getEmptyState(EmptyStateTypes.GPS);
76 | }
77 | });
78 |
79 | this.dashboardService.geolocationPositionChanged$.pipe(takeUntil(this.subsNotifier))
80 | .subscribe(() => {
81 | this.setWeatherData(this.unitMeasurement);
82 | this.setAirPollutionData();
83 | });
84 |
85 | this.dashboardService.geolocationNameChanged$.pipe(takeUntil(this.subsNotifier))
86 | .subscribe(geolocationName => this.geolocationName = geolocationName);
87 |
88 | this.setUnitAndTempSymbols(UnitsMeasurement.imperial);
89 | }
90 |
91 | onTempChanged(unitMeasurement: UnitsMeasurement): void {
92 | this.setWeatherData(unitMeasurement);
93 | this.setAirPollutionData(); // just to update the air pollution data, this call is not needed
94 | }
95 |
96 | allowGeolocation(): void {
97 | this.dashboardService.requestGeolocation();
98 | }
99 |
100 | geolocationGranted(): void {
101 | this.dashboardService.geoLocationGranted().then((isPositionEnabled) => {
102 | if (isPositionEnabled) {
103 | this.setWeatherData(this.unitMeasurement);
104 | this.setAirPollutionData();
105 | } else {
106 | this.geolocationState = this.emptyStateService.getEmptyState(EmptyStateTypes.GPS_BLOCKED);
107 | }
108 | });
109 | }
110 |
111 | ngOnDestroy(): void {
112 | this.subsNotifier.next();
113 | this.subsNotifier.complete();
114 | }
115 |
116 | private setWeatherData(unitMeasurement: UnitsMeasurement): void {
117 | this.dashboardService.getCurrentWeather(unitMeasurement).subscribe(weather => {
118 | this.currentWeather = weather.current;
119 | this.hourlyWeather = weather.hourly.slice(0, 8); // get only 8 hours forecast
120 | this.dailyWeather = weather.daily;
121 | this.setUnitAndTempSymbols(unitMeasurement);
122 | });
123 | }
124 |
125 | private setAirPollutionData(): void {
126 | this.dashboardService.getAirPollution().subscribe(airPollution => {
127 | this.airPollutionIndex = airPollution.list[0].main.aqi;
128 | });
129 | }
130 |
131 | private setUnitAndTempSymbols(unit: UnitsMeasurement): void {
132 | this.unitMeasurement = unit;
133 | if (unit === UnitsMeasurement.metric) {
134 | this.unitSymbol = 'm/s';
135 | this.temperatureSymbol = '°C';
136 | } else {
137 | this.unitSymbol = 'mph';
138 | this.temperatureSymbol = '°F';
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { Routes, RouterModule } from '@angular/router';
4 |
5 | import { MatTabsModule } from '@angular/material/tabs';
6 | import { MatButtonModule } from '@angular/material/button';
7 |
8 | import { DashboardComponent } from './dashboard.component';
9 | import { TopSectionComponent } from './top-section/top-section.component';
10 | import { MiddleSectionComponent } from './middle-section/middle-section.component';
11 | import { BottomSectionComponent } from './bottom-section/bottom-section.component';
12 | import { AsideSectionComponent } from './aside-section/aside-section.component';
13 | import { SharedModule } from '../shared/shared.module';
14 | import { WeatherResolver } from './resolvers/weather.resolver';
15 | import { AirPollutionResolver } from './resolvers/air-pollution.resolver';
16 |
17 | const routes: Routes = [
18 | {
19 | path: '',
20 | component: DashboardComponent,
21 | resolve: {
22 | weather: WeatherResolver,
23 | airPollution: AirPollutionResolver
24 | }
25 | }
26 | ];
27 |
28 | @NgModule({
29 | declarations: [DashboardComponent, TopSectionComponent, MiddleSectionComponent, BottomSectionComponent, AsideSectionComponent],
30 | imports: [
31 | CommonModule,
32 | RouterModule.forChild(routes),
33 | MatTabsModule,
34 | MatButtonModule,
35 | SharedModule
36 | ]
37 | })
38 | export class DashboardModule { }
39 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | import { Observable, of } from 'rxjs';
4 |
5 | import { OpenWeatherApiService } from '../core/api/openweather-api.service';
6 | import { UnitsMeasurement } from '../shared/enums/units-measurement.enum';
7 | import {
8 | OpenWeatherApiResponse,
9 | AirPollutionApiResponse,
10 | ReverseGeocoderApiResponse
11 | } from '../core/api/openweather-api.model';
12 | import { GeolocationApiService } from '../core/services/geolocation-api.service';
13 | import { GeolocationPosition } from '../shared/models/geolocation-position.model';
14 |
15 | @Injectable({
16 | providedIn: 'root'
17 | })
18 | export class DashboardService {
19 | geolocationStatusChanged$ = this.geolocationApiService.geolocationStatusChanged$;
20 | geolocationPositionChanged$ = this.geolocationApiService.geolocationPositionChanged$;
21 | geolocationNameChanged$ = this.geolocationApiService.geolocationNameChanged$;
22 |
23 | constructor(
24 | private openWeatherApiService: OpenWeatherApiService,
25 | private geolocationApiService: GeolocationApiService,
26 | ) { }
27 |
28 | getCurrentWeather(unit?: UnitsMeasurement): Observable {
29 | const geoLocationPosition = this.getGeolocationPosition();
30 | if (geoLocationPosition) {
31 | return this.openWeatherApiService.getCurrentAndForecastWeather(
32 | geoLocationPosition.coords.latitude,
33 | geoLocationPosition.coords.longitude,
34 | unit
35 | );
36 |
37 | // return this.openWeatherApiService.getStaticCurrentAndForecastWeather(unit);
38 | }
39 |
40 | return of(undefined);
41 | }
42 |
43 | getAirPollution(): Observable {
44 | const geoLocationPosition = this.getGeolocationPosition();
45 | if (geoLocationPosition) {
46 | return this.openWeatherApiService.getAirPollutionInfo(
47 | geoLocationPosition.coords.latitude,
48 | geoLocationPosition.coords.longitude,
49 | );
50 |
51 | // return this.openWeatherApiService.getStaticAirPollutionInfo();
52 | }
53 |
54 | return of(undefined);
55 | }
56 |
57 | getGeolocationNameWithOpenWeatherApi(): Observable {
58 | const geoLocationPosition = this.getGeolocationPosition();
59 | if (geoLocationPosition) {
60 | return this.openWeatherApiService.getLocationNameByCoords(
61 | geoLocationPosition.coords.latitude,
62 | geoLocationPosition.coords.longitude,
63 | );
64 | }
65 |
66 | return of(undefined);
67 | }
68 |
69 | isGeolocationBlocked(): boolean {
70 | return this.geolocationApiService.getGeolocationStatus() === 'denied';
71 | }
72 |
73 | requestGeolocation(): void {
74 | this.geolocationApiService.requestGeolocation();
75 | }
76 |
77 | async geoLocationGranted(): Promise {
78 | return await this.geolocationApiService.setGeolocation();
79 | }
80 |
81 | private getGeolocationPosition(): GeolocationPosition {
82 | return this.geolocationApiService.getGeolocationPosition();
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/app/dashboard/middle-section/middle-section.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |

10 |
{{ current?.humidity }} %
11 |
12 |
13 |

19 |
{{ current?.wind_speed }} {{ unitSymbol }}
20 |
21 |
22 |
23 |
24 |
25 |
26 | {{ current?.uvi | uvIndex }}
27 |
28 |
UV
29 |
30 |
31 |
32 | {{ airPollutionIndex | airPollution }}
33 |
34 |
Pollution
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/app/dashboard/middle-section/middle-section.component.scss:
--------------------------------------------------------------------------------
1 | .middle {
2 | display: grid;
3 | grid-area: main-middle;
4 | grid-template-rows: 1fr 1fr;
5 | grid-row-gap: 1em;
6 |
7 | margin: 2em 0;
8 |
9 | .humidity-wind {
10 | display: grid;
11 | grid-gap: 2em;
12 | grid-template-columns: 1fr 1fr;
13 | .humidity {
14 | place-self: center end;
15 | p {
16 | color: var(--dark-gray);
17 | }
18 | }
19 | .wind {
20 | place-self: center start;
21 | p {
22 | color: var(--dark-gray);
23 | }
24 | }
25 | }
26 | .uv-pollution {
27 | display: grid;
28 | grid-gap: 2em;
29 | grid-template-columns: 1fr 1fr;
30 |
31 | .uv {
32 | place-self: center end;
33 | }
34 | .pollution {
35 | place-self: center start;
36 | }
37 | .uv,
38 | .pollution {
39 | display: flex;
40 | flex-direction: column;
41 | justify-content: center;
42 | align-items: center;
43 |
44 | .low,
45 | .good {
46 | border-color: #afcfaf;
47 | background-color: #bfd9bf;
48 | }
49 | .uv-moderate,
50 | .fair {
51 | border-color: var(--yellow);
52 | background-color: var(--light-yellow);
53 | }
54 | .high,
55 | .air-moderate {
56 | border-color: #ffb733;
57 | background-color: #ffc04d;
58 | }
59 | .very-high,
60 | .poor {
61 | border-color: #ec4d4d;
62 | background-color: #f37171;
63 | }
64 | .extreme,
65 | .very-poor {
66 | border-color: #d55bd5;
67 | background-color: #da70da;
68 | }
69 | }
70 | .uv p,
71 | .pollution p {
72 | color: var(--dark-gray);
73 | }
74 |
75 | .chip {
76 | color: black;
77 | border-radius: 15px;
78 | padding: 3px 15px;
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/app/dashboard/middle-section/middle-section.component.ts:
--------------------------------------------------------------------------------
1 | import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2 |
3 | import { Current } from '../../core/api/openweather-api.model';
4 |
5 | @Component({
6 | selector: 'dashboard-middle-section',
7 | templateUrl: './middle-section.component.html',
8 | styleUrls: ['./middle-section.component.scss'],
9 | changeDetection: ChangeDetectionStrategy.OnPush
10 | })
11 | export class MiddleSectionComponent {
12 | @Input() current: Current;
13 | @Input() airPollutionIndex: number;
14 | @Input() unitSymbol: string;
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/dashboard/resolvers/air-pollution.resolver.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import {
3 | Resolve,
4 | RouterStateSnapshot,
5 | ActivatedRouteSnapshot
6 | } from '@angular/router';
7 |
8 | import { Observable } from 'rxjs';
9 |
10 | import { AirPollutionApiResponse } from '../../core/api/openweather-api.model';
11 | import { DashboardService } from '../dashboard.service';
12 |
13 | @Injectable({
14 | providedIn: 'root'
15 | })
16 | export class AirPollutionResolver implements Resolve {
17 | constructor(private dashboardService: DashboardService) { }
18 |
19 | resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable {
20 | return this.dashboardService.getAirPollution();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/app/dashboard/resolvers/reverse-geocoder.resolver.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import {
3 | Resolve,
4 | RouterStateSnapshot,
5 | ActivatedRouteSnapshot
6 | } from '@angular/router';
7 |
8 | import { Observable } from 'rxjs';
9 |
10 | import { ReverseGeocoderApiResponse } from '../../core/api/openweather-api.model';
11 | import { DashboardService } from '../dashboard.service';
12 |
13 | @Injectable({
14 | providedIn: 'root'
15 | })
16 | export class ReverseGeocoderResolver implements Resolve {
17 | constructor(private dashboardService: DashboardService) { }
18 |
19 | resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable {
20 | return this.dashboardService.getGeolocationNameWithOpenWeatherApi();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/app/dashboard/resolvers/weather.resolver.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import {
3 | Resolve,
4 | RouterStateSnapshot,
5 | ActivatedRouteSnapshot
6 | } from '@angular/router';
7 |
8 | import { Observable } from 'rxjs';
9 |
10 | import { DashboardService } from '../dashboard.service';
11 | import { OpenWeatherApiResponse } from '../../core/api/openweather-api.model';
12 |
13 | @Injectable({
14 | providedIn: 'root'
15 | })
16 | export class WeatherResolver implements Resolve {
17 | constructor(private dashboardService: DashboardService) { }
18 |
19 | resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable {
20 | return this.dashboardService.getCurrentWeather();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/app/dashboard/top-section/top-section.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{ geolocationName }}
4 |
{{ current?.dt | customDate }}
5 |
6 |
7 |
15 |
23 |
24 |
25 |
![Weather Illustration]()
33 |
34 |
35 |
36 | {{ current?.temp | toInteger }}{{ tempSymbol }}
37 |
38 |
{{ current?.weather[0].main }}
39 |
40 |
41 |
Feels Like
42 |
43 | {{ current?.feels_like | toInteger }}{{ tempSymbol }}
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/app/dashboard/top-section/top-section.component.scss:
--------------------------------------------------------------------------------
1 | .top {
2 | display: grid;
3 | grid-area: main-top;
4 | grid-template-columns: 2fr 1fr;
5 |
6 | .temp-control {
7 | place-self: start end;
8 | display: flex;
9 | width: 90px;
10 | justify-content: space-between;
11 |
12 | .c-temp,
13 | .f-temp {
14 | border: var(--dark-border);
15 | border-radius: 50%;
16 | width: 42px;
17 | height: 42px;
18 | display: flex;
19 | justify-content: center;
20 | align-items: center;
21 | outline: none;
22 | background-color: inherit;
23 | transition: background-color 200ms ease-in-out;
24 | cursor: pointer;
25 |
26 | &.active {
27 | background-color: var(--dashboard-dark);
28 | color: white;
29 | cursor: default;
30 | }
31 | &:not(.active):hover {
32 | background-color: var(--dashboard-dark);
33 | color: white;
34 | }
35 | }
36 | }
37 | .weather-illustration {
38 | grid-column: span 2;
39 | display: flex;
40 | justify-content: center;
41 | align-items: center;
42 | img {
43 | width: 12em;
44 | height: auto;
45 | }
46 | .temp-info {
47 | display: grid;
48 | grid-template-rows: 1fr 1fr;
49 | gap: 1em;
50 |
51 | .current-temp p:last-child,
52 | .feels-like p:first-child {
53 | color: var(--dark-gray);
54 | }
55 | }
56 | }
57 | }
58 |
59 | @media only screen and (min-width: 720px) {
60 | .top .weather-illustration img {
61 | width: 16em;
62 | }
63 | }
64 |
65 | @media only screen and (min-width: 1024px) {
66 | .top .weather-illustration img {
67 | width: 20em;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/app/dashboard/top-section/top-section.component.ts:
--------------------------------------------------------------------------------
1 | import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
2 |
3 | import { Current } from '../../core/api/openweather-api.model';
4 | import { UnitsMeasurement } from '../../shared/enums/units-measurement.enum';
5 |
6 | @Component({
7 | selector: 'dashboard-top-section',
8 | templateUrl: './top-section.component.html',
9 | styleUrls: ['./top-section.component.scss'],
10 | changeDetection: ChangeDetectionStrategy.OnPush
11 | })
12 | export class TopSectionComponent {
13 | @Input() current: Current;
14 | @Input() geolocationName: string;
15 | @Input() tempSymbol: string;
16 | @Input() unit: UnitsMeasurement;
17 | @Output() temperatureChanged = new EventEmitter();
18 |
19 | changeTempToCelsius(): void {
20 | this.temperatureChanged.emit(UnitsMeasurement.metric);
21 | }
22 |
23 | changeTempToFahrenheit(): void {
24 | this.temperatureChanged.emit(UnitsMeasurement.imperial);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/app/locations/locations.component.html:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 | {{ implementationState.title || "Favorite locations" }}
11 |
12 |
13 | {{
14 | implementationState.content ||
15 | "Favorite locations is not yet implemented."
16 | }}
17 |
18 |
26 |
27 |
--------------------------------------------------------------------------------
/src/app/locations/locations.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | display: grid;
3 | grid-area: body;
4 | justify-content: center;
5 | align-items: center;
6 | padding: 1rem;
7 |
8 | @media only screen and (min-width: 600px) {
9 | margin-left: 5rem;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/locations/locations.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { Router } from '@angular/router';
3 | import { Title } from '@angular/platform-browser';
4 |
5 | import { EmptyState } from '../shared/models/empty-state.model';
6 | import { EmptyStateService } from '../core/services/empty-state.service';
7 | import { EmptyStateTypes } from '../shared/enums/empty-states.enum';
8 |
9 | @Component({
10 | selector: 'app-locations',
11 | templateUrl: './locations.component.html',
12 | styleUrls: ['./locations.component.scss']
13 | })
14 | export class LocationsComponent {
15 | implementationState: EmptyState;
16 |
17 | constructor(
18 | private route: Router,
19 | emptyStateService: EmptyStateService,
20 | title: Title
21 | ) {
22 | this.implementationState = emptyStateService.getEmptyState(EmptyStateTypes.NOT_IMPLEMENTED);
23 | title.setTitle('Favorite locations - Weather App');
24 | }
25 |
26 | navigateToDashboard(): void {
27 | this.route.navigateByUrl('/dashboard');
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/locations/locations.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { Routes, RouterModule } from '@angular/router';
4 |
5 | import { MatButtonModule } from '@angular/material/button';
6 |
7 | import { LocationsComponent } from './locations.component';
8 | import { SharedModule } from '../shared/shared.module';
9 |
10 |
11 | const routes: Routes = [
12 | { path: '', component: LocationsComponent }
13 | ];
14 |
15 |
16 | @NgModule({
17 | declarations: [LocationsComponent],
18 | imports: [
19 | CommonModule,
20 | RouterModule.forChild(routes),
21 | MatButtonModule,
22 | SharedModule
23 | ]
24 | })
25 | export class LocationsModule { }
26 |
--------------------------------------------------------------------------------
/src/app/map/map.component.html:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 | {{ implementationState.title || "Radar Map" }}
11 |
12 |
13 | {{ implementationState.content || "Radar Map is not yet implemented." }}
14 |
15 |
23 |
24 |
--------------------------------------------------------------------------------
/src/app/map/map.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | display: grid;
3 | grid-area: body;
4 | justify-content: center;
5 | align-items: center;
6 | padding: 1rem;
7 |
8 | @media only screen and (min-width: 600px) {
9 | margin-left: 5rem;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/map/map.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { Router } from '@angular/router';
3 | import { Title } from '@angular/platform-browser';
4 |
5 | import { EmptyStateService } from '../core/services/empty-state.service';
6 | import { EmptyStateTypes } from '../shared/enums/empty-states.enum';
7 | import { EmptyState } from '../shared/models/empty-state.model';
8 |
9 | @Component({
10 | selector: 'app-map',
11 | templateUrl: './map.component.html',
12 | styleUrls: ['./map.component.scss']
13 | })
14 | export class MapComponent {
15 | implementationState: EmptyState;
16 |
17 | constructor(
18 | private route: Router,
19 | emptyStateService: EmptyStateService,
20 | title: Title
21 | ) {
22 | this.implementationState = emptyStateService.getEmptyState(EmptyStateTypes.NOT_IMPLEMENTED);
23 | title.setTitle('Radar map - Weather App');
24 | }
25 |
26 | navigateToDashboard(): void {
27 | this.route.navigateByUrl('/dashboard');
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/map/map.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { Routes, RouterModule } from '@angular/router';
4 |
5 | import { MatButtonModule } from '@angular/material/button';
6 |
7 | import { MapComponent } from './map.component';
8 | import { SharedModule } from '../shared/shared.module';
9 |
10 | const routes: Routes = [
11 | { path: '', component: MapComponent }
12 | ];
13 |
14 | @NgModule({
15 | declarations: [MapComponent],
16 | imports: [
17 | CommonModule,
18 | MatButtonModule,
19 | RouterModule.forChild(routes),
20 | SharedModule
21 | ]
22 | })
23 | export class MapModule { }
24 |
--------------------------------------------------------------------------------
/src/app/settings/settings.component.html:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 | {{ implementationState.title || "Settings" }}
11 |
12 |
13 | {{ implementationState.content || "Settings is not yet implemented." }}
14 |
15 |
23 |
24 |
--------------------------------------------------------------------------------
/src/app/settings/settings.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | display: grid;
3 | grid-area: body;
4 | justify-content: center;
5 | align-items: center;
6 | padding: 1rem;
7 |
8 | @media only screen and (min-width: 600px) {
9 | margin-left: 5rem;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/settings/settings.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { Router } from '@angular/router';
3 | import { Title } from '@angular/platform-browser';
4 |
5 | import { EmptyState } from '../shared/models/empty-state.model';
6 | import { EmptyStateService } from '../core/services/empty-state.service';
7 | import { EmptyStateTypes } from '../shared/enums/empty-states.enum';
8 |
9 | @Component({
10 | selector: 'app-settings',
11 | templateUrl: './settings.component.html',
12 | styleUrls: ['./settings.component.scss']
13 | })
14 | export class SettingsComponent {
15 | implementationState: EmptyState;
16 |
17 | constructor(private route: Router,
18 | emptyStateService: EmptyStateService,
19 | title: Title
20 | ) {
21 | this.implementationState = emptyStateService.getEmptyState(EmptyStateTypes.NOT_IMPLEMENTED);
22 | title.setTitle('Settings - Weather App');
23 | }
24 |
25 | navigateToDashboard(): void {
26 | this.route.navigateByUrl('/dashboard');
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/app/settings/settings.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { Routes, RouterModule } from '@angular/router';
4 |
5 | import { MatButtonModule } from '@angular/material/button';
6 |
7 | import { SettingsComponent } from './settings.component';
8 | import { SharedModule } from '../shared/shared.module';
9 |
10 | const routes: Routes = [
11 | { path: '', component: SettingsComponent }
12 | ];
13 |
14 | @NgModule({
15 | declarations: [SettingsComponent],
16 | imports: [
17 | CommonModule,
18 | RouterModule.forChild(routes),
19 | MatButtonModule,
20 | SharedModule
21 | ]
22 | })
23 | export class SettingsModule { }
24 |
--------------------------------------------------------------------------------
/src/app/shared/constants/empty-states.assets.ts:
--------------------------------------------------------------------------------
1 | import { EmptyStateTypes } from '../enums/empty-states.enum';
2 | import { EmptyState } from '../models/empty-state.model';
3 |
4 | export const emptyStates: EmptyState[] = [
5 | {
6 | id: EmptyStateTypes.GPS,
7 | imageSrc: 'assets/icons/global/gps-connection-illustration.svg',
8 | imageAlt: 'GPS illustration',
9 | title: 'No GPS connection',
10 | content: 'Please allow for location permission.',
11 | buttonText: 'Allow'
12 | },
13 | {
14 | id: EmptyStateTypes.GPS_BLOCKED,
15 | imageSrc: 'assets/icons/global/gps-connection-illustration.svg',
16 | imageAlt: 'GPS illustration',
17 | title: 'GPS Blocked',
18 | content: 'Use the browser menu options to select Always Ask when a site tries to get the current location.',
19 | },
20 | {
21 | id: EmptyStateTypes.NOT_IMPLEMENTED,
22 | imageSrc: 'assets/icons/global/not-implemented.svg',
23 | imageAlt: 'Feature not implemented',
24 | buttonText: 'Go to Dashboard'
25 | }
26 | ];
27 |
--------------------------------------------------------------------------------
/src/app/shared/directives/air-pollution.directive.ts:
--------------------------------------------------------------------------------
1 | import { Directive, ElementRef, Input, Renderer2, OnChanges, SimpleChanges } from '@angular/core';
2 |
3 | @Directive({
4 | selector: '[appAirPollution]'
5 | })
6 | export class AirPollutionDirective implements OnChanges {
7 | private readonly airPollution = ['good', 'fair', 'air-moderate', 'poor', 'very-poor'];
8 |
9 | @Input('appAirPollution') airPollutionIndex: number;
10 |
11 | constructor(
12 | private el: ElementRef,
13 | private renderer: Renderer2
14 | ) { }
15 |
16 | /*
17 | * Using the lifecycle hook OnChanges on AirPollutionDirective to change data values
18 | * instead of using a Resolver to wait data from de server before present the view.
19 | */
20 | ngOnChanges(changes: SimpleChanges): void {
21 | if (changes.airPollutionIndex.currentValue !== undefined) {
22 | if (!changes.airPollutionIndex.firstChange) {
23 | this.renderer.removeClass(this.el.nativeElement,
24 | this.airPollution[changes.airPollutionIndex.previousValue - 1]);
25 | }
26 | this.renderer.addClass(this.el.nativeElement,
27 | this.airPollution[changes.airPollutionIndex.currentValue - 1]);
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/app/shared/directives/index.ts:
--------------------------------------------------------------------------------
1 | export { UvIndexDirective } from './uv-index.directive';
2 | export { AirPollutionDirective } from './air-pollution.directive';
3 |
--------------------------------------------------------------------------------
/src/app/shared/directives/uv-index.directive.ts:
--------------------------------------------------------------------------------
1 | import { Directive, ElementRef, Input, OnInit, Renderer2 } from '@angular/core';
2 |
3 | @Directive({
4 | selector: '[appUvIndex]'
5 | })
6 | export class UvIndexDirective implements OnInit {
7 | private readonly uvi = ['low', 'low', 'low', 'uv-moderate', 'uv-moderate', 'uv-moderate', 'high', 'high', 'very-high', 'very-high', 'very-high'];
8 |
9 | @Input('appUvIndex') uvIndex: number;
10 |
11 | constructor(
12 | private el: ElementRef,
13 | private renderer: Renderer2
14 | ) { }
15 |
16 | ngOnInit(): void {
17 | let uvIndexClass = 'extreme';
18 | if (this.uvIndex < 11) {
19 | uvIndexClass = this.uvi[Math.round(this.uvIndex)];
20 | }
21 | this.renderer.addClass(this.el.nativeElement, uvIndexClass);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/app/shared/enums/empty-states.enum.ts:
--------------------------------------------------------------------------------
1 | export enum EmptyStateTypes {
2 | GPS = 1,
3 | GPS_BLOCKED,
4 | NOT_IMPLEMENTED
5 | }
6 |
--------------------------------------------------------------------------------
/src/app/shared/enums/units-measurement.enum.ts:
--------------------------------------------------------------------------------
1 | export enum UnitsMeasurement {
2 | standard = 'standard',
3 | metric = 'metric',
4 | imperial = 'imperial'
5 | }
6 |
--------------------------------------------------------------------------------
/src/app/shared/models/empty-state.model.ts:
--------------------------------------------------------------------------------
1 | export interface EmptyState {
2 | id: number;
3 | imageSrc: string;
4 | imageAlt: string;
5 | title?: string;
6 | content?: string;
7 | buttonText?: string;
8 | }
9 |
--------------------------------------------------------------------------------
/src/app/shared/models/geolocation-position.model.ts:
--------------------------------------------------------------------------------
1 | export interface GeolocationPosition {
2 | coords: GeolocationCoordinates;
3 | timestamp: number;
4 | }
5 | export interface GeolocationCoordinates {
6 | accuracy?: number;
7 | altitude?: number;
8 | altitudeAccuracy?: number;
9 | heading?: number;
10 | latitude: number;
11 | longitude: number;
12 | speed?: number;
13 | }
14 | export interface GeolocationPositionError {
15 | code: number;
16 | message: string;
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/shared/pipes/air-pollution.pipe.ts:
--------------------------------------------------------------------------------
1 | import { Pipe, PipeTransform } from '@angular/core';
2 |
3 | @Pipe({
4 | name: 'airPollution'
5 | })
6 | export class AirPollutionPipe implements PipeTransform {
7 | private readonly airPollution = ['Good', 'Fair', 'Moderate', 'Poor', 'Very Poor'];
8 |
9 | transform(value: number): string {
10 | return this.airPollution[value - 1];
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/shared/pipes/custom-date.pipe.ts:
--------------------------------------------------------------------------------
1 | import { Pipe, PipeTransform } from '@angular/core';
2 | import { formatDate } from '@angular/common';
3 |
4 | @Pipe({
5 | name: 'customDate'
6 | })
7 | export class CustomDatePipe implements PipeTransform {
8 |
9 | transform(value: number, format: string = 'mediumDate'): string {
10 | return formatDate(value * 1000, format, 'en-US');
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/shared/pipes/humidity-range.pipe.ts:
--------------------------------------------------------------------------------
1 | import { Pipe, PipeTransform } from '@angular/core';
2 |
3 | @Pipe({
4 | name: 'humidityRange'
5 | })
6 | export class HumidityRangePipe implements PipeTransform {
7 |
8 | transform(value: number): string {
9 | if (value <= 30) {
10 | return 'Too Dry';
11 | }
12 | else if (value > 30 && value <= 60) {
13 | return 'Comfortable';
14 | }
15 | else {
16 | return 'Too Moist';
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/shared/pipes/index.ts:
--------------------------------------------------------------------------------
1 | export { CustomDatePipe } from './custom-date.pipe';
2 | export { ToIntegerPipe } from './to-integer.pipe';
3 | export { UvIndexPipe } from './uv-index.pipe';
4 | export { AirPollutionPipe } from './air-pollution.pipe';
5 | export { WindDirectionPipe } from './wind-direction.pipe';
6 | export { HumidityRangePipe } from './humidity-range.pipe';
7 |
--------------------------------------------------------------------------------
/src/app/shared/pipes/to-integer.pipe.ts:
--------------------------------------------------------------------------------
1 | import { Pipe, PipeTransform } from '@angular/core';
2 |
3 | @Pipe({
4 | name: 'toInteger'
5 | })
6 | export class ToIntegerPipe implements PipeTransform {
7 |
8 | transform(value: number): number {
9 | return Math.round(value);
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/app/shared/pipes/uv-index.pipe.ts:
--------------------------------------------------------------------------------
1 | import { Pipe, PipeTransform } from '@angular/core';
2 |
3 | @Pipe({
4 | name: 'uvIndex'
5 | })
6 | export class UvIndexPipe implements PipeTransform {
7 | private readonly uvi = ['Low', 'Low', 'Low', 'Moderate', 'Moderate', 'Moderate', 'High', 'High', 'Very high', 'Very high', 'Very high'];
8 |
9 | transform(value: number): string {
10 | if (value >= 11) {
11 | return 'Extreme';
12 | }
13 | return this.uvi[Math.round(value)];
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/app/shared/pipes/wind-direction.pipe.ts:
--------------------------------------------------------------------------------
1 | import { Pipe, PipeTransform } from '@angular/core';
2 |
3 | @Pipe({
4 | name: 'windDirection'
5 | })
6 | export class WindDirectionPipe implements PipeTransform {
7 | private readonly compass = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N'];
8 |
9 | transform(windDeg: number): string {
10 | if (windDeg > 360) {
11 | return this.compass[Math.round(windDeg % 360 / 22.5)];
12 | }
13 | return this.compass[Math.round(windDeg / 22.5)];
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/app/shared/shared.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import {
5 | ToIntegerPipe,
6 | CustomDatePipe,
7 | UvIndexPipe,
8 | AirPollutionPipe,
9 | WindDirectionPipe,
10 | HumidityRangePipe
11 | } from './pipes/index';
12 |
13 | import {
14 | UvIndexDirective,
15 | AirPollutionDirective
16 | } from './directives/index';
17 | import { EmptyStateComponent } from './widgets/empty-state/empty-state.component';
18 |
19 | const sharedItems = [
20 | ToIntegerPipe,
21 | CustomDatePipe,
22 | UvIndexPipe,
23 | AirPollutionPipe,
24 | UvIndexDirective,
25 | AirPollutionDirective,
26 | WindDirectionPipe,
27 | HumidityRangePipe,
28 | EmptyStateComponent
29 | ];
30 |
31 | @NgModule({
32 | declarations: [...sharedItems],
33 | imports: [
34 | CommonModule
35 | ],
36 | exports: [...sharedItems]
37 | })
38 | export class SharedModule { }
39 |
--------------------------------------------------------------------------------
/src/app/shared/widgets/empty-state/empty-state.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/app/shared/widgets/empty-state/empty-state.component.scss:
--------------------------------------------------------------------------------
1 | :host {
2 | display: grid;
3 | grid-area: main;
4 | }
5 | :host ::ng-deep .empty-state {
6 | width: 100%;
7 | display: flex;
8 | flex-direction: column;
9 | justify-content: center;
10 | align-items: center;
11 |
12 | img {
13 | max-width: 16em;
14 | height: auto;
15 | }
16 |
17 | p {
18 | max-width: 22em;
19 | margin-bottom: 1em;
20 | }
21 |
22 | button {
23 | text-transform: uppercase;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/app/shared/widgets/empty-state/empty-state.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'widget-empty-state',
5 | templateUrl: './empty-state.component.html',
6 | styleUrls: ['./empty-state.component.scss']
7 | })
8 | export class EmptyStateComponent { }
9 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/assets/icons/dashboard/drops.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/assets/icons/dashboard/search-icon.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/src/assets/icons/dashboard/sunrise.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/assets/icons/dashboard/sunset.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/assets/icons/dashboard/wind.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/assets/icons/global/global-error.svg:
--------------------------------------------------------------------------------
1 |
52 |
--------------------------------------------------------------------------------
/src/assets/icons/global/location-illustration.svg:
--------------------------------------------------------------------------------
1 |
78 |
--------------------------------------------------------------------------------
/src/assets/icons/global/not-implemented.svg:
--------------------------------------------------------------------------------
1 |
52 |
--------------------------------------------------------------------------------
/src/assets/icons/navbar/dashboard.svg:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/src/assets/icons/navbar/location-icon.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/src/assets/icons/navbar/map-icon.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/src/assets/icons/navbar/settings-icon.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/src/assets/icons/pwa/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/apple-touch-icon.png
--------------------------------------------------------------------------------
/src/assets/icons/pwa/shortcut_location_icon_x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/shortcut_location_icon_x192.png
--------------------------------------------------------------------------------
/src/assets/icons/pwa/shortcut_map_icon_x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/shortcut_map_icon_x192.png
--------------------------------------------------------------------------------
/src/assets/icons/pwa/shortcut_settings_icon_x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/shortcut_settings_icon_x192.png
--------------------------------------------------------------------------------
/src/assets/icons/pwa/weather_icon_x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/weather_icon_x128.png
--------------------------------------------------------------------------------
/src/assets/icons/pwa/weather_icon_x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/weather_icon_x192.png
--------------------------------------------------------------------------------
/src/assets/icons/pwa/weather_icon_x384.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/weather_icon_x384.png
--------------------------------------------------------------------------------
/src/assets/icons/pwa/weather_icon_x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/weather_icon_x512.png
--------------------------------------------------------------------------------
/src/assets/icons/pwa/weather_icon_x72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/weather_icon_x72.png
--------------------------------------------------------------------------------
/src/assets/icons/pwa/weather_icon_x96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/icons/pwa/weather_icon_x96.png
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/01d.svg:
--------------------------------------------------------------------------------
1 |
21 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/02d.svg:
--------------------------------------------------------------------------------
1 |
52 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/03d.svg:
--------------------------------------------------------------------------------
1 |
34 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/03n.svg:
--------------------------------------------------------------------------------
1 |
38 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/04d.svg:
--------------------------------------------------------------------------------
1 |
26 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/04n.svg:
--------------------------------------------------------------------------------
1 |
38 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/09d.svg:
--------------------------------------------------------------------------------
1 |
41 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/09n.svg:
--------------------------------------------------------------------------------
1 |
45 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/10d.svg:
--------------------------------------------------------------------------------
1 |
59 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/11d.svg:
--------------------------------------------------------------------------------
1 |
79 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/50d.svg:
--------------------------------------------------------------------------------
1 |
42 |
--------------------------------------------------------------------------------
/src/assets/icons/weather-conditions/50n.svg:
--------------------------------------------------------------------------------
1 |
46 |
--------------------------------------------------------------------------------
/src/assets/images/profile-picture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/assets/images/profile-picture.png
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | openWeatherApiKey: '{Your OpenWeather API key}',
4 | firebase: {
5 | apiKey: "YOUR_API_KEY",
6 | authDomain: "YOUR_AUTH_DOMAIN",
7 | projectId: "YOUR_PROJECT_ID",
8 | storageBucket: "YOUR_STORAGE_BUCKET",
9 | messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
10 | appId: "YOUR_APP_ID",
11 | measurementId: "YOUR_MEASUREMENT_ID"
12 | }
13 | };
14 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` 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 | openWeatherApiKey: '{Your OpenWeather API key}',
8 | firebase: {
9 | apiKey: "YOUR_API_KEY",
10 | authDomain: "YOUR_AUTH_DOMAIN",
11 | projectId: "YOUR_PROJECT_ID",
12 | storageBucket: "YOUR_STORAGE_BUCKET",
13 | messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
14 | appId: "YOUR_APP_ID",
15 | measurementId: "YOUR_MEASUREMENT_ID"
16 | }
17 | };
18 |
19 | /*
20 | * For easier debugging in development mode, you can import the following file
21 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
22 | *
23 | * This import should be commented out in production mode because it will have a negative impact
24 | * on performance if an error is thrown.
25 | */
26 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
27 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sldiaz04us/angular-weather-app/45254baf13854ae7cb6c1eb3d2bb951249311926/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'googlemaps';
2 |
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Weather App
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
26 |
27 |
28 |
29 |
30 |
31 |
37 |
43 |
47 |
48 |
49 |
50 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/manifest.webmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Weather App",
3 | "short_name": "Weather",
4 | "description": "Get the most accurate weather forecast",
5 | "categories": [
6 | "weather",
7 | "utilities"
8 | ],
9 | "theme_color": "#b3e0fb",
10 | "background_color": "#e1f3fe",
11 | "display": "standalone",
12 | "scope": "./",
13 | "start_url": "./",
14 | "icons": [
15 | {
16 | "src": "assets/icons/pwa/weather_icon_x72.png",
17 | "sizes": "72x72",
18 | "type": "image/png",
19 | "purpose": "maskable any"
20 | },
21 | {
22 | "src": "assets/icons/pwa/weather_icon_x96.png",
23 | "sizes": "96x96",
24 | "type": "image/png",
25 | "purpose": "maskable any"
26 | },
27 | {
28 | "src": "assets/icons/pwa/weather_icon_x128.png",
29 | "sizes": "128x128",
30 | "type": "image/png",
31 | "purpose": "maskable any"
32 | },
33 | {
34 | "src": "assets/icons/pwa/weather_icon_x192.png",
35 | "sizes": "192x192",
36 | "type": "image/png",
37 | "purpose": "maskable any"
38 | },
39 | {
40 | "src": "assets/icons/pwa/weather_icon_x384.png",
41 | "sizes": "384x384",
42 | "type": "image/png",
43 | "purpose": "maskable any"
44 | },
45 | {
46 | "src": "assets/icons/pwa/weather_icon_x512.png",
47 | "sizes": "512x512",
48 | "type": "image/png",
49 | "purpose": "maskable any"
50 | }
51 | ],
52 | "shortcuts": [
53 | {
54 | "name": "Settings",
55 | "short_name": "Settings",
56 | "description": "Settings",
57 | "url": "/settings",
58 | "icons": [
59 | {
60 | "src": "assets/icons/pwa/shortcut_settings_icon_x192.png",
61 | "sizes": "192x192"
62 | }
63 | ]
64 | },
65 | {
66 | "name": "Radar Map",
67 | "short_name": "Map",
68 | "description": "View the Radar Map of the weather",
69 | "url": "/map",
70 | "icons": [
71 | {
72 | "src": "assets/icons/pwa/shortcut_map_icon_x192.png",
73 | "sizes": "192x192"
74 | }
75 | ]
76 | },
77 | {
78 | "name": "Favorite locations",
79 | "short_name": "Locations",
80 | "description": "View weather forecast of your facorite locations",
81 | "url": "/locations",
82 | "icons": [
83 | {
84 | "src": "assets/icons/pwa/shortcut_location_icon_x192.png",
85 | "sizes": "192x192"
86 | }
87 | ]
88 | }
89 | ]
90 | }
91 |
--------------------------------------------------------------------------------
/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 Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE11 requires the following for NgClass support on SVG elements */
22 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
23 |
24 | /**
25 | * Web Animations `@angular/platform-browser/animations`
26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28 | */
29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30 |
31 | /**
32 | * By default, zone.js will patch all possible macroTask and DomEvents
33 | * user can disable parts of macroTask/DomEvents patch by setting following flags
34 | * because those flags need to be set before `zone.js` being loaded, and webpack
35 | * will put import in the top of bundle, so user need to create a separate file
36 | * in this directory (for example: zone-flags.ts), and put the following flags
37 | * into that file, and then add the following code before importing zone.js.
38 | * import './zone-flags';
39 | *
40 | * The flags allowed in zone-flags.ts are listed here.
41 | *
42 | * The following flags will work for all browsers.
43 | *
44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47 | *
48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
50 | *
51 | * (window as any).__Zone_enable_cross_context_check = true;
52 | *
53 | */
54 |
55 | /***************************************************************************************************
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'; // Included with Angular CLI.
59 |
60 |
61 | /***************************************************************************************************
62 | * APPLICATION IMPORTS
63 | */
64 |
--------------------------------------------------------------------------------
/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
3 | * {
4 | margin: 0;
5 | padding: 0;
6 | box-sizing: border-box;
7 | font-family: "Poppins", sans-serif;
8 | }
9 |
10 | body,
11 | html {
12 | height: 100%;
13 | color: var(--dashboard-dark);
14 | background: var(--gradient-blue);
15 | }
16 |
17 | :root {
18 | --vivid-yellow: #f8ce31;
19 | --yellow: #fbe698;
20 | --light-yellow: #fef5d6;
21 | --gradient-yellow: linear-gradient(
22 | 180deg,
23 | var(--light-yellow) 0%,
24 | rgba(255, 255, 255, 0.8) 31.05%,
25 | #ffffff 83.79%,
26 | var(--light-yellow) 100%
27 | );
28 |
29 | --dark-gray: #5b7186;
30 | --gray: #adb8c2;
31 | --light-gray: #dee3e7;
32 | --gradient-gray: linear-gradient(
33 | 180deg,
34 | var(--light-gray) 0%,
35 | rgba(255, 255, 255, 0.8) 31.05%,
36 | #ffffff 83.79%,
37 | var(--light-gray) 100%
38 | );
39 |
40 | --blue: #69c1f8;
41 | --light-blue: #b3e0fb;
42 | --lighter-blue: #e1f3fe;
43 | --gradient-blue: linear-gradient(
44 | 180deg,
45 | var(--lighter-blue) 0%,
46 | rgba(255, 255, 255, 0.8) 31.05%,
47 | #ffffff 83.79%,
48 | var(--lighter-blue) 100%
49 | );
50 |
51 | --dashboard-dark: #333866;
52 | --dashboard-light: #adb1cc;
53 |
54 | --dark-border: 1px solid var(--dashboard-dark);
55 |
56 | --transition-speed: 600ms;
57 | }
58 |
59 | @import "~@angular/material/theming";
60 |
61 | // Foreground Elements
62 |
63 | // Light Theme Text
64 | $dark-text: #333866;
65 | $dark-primary-text: rgba($dark-text, 0.87);
66 | $dark-accent-text: rgba($dark-primary-text, 0.54);
67 | $dark-disabled-text: rgba($dark-primary-text, 0.38);
68 | $dark-dividers: rgba($dark-primary-text, 0.12);
69 | $dark-focused: rgba($dark-primary-text, 0.12);
70 |
71 | $mat-light-theme-foreground: (
72 | base: black,
73 | divider: $dark-dividers,
74 | dividers: $dark-dividers,
75 | disabled: $dark-disabled-text,
76 | disabled-button: rgba($dark-text, 0.26),
77 | disabled-text: $dark-disabled-text,
78 | elevation: black,
79 | secondary-text: $dark-accent-text,
80 | hint-text: $dark-disabled-text,
81 | accent-text: $dark-accent-text,
82 | icon: $dark-accent-text,
83 | icons: $dark-accent-text,
84 | text: $dark-primary-text,
85 | slider-min: $dark-primary-text,
86 | slider-off: rgba($dark-text, 0.26),
87 | slider-off-active: $dark-disabled-text,
88 | );
89 |
90 | // Background config
91 | // Light bg
92 | $light-background: #fafafa;
93 | $light-bg-darker-5: darken($light-background, 5%);
94 | $light-bg-darker-10: darken($light-background, 10%);
95 | $light-bg-darker-20: darken($light-background, 20%);
96 | $light-bg-darker-30: darken($light-background, 30%);
97 | $light-bg-lighter-5: lighten($light-background, 5%);
98 | $dark-bg-tooltip: lighten(#2c2c2c, 20%);
99 | $dark-bg-alpha-4: rgba(#2c2c2c, 0.04);
100 | $dark-bg-alpha-12: rgba(#2c2c2c, 0.12);
101 |
102 | $mat-light-theme-background: (
103 | background: $light-background,
104 | status-bar: $light-bg-darker-20,
105 | app-bar: $light-bg-darker-5,
106 | hover: $dark-bg-alpha-4,
107 | card: $light-bg-lighter-5,
108 | dialog: $light-bg-lighter-5,
109 | tooltip: $dark-bg-tooltip,
110 | disabled-button: $dark-bg-alpha-12,
111 | raised-button: $light-bg-lighter-5,
112 | focused-button: $dark-focused,
113 | selected-button: $light-bg-darker-20,
114 | selected-disabled-button: $light-bg-darker-30,
115 | disabled-button-toggle: $light-bg-darker-10,
116 | unselected-chip: $light-bg-darker-10,
117 | disabled-list-option: $light-bg-darker-10,
118 | );
119 |
120 | @include mat-core();
121 |
122 | // Theme Config
123 |
124 | body {
125 | --primary-color: #69c1f8;
126 | --primary-lighter-color: #d2ecfd;
127 | --primary-darker-color: #4cabf5;
128 | --text-primary-color: #{$dark-primary-text};
129 | --text-primary-lighter-color: #{$dark-primary-text};
130 | --text-primary-darker-color: #{$dark-primary-text};
131 | }
132 |
133 | $mat-primary: (
134 | main: #69c1f8,
135 | lighter: #d2ecfd,
136 | darker: #4cabf5,
137 | 200: #69c1f8,
138 | // For slide toggle,
139 | contrast:
140 | (
141 | main: $dark-primary-text,
142 | lighter: $dark-primary-text,
143 | darker: $dark-primary-text,
144 | ),
145 | );
146 | $theme-primary: mat-palette($mat-primary, main, lighter, darker);
147 |
148 | body {
149 | --accent-color: #333866;
150 | --accent-lighter-color: #c2c3d1;
151 | --accent-darker-color: #202449;
152 | --text-accent-color: #{$light-primary-text};
153 | --text-accent-lighter-color: #{$dark-primary-text};
154 | --text-accent-darker-color: #{$light-primary-text};
155 | }
156 |
157 | $mat-accent: (
158 | main: #333866,
159 | lighter: #c2c3d1,
160 | darker: #202449,
161 | 200: #333866,
162 | // For slide toggle,
163 | contrast:
164 | (
165 | main: $light-primary-text,
166 | lighter: $dark-primary-text,
167 | darker: $light-primary-text,
168 | ),
169 | );
170 | $theme-accent: mat-palette($mat-accent, main, lighter, darker);
171 |
172 | $theme: mat-light-theme($theme-primary, $theme-accent);
173 |
174 | // Theme Init
175 | @include angular-material-theme($theme);
176 |
177 | /*
178 | * Typography
179 | */
180 | .heading-1 {
181 | font-size: 2em;
182 | font-weight: 800;
183 | }
184 | .heading-2 {
185 | font-size: 1.5em;
186 | font-weight: 700;
187 | }
188 |
189 | .large-text {
190 | font-size: 1.2em;
191 | font-weight: 600;
192 | }
193 | .large-text-semibold {
194 | font-size: 1.3em;
195 | font-weight: 700;
196 | }
197 |
198 | .medium-text {
199 | font-size: 1em;
200 | font-weight: 600;
201 | }
202 | .medium-text-semibold {
203 | font-size: 1em;
204 | font-weight: 700;
205 | }
206 |
207 | .normal-text {
208 | font-size: 0.8em;
209 | font-weight: 400;
210 | }
211 | .normal-text-semibold {
212 | font-size: 0.8em;
213 | font-weight: 700;
214 | color: var(--dark-gray);
215 | }
216 | .normal-text-bold {
217 | font-size: 0.8em;
218 | font-weight: 800;
219 | }
220 |
221 | .small-text {
222 | font-size: 0.6em;
223 | font-weight: 400;
224 | color: var(--dark-gray);
225 | }
226 | .small-text-medium {
227 | font-size: 0.7em;
228 | font-weight: 600;
229 | color: var(--dark-gray);
230 | }
231 |
232 | /*
233 | * Angular Material
234 | */
235 | .mat-snack-bar-container {
236 | background-color: var(--blue);
237 | color: black;
238 | }
239 |
--------------------------------------------------------------------------------
/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/dist/zone-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 | keys(): string[];
13 | (id: string): T;
14 | };
15 | };
16 |
17 | // First, initialize the Angular testing environment.
18 | getTestBed().initTestEnvironment(
19 | BrowserDynamicTestingModule,
20 | platformBrowserDynamicTesting()
21 | );
22 | // Then we find all the tests.
23 | const context = require.context('./', true, /\.spec\.ts$/);
24 | // And load the modules.
25 | context.keys().map(context);
26 |
--------------------------------------------------------------------------------
/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.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": "es2015",
14 | "module": "es2020",
15 | "lib": [
16 | "es2018",
17 | "dom"
18 | ],
19 | "types": [
20 | "googlemaps"
21 | ]
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint:recommended",
3 | "rulesDirectory": [
4 | "codelyzer"
5 | ],
6 | "rules": {
7 | "align": {
8 | "options": [
9 | "parameters",
10 | "statements"
11 | ]
12 | },
13 | "array-type": false,
14 | "arrow-return-shorthand": true,
15 | "curly": true,
16 | "deprecation": {
17 | "severity": "warning"
18 | },
19 | "eofline": true,
20 | "import-blacklist": [
21 | true,
22 | "rxjs/Rx"
23 | ],
24 | "import-spacing": true,
25 | "indent": {
26 | "options": [
27 | "spaces"
28 | ]
29 | },
30 | "max-classes-per-file": false,
31 | "max-line-length": [
32 | true,
33 | 140
34 | ],
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-console": [
47 | true,
48 | "debug",
49 | "info",
50 | "time",
51 | "timeEnd",
52 | "trace"
53 | ],
54 | "no-empty": false,
55 | "no-inferrable-types": [
56 | true,
57 | "ignore-params"
58 | ],
59 | "no-non-null-assertion": true,
60 | "no-redundant-jsdoc": true,
61 | "no-switch-case-fall-through": true,
62 | "no-var-requires": false,
63 | "object-literal-key-quotes": [
64 | true,
65 | "as-needed"
66 | ],
67 | "quotemark": [
68 | true,
69 | "single"
70 | ],
71 | "semicolon": {
72 | "options": [
73 | "always"
74 | ]
75 | },
76 | "space-before-function-paren": {
77 | "options": {
78 | "anonymous": "never",
79 | "asyncArrow": "always",
80 | "constructor": "never",
81 | "method": "never",
82 | "named": "never"
83 | }
84 | },
85 | "typedef": [
86 | true,
87 | "call-signature"
88 | ],
89 | "typedef-whitespace": {
90 | "options": [
91 | {
92 | "call-signature": "nospace",
93 | "index-signature": "nospace",
94 | "parameter": "nospace",
95 | "property-declaration": "nospace",
96 | "variable-declaration": "nospace"
97 | },
98 | {
99 | "call-signature": "onespace",
100 | "index-signature": "onespace",
101 | "parameter": "onespace",
102 | "property-declaration": "onespace",
103 | "variable-declaration": "onespace"
104 | }
105 | ]
106 | },
107 | "variable-name": {
108 | "options": [
109 | "ban-keywords",
110 | "check-format",
111 | "allow-pascal-case"
112 | ]
113 | },
114 | "whitespace": {
115 | "options": [
116 | "check-branch",
117 | "check-decl",
118 | "check-operator",
119 | "check-separator",
120 | "check-type",
121 | "check-typecast"
122 | ]
123 | },
124 | "component-class-suffix": true,
125 | "contextual-lifecycle": true,
126 | "directive-class-suffix": true,
127 | "no-conflicting-lifecycle": true,
128 | "no-host-metadata-property": true,
129 | "no-input-rename": true,
130 | "no-inputs-metadata-property": true,
131 | "no-output-native": true,
132 | "no-output-on-prefix": true,
133 | "no-output-rename": true,
134 | "no-outputs-metadata-property": true,
135 | "template-banana-in-box": true,
136 | "template-no-negated-async": true,
137 | "use-lifecycle-interface": true,
138 | "use-pipe-transform-interface": true,
139 | "directive-selector": [
140 | true,
141 | "attribute",
142 | "app",
143 | "camelCase"
144 | ],
145 | "component-selector": [
146 | true,
147 | "element",
148 | [
149 | "app",
150 | "dashboard",
151 | "widget"
152 | ],
153 | "kebab-case"
154 | ]
155 | }
156 | }
157 |
--------------------------------------------------------------------------------