From 8a4f8d7194e4c69cca22ca01913ebec8b91de38a Mon Sep 17 00:00:00 2001 From: Adriano Markovic Date: Wed, 1 Apr 2020 18:16:51 +0200 Subject: [PATCH] Added web component "weather-forecast-today". --- web-angular/angular.json | 127 ++++++++++++++++++ web-angular/package-lock.json | 75 ++++++++++- web-angular/package.json | 6 + .../weather-forecast-today/browserslist | 12 ++ .../weather-forecast-today/build-script.js | 29 ++++ .../e2e/protractor.conf.js | 32 +++++ .../e2e/src/app.e2e-spec.ts | 23 ++++ .../weather-forecast-today/e2e/src/app.po.ts | 11 ++ .../weather-forecast-today/e2e/tsconfig.json | 13 ++ .../weather-forecast-today/karma.conf.js | 32 +++++ .../src/app/app.module.ts | 93 +++++++++++++ .../src/app/element.dependency.ts | 34 +++++ .../src/assets/.gitkeep | 0 .../src/environments/environment.prod.ts | 3 + .../src/environments/environment.ts | 16 +++ .../weather-forecast-today/src/favicon.ico | Bin 0 -> 948 bytes .../weather-forecast-today/src/index.html | 13 ++ .../weather-forecast-today/src/main.ts | 12 ++ .../weather-forecast-today/src/polyfills.ts | 64 +++++++++ .../weather-forecast-today/src/styles.scss | 1 + .../weather-forecast-today/src/test.ts | 25 ++++ .../weather-forecast-today/tsconfig.app.json | 14 ++ .../weather-forecast-today/tsconfig.spec.json | 18 +++ .../weather-forecast-today/tslint.json | 17 +++ web-angular/src/app/app.routing.ts | 7 +- .../dialogs/conditions-dialog.component.ts | 2 +- web-angular/src/app/pipes/location.pipes.ts | 2 +- .../weather-summary.component.ts | 16 ++- web-angular/src/polyfills.ts | 1 + 29 files changed, 683 insertions(+), 15 deletions(-) create mode 100644 web-angular/projects/weather-forecast-today/browserslist create mode 100644 web-angular/projects/weather-forecast-today/build-script.js create mode 100644 web-angular/projects/weather-forecast-today/e2e/protractor.conf.js create mode 100644 web-angular/projects/weather-forecast-today/e2e/src/app.e2e-spec.ts create mode 100644 web-angular/projects/weather-forecast-today/e2e/src/app.po.ts create mode 100644 web-angular/projects/weather-forecast-today/e2e/tsconfig.json create mode 100644 web-angular/projects/weather-forecast-today/karma.conf.js create mode 100644 web-angular/projects/weather-forecast-today/src/app/app.module.ts create mode 100644 web-angular/projects/weather-forecast-today/src/app/element.dependency.ts create mode 100644 web-angular/projects/weather-forecast-today/src/assets/.gitkeep create mode 100644 web-angular/projects/weather-forecast-today/src/environments/environment.prod.ts create mode 100644 web-angular/projects/weather-forecast-today/src/environments/environment.ts create mode 100644 web-angular/projects/weather-forecast-today/src/favicon.ico create mode 100644 web-angular/projects/weather-forecast-today/src/index.html create mode 100644 web-angular/projects/weather-forecast-today/src/main.ts create mode 100644 web-angular/projects/weather-forecast-today/src/polyfills.ts create mode 100644 web-angular/projects/weather-forecast-today/src/styles.scss create mode 100644 web-angular/projects/weather-forecast-today/src/test.ts create mode 100644 web-angular/projects/weather-forecast-today/tsconfig.app.json create mode 100644 web-angular/projects/weather-forecast-today/tsconfig.spec.json create mode 100644 web-angular/projects/weather-forecast-today/tslint.json diff --git a/web-angular/angular.json b/web-angular/angular.json index f2fe85c9..97e06585 100644 --- a/web-angular/angular.json +++ b/web-angular/angular.json @@ -130,6 +130,133 @@ } } } + }, + "weather-forecast-today": { + "projectType": "application", + "schematics": { + "@schematics/angular:component": { + "style": "scss" + } + }, + "root": "projects/weather-forecast-today", + "sourceRoot": "projects/weather-forecast-today/src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/weather-forecast-today", + "index": "projects/weather-forecast-today/src/index.html", + "main": "projects/weather-forecast-today/src/main.ts", + "polyfills": "projects/weather-forecast-today/src/polyfills.ts", + "tsConfig": "projects/weather-forecast-today/tsconfig.app.json", + "aot": true, + "assets": [ + "projects/weather-forecast-today/src/favicon.ico", + "projects/weather-forecast-today/src/assets" + ], + "styles": [ + "projects/weather-forecast-today/src/styles.scss", + { + "input": "src/styles.scss", + "inject": false, + "bundleName": "weather-forecast-today-styles", + "lazy": true + } + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "projects/weather-forecast-today/src/environments/environment.ts", + "with": "projects/weather-forecast-today/src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "6kb", + "maximumError": "10kb" + } + ] + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "weather-forecast-today:build" + }, + "configurations": { + "production": { + "browserTarget": "weather-forecast-today:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "weather-forecast-today:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/weather-forecast-today/src/test.ts", + "polyfills": "projects/weather-forecast-today/src/polyfills.ts", + "tsConfig": "projects/weather-forecast-today/tsconfig.spec.json", + "karmaConfig": "projects/weather-forecast-today/karma.conf.js", + "assets": [ + "projects/weather-forecast-today/src/favicon.ico", + "projects/weather-forecast-today/src/assets" + ], + "styles": [ + "projects/weather-forecast-today/src/styles.scss" + ], + "scripts": [] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "projects/weather-forecast-today/tsconfig.app.json", + "projects/weather-forecast-today/tsconfig.spec.json", + "projects/weather-forecast-today/e2e/tsconfig.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + }, + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "projects/weather-forecast-today/e2e/protractor.conf.js", + "devServerTarget": "weather-forecast-today:serve" + }, + "configurations": { + "production": { + "devServerTarget": "weather-forecast-today:serve:production" + } + } + } + } } }, "defaultProject": "webapp-ng", diff --git a/web-angular/package-lock.json b/web-angular/package-lock.json index 9c63ad26..2d3ac3b6 100644 --- a/web-angular/package-lock.json +++ b/web-angular/package-lock.json @@ -303,6 +303,17 @@ "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, + "fs-extra": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.2.tgz", + "integrity": "sha1-+RcExT0bRh+JNFKwwwfZmXZHq2s=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -377,6 +388,11 @@ "resolved": "https://registry.npmjs.org/@angular/core/-/core-9.0.4.tgz", "integrity": "sha512-6RqQb1GO2uglSlgiGbxhvy8plztZtABCWLRn0X+T1PnrxoqgxqA5WkKJjGxao+1M/ECW1V0fw4Xy7DE6KvAJwQ==" }, + "@angular/elements": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/@angular/elements/-/elements-9.0.4.tgz", + "integrity": "sha512-6d0WSgxv5V/D8BJkJ1tmiuApKBv3X2K3/ZcHY9IW/ROlU30uUe3squI27sOhe7vVJdbaGoZAtzzMr5imJ3gpkw==" + }, "@angular/flex-layout": { "version": "9.0.0-beta.29", "resolved": "https://registry.npmjs.org/@angular/flex-layout/-/flex-layout-9.0.0-beta.29.tgz", @@ -2043,6 +2059,12 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, + "at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", + "dev": true + }, "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -3184,6 +3206,15 @@ } } }, + "concat": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/concat/-/concat-1.0.3.tgz", + "integrity": "sha1-QPM1MInWVGdpXLGIa0Xt1jfYzKg=", + "dev": true, + "requires": { + "commander": "^2.9.0" + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -4101,6 +4132,14 @@ "buffer-indexof": "^1.0.0" } }, + "document-register-element": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/document-register-element/-/document-register-element-1.14.3.tgz", + "integrity": "sha512-SbJTzoQXLTcYxnpdDNRZXu/gwsGSShemXpvj6Pa6ujRwJFpJ41siil4tk4y+cQXnqylS6mc2Rtxp/PkMzfkqyQ==", + "requires": { + "lightercollective": "^0.3.0" + } + }, "dom-serialize": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", @@ -5082,14 +5121,33 @@ } }, "fs-extra": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.2.tgz", - "integrity": "sha1-+RcExT0bRh+JNFKwwwfZmXZHq2s=", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.0.tgz", + "integrity": "sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^1.0.0" + }, + "dependencies": { + "jsonfile": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz", + "integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^1.0.0" + } + }, + "universalify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", + "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==", + "dev": true + } } }, "fs-minipass": { @@ -6730,6 +6788,11 @@ "immediate": "~3.0.5" } }, + "lightercollective": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/lightercollective/-/lightercollective-0.3.0.tgz", + "integrity": "sha512-RFOLSUVvwdK3xA0P8o6G7QGXLIyy1L2qv5caEI7zXN5ciaEjbAriRF182kbsoJ1S1TgvpyGcN485fMky6qxOPw==" + }, "loader-runner": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz", diff --git a/web-angular/package.json b/web-angular/package.json index 506e41d2..63eeb130 100644 --- a/web-angular/package.json +++ b/web-angular/package.json @@ -6,6 +6,8 @@ "ng": "ng", "start": "ng serve", "build": "ng build", + "build:forecast": "ng build --output-hashing none weather-forecast-today && npm run concat:forecast", + "concat:forecast": "node ./projects/weather-forecast-today/build-script.js", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", @@ -18,6 +20,7 @@ "@angular/common": "^9.0.4", "@angular/compiler": "^9.0.4", "@angular/core": "^9.0.4", + "@angular/elements": "^9.0.4", "@angular/flex-layout": "^9.0.0-beta.29", "@angular/forms": "^9.0.4", "@angular/material": "^9.1.0", @@ -25,6 +28,7 @@ "@angular/platform-browser-dynamic": "^9.0.4", "@angular/router": "^9.0.4", "@types/jszip": "^3.1.6", + "document-register-element": "^1.7.2", "jszip": "^3.2.2", "leaflet": "^1.5.1", "ngx-gauge": "^1.1.0", @@ -43,7 +47,9 @@ "@types/node": "^12.11.1", "acorn": "^6.2.0", "codelyzer": "^5.1.2", + "concat": "^1.0.3", "events": "^3.0.0", + "fs-extra": "^9.0.0", "jasmine-core": "^2.8.0", "jasmine-spec-reporter": "^4.2.1", "karma": "^4.2.0", diff --git a/web-angular/projects/weather-forecast-today/browserslist b/web-angular/projects/weather-forecast-today/browserslist new file mode 100644 index 00000000..80848532 --- /dev/null +++ b/web-angular/projects/weather-forecast-today/browserslist @@ -0,0 +1,12 @@ +# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. +# For additional information regarding the format and rule options, please see: +# https://github.com/browserslist/browserslist#queries + +# You can see what browsers were selected by your queries by running: +# npx browserslist + +> 0.5% +last 2 versions +Firefox ESR +not dead +not IE 9-11 # For IE 9-11 support, remove 'not'. \ No newline at end of file diff --git a/web-angular/projects/weather-forecast-today/build-script.js b/web-angular/projects/weather-forecast-today/build-script.js new file mode 100644 index 00000000..469a7ebb --- /dev/null +++ b/web-angular/projects/weather-forecast-today/build-script.js @@ -0,0 +1,29 @@ +const fs = require('fs-extra'); +const concat = require('concat'); + +// Configuration +const elementName = 'weather-forecast-today'; +const distDir = `./dist/${elementName}`; +const outputDir = './dist/webcomponents'; + +/** + * Builds the web component through concatenating all javascript files. + *  + * @param {string} versionString The ECMAScript version. Either ES5 or ES2015. + */ +async function buildElement(versionString) { +    const files = [ +        `${distDir}/runtime${versionString}.js`, +        `${distDir}/main${versionString}.js`, +        `${distDir}/polyfills${versionString}.js` +    ]; +    await fs.ensureDir(outputDir); +    await concat(files, `${outputDir}/${elementName}${versionString}.js`); +} +(async function() { +    console.log('Building Angular Element...'); +    buildElement('-es5'); +    buildElement('-es2015'); +//     await fs.copyFile(`${distDir}/styles.css`, `${outputDir}/styles.css`); +    console.log('Build finished!'); +})(); \ No newline at end of file diff --git a/web-angular/projects/weather-forecast-today/e2e/protractor.conf.js b/web-angular/projects/weather-forecast-today/e2e/protractor.conf.js new file mode 100644 index 00000000..7c798cff --- /dev/null +++ b/web-angular/projects/weather-forecast-today/e2e/protractor.conf.js @@ -0,0 +1,32 @@ +// @ts-check +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/lib/config.ts + +const { SpecReporter } = require('jasmine-spec-reporter'); + +/** + * @type { import("protractor").Config } + */ +exports.config = { + allScriptsTimeout: 11000, + specs: [ + './src/**/*.e2e-spec.ts' + ], + capabilities: { + browserName: 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + onPrepare() { + require('ts-node').register({ + project: require('path').join(__dirname, './tsconfig.json') + }); + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +}; \ No newline at end of file diff --git a/web-angular/projects/weather-forecast-today/e2e/src/app.e2e-spec.ts b/web-angular/projects/weather-forecast-today/e2e/src/app.e2e-spec.ts new file mode 100644 index 00000000..c2da4751 --- /dev/null +++ b/web-angular/projects/weather-forecast-today/e2e/src/app.e2e-spec.ts @@ -0,0 +1,23 @@ +import { AppPage } from './app.po'; +import { browser, logging } from 'protractor'; + +describe('workspace-project App', () => { + let page: AppPage; + + beforeEach(() => { + page = new AppPage(); + }); + + it('should display welcome message', () => { + page.navigateTo(); + expect(page.getTitleText()).toEqual('weather-forecast-today app is running!'); + }); + + afterEach(async () => { + // Assert that there are no errors emitted from the browser + const logs = await browser.manage().logs().get(logging.Type.BROWSER); + expect(logs).not.toContain(jasmine.objectContaining({ + level: logging.Level.SEVERE, + } as logging.Entry)); + }); +}); diff --git a/web-angular/projects/weather-forecast-today/e2e/src/app.po.ts b/web-angular/projects/weather-forecast-today/e2e/src/app.po.ts new file mode 100644 index 00000000..b68475e0 --- /dev/null +++ b/web-angular/projects/weather-forecast-today/e2e/src/app.po.ts @@ -0,0 +1,11 @@ +import { browser, by, element } from 'protractor'; + +export class AppPage { + navigateTo(): Promise { + return browser.get(browser.baseUrl) as Promise; + } + + getTitleText(): Promise { + return element(by.css('app-root .content span')).getText() as Promise; + } +} diff --git a/web-angular/projects/weather-forecast-today/e2e/tsconfig.json b/web-angular/projects/weather-forecast-today/e2e/tsconfig.json new file mode 100644 index 00000000..bc240fbf --- /dev/null +++ b/web-angular/projects/weather-forecast-today/e2e/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "../../../out-tsc/e2e", + "module": "commonjs", + "target": "es5", + "types": [ + "jasmine", + "jasminewd2", + "node" + ] + } +} diff --git a/web-angular/projects/weather-forecast-today/karma.conf.js b/web-angular/projects/weather-forecast-today/karma.conf.js new file mode 100644 index 00000000..c25af4ce --- /dev/null +++ b/web-angular/projects/weather-forecast-today/karma.conf.js @@ -0,0 +1,32 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage/weather-forecast-today'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true + }); +}; diff --git a/web-angular/projects/weather-forecast-today/src/app/app.module.ts b/web-angular/projects/weather-forecast-today/src/app/app.module.ts new file mode 100644 index 00000000..bf32a7da --- /dev/null +++ b/web-angular/projects/weather-forecast-today/src/app/app.module.ts @@ -0,0 +1,93 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule, Injector } from '@angular/core'; +import { createCustomElement } from '@angular/elements'; +import { MatCardModule } from '@angular/material/card'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { MatIconModule } from '@angular/material/icon'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatDialogModule } from '@angular/material/dialog'; +// import { MatPaginatorModule } from '@angular/material/paginator'; +// import { MatTabsModule } from '@angular/material/tabs'; +// import { MatTableModule } from '@angular/material/table'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; +// import { +//   WeatherSummaryComponent, +//   WeatherTimeOfDayComponent, +//   WeatherConditionComponent, +//   WeatherVideoBarComponent, +//   WeatherVideoListComponent, +//   WeatherStationsListComponent, +//   WeatherReportsListComponent, +//   CitiesListComponent, +//   ConfirmationDialogComponent, +//   ConditionsDialogComponent, +//   LogDialogComponent, +//   MessageDialogComponent, +//   ResourceService, +//   CityForecastService, +//   DefaultService, +//   LocalDatePipe +// } from './element.dependency'; +import { +  WeatherSummaryComponent, +  WeatherTimeOfDayComponent, +  ConditionsDialogComponent, +  ResourceService, +  CityForecastService, +  DefaultService, +  LocalDatePipe +} from './element.dependency'; +import { HttpClientModule } from '@angular/common/http'; +import '../../../../src/styles.scss'; + +@NgModule({ +//   declarations: [ +//     WeatherSummaryComponent, +//     WeatherTimeOfDayComponent, +//     WeatherConditionComponent, +//     WeatherVideoBarComponent, +//     WeatherVideoListComponent, +//     WeatherStationsListComponent, +//     WeatherReportsListComponent, +//     CitiesListComponent, +//     ConfirmationDialogComponent, +//     ConditionsDialogComponent, +//     LogDialogComponent, +//     MessageDialogComponent, +//     LocalDatePipe +//   ], + declarations: [ +     WeatherSummaryComponent, +     WeatherTimeOfDayComponent, +     ConditionsDialogComponent, +     LocalDatePipe +   ], +  imports: [ +    BrowserModule, +    HttpClientModule, +    MatCardModule, +    MatTooltipModule, +    MatIconModule, +    MatToolbarModule, +    MatDialogModule, +//     MatPaginatorModule, +//     MatTabsModule, +//     MatTableModule, + MatProgressSpinnerModule +  ], +  providers: [ +    ResourceService, +    CityForecastService, +    DefaultService, +    LocalDatePipe +  ], +  entryComponents: [WeatherTimeOfDayComponent] +}) +export class AppModule { +  constructor(private injector: Injector) { } +  ngDoBootstrap() { +    const el = createCustomElement(WeatherTimeOfDayComponent, { injector: this.injector }); +    // @ts-ignore +    customElements.define('weather-forecast-today', el); +  } +} diff --git a/web-angular/projects/weather-forecast-today/src/app/element.dependency.ts b/web-angular/projects/weather-forecast-today/src/app/element.dependency.ts new file mode 100644 index 00000000..4725a847 --- /dev/null +++ b/web-angular/projects/weather-forecast-today/src/app/element.dependency.ts @@ -0,0 +1,34 @@ +// export { +//   WeatherSummaryComponent, +//   WeatherTimeOfDayComponent, +//   WeatherConditionComponent, +//   WeatherVideoBarComponent, +//   WeatherVideoListComponent, +//   WeatherStationsListComponent, +//   WeatherReportsListComponent, +//   CitiesListComponent +// } from '../../../../src/app/widgets-weather'; +// export { +//   ConfirmationDialogComponent, +//   ConditionsDialogComponent, +//   LogDialogComponent, +//   MessageDialogComponent +// } from '../../../../src/app/dialogs'; +// export { +//   ResourceService, +//   CityForecastService +// } from '../../../../src/app/services'; +// export { +//   DefaultService +// } from '../../../../src/app/api'; +// export { +//   LocalDatePipe +// } from '../../../../src/app/pipes'; + +export { WeatherSummaryComponent } from '../../../../src/app/widgets-weather/weather-summary.component'; +export { WeatherTimeOfDayComponent } from '../../../../src/app/widgets-weather/weather-time-of-day.component'; +export { ConditionsDialogComponent } from '../../../../src/app/dialogs/conditions-dialog.component'; +export { ResourceService } from '../../../../src/app/services/resource.service'; +export { CityForecastService } from '../../../../src/app/services/city-forecast.service'; +export { DefaultService } from '../../../../src/api/api/default.service'; +export { LocalDatePipe } from '../../../../src/app/pipes/location.pipes'; diff --git a/web-angular/projects/weather-forecast-today/src/assets/.gitkeep b/web-angular/projects/weather-forecast-today/src/assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/web-angular/projects/weather-forecast-today/src/environments/environment.prod.ts b/web-angular/projects/weather-forecast-today/src/environments/environment.prod.ts new file mode 100644 index 00000000..3612073b --- /dev/null +++ b/web-angular/projects/weather-forecast-today/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/web-angular/projects/weather-forecast-today/src/environments/environment.ts b/web-angular/projects/weather-forecast-today/src/environments/environment.ts new file mode 100644 index 00000000..7b4f817a --- /dev/null +++ b/web-angular/projects/weather-forecast-today/src/environments/environment.ts @@ -0,0 +1,16 @@ +// This file can be replaced during build by using the `fileReplacements` array. +// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. +// The list of file replacements can be found in `angular.json`. + +export const environment = { + production: false +}; + +/* + * For easier debugging in development mode, you can import the following file + * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. + * + * This import should be commented out in production mode because it will have a negative impact + * on performance if an error is thrown. + */ +// import 'zone.js/dist/zone-error'; // Included with Angular CLI. diff --git a/web-angular/projects/weather-forecast-today/src/favicon.ico b/web-angular/projects/weather-forecast-today/src/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..997406ad22c29aae95893fb3d666c30258a09537 GIT binary patch literal 948 zcmV;l155mgP)CBYU7IjCFmI-B}4sMJt3^s9NVg!P0 z6hDQy(L`XWMkB@zOLgN$4KYz;j0zZxq9KKdpZE#5@k0crP^5f9KO};h)ZDQ%ybhht z%t9#h|nu0K(bJ ztIkhEr!*UyrZWQ1k2+YkGqDi8Z<|mIN&$kzpKl{cNP=OQzXHz>vn+c)F)zO|Bou>E z2|-d_=qY#Y+yOu1a}XI?cU}%04)zz%anD(XZC{#~WreV!a$7k2Ug`?&CUEc0EtrkZ zL49MB)h!_K{H(*l_93D5tO0;BUnvYlo+;yss%n^&qjt6fZOa+}+FDO(~2>G z2dx@=JZ?DHP^;b7*Y1as5^uphBsh*s*z&MBd?e@I>-9kU>63PjP&^#5YTOb&x^6Cf z?674rmSHB5Fk!{Gv7rv!?qX#ei_L(XtwVqLX3L}$MI|kJ*w(rhx~tc&L&xP#?cQow zX_|gx$wMr3pRZIIr_;;O|8fAjd;1`nOeu5K(pCu7>^3E&D2OBBq?sYa(%S?GwG&_0-s%_v$L@R!5H_fc)lOb9ZoOO#p`Nn`KU z3LTTBtjwo`7(HA6 z7gmO$yTR!5L>Bsg!X8616{JUngg_@&85%>W=mChTR;x4`P=?PJ~oPuy5 zU-L`C@_!34D21{fD~Y8NVnR3t;aqZI3fIhmgmx}$oc-dKDC6Ap$Gy>a!`A*x2L1v0 WcZ@i?LyX}70000 + + + + WeatherForecastToday + + + + + + + + diff --git a/web-angular/projects/weather-forecast-today/src/main.ts b/web-angular/projects/weather-forecast-today/src/main.ts new file mode 100644 index 00000000..c7b673cf --- /dev/null +++ b/web-angular/projects/weather-forecast-today/src/main.ts @@ -0,0 +1,12 @@ +import { enableProdMode } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app/app.module'; +import { environment } from './environments/environment'; + +if (environment.production) { + enableProdMode(); +} + +platformBrowserDynamic().bootstrapModule(AppModule) + .catch(err => console.error(err)); diff --git a/web-angular/projects/weather-forecast-today/src/polyfills.ts b/web-angular/projects/weather-forecast-today/src/polyfills.ts new file mode 100644 index 00000000..32ad5eaf --- /dev/null +++ b/web-angular/projects/weather-forecast-today/src/polyfills.ts @@ -0,0 +1,64 @@ +/** + * This file includes polyfills needed by Angular and is loaded before the app. + * You can add your own extra polyfills to this file. + * + * This file is divided into 2 sections: + * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. + * 2. Application imports. Files imported after ZoneJS that should be loaded before your main + * file. + * + * The current setup is for so-called "evergreen" browsers; the last versions of browsers that + * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), + * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. + * + * Learn more in https://angular.io/guide/browser-support + */ + +/*************************************************************************************************** + * BROWSER POLYFILLS + */ + +/** IE10 and IE11 requires the following for NgClass support on SVG elements */ +// import 'classlist.js'; // Run `npm install --save classlist.js`. + +/** + * Web Animations `@angular/platform-browser/animations` + * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. + * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). + */ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + +/** + * By default, zone.js will patch all possible macroTask and DomEvents + * user can disable parts of macroTask/DomEvents patch by setting following flags + * because those flags need to be set before `zone.js` being loaded, and webpack + * will put import in the top of bundle, so user need to create a separate file + * in this directory (for example: zone-flags.ts), and put the following flags + * into that file, and then add the following code before importing zone.js. + * import './zone-flags'; + * + * The flags allowed in zone-flags.ts are listed here. + * + * The following flags will work for all browsers. + * + * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame + * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick + * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames + * + * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js + * with the following flag, it will bypass `zone.js` patch for IE/Edge + * + * (window as any).__Zone_enable_cross_context_check = true; + * + */ + +/*************************************************************************************************** + * Zone JS is required by default for Angular itself. + */ +import 'zone.js/dist/zone'; // Included with Angular CLI. + + +/*************************************************************************************************** + * APPLICATION IMPORTS + */ +import 'document-register-element'; diff --git a/web-angular/projects/weather-forecast-today/src/styles.scss b/web-angular/projects/weather-forecast-today/src/styles.scss new file mode 100644 index 00000000..90d4ee00 --- /dev/null +++ b/web-angular/projects/weather-forecast-today/src/styles.scss @@ -0,0 +1 @@ +/* You can add global styles to this file, and also import other style files */ diff --git a/web-angular/projects/weather-forecast-today/src/test.ts b/web-angular/projects/weather-forecast-today/src/test.ts new file mode 100644 index 00000000..50193eb0 --- /dev/null +++ b/web-angular/projects/weather-forecast-today/src/test.ts @@ -0,0 +1,25 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/zone-testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: { + context(path: string, deep?: boolean, filter?: RegExp): { + keys(): string[]; + (id: string): T; + }; +}; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); diff --git a/web-angular/projects/weather-forecast-today/tsconfig.app.json b/web-angular/projects/weather-forecast-today/tsconfig.app.json new file mode 100644 index 00000000..809c09ca --- /dev/null +++ b/web-angular/projects/weather-forecast-today/tsconfig.app.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/web-angular/projects/weather-forecast-today/tsconfig.spec.json b/web-angular/projects/weather-forecast-today/tsconfig.spec.json new file mode 100644 index 00000000..a8ce1d39 --- /dev/null +++ b/web-angular/projects/weather-forecast-today/tsconfig.spec.json @@ -0,0 +1,18 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "src/test.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/web-angular/projects/weather-forecast-today/tslint.json b/web-angular/projects/weather-forecast-today/tslint.json new file mode 100644 index 00000000..19e8161a --- /dev/null +++ b/web-angular/projects/weather-forecast-today/tslint.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tslint.json", + "rules": { + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ] + } +} diff --git a/web-angular/src/app/app.routing.ts b/web-angular/src/app/app.routing.ts index 7538c87e..6e9f3120 100644 --- a/web-angular/src/app/app.routing.ts +++ b/web-angular/src/app/app.routing.ts @@ -9,10 +9,15 @@ import { CityComponent, StateComponent, CountryComponent, CitiesComponent, Video import { UserDevicesComponent, UserAccountComponent, UserFavoritesComponent, UserDeviceComponent } from './views-user'; import { ManageLogComponent, ManageSystemComponent, ManageUsersComponent } from './views-manage'; import { CityResolver, StateResolver, CountryResolver, UserResolver, StationResolver, LanguageResolver, - BootstrapResolver, + BootstrapResolver, DeviceResolver} from './resolvers'; +// TODO: Remove +import { TestSiteComponent } from './test-site/test-site.component'; + export const routes: Routes = [ + // TODO: Remove + { path: 'web-test', component: TestSiteComponent }, // backwards compatibility { path: 'activate/:token', resolve: { bs: BootstrapResolver}, component: LoadingComponent }, { path: 'reset/:token', resolve: { bs: BootstrapResolver}, component: LoadingComponent }, diff --git a/web-angular/src/app/dialogs/conditions-dialog.component.ts b/web-angular/src/app/dialogs/conditions-dialog.component.ts index 70387daa..8643c959 100644 --- a/web-angular/src/app/dialogs/conditions-dialog.component.ts +++ b/web-angular/src/app/dialogs/conditions-dialog.component.ts @@ -2,7 +2,7 @@ import { Component, Inject } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog'; import { Observable } from 'rxjs'; import { WeatherCondition } from '../api'; -import { ResourceService } from '../services'; +import { ResourceService } from '../services/resource.service'; @Component({ selector: 'app-conditions-dialog', diff --git a/web-angular/src/app/pipes/location.pipes.ts b/web-angular/src/app/pipes/location.pipes.ts index 001d9639..706b4c5e 100644 --- a/web-angular/src/app/pipes/location.pipes.ts +++ b/web-angular/src/app/pipes/location.pipes.ts @@ -1,6 +1,6 @@ import { Pipe, PipeTransform } from '@angular/core'; import { Coordinate, City, LocationHierarchy } from '../api'; -import { ResourceService } from '../services'; +import { ResourceService } from '../services/resource.service'; /** * The pipe to render the url to bing maps. diff --git a/web-angular/src/app/widgets-weather/weather-summary.component.ts b/web-angular/src/app/widgets-weather/weather-summary.component.ts index 5b88f008..4abac493 100644 --- a/web-angular/src/app/widgets-weather/weather-summary.component.ts +++ b/web-angular/src/app/widgets-weather/weather-summary.component.ts @@ -1,9 +1,9 @@ import { Component, Input, OnChanges, SimpleChanges, OnInit } from '@angular/core'; -import { ResourceService } from '../services'; -import { WeatherCondition } from '../api'; -import { LocalTimePipe, LocalDatePipe } from '../pipes'; import { MatDialog } from '@angular/material/dialog'; -import { ConditionsDialogComponent } from '../dialogs'; +import { ResourceService } from '../services/resource.service'; +import { WeatherCondition } from '../api'; +import { LocalTimePipe, LocalDatePipe } from '../pipes/location.pipes'; +import { ConditionsDialogComponent } from '../dialogs/conditions-dialog.component'; /** * Implements a component to display a single @@ -26,8 +26,12 @@ export class WeatherSummaryComponent implements OnInit, OnChanges { displayTitle = ''; displaySubtitle = ''; - constructor(public res: ResourceService, private localTime: LocalTimePipe, private localDate: LocalDatePipe, - private dialog: MatDialog) { } + constructor( + public res: ResourceService, + private localTime: LocalTimePipe, + private localDate: LocalDatePipe, + private dialog: MatDialog + ) { } hasCondition() { return this.min != null && this.max != null; diff --git a/web-angular/src/polyfills.ts b/web-angular/src/polyfills.ts index 5b598b86..25339311 100644 --- a/web-angular/src/polyfills.ts +++ b/web-angular/src/polyfills.ts @@ -32,3 +32,4 @@ import 'zone.js/dist/zone'; // Included with Angular CLI. /*************************************************************************************************** * APPLICATION IMPORTS */ +import 'document-register-element';