From e0510755bc7079969d49eabb0824b3a4b6c29582 Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Wed, 9 Sep 2020 19:09:07 +0545 Subject: [PATCH 01/12] week1 --- .browserslistrc | 18 +++ .editorconfig | 16 ++ .gitignore | 50 +++++++ README.md | 27 ++++ Vagrantfile | 88 +++++++++++ angular.json | 134 +++++++++++++++++ couchdb-setup.sh | 128 ++++++++++++++++ e2e/src/app.e2e-spec.ts | 23 +++ e2e/src/app.po.ts | 11 ++ e2e/tsconfig.json | 14 ++ karma.conf.js | 32 ++++ package.json | 48 ++++++ src/app/app-routing.module.ts | 10 ++ src/app/app.component.html | 44 ++++++ src/app/app.component.scss | 0 src/app/app.component.spec.ts | 35 +++++ src/app/app.component.ts | 18 +++ src/app/app.module.ts | 29 ++++ src/assets/.gitkeep | 0 src/assets/cropped-ole-ico-logo-32x32.png | Bin 0 -> 1683 bytes src/environments/environment.prod.ts | 3 + src/environments/environment.ts | 16 ++ src/favicon.ico | Bin 0 -> 948 bytes src/index.html | 15 ++ src/main.ts | 12 ++ src/polyfills.ts | 63 ++++++++ src/styles.scss | 174 ++++++++++++++++++++++ src/test.ts | 25 ++++ tsconfig.app.json | 15 ++ tsconfig.base.json | 20 +++ tsconfig.json | 17 +++ tsconfig.spec.json | 18 +++ tslint.json | 152 +++++++++++++++++++ 33 files changed, 1255 insertions(+) create mode 100644 .browserslistrc create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 README.md create mode 100644 Vagrantfile create mode 100644 angular.json create mode 100755 couchdb-setup.sh create mode 100644 e2e/src/app.e2e-spec.ts create mode 100644 e2e/src/app.po.ts create mode 100644 e2e/tsconfig.json create mode 100644 karma.conf.js create mode 100644 package.json create mode 100644 src/app/app-routing.module.ts create mode 100644 src/app/app.component.html create mode 100644 src/app/app.component.scss create mode 100644 src/app/app.component.spec.ts create mode 100644 src/app/app.component.ts create mode 100644 src/app/app.module.ts create mode 100644 src/assets/.gitkeep create mode 100644 src/assets/cropped-ole-ico-logo-32x32.png create mode 100644 src/environments/environment.prod.ts create mode 100644 src/environments/environment.ts create mode 100644 src/favicon.ico create mode 100644 src/index.html create mode 100644 src/main.ts create mode 100644 src/polyfills.ts create mode 100644 src/styles.scss create mode 100644 src/test.ts create mode 100644 tsconfig.app.json create mode 100644 tsconfig.base.json create mode 100644 tsconfig.json create mode 100644 tsconfig.spec.json create mode 100644 tslint.json diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 0000000..0ccadaf --- /dev/null +++ b/.browserslistrc @@ -0,0 +1,18 @@ +# 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 + +# For the full list of supported browsers by the Angular framework, please see: +# https://angular.io/guide/browser-support + +# You can see what browsers were selected by your queries by running: +# npx browserslist + +last 1 Chrome version +last 1 Firefox version +last 2 Edge major versions +last 2 Safari major versions +last 2 iOS major versions +Firefox ESR +not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line. +not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..59d9a3a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# Editor configuration, see https://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.ts] +quote_type = single + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d38df41 --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp +/out-tsc + +# dependencies +/node_modules + +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.sass-cache +/connect.lock +/coverage +/libpeerconnection.log +npm-debug.log +testem.log +/typings + +# e2e +/e2e/*.js +/e2e/*.map + +# System Files +.DS_Store +Thumbs.db + +# Virtual Machine +.vagrant/ + +# NPM/Yarn +*.lock +package-lock.json + diff --git a/README.md b/README.md new file mode 100644 index 0000000..cac0e41 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Week1 + +This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.3. + +## Development server + +Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. + +## Code scaffolding + +Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. + +## Build + +Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. + +## Running unit tests + +Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Running end-to-end tests + +Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..2218c4f --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,88 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# The most common configuration options are documented and commented below. +# For a complete reference, please see the online documentation at +# https://docs.vagrantup.com. + +Vagrant.configure(2) do |config| + + if Vagrant.has_plugin?("vagrant-vbguest") + config.vbguest.auto_update = false + end + + BOX = "treehouses/buster64" + BOX_VERSION = "0.13.3" + + # planetlearingelopment VM + config.vm.define "planetlearing" do |planetlearing| + planetlearing.vm.box = BOX + planetlearing.vm.box_version = BOX_VERSION + + planetlearing.vm.hostname = "planetlearing" + + planetlearing.vm.provider "virtualbox" do |vb| + vb.name = "planetlearing" + end + + planetlearing.vm.provider "virtualbox" do |vb| + vb.memory = "1111" + end + + # Port expose for planetlearing server (5984:2200 = CouchDB 3000:3000 = App) + planetlearing.vm.network "forwarded_port", guest: 5984, host: 5200, auto_correct: true + planetlearing.vm.network "forwarded_port", guest: 4200, host: 5000, auto_correct: true + planetlearing.vm.network "forwarded_port", guest: 22, host: 5222, host_ip: "0.0.0.0", id: "ssh", auto_correct: true + + # Prevent TTY Errors (copied from laravel/homestead: "homestead.rb" file)... By default this is "bash -l". + planetlearing.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" + + planetlearing.vm.provision "shell", inline: <<-SHELL + # Add CouchDB Docker + sudo docker run -d -p 5984:5984 --name planet \ + -v /srv/planetlearning/conf:/opt/couchdb/etc/local.d \ + -v /srv/planetlearning/data:/opt/couchdb/data \ + -v /srv/planetlearning/log:/opt/couchdb/var/log/ \ + treehouses/couchdb:2.3.1 + + # Add CORS to CouchDB so app has access to databases + #git clone https://github.com/pouchdb/add-cors-to-couchdb.git + #cd add-cors-to-couchdb + #npm install + cd add-cors-to-couchdb + while ! curl -X GET http://127.0.0.1:5984/_all_dbs ; do sleep 1; done + node bin.js http://localhost:5984 + cd /vagrant + # End add CORS to CouchDB + + curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/log/file -d '"/opt/couchdb/var/log/couch.log"' + curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/log/writer -d '"file"' + curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/chttpd/authentication_handlers -d '"{chttpd_auth, cookie_authentication_handler}, {chttpd_auth, proxy_authentication_handler}, {chttpd_auth, default_authentication_handler}"' + + docker restart planet + + # node_modules folder breaks when setting up in Windows, so use binding to fix + #echo "Preparing local node_modules folder…" + #mkdir -p /vagrant_node_modules + mkdir -p /vagrant/node_modules + chown vagrant:vagrant /vagrant_node_modules + mount --bind /vagrant_node_modules /vagrant/node_modules + npm i --unsafe-perm + #sudo npm run webdriver-set-version + # End node_modules fix + + # Add initial Couch databases here + chmod +x couchdb-setup.sh + . couchdb-setup.sh -p 5984 -i + # End Couch database addition + SHELL + + # Run binding on each startup make sure the mount is available on VM restart + planetlearing.vm.provision "shell", run: "always", inline: <<-SHELL + mount --bind /vagrant_node_modules /vagrant/node_modules + # Starts the app in a screen (virtual terminal) + sudo -u vagrant screen -dmS build bash -c 'cd /vagrant; ng serve --host=0.0.0.0 --poll=2000' + SHELL + end + +end diff --git a/angular.json b/angular.json new file mode 100644 index 0000000..4961888 --- /dev/null +++ b/angular.json @@ -0,0 +1,134 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "week1": { + "projectType": "application", + "schematics": { + "@schematics/angular:component": { + "style": "scss" + } + }, + "root": "", + "sourceRoot": "src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/week1", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.app.json", + "aot": true, + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", + "src/styles.scss" + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "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": "week1:build" + }, + "configurations": { + "production": { + "browserTarget": "week1:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "week1:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", + "src/styles.scss" + ], + "scripts": [] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "tsconfig.app.json", + "tsconfig.spec.json", + "e2e/tsconfig.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + }, + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "week1:serve" + }, + "configurations": { + "production": { + "devServerTarget": "week1:serve:production" + } + } + } + } + } + }, + "defaultProject": "week1", + "cli": { + "analytics": false + } +} \ No newline at end of file diff --git a/couchdb-setup.sh b/couchdb-setup.sh new file mode 100755 index 0000000..5d55ca4 --- /dev/null +++ b/couchdb-setup.sh @@ -0,0 +1,128 @@ +#!/bin/bash + +# Function for upsert of design & other configuration docs +upsert_doc() { + DB=$1 + DOC_NAME=$2 + DOC_LOC=$3 + # Default method is PUT, fourth argument overrides + METHOD=${4:-"PUT"} + DOC=$(curl $COUCHURL/$DB/$DOC_NAME $PROXYHEADER) + # If DOC includes a rev then it exists so we need to update + # Otherwise we simply insert + if [[ $DOC == *rev* ]]; then + DOC_REV=$(echo $DOC | jq -r '. | ._rev') + curl -H 'Content-Type: application/json' -X $METHOD $COUCHURL/$DB/$DOC_NAME?rev=$DOC_REV -d $DOC_LOC $PROXYHEADER + else + curl -H 'Content-Type: application/json' -X $METHOD $COUCHURL/$DB/$DOC_NAME -d $DOC_LOC $PROXYHEADER + fi +} + +# Function for insert mock data docs +insert_docs() { + DB=$1 + DOC_LOC=$2 + curl -H 'Content-Type: application/json' -X POST $COUCHURL/$DB/_bulk_docs -d @$DOC_LOC $PROXYHEADER +} + +# Function to add databases +insert_dbs() { + DBS=$1 + for DB in "${DBS[@]}" + do + curl -X PUT $COUCHURL/$DB $PROXYHEADER + done +} + +# Options are -u for username -w for passWord and -p for port number +while getopts "u:w:p:h:ix" option; do + case $option in + u) COUCHUSER=${OPTARG};; + w) COUCHPASSWORD=${OPTARG};; + p) PORT=${OPTARG};; + h) HOST=${OPTARG};; + i) INSTALLFLAG=1;; + x) PROXYHEADER="-H X-Auth-CouchDB-Roles:_admin -H X-Auth-CouchDB-UserName:username";; + esac +done + +ISINSTALL=${INSTALLFLAG:-0} +echo $ISINSTALL +if [ -z "$HOST" ] +then + HOST=127.0.0.1 +fi + +# Default port for CouchDB accessed from host machine is 2200 +PORT=${PORT:-2200} +if [ -z "$COUCHUSER" ] +then + COUCHURL=http://$HOST:$PORT +else + COUCHURL=http://$COUCHUSER:$COUCHPASSWORD@$HOST:$PORT +fi + +# Adding attachments to database documents +# To add attachment added two file (resources-mock.json and resources-attachment-mockup.json) +# Ids must match between two files +insert_attachments() { + DB=$1 + DOC_LOC=$2 + # Use echo $(<$DOC_LOC) to be able to run in Windows + INPUTS=$(echo $(<$DOC_LOC) | jq -c '.[]') + for i in $INPUTS + do + ID=$(echo $i | jq -r '.doc_id' ) + FILE_NAME=$(echo $i | jq -r '.file_name') + FILE_LOCATION=$(echo $i | jq -r '.file_location') + FILE_TYPE=$(echo $i | jq -r '.file_type') + REV=$(curl $COUCHURL/$DB/$ID | jq -r '._rev' $PROXYHEADER) + curl -X PUT $COUCHURL/$DB/$ID/$FILE_NAME?rev=$REV --data-binary @$FILE_LOCATION -H Content-Type:$FILE_TYPE $PROXYHEADER + done +} + +# Reads one JSON file to update multiple databases +# JSON file needs a 'dbName' field with a string and +# a 'json' field with the JSON to be updated +multi_db_update() { + DOC_LOC=$1 + DOC_NAME=$2 + INPUTS=$(echo $DOC_LOC | jq -c '.[]') + for i in $INPUTS + do + JSON=$(echo $i | jq -c '. | .json' ) + DB_NAME=$(echo $i | jq -r '. | .dbName') + upsert_doc $DB_NAME $DOC_NAME $JSON + done +} + +DBS=( + # CouchDB standard databases + "_users" + "_replicator" + "_global_changes" + # Planetlearning databases + "messages" +) + +insert_dbs $DBS + +# Increase session timeout +upsert_doc _node/nonode@nohost/_config couch_httpd_auth/timeout '"2400"' +# Increse http request size for large attachments +upsert_doc _node/nonode@nohost/_config httpd/max_http_request_size '"1073741824"' +# Increse replication timeout +upsert_doc _node/nonode@nohost/_config replicator/connection_timeout '"300000"' + +# Make user database public +upsert_doc _node/nonode@nohost/_config couch_httpd_auth/users_db_public '"true"' +# Specify user public fields (note: adding spaces to string breaks upsert_doc) +upsert_doc _node/nonode@nohost/_config couch_httpd_auth/public_fields '"name"' + +# Only insert dummy data and update security on install +# _users security is set in app and auto accept will be overwritten if set here +if (($ISINSTALL)) +then + # Insert dummy data docs + upsert_doc _node/nonode@nohost/_config admins/user '"password"' +fi diff --git a/e2e/src/app.e2e-spec.ts b/e2e/src/app.e2e-spec.ts new file mode 100644 index 0000000..a752e8a --- /dev/null +++ b/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('week1 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/e2e/src/app.po.ts b/e2e/src/app.po.ts new file mode 100644 index 0000000..b68475e --- /dev/null +++ b/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/e2e/tsconfig.json b/e2e/tsconfig.json new file mode 100644 index 0000000..1807fd6 --- /dev/null +++ b/e2e/tsconfig.json @@ -0,0 +1,14 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es2018", + "types": [ + "jasmine", + "jasminewd2", + "node" + ] + } +} diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..173487c --- /dev/null +++ b/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/week1'), + 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/package.json b/package.json new file mode 100644 index 0000000..1843830 --- /dev/null +++ b/package.json @@ -0,0 +1,48 @@ +{ + "name": "week1", + "version": "0.0.0", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e" + }, + "private": true, + "dependencies": { + "@angular/animations": "~10.0.4", + "@angular/cdk": "^10.2.0", + "@angular/common": "~10.0.4", + "@angular/compiler": "~10.0.4", + "@angular/core": "~10.0.4", + "@angular/forms": "~10.0.4", + "@angular/material": "^10.2.0", + "@angular/platform-browser": "~10.0.4", + "@angular/platform-browser-dynamic": "~10.0.4", + "@angular/router": "~10.0.4", + "rxjs": "~6.5.5", + "tslib": "^2.0.0", + "zone.js": "~0.10.3" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.1000.3", + "@angular/cli": "~10.0.3", + "@angular/compiler-cli": "~10.0.4", + "@types/node": "^12.11.1", + "@types/jasmine": "~3.5.0", + "@types/jasminewd2": "~2.0.3", + "codelyzer": "^6.0.0", + "jasmine-core": "~3.5.0", + "jasmine-spec-reporter": "~5.0.0", + "karma": "~5.0.0", + "karma-chrome-launcher": "~3.1.0", + "karma-coverage-istanbul-reporter": "~3.0.2", + "karma-jasmine": "~3.3.0", + "karma-jasmine-html-reporter": "^1.5.0", + "protractor": "~7.0.0", + "ts-node": "~8.3.0", + "tslint": "~6.1.0", + "typescript": "~3.9.5" + } +} diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts new file mode 100644 index 0000000..d425c6f --- /dev/null +++ b/src/app/app-routing.module.ts @@ -0,0 +1,10 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +const routes: Routes = []; + +@NgModule({ + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule] +}) +export class AppRoutingModule { } diff --git a/src/app/app.component.html b/src/app/app.component.html new file mode 100644 index 0000000..0eb97e0 --- /dev/null +++ b/src/app/app.component.html @@ -0,0 +1,44 @@ + + + Planet Learning + + + +
+ + + + +
+ +
+ + + +
+
+
+ + Username + + + + Password + + +
+
+
+ +
+ + {{d.name}} + +
+ + +
+ + \ No newline at end of file diff --git a/src/app/app.component.scss b/src/app/app.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts new file mode 100644 index 0000000..23e693c --- /dev/null +++ b/src/app/app.component.spec.ts @@ -0,0 +1,35 @@ +import { TestBed, async } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + RouterTestingModule + ], + declarations: [ + AppComponent + ], + }).compileComponents(); + })); + + it('should create the app', () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app).toBeTruthy(); + }); + + it(`should have as title 'week1'`, () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app.title).toEqual('week1'); + }); + + it('should render title', () => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.nativeElement; + expect(compiled.querySelector('.content span').textContent).toContain('week1 app is running!'); + }); +}); diff --git a/src/app/app.component.ts b/src/app/app.component.ts new file mode 100644 index 0000000..2f3d3fc --- /dev/null +++ b/src/app/app.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.scss'] +}) +export class AppComponent { + title = 'week1'; + + data = [{ + name: 'ok' + }]; + + login() { + + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts new file mode 100644 index 0000000..e07af50 --- /dev/null +++ b/src/app/app.module.ts @@ -0,0 +1,29 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; + +import { AppRoutingModule } from './app-routing.module'; +import { AppComponent } from './app.component'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; + +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { MatToolbarModule } from '@angular/material/toolbar'; + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ + BrowserModule, + AppRoutingModule, + BrowserAnimationsModule, + MatFormFieldModule, + MatIconModule, + MatInputModule, + MatToolbarModule + ], + providers: [], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/src/assets/.gitkeep b/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/assets/cropped-ole-ico-logo-32x32.png b/src/assets/cropped-ole-ico-logo-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..aafe29fb672578dbf07cfa22a112fef9af172312 GIT binary patch literal 1683 zcmV;E25k9>P)M29b!>jgzE!p!ABl9WUW2$Xj?{lWFqp9I3>yPf@Zo_(L^ zzV7?JuIs)V4s^x(ntotXU*7FL!fzRVs{1{hb6=o*j z8Tb!w#LBei6WE4-9*hbO!(?>fdS!jSvL2zVkH@k3;GeMo8*o|fPR2lNL?`Y|wxw^*>uZ$t zBxQZHver=6=U@mn2f!pu!4uK_$v81;=$oM3$@*?wf?29!OOol43N%vLo&o#qeE)m+ z8RlR_18>8Ol<>3=>^58+^O=HKn2&oSu^TWk!5>f+J6fvRE7F60Y0<>AZ9sta#)mPz zfuCYJPQh>REeyrWs^Za*?y6L#8T6aDzoWf#XGeSIn2vd)kL#E>x=G%)WGw+th>`W) ztNm?gZ>WmhSc)%VaWbBZ3zc;*RY6tkQWaZN#paIo&K@1@o$v2x@9dk_&A~M-L3f6H z5_CAW?}vli_K>hDn#S@~+!a5ciK~?LtA3v>Cxwh1alZk042_O?qmLPL%7R^39-g#? z)W1t>ThC71{+bc(0nudi<8iX-xI$SUmRsFeg5SsEC*_^K0etI8$1Xh*zin~9QSpfD z@%L0`b?)EtdMDfiVmWRO;{KU>XGdOb88SB|tBW#dzK+uqs4pIggEo2a@i70q%!iL) zDpoh5(LT!hG-drkyd%0_kcSs z9zylQJJb6C_*2X1J@e`3N3F|Dm>R=53ctt<7#1lv+qna?^R0i!nmaM56+|P`tmj?~ zJpyC!#}+mZTk^~~J-Ws(S(|64VqN~4#&t*6_$A#fAhyIuu8h<#$aeMWI@j3Gve9(3 zC$OcZ3QeH9(zc7SqHEE#ZC#6|E$&)0ZKtyCtE_t~>mJIQs@RTsnT|7(*i4L6){O=p zPDZU~YozvUdMJaX8@k3X>Fyf8WNp`?X-m5nP3sv}-<)>b8AqLsFDdKyq_ry|#R=IP zrsK1XNa+3q-5sLMLXH2nxZ1y7=V*Jp;avPOThP>ed|c#qS%^75g#Jug`t9qA zcc_Y4s^URa@k*rBGb42!9#a*Rb*~Jk={Pz;*W$ALkGW|ax0Y-&8t5wCS7|-4Dg-cs^%mV>1!G9_Wd=Brzud^4-j~RU-1k*Bx zFNs|{n4NH6=kQqTEUd-5y|(vH!SXDi&Bb+J?+-l`0K@HBsqcyHPL71G! zyuUpb{H6i?BMaoFaN(pde|1Z6k=ndSR?FV-aLnvY0;q}?RK;@%HZ(z=+$(s~HE&9* zUW$L*nT2J|fdKpu3W?&Z>5BAr0000bbVXQnWMOn=I%9HWVRU5xGB7bWEig4LGcZ&! zFgi3gIx;dXFgH3dFw9Jt@&Et;C3HntbYx+4WjbwdWNBu305UK!H!UzVEi*7wF)%tb dHaapgEigAaFfhFlAWi@P002ovPDHLkV1kBSD>DE9 literal 0 HcmV?d00001 diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts new file mode 100644 index 0000000..3612073 --- /dev/null +++ b/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts new file mode 100644 index 0000000..7b4f817 --- /dev/null +++ b/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/src/favicon.ico b/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 + + + + Week1 + + + + + + + + + + diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..c7b673c --- /dev/null +++ b/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/src/polyfills.ts b/src/polyfills.ts new file mode 100644 index 0000000..03711e5 --- /dev/null +++ b/src/polyfills.ts @@ -0,0 +1,63 @@ +/** + * 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 + */ diff --git a/src/styles.scss b/src/styles.scss new file mode 100644 index 0000000..022444b --- /dev/null +++ b/src/styles.scss @@ -0,0 +1,174 @@ +/* You can add global styles to this file, and also import other style files */ + +html, body { height: 100%; } +body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } + +h1, h2, h3, h4, h5, h6 { + margin: 8px 0; +} + +p { + margin: 0; +} + +.spacer { + flex: 1; +} + +.mat-toolbar { + position: absolute; + top: 0; + left: 0; + right: 0; + height: 60px; + display: flex; + align-items: center; + background-color: #1976d2; + color: white; + font-weight: 600; + + img { + margin: 0 16px; + } +} + +.content { + display: flex; + margin: 82px auto 32px; + padding: 0 16px; + max-width: 960px; + flex-direction: column; + align-items: center; +} + +svg.material-icons { + height: 24px; + width: auto; +} + +svg.material-icons:not(:last-child) { + margin-right: 8px; +} + +.card svg.material-icons path { + fill: #888; +} + +.card-container { + display: flex; + flex-wrap: wrap; + justify-content: center; + margin-top: 16px; +} + +.card { + border-radius: 4px; + border: 1px solid #eee; + background-color: #fafafa; + height: 40px; + width: 200px; + margin: 0 8px 16px; + padding: 16px; + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + transition: all 0.2s ease-in-out; + line-height: 24px; +} + +.card-container .card:not(:last-child) { + margin-right: 0; +} + +.card.card-small { + height: 16px; + width: 168px; +} + +.card-container .card:not(.highlight-card) { + cursor: pointer; +} + +.card-container .card:not(.highlight-card):hover { + transform: translateY(-3px); + box-shadow: 0 4px 17px rgba(0, 0, 0, 0.35); + .material-icons path { + fill: rgb(105, 103, 103); + } +} + +.card.highlight-card { + background-color: #1976d2; + color: white; + font-weight: 600; + border: none; + width: auto; + min-width: 30%; + position: relative; + + span { + margin-left: 60px; + } +} + +a, +a:visited, +a:hover { + color: #1976d2; + text-decoration: none; +} + +a:hover { + color: #125699; +} + +.circle-link { + height: 40px; + width: 40px; + border-radius: 40px; + margin: 8px; + background-color: white; + border: 1px solid #eeeeee; + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); + transition: 1s ease-out; +} + +.circle-link:hover { + transform: translateY(-0.25rem); + box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2); +} + +footer { + margin-top: 8px; + display: flex; + align-items: center; + line-height: 20px; + + a { + display: flex; + align-items: center; + } +} + +/* Responsive Styles */ +@media screen and (max-width: 767px) { + + .card-container > *:not(.circle-link) { + width: 100%; + } + + .card:not(.highlight-card) { + height: 16px; + margin: 8px 0; + } + + .card.highlight-card span { + margin-left: 72px; + } + +} diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 0000000..50193eb --- /dev/null +++ b/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/tsconfig.app.json b/tsconfig.app.json new file mode 100644 index 0000000..232c3a5 --- /dev/null +++ b/tsconfig.app.json @@ -0,0 +1,15 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..f69f654 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,20 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "moduleResolution": "node", + "importHelpers": true, + "target": "es2015", + "module": "es2020", + "lib": [ + "es2018", + "dom" + ] + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..2338536 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +/* + This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience. + It is not intended to be used to perform a compilation. + + To learn more about this file see: https://angular.io/config/solution-tsconfig. +*/ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.spec.json" + } +] +} diff --git a/tsconfig.spec.json b/tsconfig.spec.json new file mode 100644 index 0000000..729a6d6 --- /dev/null +++ b/tsconfig.spec.json @@ -0,0 +1,18 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "outDir": "./out-tsc/spec", + "types": [ + "jasmine" + ] + }, + "files": [ + "src/test.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..67bcdea --- /dev/null +++ b/tslint.json @@ -0,0 +1,152 @@ +{ + "extends": "tslint:recommended", + "rules": { + "align": { + "options": [ + "parameters", + "statements" + ] + }, + "array-type": false, + "arrow-return-shorthand": true, + "curly": true, + "deprecation": { + "severity": "warning" + }, + "component-class-suffix": true, + "contextual-lifecycle": true, + "directive-class-suffix": true, + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], + "eofline": true, + "import-blacklist": [ + true, + "rxjs/Rx" + ], + "import-spacing": true, + "indent": { + "options": [ + "spaces" + ] + }, + "max-classes-per-file": false, + "max-line-length": [ + true, + 140 + ], + "member-ordering": [ + true, + { + "order": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } + ], + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-empty": false, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-non-null-assertion": true, + "no-redundant-jsdoc": true, + "no-switch-case-fall-through": true, + "no-var-requires": false, + "object-literal-key-quotes": [ + true, + "as-needed" + ], + "quotemark": [ + true, + "single" + ], + "semicolon": { + "options": [ + "always" + ] + }, + "space-before-function-paren": { + "options": { + "anonymous": "never", + "asyncArrow": "always", + "constructor": "never", + "method": "never", + "named": "never" + } + }, + "typedef": [ + true, + "call-signature" + ], + "typedef-whitespace": { + "options": [ + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + } + ] + }, + "variable-name": { + "options": [ + "ban-keywords", + "check-format", + "allow-pascal-case" + ] + }, + "whitespace": { + "options": [ + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type", + "check-typecast" + ] + }, + "no-conflicting-lifecycle": true, + "no-host-metadata-property": true, + "no-input-rename": true, + "no-inputs-metadata-property": true, + "no-output-native": true, + "no-output-on-prefix": true, + "no-output-rename": true, + "no-outputs-metadata-property": true, + "template-banana-in-box": true, + "template-no-negated-async": true, + "use-lifecycle-interface": true, + "use-pipe-transform-interface": true + }, + "rulesDirectory": [ + "codelyzer" + ] +} \ No newline at end of file From d9ab56fb49ba47996bf733d3211b336e9b10eea2 Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Wed, 9 Sep 2020 22:18:43 +0545 Subject: [PATCH 02/12] adding http --- src/app/app.component.html | 3 +-- src/app/app.component.ts | 14 ++++++++++---- src/app/app.module.ts | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 0eb97e0..756b248 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -27,14 +27,13 @@ Password - +
- {{d.name}}
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2f3d3fc..0f16796 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { HttpHeaders, HttpClient } from '@angular/common/http'; @Component({ selector: 'app-root', @@ -7,12 +8,17 @@ import { Component } from '@angular/core'; }) export class AppComponent { title = 'week1'; + username: string; + password: string; + data: [ any ]; - data = [{ - name: 'ok' - }]; + constructor( + private http: HttpClient + ) {} login() { - + const httpOpts = { headers: new HttpHeaders().set('Content-Type', 'application/json') }; + this.http.post('http://localhost:5200/_session', { }, httpOpts) + .subscribe(); } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index e07af50..716621a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -5,6 +5,8 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { HttpClientModule } from '@angular/common/http'; + import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; @@ -18,6 +20,7 @@ import { MatToolbarModule } from '@angular/material/toolbar'; BrowserModule, AppRoutingModule, BrowserAnimationsModule, + HttpClientModule, MatFormFieldModule, MatIconModule, MatInputModule, From 0465cf74e08496b8f5e6e7d40c4e7f0a9a0b7260 Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Mon, 14 Sep 2020 17:39:05 +0545 Subject: [PATCH 03/12] update vagrant file --- Vagrantfile | 10 ++++++++-- src/app/app.component.ts | 11 +++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 2218c4f..cfb2186 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -39,7 +39,7 @@ Vagrant.configure(2) do |config| planetlearing.vm.provision "shell", inline: <<-SHELL # Add CouchDB Docker - sudo docker run -d -p 5984:5984 --name planet \ + sudo docker run -d -p 5984:5984 --name planetlearning \ -v /srv/planetlearning/conf:/opt/couchdb/etc/local.d \ -v /srv/planetlearning/data:/opt/couchdb/data \ -v /srv/planetlearning/log:/opt/couchdb/var/log/ \ @@ -59,7 +59,7 @@ Vagrant.configure(2) do |config| curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/log/writer -d '"file"' curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/chttpd/authentication_handlers -d '"{chttpd_auth, cookie_authentication_handler}, {chttpd_auth, proxy_authentication_handler}, {chttpd_auth, default_authentication_handler}"' - docker restart planet + docker restart planetlearning # node_modules folder breaks when setting up in Windows, so use binding to fix #echo "Preparing local node_modules folder…" @@ -79,6 +79,12 @@ Vagrant.configure(2) do |config| # Run binding on each startup make sure the mount is available on VM restart planetlearing.vm.provision "shell", run: "always", inline: <<-SHELL + if [ $(docker inspect -f '{{.State.Running}}' planetlearning) = "false" ]; then + docker start planetlearning + while ! curl -X GET http://127.0.0.1:5984/_all_dbs ; do sleep 1; done + cd /vagrant + . couchdb-setup.sh -p 5984 -x + fi mount --bind /vagrant_node_modules /vagrant/node_modules # Starts the app in a screen (virtual terminal) sudo -u vagrant screen -dmS build bash -c 'cd /vagrant; ng serve --host=0.0.0.0 --poll=2000' diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 0f16796..f961bdb 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -7,16 +7,19 @@ import { HttpHeaders, HttpClient } from '@angular/common/http'; styleUrls: ['./app.component.scss'] }) export class AppComponent { + title = 'week1'; - username: string; - password: string; - data: [ any ]; + + data: [ { + name: string, + message: string + } ]; constructor( private http: HttpClient ) {} - login() { + login(form) { const httpOpts = { headers: new HttpHeaders().set('Content-Type', 'application/json') }; this.http.post('http://localhost:5200/_session', { }, httpOpts) .subscribe(); From 64c1a3052a0552a2e1a4d55007b6c486dd53ee6d Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Mon, 14 Sep 2020 18:30:36 +0545 Subject: [PATCH 04/12] week1 folder --- .gitignore | 18 +++++------ .browserslistrc => week1/.browserslistrc | 0 README.md => week1/README.md | 0 Vagrantfile => week1/Vagrantfile | 30 +++++++++--------- angular.json => week1/angular.json | 0 couchdb-setup.sh => week1/couchdb-setup.sh | 0 {e2e => week1/e2e}/src/app.e2e-spec.ts | 0 {e2e => week1/e2e}/src/app.po.ts | 0 {e2e => week1/e2e}/tsconfig.json | 0 karma.conf.js => week1/karma.conf.js | 0 package.json => week1/package.json | 0 {src => week1/src}/app/app-routing.module.ts | 0 {src => week1/src}/app/app.component.html | 0 {src => week1/src}/app/app.component.scss | 0 {src => week1/src}/app/app.component.spec.ts | 0 {src => week1/src}/app/app.component.ts | 0 {src => week1/src}/app/app.module.ts | 0 {src => week1/src}/assets/.gitkeep | 0 .../assets/cropped-ole-ico-logo-32x32.png | Bin .../src}/environments/environment.prod.ts | 0 .../src}/environments/environment.ts | 0 {src => week1/src}/favicon.ico | Bin {src => week1/src}/index.html | 0 {src => week1/src}/main.ts | 0 {src => week1/src}/polyfills.ts | 0 {src => week1/src}/styles.scss | 0 {src => week1/src}/test.ts | 0 tsconfig.app.json => week1/tsconfig.app.json | 0 .../tsconfig.base.json | 0 tsconfig.json => week1/tsconfig.json | 0 .../tsconfig.spec.json | 0 tslint.json => week1/tslint.json | 0 32 files changed, 24 insertions(+), 24 deletions(-) rename .browserslistrc => week1/.browserslistrc (100%) rename README.md => week1/README.md (100%) rename Vagrantfile => week1/Vagrantfile (74%) rename angular.json => week1/angular.json (100%) rename couchdb-setup.sh => week1/couchdb-setup.sh (100%) rename {e2e => week1/e2e}/src/app.e2e-spec.ts (100%) rename {e2e => week1/e2e}/src/app.po.ts (100%) rename {e2e => week1/e2e}/tsconfig.json (100%) rename karma.conf.js => week1/karma.conf.js (100%) rename package.json => week1/package.json (100%) rename {src => week1/src}/app/app-routing.module.ts (100%) rename {src => week1/src}/app/app.component.html (100%) rename {src => week1/src}/app/app.component.scss (100%) rename {src => week1/src}/app/app.component.spec.ts (100%) rename {src => week1/src}/app/app.component.ts (100%) rename {src => week1/src}/app/app.module.ts (100%) rename {src => week1/src}/assets/.gitkeep (100%) rename {src => week1/src}/assets/cropped-ole-ico-logo-32x32.png (100%) rename {src => week1/src}/environments/environment.prod.ts (100%) rename {src => week1/src}/environments/environment.ts (100%) rename {src => week1/src}/favicon.ico (100%) rename {src => week1/src}/index.html (100%) rename {src => week1/src}/main.ts (100%) rename {src => week1/src}/polyfills.ts (100%) rename {src => week1/src}/styles.scss (100%) rename {src => week1/src}/test.ts (100%) rename tsconfig.app.json => week1/tsconfig.app.json (100%) rename tsconfig.base.json => week1/tsconfig.base.json (100%) rename tsconfig.json => week1/tsconfig.json (100%) rename tsconfig.spec.json => week1/tsconfig.spec.json (100%) rename tslint.json => week1/tslint.json (100%) diff --git a/.gitignore b/.gitignore index d38df41..6e9dd69 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,12 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. # compiled output -/dist -/tmp -/out-tsc +/*/dist +/*/tmp +/*/out-tsc # dependencies -/node_modules +/*/node_modules # IDEs and editors /.idea @@ -34,17 +34,17 @@ testem.log /typings # e2e -/e2e/*.js -/e2e/*.map +/*/e2e/*.js +/*/e2e/*.map # System Files .DS_Store Thumbs.db # Virtual Machine -.vagrant/ +/*/.vagrant/ # NPM/Yarn -*.lock -package-lock.json +/*/*.lock +/*/package-lock.json diff --git a/.browserslistrc b/week1/.browserslistrc similarity index 100% rename from .browserslistrc rename to week1/.browserslistrc diff --git a/README.md b/week1/README.md similarity index 100% rename from README.md rename to week1/README.md diff --git a/Vagrantfile b/week1/Vagrantfile similarity index 74% rename from Vagrantfile rename to week1/Vagrantfile index cfb2186..d2d1d37 100644 --- a/Vagrantfile +++ b/week1/Vagrantfile @@ -14,30 +14,30 @@ Vagrant.configure(2) do |config| BOX = "treehouses/buster64" BOX_VERSION = "0.13.3" - # planetlearingelopment VM - config.vm.define "planetlearing" do |planetlearing| - planetlearing.vm.box = BOX - planetlearing.vm.box_version = BOX_VERSION + # planetlearning1elopment VM + config.vm.define "planetlearning1" do |planetlearning1| + planetlearning1.vm.box = BOX + planetlearning1.vm.box_version = BOX_VERSION - planetlearing.vm.hostname = "planetlearing" + planetlearning1.vm.hostname = "planetlearning1" - planetlearing.vm.provider "virtualbox" do |vb| - vb.name = "planetlearing" + planetlearning1.vm.provider "virtualbox" do |vb| + vb.name = "planetlearning1" end - planetlearing.vm.provider "virtualbox" do |vb| + planetlearning1.vm.provider "virtualbox" do |vb| vb.memory = "1111" end - # Port expose for planetlearing server (5984:2200 = CouchDB 3000:3000 = App) - planetlearing.vm.network "forwarded_port", guest: 5984, host: 5200, auto_correct: true - planetlearing.vm.network "forwarded_port", guest: 4200, host: 5000, auto_correct: true - planetlearing.vm.network "forwarded_port", guest: 22, host: 5222, host_ip: "0.0.0.0", id: "ssh", auto_correct: true + # Port expose for planetlearning1 server (5984:2200 = CouchDB 3000:3000 = App) + planetlearning1.vm.network "forwarded_port", guest: 5984, host: 5201, auto_correct: true + planetlearning1.vm.network "forwarded_port", guest: 4200, host: 5001, auto_correct: true + planetlearning1.vm.network "forwarded_port", guest: 22, host: 5222, host_ip: "0.0.0.0", id: "ssh", auto_correct: true # Prevent TTY Errors (copied from laravel/homestead: "homestead.rb" file)... By default this is "bash -l". - planetlearing.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" + planetlearning1.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" - planetlearing.vm.provision "shell", inline: <<-SHELL + planetlearning1.vm.provision "shell", inline: <<-SHELL # Add CouchDB Docker sudo docker run -d -p 5984:5984 --name planetlearning \ -v /srv/planetlearning/conf:/opt/couchdb/etc/local.d \ @@ -78,7 +78,7 @@ Vagrant.configure(2) do |config| SHELL # Run binding on each startup make sure the mount is available on VM restart - planetlearing.vm.provision "shell", run: "always", inline: <<-SHELL + planetlearning1.vm.provision "shell", run: "always", inline: <<-SHELL if [ $(docker inspect -f '{{.State.Running}}' planetlearning) = "false" ]; then docker start planetlearning while ! curl -X GET http://127.0.0.1:5984/_all_dbs ; do sleep 1; done diff --git a/angular.json b/week1/angular.json similarity index 100% rename from angular.json rename to week1/angular.json diff --git a/couchdb-setup.sh b/week1/couchdb-setup.sh similarity index 100% rename from couchdb-setup.sh rename to week1/couchdb-setup.sh diff --git a/e2e/src/app.e2e-spec.ts b/week1/e2e/src/app.e2e-spec.ts similarity index 100% rename from e2e/src/app.e2e-spec.ts rename to week1/e2e/src/app.e2e-spec.ts diff --git a/e2e/src/app.po.ts b/week1/e2e/src/app.po.ts similarity index 100% rename from e2e/src/app.po.ts rename to week1/e2e/src/app.po.ts diff --git a/e2e/tsconfig.json b/week1/e2e/tsconfig.json similarity index 100% rename from e2e/tsconfig.json rename to week1/e2e/tsconfig.json diff --git a/karma.conf.js b/week1/karma.conf.js similarity index 100% rename from karma.conf.js rename to week1/karma.conf.js diff --git a/package.json b/week1/package.json similarity index 100% rename from package.json rename to week1/package.json diff --git a/src/app/app-routing.module.ts b/week1/src/app/app-routing.module.ts similarity index 100% rename from src/app/app-routing.module.ts rename to week1/src/app/app-routing.module.ts diff --git a/src/app/app.component.html b/week1/src/app/app.component.html similarity index 100% rename from src/app/app.component.html rename to week1/src/app/app.component.html diff --git a/src/app/app.component.scss b/week1/src/app/app.component.scss similarity index 100% rename from src/app/app.component.scss rename to week1/src/app/app.component.scss diff --git a/src/app/app.component.spec.ts b/week1/src/app/app.component.spec.ts similarity index 100% rename from src/app/app.component.spec.ts rename to week1/src/app/app.component.spec.ts diff --git a/src/app/app.component.ts b/week1/src/app/app.component.ts similarity index 100% rename from src/app/app.component.ts rename to week1/src/app/app.component.ts diff --git a/src/app/app.module.ts b/week1/src/app/app.module.ts similarity index 100% rename from src/app/app.module.ts rename to week1/src/app/app.module.ts diff --git a/src/assets/.gitkeep b/week1/src/assets/.gitkeep similarity index 100% rename from src/assets/.gitkeep rename to week1/src/assets/.gitkeep diff --git a/src/assets/cropped-ole-ico-logo-32x32.png b/week1/src/assets/cropped-ole-ico-logo-32x32.png similarity index 100% rename from src/assets/cropped-ole-ico-logo-32x32.png rename to week1/src/assets/cropped-ole-ico-logo-32x32.png diff --git a/src/environments/environment.prod.ts b/week1/src/environments/environment.prod.ts similarity index 100% rename from src/environments/environment.prod.ts rename to week1/src/environments/environment.prod.ts diff --git a/src/environments/environment.ts b/week1/src/environments/environment.ts similarity index 100% rename from src/environments/environment.ts rename to week1/src/environments/environment.ts diff --git a/src/favicon.ico b/week1/src/favicon.ico similarity index 100% rename from src/favicon.ico rename to week1/src/favicon.ico diff --git a/src/index.html b/week1/src/index.html similarity index 100% rename from src/index.html rename to week1/src/index.html diff --git a/src/main.ts b/week1/src/main.ts similarity index 100% rename from src/main.ts rename to week1/src/main.ts diff --git a/src/polyfills.ts b/week1/src/polyfills.ts similarity index 100% rename from src/polyfills.ts rename to week1/src/polyfills.ts diff --git a/src/styles.scss b/week1/src/styles.scss similarity index 100% rename from src/styles.scss rename to week1/src/styles.scss diff --git a/src/test.ts b/week1/src/test.ts similarity index 100% rename from src/test.ts rename to week1/src/test.ts diff --git a/tsconfig.app.json b/week1/tsconfig.app.json similarity index 100% rename from tsconfig.app.json rename to week1/tsconfig.app.json diff --git a/tsconfig.base.json b/week1/tsconfig.base.json similarity index 100% rename from tsconfig.base.json rename to week1/tsconfig.base.json diff --git a/tsconfig.json b/week1/tsconfig.json similarity index 100% rename from tsconfig.json rename to week1/tsconfig.json diff --git a/tsconfig.spec.json b/week1/tsconfig.spec.json similarity index 100% rename from tsconfig.spec.json rename to week1/tsconfig.spec.json diff --git a/tslint.json b/week1/tslint.json similarity index 100% rename from tslint.json rename to week1/tslint.json From dd1d397f3911a643eb25a6c88b0f357d4db2e2a3 Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Mon, 14 Sep 2020 18:45:28 +0545 Subject: [PATCH 05/12] change variable name --- week1/src/app/app.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week1/src/app/app.component.html b/week1/src/app/app.component.html index 756b248..5c1362a 100644 --- a/week1/src/app/app.component.html +++ b/week1/src/app/app.component.html @@ -33,7 +33,7 @@
- +
From 2e12dbe13873593536e6d7ddf47ec517c4e86dbf Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Mon, 14 Sep 2020 18:47:21 +0545 Subject: [PATCH 06/12] update new couchdb url --- week1/src/app/app.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week1/src/app/app.component.ts b/week1/src/app/app.component.ts index f961bdb..7b73151 100644 --- a/week1/src/app/app.component.ts +++ b/week1/src/app/app.component.ts @@ -21,7 +21,7 @@ export class AppComponent { login(form) { const httpOpts = { headers: new HttpHeaders().set('Content-Type', 'application/json') }; - this.http.post('http://localhost:5200/_session', { }, httpOpts) + this.http.post('http://localhost:5201/_session', { }, httpOpts) .subscribe(); } } From 3843c2271a48436b0d27c5dc7b4718291f275a7f Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Mon, 14 Sep 2020 21:59:05 +0545 Subject: [PATCH 07/12] update ports --- week1/Vagrantfile | 4 ++-- week1/src/app/app.component.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/week1/Vagrantfile b/week1/Vagrantfile index d2d1d37..fcadc77 100644 --- a/week1/Vagrantfile +++ b/week1/Vagrantfile @@ -30,8 +30,8 @@ Vagrant.configure(2) do |config| end # Port expose for planetlearning1 server (5984:2200 = CouchDB 3000:3000 = App) - planetlearning1.vm.network "forwarded_port", guest: 5984, host: 5201, auto_correct: true - planetlearning1.vm.network "forwarded_port", guest: 4200, host: 5001, auto_correct: true + planetlearning1.vm.network "forwarded_port", guest: 5984, host: 5200, auto_correct: true + planetlearning1.vm.network "forwarded_port", guest: 4200, host: 5000, auto_correct: true planetlearning1.vm.network "forwarded_port", guest: 22, host: 5222, host_ip: "0.0.0.0", id: "ssh", auto_correct: true # Prevent TTY Errors (copied from laravel/homestead: "homestead.rb" file)... By default this is "bash -l". diff --git a/week1/src/app/app.component.ts b/week1/src/app/app.component.ts index 7b73151..f961bdb 100644 --- a/week1/src/app/app.component.ts +++ b/week1/src/app/app.component.ts @@ -21,7 +21,7 @@ export class AppComponent { login(form) { const httpOpts = { headers: new HttpHeaders().set('Content-Type', 'application/json') }; - this.http.post('http://localhost:5201/_session', { }, httpOpts) + this.http.post('http://localhost:5200/_session', { }, httpOpts) .subscribe(); } } From 39189be6cc6ee0d4d796dce7ee27b0effd9dee9b Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Tue, 15 Sep 2020 22:15:09 +0545 Subject: [PATCH 08/12] update data variable --- week1/Vagrantfile | 2 +- week1/src/app/app.component.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/week1/Vagrantfile b/week1/Vagrantfile index fcadc77..b95cda2 100644 --- a/week1/Vagrantfile +++ b/week1/Vagrantfile @@ -14,7 +14,7 @@ Vagrant.configure(2) do |config| BOX = "treehouses/buster64" BOX_VERSION = "0.13.3" - # planetlearning1elopment VM + # planetlearning1 VM config.vm.define "planetlearning1" do |planetlearning1| planetlearning1.vm.box = BOX planetlearning1.vm.box_version = BOX_VERSION diff --git a/week1/src/app/app.component.ts b/week1/src/app/app.component.ts index f961bdb..9e756f9 100644 --- a/week1/src/app/app.component.ts +++ b/week1/src/app/app.component.ts @@ -10,10 +10,10 @@ export class AppComponent { title = 'week1'; - data: [ { + data: Array<{ name: string, message: string - } ]; + }> = []; constructor( private http: HttpClient From c657ac6ecf183e97bad8d1441175e37569f76be8 Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Wed, 23 Sep 2020 09:56:29 +0545 Subject: [PATCH 09/12] week2 start --- week2/.browserslistrc | 18 ++ week2/README.md | 27 +++ week2/Vagrantfile | 94 ++++++++++ week2/angular.json | 134 ++++++++++++++ week2/couchdb-setup.sh | 128 +++++++++++++ week2/e2e/src/app.e2e-spec.ts | 23 +++ week2/e2e/src/app.po.ts | 11 ++ week2/e2e/tsconfig.json | 14 ++ week2/karma.conf.js | 32 ++++ week2/package.json | 48 +++++ week2/src/app/app-routing.module.ts | 10 + week2/src/app/app.component.html | 70 +++++++ week2/src/app/app.component.scss | 5 + week2/src/app/app.component.spec.ts | 35 ++++ week2/src/app/app.component.ts | 46 +++++ week2/src/app/app.module.ts | 41 +++++ week2/src/app/session-storage.service.spec.ts | 16 ++ week2/src/app/session-storage.service.ts | 22 +++ week2/src/assets/.gitkeep | 0 .../src/assets/cropped-ole-ico-logo-32x32.png | Bin 0 -> 1683 bytes week2/src/environments/environment.prod.ts | 3 + week2/src/environments/environment.ts | 16 ++ week2/src/favicon.ico | Bin 0 -> 948 bytes week2/src/index.html | 15 ++ week2/src/main.ts | 12 ++ week2/src/polyfills.ts | 63 +++++++ week2/src/styles.scss | 174 ++++++++++++++++++ week2/src/test.ts | 25 +++ week2/tsconfig.app.json | 15 ++ week2/tsconfig.base.json | 20 ++ week2/tsconfig.json | 17 ++ week2/tsconfig.spec.json | 18 ++ week2/tslint.json | 152 +++++++++++++++ 33 files changed, 1304 insertions(+) create mode 100644 week2/.browserslistrc create mode 100644 week2/README.md create mode 100644 week2/Vagrantfile create mode 100644 week2/angular.json create mode 100755 week2/couchdb-setup.sh create mode 100644 week2/e2e/src/app.e2e-spec.ts create mode 100644 week2/e2e/src/app.po.ts create mode 100644 week2/e2e/tsconfig.json create mode 100644 week2/karma.conf.js create mode 100644 week2/package.json create mode 100644 week2/src/app/app-routing.module.ts create mode 100644 week2/src/app/app.component.html create mode 100644 week2/src/app/app.component.scss create mode 100644 week2/src/app/app.component.spec.ts create mode 100644 week2/src/app/app.component.ts create mode 100644 week2/src/app/app.module.ts create mode 100644 week2/src/app/session-storage.service.spec.ts create mode 100644 week2/src/app/session-storage.service.ts create mode 100644 week2/src/assets/.gitkeep create mode 100644 week2/src/assets/cropped-ole-ico-logo-32x32.png create mode 100644 week2/src/environments/environment.prod.ts create mode 100644 week2/src/environments/environment.ts create mode 100644 week2/src/favicon.ico create mode 100644 week2/src/index.html create mode 100644 week2/src/main.ts create mode 100644 week2/src/polyfills.ts create mode 100644 week2/src/styles.scss create mode 100644 week2/src/test.ts create mode 100644 week2/tsconfig.app.json create mode 100644 week2/tsconfig.base.json create mode 100644 week2/tsconfig.json create mode 100644 week2/tsconfig.spec.json create mode 100644 week2/tslint.json diff --git a/week2/.browserslistrc b/week2/.browserslistrc new file mode 100644 index 0000000..0ccadaf --- /dev/null +++ b/week2/.browserslistrc @@ -0,0 +1,18 @@ +# 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 + +# For the full list of supported browsers by the Angular framework, please see: +# https://angular.io/guide/browser-support + +# You can see what browsers were selected by your queries by running: +# npx browserslist + +last 1 Chrome version +last 1 Firefox version +last 2 Edge major versions +last 2 Safari major versions +last 2 iOS major versions +Firefox ESR +not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line. +not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. diff --git a/week2/README.md b/week2/README.md new file mode 100644 index 0000000..ae88bf2 --- /dev/null +++ b/week2/README.md @@ -0,0 +1,27 @@ +# week2 + +This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.3. + +## Development server + +Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. + +## Code scaffolding + +Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. + +## Build + +Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. + +## Running unit tests + +Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Running end-to-end tests + +Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/week2/Vagrantfile b/week2/Vagrantfile new file mode 100644 index 0000000..1334f1e --- /dev/null +++ b/week2/Vagrantfile @@ -0,0 +1,94 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# The most common configuration options are documented and commented below. +# For a complete reference, please see the online documentation at +# https://docs.vagrantup.com. + +Vagrant.configure(2) do |config| + + if Vagrant.has_plugin?("vagrant-vbguest") + config.vbguest.auto_update = false + end + + BOX = "treehouses/buster64" + BOX_VERSION = "0.13.3" + + # planetlearning2 VM + config.vm.define "planetlearning2" do |planetlearning2| + planetlearning2.vm.box = BOX + planetlearning2.vm.box_version = BOX_VERSION + + planetlearning2.vm.hostname = "planetlearning2" + + planetlearning2.vm.provider "virtualbox" do |vb| + vb.name = "planetlearning2" + end + + planetlearning2.vm.provider "virtualbox" do |vb| + vb.memory = "1111" + end + + # Port expose for planetlearning2 server (5984:2200 = CouchDB 3000:3000 = App) + planetlearning2.vm.network "forwarded_port", guest: 5984, host: 5200, auto_correct: true + planetlearning2.vm.network "forwarded_port", guest: 4200, host: 5000, auto_correct: true + planetlearning2.vm.network "forwarded_port", guest: 22, host: 5222, host_ip: "0.0.0.0", id: "ssh", auto_correct: true + + # Prevent TTY Errors (copied from laravel/homestead: "homestead.rb" file)... By default this is "bash -l". + planetlearning2.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" + + planetlearning2.vm.provision "shell", inline: <<-SHELL + # Add CouchDB Docker + sudo docker run -d -p 5984:5984 --name planetlearning \ + -v /srv/planetlearning/conf:/opt/couchdb/etc/local.d \ + -v /srv/planetlearning/data:/opt/couchdb/data \ + -v /srv/planetlearning/log:/opt/couchdb/var/log/ \ + treehouses/couchdb:2.3.1 + + # Add CORS to CouchDB so app has access to databases + #git clone https://github.com/pouchdb/add-cors-to-couchdb.git + #cd add-cors-to-couchdb + #npm install + cd add-cors-to-couchdb + while ! curl -X GET http://127.0.0.1:5984/_all_dbs ; do sleep 1; done + node bin.js http://localhost:5984 + cd /vagrant + # End add CORS to CouchDB + + curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/log/file -d '"/opt/couchdb/var/log/couch.log"' + curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/log/writer -d '"file"' + curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/chttpd/authentication_handlers -d '"{chttpd_auth, cookie_authentication_handler}, {chttpd_auth, proxy_authentication_handler}, {chttpd_auth, default_authentication_handler}"' + + docker restart planetlearning + + # node_modules folder breaks when setting up in Windows, so use binding to fix + #echo "Preparing local node_modules folder…" + #mkdir -p /vagrant_node_modules + mkdir -p /vagrant/node_modules + chown vagrant:vagrant /vagrant_node_modules + mount --bind /vagrant_node_modules /vagrant/node_modules + npm i --unsafe-perm + #sudo npm run webdriver-set-version + # End node_modules fix + + # Add initial Couch databases here + chmod +x couchdb-setup.sh + . couchdb-setup.sh -p 5984 -i + # End Couch database addition + SHELL + + # Run binding on each startup make sure the mount is available on VM restart + planetlearning2.vm.provision "shell", run: "always", inline: <<-SHELL + if [ $(docker inspect -f '{{.State.Running}}' planetlearning) = "false" ]; then + docker start planetlearning + while ! curl -X GET http://127.0.0.1:5984/_all_dbs ; do sleep 1; done + cd /vagrant + . couchdb-setup.sh -p 5984 -x + fi + mount --bind /vagrant_node_modules /vagrant/node_modules + # Starts the app in a screen (virtual terminal) + sudo -u vagrant screen -dmS build bash -c 'cd /vagrant; ng serve --host=0.0.0.0 --poll=2000' + SHELL + end + +end diff --git a/week2/angular.json b/week2/angular.json new file mode 100644 index 0000000..ce86bc9 --- /dev/null +++ b/week2/angular.json @@ -0,0 +1,134 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "week2": { + "projectType": "application", + "schematics": { + "@schematics/angular:component": { + "style": "scss" + } + }, + "root": "", + "sourceRoot": "src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/week2", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.app.json", + "aot": true, + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", + "src/styles.scss" + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "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": "week2:build" + }, + "configurations": { + "production": { + "browserTarget": "week2:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "week2:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", + "src/styles.scss" + ], + "scripts": [] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "tsconfig.app.json", + "tsconfig.spec.json", + "e2e/tsconfig.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + }, + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "week2:serve" + }, + "configurations": { + "production": { + "devServerTarget": "week2:serve:production" + } + } + } + } + } + }, + "defaultProject": "week2", + "cli": { + "analytics": false + } +} \ No newline at end of file diff --git a/week2/couchdb-setup.sh b/week2/couchdb-setup.sh new file mode 100755 index 0000000..5d55ca4 --- /dev/null +++ b/week2/couchdb-setup.sh @@ -0,0 +1,128 @@ +#!/bin/bash + +# Function for upsert of design & other configuration docs +upsert_doc() { + DB=$1 + DOC_NAME=$2 + DOC_LOC=$3 + # Default method is PUT, fourth argument overrides + METHOD=${4:-"PUT"} + DOC=$(curl $COUCHURL/$DB/$DOC_NAME $PROXYHEADER) + # If DOC includes a rev then it exists so we need to update + # Otherwise we simply insert + if [[ $DOC == *rev* ]]; then + DOC_REV=$(echo $DOC | jq -r '. | ._rev') + curl -H 'Content-Type: application/json' -X $METHOD $COUCHURL/$DB/$DOC_NAME?rev=$DOC_REV -d $DOC_LOC $PROXYHEADER + else + curl -H 'Content-Type: application/json' -X $METHOD $COUCHURL/$DB/$DOC_NAME -d $DOC_LOC $PROXYHEADER + fi +} + +# Function for insert mock data docs +insert_docs() { + DB=$1 + DOC_LOC=$2 + curl -H 'Content-Type: application/json' -X POST $COUCHURL/$DB/_bulk_docs -d @$DOC_LOC $PROXYHEADER +} + +# Function to add databases +insert_dbs() { + DBS=$1 + for DB in "${DBS[@]}" + do + curl -X PUT $COUCHURL/$DB $PROXYHEADER + done +} + +# Options are -u for username -w for passWord and -p for port number +while getopts "u:w:p:h:ix" option; do + case $option in + u) COUCHUSER=${OPTARG};; + w) COUCHPASSWORD=${OPTARG};; + p) PORT=${OPTARG};; + h) HOST=${OPTARG};; + i) INSTALLFLAG=1;; + x) PROXYHEADER="-H X-Auth-CouchDB-Roles:_admin -H X-Auth-CouchDB-UserName:username";; + esac +done + +ISINSTALL=${INSTALLFLAG:-0} +echo $ISINSTALL +if [ -z "$HOST" ] +then + HOST=127.0.0.1 +fi + +# Default port for CouchDB accessed from host machine is 2200 +PORT=${PORT:-2200} +if [ -z "$COUCHUSER" ] +then + COUCHURL=http://$HOST:$PORT +else + COUCHURL=http://$COUCHUSER:$COUCHPASSWORD@$HOST:$PORT +fi + +# Adding attachments to database documents +# To add attachment added two file (resources-mock.json and resources-attachment-mockup.json) +# Ids must match between two files +insert_attachments() { + DB=$1 + DOC_LOC=$2 + # Use echo $(<$DOC_LOC) to be able to run in Windows + INPUTS=$(echo $(<$DOC_LOC) | jq -c '.[]') + for i in $INPUTS + do + ID=$(echo $i | jq -r '.doc_id' ) + FILE_NAME=$(echo $i | jq -r '.file_name') + FILE_LOCATION=$(echo $i | jq -r '.file_location') + FILE_TYPE=$(echo $i | jq -r '.file_type') + REV=$(curl $COUCHURL/$DB/$ID | jq -r '._rev' $PROXYHEADER) + curl -X PUT $COUCHURL/$DB/$ID/$FILE_NAME?rev=$REV --data-binary @$FILE_LOCATION -H Content-Type:$FILE_TYPE $PROXYHEADER + done +} + +# Reads one JSON file to update multiple databases +# JSON file needs a 'dbName' field with a string and +# a 'json' field with the JSON to be updated +multi_db_update() { + DOC_LOC=$1 + DOC_NAME=$2 + INPUTS=$(echo $DOC_LOC | jq -c '.[]') + for i in $INPUTS + do + JSON=$(echo $i | jq -c '. | .json' ) + DB_NAME=$(echo $i | jq -r '. | .dbName') + upsert_doc $DB_NAME $DOC_NAME $JSON + done +} + +DBS=( + # CouchDB standard databases + "_users" + "_replicator" + "_global_changes" + # Planetlearning databases + "messages" +) + +insert_dbs $DBS + +# Increase session timeout +upsert_doc _node/nonode@nohost/_config couch_httpd_auth/timeout '"2400"' +# Increse http request size for large attachments +upsert_doc _node/nonode@nohost/_config httpd/max_http_request_size '"1073741824"' +# Increse replication timeout +upsert_doc _node/nonode@nohost/_config replicator/connection_timeout '"300000"' + +# Make user database public +upsert_doc _node/nonode@nohost/_config couch_httpd_auth/users_db_public '"true"' +# Specify user public fields (note: adding spaces to string breaks upsert_doc) +upsert_doc _node/nonode@nohost/_config couch_httpd_auth/public_fields '"name"' + +# Only insert dummy data and update security on install +# _users security is set in app and auto accept will be overwritten if set here +if (($ISINSTALL)) +then + # Insert dummy data docs + upsert_doc _node/nonode@nohost/_config admins/user '"password"' +fi diff --git a/week2/e2e/src/app.e2e-spec.ts b/week2/e2e/src/app.e2e-spec.ts new file mode 100644 index 0000000..9dac7cb --- /dev/null +++ b/week2/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('week2 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/week2/e2e/src/app.po.ts b/week2/e2e/src/app.po.ts new file mode 100644 index 0000000..b68475e --- /dev/null +++ b/week2/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/week2/e2e/tsconfig.json b/week2/e2e/tsconfig.json new file mode 100644 index 0000000..1807fd6 --- /dev/null +++ b/week2/e2e/tsconfig.json @@ -0,0 +1,14 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es2018", + "types": [ + "jasmine", + "jasminewd2", + "node" + ] + } +} diff --git a/week2/karma.conf.js b/week2/karma.conf.js new file mode 100644 index 0000000..f06d4ba --- /dev/null +++ b/week2/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/week2'), + 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/week2/package.json b/week2/package.json new file mode 100644 index 0000000..d7033b4 --- /dev/null +++ b/week2/package.json @@ -0,0 +1,48 @@ +{ + "name": "week2", + "version": "0.0.0", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e" + }, + "private": true, + "dependencies": { + "@angular/animations": "~10.0.4", + "@angular/cdk": "^10.2.0", + "@angular/common": "~10.0.4", + "@angular/compiler": "~10.0.4", + "@angular/core": "~10.0.4", + "@angular/forms": "~10.0.4", + "@angular/material": "^10.2.0", + "@angular/platform-browser": "~10.0.4", + "@angular/platform-browser-dynamic": "~10.0.4", + "@angular/router": "~10.0.4", + "rxjs": "~6.5.5", + "tslib": "^2.0.0", + "zone.js": "~0.10.3" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.1000.3", + "@angular/cli": "~10.0.3", + "@angular/compiler-cli": "~10.0.4", + "@types/node": "^12.11.1", + "@types/jasmine": "~3.5.0", + "@types/jasminewd2": "~2.0.3", + "codelyzer": "^6.0.0", + "jasmine-core": "~3.5.0", + "jasmine-spec-reporter": "~5.0.0", + "karma": "~5.0.0", + "karma-chrome-launcher": "~3.1.0", + "karma-coverage-istanbul-reporter": "~3.0.2", + "karma-jasmine": "~3.3.0", + "karma-jasmine-html-reporter": "^1.5.0", + "protractor": "~7.0.0", + "ts-node": "~8.3.0", + "tslint": "~6.1.0", + "typescript": "~3.9.5" + } +} diff --git a/week2/src/app/app-routing.module.ts b/week2/src/app/app-routing.module.ts new file mode 100644 index 0000000..d425c6f --- /dev/null +++ b/week2/src/app/app-routing.module.ts @@ -0,0 +1,10 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +const routes: Routes = []; + +@NgModule({ + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule] +}) +export class AppRoutingModule { } diff --git a/week2/src/app/app.component.html b/week2/src/app/app.component.html new file mode 100644 index 0000000..ae5e8b9 --- /dev/null +++ b/week2/src/app/app.component.html @@ -0,0 +1,70 @@ + + + Planet Learning + + Message + LogOut + + + +
+ + + + + +
+ + + +
{{notification}}
+
+
+ +
+
+
+
+ + Username + + + + Password + + + +
+
+
+
+
+
+ + Name + + + + Message + + + +
+
+
+
+ + +
{{msg.name}}
+
{{msg.message}}
+ +
+
+
+
+ + diff --git a/week2/src/app/app.component.scss b/week2/src/app/app.component.scss new file mode 100644 index 0000000..dd2ce7e --- /dev/null +++ b/week2/src/app/app.component.scss @@ -0,0 +1,5 @@ +mat-toolbar { + .mat-raised-button { + margin-left: 10px; + } +} \ No newline at end of file diff --git a/week2/src/app/app.component.spec.ts b/week2/src/app/app.component.spec.ts new file mode 100644 index 0000000..f747de7 --- /dev/null +++ b/week2/src/app/app.component.spec.ts @@ -0,0 +1,35 @@ +import { TestBed, async } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + RouterTestingModule + ], + declarations: [ + AppComponent + ], + }).compileComponents(); + })); + + it('should create the app', () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app).toBeTruthy(); + }); + + it(`should have as title 'week2'`, () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app.title).toEqual('week2'); + }); + + it('should render title', () => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.nativeElement; + expect(compiled.querySelector('.content span').textContent).toContain('week2 app is running!'); + }); +}); diff --git a/week2/src/app/app.component.ts b/week2/src/app/app.component.ts new file mode 100644 index 0000000..6985ad3 --- /dev/null +++ b/week2/src/app/app.component.ts @@ -0,0 +1,46 @@ +import { Component } from '@angular/core'; +import { HttpHeaders, HttpClient } from '@angular/common/http'; +import { SessionStorageService } from './session-storage.service'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.scss'] +}) +export class AppComponent { + + title = 'week2'; + loggedIn: boolean = false; + data: Array<{ + name: string, + message: string + }> = []; + notifications = []; + + constructor( + private http: HttpClient, + private sessionStorageService: SessionStorageService, + private router: Router + ) { + this.router.events.subscribe(() => { + this.loggedIn = this.sessionStorageService.isLoggedIn(); + }); + } + + login(form) { + const httpOpts = { headers: new HttpHeaders().set('Content-Type', 'application/json'), withCredentials: true }; + this.http.post('http://localhost:5200/_session', { name: form.value.username, password: form.value.password }, httpOpts) + .subscribe(() => this.loggedIn = true); + } + + message(form) { + const httpOpts = { headers: new HttpHeaders().set('Content-Type', 'application/json'), withCredentials: true }; + this.http.post('http://localhost:5200/messages', { name: form.value.name, message: form.value.message }, httpOpts) + .subscribe(() => { + this.data.push({ name: form.value.name, message: form.value.message }); + this.notifications.push('New message added'); + }); + } + +} diff --git a/week2/src/app/app.module.ts b/week2/src/app/app.module.ts new file mode 100644 index 0000000..df05b7e --- /dev/null +++ b/week2/src/app/app.module.ts @@ -0,0 +1,41 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; + +import { AppRoutingModule } from './app-routing.module'; +import { AppComponent } from './app.component'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; + +import { HttpClientModule } from '@angular/common/http'; + +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatButtonModule } from '@angular/material/button'; +import { FormsModule } from '@angular/forms'; +import { MatMenuModule } from '@angular/material/menu'; +import { MatListModule } from '@angular/material/list'; + + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ + BrowserModule, + AppRoutingModule, + BrowserAnimationsModule, + HttpClientModule, + MatFormFieldModule, + MatIconModule, + MatInputModule, + MatToolbarModule, + MatButtonModule, + FormsModule, + MatMenuModule, + MatListModule + ], + providers: [], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/week2/src/app/session-storage.service.spec.ts b/week2/src/app/session-storage.service.spec.ts new file mode 100644 index 0000000..78a1335 --- /dev/null +++ b/week2/src/app/session-storage.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { SessionStorageService } from './session-storage.service'; + +describe('SessionStorageService', () => { + let service: SessionStorageService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(SessionStorageService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/week2/src/app/session-storage.service.ts b/week2/src/app/session-storage.service.ts new file mode 100644 index 0000000..74274e6 --- /dev/null +++ b/week2/src/app/session-storage.service.ts @@ -0,0 +1,22 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class SessionStorageService { + + constructor() { } + + setToken(expiresIn){ + sessionStorage.setItem('expiryTime', expiresIn.toString()); + } + + getToken(){ + return Number.parseInt(sessionStorage.getItem('expiryTime')); + } + + isLoggedIn() { + return this.getToken() > Date.now(); + } + +} diff --git a/week2/src/assets/.gitkeep b/week2/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/week2/src/assets/cropped-ole-ico-logo-32x32.png b/week2/src/assets/cropped-ole-ico-logo-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..aafe29fb672578dbf07cfa22a112fef9af172312 GIT binary patch literal 1683 zcmV;E25k9>P)M29b!>jgzE!p!ABl9WUW2$Xj?{lWFqp9I3>yPf@Zo_(L^ zzV7?JuIs)V4s^x(ntotXU*7FL!fzRVs{1{hb6=o*j z8Tb!w#LBei6WE4-9*hbO!(?>fdS!jSvL2zVkH@k3;GeMo8*o|fPR2lNL?`Y|wxw^*>uZ$t zBxQZHver=6=U@mn2f!pu!4uK_$v81;=$oM3$@*?wf?29!OOol43N%vLo&o#qeE)m+ z8RlR_18>8Ol<>3=>^58+^O=HKn2&oSu^TWk!5>f+J6fvRE7F60Y0<>AZ9sta#)mPz zfuCYJPQh>REeyrWs^Za*?y6L#8T6aDzoWf#XGeSIn2vd)kL#E>x=G%)WGw+th>`W) ztNm?gZ>WmhSc)%VaWbBZ3zc;*RY6tkQWaZN#paIo&K@1@o$v2x@9dk_&A~M-L3f6H z5_CAW?}vli_K>hDn#S@~+!a5ciK~?LtA3v>Cxwh1alZk042_O?qmLPL%7R^39-g#? z)W1t>ThC71{+bc(0nudi<8iX-xI$SUmRsFeg5SsEC*_^K0etI8$1Xh*zin~9QSpfD z@%L0`b?)EtdMDfiVmWRO;{KU>XGdOb88SB|tBW#dzK+uqs4pIggEo2a@i70q%!iL) zDpoh5(LT!hG-drkyd%0_kcSs z9zylQJJb6C_*2X1J@e`3N3F|Dm>R=53ctt<7#1lv+qna?^R0i!nmaM56+|P`tmj?~ zJpyC!#}+mZTk^~~J-Ws(S(|64VqN~4#&t*6_$A#fAhyIuu8h<#$aeMWI@j3Gve9(3 zC$OcZ3QeH9(zc7SqHEE#ZC#6|E$&)0ZKtyCtE_t~>mJIQs@RTsnT|7(*i4L6){O=p zPDZU~YozvUdMJaX8@k3X>Fyf8WNp`?X-m5nP3sv}-<)>b8AqLsFDdKyq_ry|#R=IP zrsK1XNa+3q-5sLMLXH2nxZ1y7=V*Jp;avPOThP>ed|c#qS%^75g#Jug`t9qA zcc_Y4s^URa@k*rBGb42!9#a*Rb*~Jk={Pz;*W$ALkGW|ax0Y-&8t5wCS7|-4Dg-cs^%mV>1!G9_Wd=Brzud^4-j~RU-1k*Bx zFNs|{n4NH6=kQqTEUd-5y|(vH!SXDi&Bb+J?+-l`0K@HBsqcyHPL71G! zyuUpb{H6i?BMaoFaN(pde|1Z6k=ndSR?FV-aLnvY0;q}?RK;@%HZ(z=+$(s~HE&9* zUW$L*nT2J|fdKpu3W?&Z>5BAr0000bbVXQnWMOn=I%9HWVRU5xGB7bWEig4LGcZ&! zFgi3gIx;dXFgH3dFw9Jt@&Et;C3HntbYx+4WjbwdWNBu305UK!H!UzVEi*7wF)%tb dHaapgEigAaFfhFlAWi@P002ovPDHLkV1kBSD>DE9 literal 0 HcmV?d00001 diff --git a/week2/src/environments/environment.prod.ts b/week2/src/environments/environment.prod.ts new file mode 100644 index 0000000..3612073 --- /dev/null +++ b/week2/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/week2/src/environments/environment.ts b/week2/src/environments/environment.ts new file mode 100644 index 0000000..7b4f817 --- /dev/null +++ b/week2/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/week2/src/favicon.ico b/week2/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 + + + + week2 + + + + + + + + + + diff --git a/week2/src/main.ts b/week2/src/main.ts new file mode 100644 index 0000000..c7b673c --- /dev/null +++ b/week2/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/week2/src/polyfills.ts b/week2/src/polyfills.ts new file mode 100644 index 0000000..03711e5 --- /dev/null +++ b/week2/src/polyfills.ts @@ -0,0 +1,63 @@ +/** + * 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 + */ diff --git a/week2/src/styles.scss b/week2/src/styles.scss new file mode 100644 index 0000000..022444b --- /dev/null +++ b/week2/src/styles.scss @@ -0,0 +1,174 @@ +/* You can add global styles to this file, and also import other style files */ + +html, body { height: 100%; } +body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } + +h1, h2, h3, h4, h5, h6 { + margin: 8px 0; +} + +p { + margin: 0; +} + +.spacer { + flex: 1; +} + +.mat-toolbar { + position: absolute; + top: 0; + left: 0; + right: 0; + height: 60px; + display: flex; + align-items: center; + background-color: #1976d2; + color: white; + font-weight: 600; + + img { + margin: 0 16px; + } +} + +.content { + display: flex; + margin: 82px auto 32px; + padding: 0 16px; + max-width: 960px; + flex-direction: column; + align-items: center; +} + +svg.material-icons { + height: 24px; + width: auto; +} + +svg.material-icons:not(:last-child) { + margin-right: 8px; +} + +.card svg.material-icons path { + fill: #888; +} + +.card-container { + display: flex; + flex-wrap: wrap; + justify-content: center; + margin-top: 16px; +} + +.card { + border-radius: 4px; + border: 1px solid #eee; + background-color: #fafafa; + height: 40px; + width: 200px; + margin: 0 8px 16px; + padding: 16px; + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + transition: all 0.2s ease-in-out; + line-height: 24px; +} + +.card-container .card:not(:last-child) { + margin-right: 0; +} + +.card.card-small { + height: 16px; + width: 168px; +} + +.card-container .card:not(.highlight-card) { + cursor: pointer; +} + +.card-container .card:not(.highlight-card):hover { + transform: translateY(-3px); + box-shadow: 0 4px 17px rgba(0, 0, 0, 0.35); + .material-icons path { + fill: rgb(105, 103, 103); + } +} + +.card.highlight-card { + background-color: #1976d2; + color: white; + font-weight: 600; + border: none; + width: auto; + min-width: 30%; + position: relative; + + span { + margin-left: 60px; + } +} + +a, +a:visited, +a:hover { + color: #1976d2; + text-decoration: none; +} + +a:hover { + color: #125699; +} + +.circle-link { + height: 40px; + width: 40px; + border-radius: 40px; + margin: 8px; + background-color: white; + border: 1px solid #eeeeee; + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); + transition: 1s ease-out; +} + +.circle-link:hover { + transform: translateY(-0.25rem); + box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2); +} + +footer { + margin-top: 8px; + display: flex; + align-items: center; + line-height: 20px; + + a { + display: flex; + align-items: center; + } +} + +/* Responsive Styles */ +@media screen and (max-width: 767px) { + + .card-container > *:not(.circle-link) { + width: 100%; + } + + .card:not(.highlight-card) { + height: 16px; + margin: 8px 0; + } + + .card.highlight-card span { + margin-left: 72px; + } + +} diff --git a/week2/src/test.ts b/week2/src/test.ts new file mode 100644 index 0000000..50193eb --- /dev/null +++ b/week2/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/week2/tsconfig.app.json b/week2/tsconfig.app.json new file mode 100644 index 0000000..232c3a5 --- /dev/null +++ b/week2/tsconfig.app.json @@ -0,0 +1,15 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/week2/tsconfig.base.json b/week2/tsconfig.base.json new file mode 100644 index 0000000..f69f654 --- /dev/null +++ b/week2/tsconfig.base.json @@ -0,0 +1,20 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "moduleResolution": "node", + "importHelpers": true, + "target": "es2015", + "module": "es2020", + "lib": [ + "es2018", + "dom" + ] + } +} diff --git a/week2/tsconfig.json b/week2/tsconfig.json new file mode 100644 index 0000000..2338536 --- /dev/null +++ b/week2/tsconfig.json @@ -0,0 +1,17 @@ +/* + This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience. + It is not intended to be used to perform a compilation. + + To learn more about this file see: https://angular.io/config/solution-tsconfig. +*/ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.spec.json" + } +] +} diff --git a/week2/tsconfig.spec.json b/week2/tsconfig.spec.json new file mode 100644 index 0000000..729a6d6 --- /dev/null +++ b/week2/tsconfig.spec.json @@ -0,0 +1,18 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "outDir": "./out-tsc/spec", + "types": [ + "jasmine" + ] + }, + "files": [ + "src/test.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/week2/tslint.json b/week2/tslint.json new file mode 100644 index 0000000..67bcdea --- /dev/null +++ b/week2/tslint.json @@ -0,0 +1,152 @@ +{ + "extends": "tslint:recommended", + "rules": { + "align": { + "options": [ + "parameters", + "statements" + ] + }, + "array-type": false, + "arrow-return-shorthand": true, + "curly": true, + "deprecation": { + "severity": "warning" + }, + "component-class-suffix": true, + "contextual-lifecycle": true, + "directive-class-suffix": true, + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], + "eofline": true, + "import-blacklist": [ + true, + "rxjs/Rx" + ], + "import-spacing": true, + "indent": { + "options": [ + "spaces" + ] + }, + "max-classes-per-file": false, + "max-line-length": [ + true, + 140 + ], + "member-ordering": [ + true, + { + "order": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } + ], + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-empty": false, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-non-null-assertion": true, + "no-redundant-jsdoc": true, + "no-switch-case-fall-through": true, + "no-var-requires": false, + "object-literal-key-quotes": [ + true, + "as-needed" + ], + "quotemark": [ + true, + "single" + ], + "semicolon": { + "options": [ + "always" + ] + }, + "space-before-function-paren": { + "options": { + "anonymous": "never", + "asyncArrow": "always", + "constructor": "never", + "method": "never", + "named": "never" + } + }, + "typedef": [ + true, + "call-signature" + ], + "typedef-whitespace": { + "options": [ + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + } + ] + }, + "variable-name": { + "options": [ + "ban-keywords", + "check-format", + "allow-pascal-case" + ] + }, + "whitespace": { + "options": [ + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type", + "check-typecast" + ] + }, + "no-conflicting-lifecycle": true, + "no-host-metadata-property": true, + "no-input-rename": true, + "no-inputs-metadata-property": true, + "no-output-native": true, + "no-output-on-prefix": true, + "no-output-rename": true, + "no-outputs-metadata-property": true, + "template-banana-in-box": true, + "template-no-negated-async": true, + "use-lifecycle-interface": true, + "use-pipe-transform-interface": true + }, + "rulesDirectory": [ + "codelyzer" + ] +} \ No newline at end of file From 2b72cea312ca509b6f774a1594f39ceadf6e44f1 Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Wed, 23 Sep 2020 13:10:41 +0545 Subject: [PATCH 10/12] week3 --- week3/.browserslistrc | 18 ++ week3/README.md | 27 +++ week3/Vagrantfile | 94 ++++++++++ week3/angular.json | 134 ++++++++++++++ week3/couchdb-setup.sh | 128 +++++++++++++ week3/e2e/src/app.e2e-spec.ts | 23 +++ week3/e2e/src/app.po.ts | 11 ++ week3/e2e/tsconfig.json | 14 ++ week3/karma.conf.js | 32 ++++ week3/package.json | 48 +++++ week3/src/app/app-routing.module.ts | 15 ++ week3/src/app/app.component.html | 28 +++ week3/src/app/app.component.scss | 5 + week3/src/app/app.component.spec.ts | 35 ++++ week3/src/app/app.component.ts | 31 ++++ week3/src/app/app.module.ts | 44 +++++ week3/src/app/login/login.component.spec.ts | 25 +++ week3/src/app/login/login.component.ts | 57 ++++++ week3/src/app/message/message.component.html | 24 +++ week3/src/app/message/message.component.scss | 0 .../src/app/message/message.component.spec.ts | 25 +++ week3/src/app/message/message.component.ts | 54 ++++++ week3/src/app/session-storage.service.spec.ts | 16 ++ week3/src/app/session-storage.service.ts | 22 +++ week3/src/assets/.gitkeep | 0 .../src/assets/cropped-ole-ico-logo-32x32.png | Bin 0 -> 1683 bytes week3/src/environments/environment.prod.ts | 3 + week3/src/environments/environment.ts | 16 ++ week3/src/favicon.ico | Bin 0 -> 948 bytes week3/src/index.html | 15 ++ week3/src/main.ts | 12 ++ week3/src/polyfills.ts | 63 +++++++ week3/src/styles.scss | 174 ++++++++++++++++++ week3/src/test.ts | 25 +++ week3/tsconfig.app.json | 15 ++ week3/tsconfig.base.json | 20 ++ week3/tsconfig.json | 17 ++ week3/tsconfig.spec.json | 18 ++ week3/tslint.json | 152 +++++++++++++++ 39 files changed, 1440 insertions(+) create mode 100644 week3/.browserslistrc create mode 100644 week3/README.md create mode 100644 week3/Vagrantfile create mode 100644 week3/angular.json create mode 100755 week3/couchdb-setup.sh create mode 100644 week3/e2e/src/app.e2e-spec.ts create mode 100644 week3/e2e/src/app.po.ts create mode 100644 week3/e2e/tsconfig.json create mode 100644 week3/karma.conf.js create mode 100644 week3/package.json create mode 100644 week3/src/app/app-routing.module.ts create mode 100644 week3/src/app/app.component.html create mode 100644 week3/src/app/app.component.scss create mode 100644 week3/src/app/app.component.spec.ts create mode 100644 week3/src/app/app.component.ts create mode 100644 week3/src/app/app.module.ts create mode 100644 week3/src/app/login/login.component.spec.ts create mode 100644 week3/src/app/login/login.component.ts create mode 100644 week3/src/app/message/message.component.html create mode 100644 week3/src/app/message/message.component.scss create mode 100644 week3/src/app/message/message.component.spec.ts create mode 100644 week3/src/app/message/message.component.ts create mode 100644 week3/src/app/session-storage.service.spec.ts create mode 100644 week3/src/app/session-storage.service.ts create mode 100644 week3/src/assets/.gitkeep create mode 100644 week3/src/assets/cropped-ole-ico-logo-32x32.png create mode 100644 week3/src/environments/environment.prod.ts create mode 100644 week3/src/environments/environment.ts create mode 100644 week3/src/favicon.ico create mode 100644 week3/src/index.html create mode 100644 week3/src/main.ts create mode 100644 week3/src/polyfills.ts create mode 100644 week3/src/styles.scss create mode 100644 week3/src/test.ts create mode 100644 week3/tsconfig.app.json create mode 100644 week3/tsconfig.base.json create mode 100644 week3/tsconfig.json create mode 100644 week3/tsconfig.spec.json create mode 100644 week3/tslint.json diff --git a/week3/.browserslistrc b/week3/.browserslistrc new file mode 100644 index 0000000..0ccadaf --- /dev/null +++ b/week3/.browserslistrc @@ -0,0 +1,18 @@ +# 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 + +# For the full list of supported browsers by the Angular framework, please see: +# https://angular.io/guide/browser-support + +# You can see what browsers were selected by your queries by running: +# npx browserslist + +last 1 Chrome version +last 1 Firefox version +last 2 Edge major versions +last 2 Safari major versions +last 2 iOS major versions +Firefox ESR +not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line. +not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. diff --git a/week3/README.md b/week3/README.md new file mode 100644 index 0000000..ae88bf2 --- /dev/null +++ b/week3/README.md @@ -0,0 +1,27 @@ +# week2 + +This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.3. + +## Development server + +Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. + +## Code scaffolding + +Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. + +## Build + +Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. + +## Running unit tests + +Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Running end-to-end tests + +Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/week3/Vagrantfile b/week3/Vagrantfile new file mode 100644 index 0000000..1e5b136 --- /dev/null +++ b/week3/Vagrantfile @@ -0,0 +1,94 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# The most common configuration options are documented and commented below. +# For a complete reference, please see the online documentation at +# https://docs.vagrantup.com. + +Vagrant.configure(2) do |config| + + if Vagrant.has_plugin?("vagrant-vbguest") + config.vbguest.auto_update = false + end + + BOX = "treehouses/buster64" + BOX_VERSION = "0.13.3" + + # planetlearning3 VM + config.vm.define "planetlearning3" do |planetlearning3| + planetlearning3.vm.box = BOX + planetlearning3.vm.box_version = BOX_VERSION + + planetlearning3.vm.hostname = "planetlearning3" + + planetlearning3.vm.provider "virtualbox" do |vb| + vb.name = "planetlearning3" + end + + planetlearning3.vm.provider "virtualbox" do |vb| + vb.memory = "1111" + end + + # Port expose for planetlearning3 server (5984:2200 = CouchDB 3000:3000 = App) + planetlearning3.vm.network "forwarded_port", guest: 5984, host: 5200, auto_correct: true + planetlearning3.vm.network "forwarded_port", guest: 4200, host: 5000, auto_correct: true + planetlearning3.vm.network "forwarded_port", guest: 22, host: 5222, host_ip: "0.0.0.0", id: "ssh", auto_correct: true + + # Prevent TTY Errors (copied from laravel/homestead: "homestead.rb" file)... By default this is "bash -l". + planetlearning3.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" + + planetlearning3.vm.provision "shell", inline: <<-SHELL + # Add CouchDB Docker + sudo docker run -d -p 5984:5984 --name planetlearning \ + -v /srv/planetlearning/conf:/opt/couchdb/etc/local.d \ + -v /srv/planetlearning/data:/opt/couchdb/data \ + -v /srv/planetlearning/log:/opt/couchdb/var/log/ \ + treehouses/couchdb:2.3.1 + + # Add CORS to CouchDB so app has access to databases + #git clone https://github.com/pouchdb/add-cors-to-couchdb.git + #cd add-cors-to-couchdb + #npm install + cd add-cors-to-couchdb + while ! curl -X GET http://127.0.0.1:5984/_all_dbs ; do sleep 1; done + node bin.js http://localhost:5984 + cd /vagrant + # End add CORS to CouchDB + + curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/log/file -d '"/opt/couchdb/var/log/couch.log"' + curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/log/writer -d '"file"' + curl -X PUT http://localhost:5984/_node/nonode@nohost/_config/chttpd/authentication_handlers -d '"{chttpd_auth, cookie_authentication_handler}, {chttpd_auth, proxy_authentication_handler}, {chttpd_auth, default_authentication_handler}"' + + docker restart planetlearning + + # node_modules folder breaks when setting up in Windows, so use binding to fix + #echo "Preparing local node_modules folder…" + #mkdir -p /vagrant_node_modules + mkdir -p /vagrant/node_modules + chown vagrant:vagrant /vagrant_node_modules + mount --bind /vagrant_node_modules /vagrant/node_modules + npm i --unsafe-perm + #sudo npm run webdriver-set-version + # End node_modules fix + + # Add initial Couch databases here + chmod +x couchdb-setup.sh + . couchdb-setup.sh -p 5984 -i + # End Couch database addition + SHELL + + # Run binding on each startup make sure the mount is available on VM restart + planetlearning3.vm.provision "shell", run: "always", inline: <<-SHELL + if [ $(docker inspect -f '{{.State.Running}}' planetlearning) = "false" ]; then + docker start planetlearning + while ! curl -X GET http://127.0.0.1:5984/_all_dbs ; do sleep 1; done + cd /vagrant + . couchdb-setup.sh -p 5984 -x + fi + mount --bind /vagrant_node_modules /vagrant/node_modules + # Starts the app in a screen (virtual terminal) + sudo -u vagrant screen -dmS build bash -c 'cd /vagrant; ng serve --host=0.0.0.0 --poll=2000' + SHELL + end + +end diff --git a/week3/angular.json b/week3/angular.json new file mode 100644 index 0000000..ce86bc9 --- /dev/null +++ b/week3/angular.json @@ -0,0 +1,134 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "week2": { + "projectType": "application", + "schematics": { + "@schematics/angular:component": { + "style": "scss" + } + }, + "root": "", + "sourceRoot": "src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/week2", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.app.json", + "aot": true, + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", + "src/styles.scss" + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "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": "week2:build" + }, + "configurations": { + "production": { + "browserTarget": "week2:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "week2:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", + "src/styles.scss" + ], + "scripts": [] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "tsconfig.app.json", + "tsconfig.spec.json", + "e2e/tsconfig.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + }, + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "week2:serve" + }, + "configurations": { + "production": { + "devServerTarget": "week2:serve:production" + } + } + } + } + } + }, + "defaultProject": "week2", + "cli": { + "analytics": false + } +} \ No newline at end of file diff --git a/week3/couchdb-setup.sh b/week3/couchdb-setup.sh new file mode 100755 index 0000000..5d55ca4 --- /dev/null +++ b/week3/couchdb-setup.sh @@ -0,0 +1,128 @@ +#!/bin/bash + +# Function for upsert of design & other configuration docs +upsert_doc() { + DB=$1 + DOC_NAME=$2 + DOC_LOC=$3 + # Default method is PUT, fourth argument overrides + METHOD=${4:-"PUT"} + DOC=$(curl $COUCHURL/$DB/$DOC_NAME $PROXYHEADER) + # If DOC includes a rev then it exists so we need to update + # Otherwise we simply insert + if [[ $DOC == *rev* ]]; then + DOC_REV=$(echo $DOC | jq -r '. | ._rev') + curl -H 'Content-Type: application/json' -X $METHOD $COUCHURL/$DB/$DOC_NAME?rev=$DOC_REV -d $DOC_LOC $PROXYHEADER + else + curl -H 'Content-Type: application/json' -X $METHOD $COUCHURL/$DB/$DOC_NAME -d $DOC_LOC $PROXYHEADER + fi +} + +# Function for insert mock data docs +insert_docs() { + DB=$1 + DOC_LOC=$2 + curl -H 'Content-Type: application/json' -X POST $COUCHURL/$DB/_bulk_docs -d @$DOC_LOC $PROXYHEADER +} + +# Function to add databases +insert_dbs() { + DBS=$1 + for DB in "${DBS[@]}" + do + curl -X PUT $COUCHURL/$DB $PROXYHEADER + done +} + +# Options are -u for username -w for passWord and -p for port number +while getopts "u:w:p:h:ix" option; do + case $option in + u) COUCHUSER=${OPTARG};; + w) COUCHPASSWORD=${OPTARG};; + p) PORT=${OPTARG};; + h) HOST=${OPTARG};; + i) INSTALLFLAG=1;; + x) PROXYHEADER="-H X-Auth-CouchDB-Roles:_admin -H X-Auth-CouchDB-UserName:username";; + esac +done + +ISINSTALL=${INSTALLFLAG:-0} +echo $ISINSTALL +if [ -z "$HOST" ] +then + HOST=127.0.0.1 +fi + +# Default port for CouchDB accessed from host machine is 2200 +PORT=${PORT:-2200} +if [ -z "$COUCHUSER" ] +then + COUCHURL=http://$HOST:$PORT +else + COUCHURL=http://$COUCHUSER:$COUCHPASSWORD@$HOST:$PORT +fi + +# Adding attachments to database documents +# To add attachment added two file (resources-mock.json and resources-attachment-mockup.json) +# Ids must match between two files +insert_attachments() { + DB=$1 + DOC_LOC=$2 + # Use echo $(<$DOC_LOC) to be able to run in Windows + INPUTS=$(echo $(<$DOC_LOC) | jq -c '.[]') + for i in $INPUTS + do + ID=$(echo $i | jq -r '.doc_id' ) + FILE_NAME=$(echo $i | jq -r '.file_name') + FILE_LOCATION=$(echo $i | jq -r '.file_location') + FILE_TYPE=$(echo $i | jq -r '.file_type') + REV=$(curl $COUCHURL/$DB/$ID | jq -r '._rev' $PROXYHEADER) + curl -X PUT $COUCHURL/$DB/$ID/$FILE_NAME?rev=$REV --data-binary @$FILE_LOCATION -H Content-Type:$FILE_TYPE $PROXYHEADER + done +} + +# Reads one JSON file to update multiple databases +# JSON file needs a 'dbName' field with a string and +# a 'json' field with the JSON to be updated +multi_db_update() { + DOC_LOC=$1 + DOC_NAME=$2 + INPUTS=$(echo $DOC_LOC | jq -c '.[]') + for i in $INPUTS + do + JSON=$(echo $i | jq -c '. | .json' ) + DB_NAME=$(echo $i | jq -r '. | .dbName') + upsert_doc $DB_NAME $DOC_NAME $JSON + done +} + +DBS=( + # CouchDB standard databases + "_users" + "_replicator" + "_global_changes" + # Planetlearning databases + "messages" +) + +insert_dbs $DBS + +# Increase session timeout +upsert_doc _node/nonode@nohost/_config couch_httpd_auth/timeout '"2400"' +# Increse http request size for large attachments +upsert_doc _node/nonode@nohost/_config httpd/max_http_request_size '"1073741824"' +# Increse replication timeout +upsert_doc _node/nonode@nohost/_config replicator/connection_timeout '"300000"' + +# Make user database public +upsert_doc _node/nonode@nohost/_config couch_httpd_auth/users_db_public '"true"' +# Specify user public fields (note: adding spaces to string breaks upsert_doc) +upsert_doc _node/nonode@nohost/_config couch_httpd_auth/public_fields '"name"' + +# Only insert dummy data and update security on install +# _users security is set in app and auto accept will be overwritten if set here +if (($ISINSTALL)) +then + # Insert dummy data docs + upsert_doc _node/nonode@nohost/_config admins/user '"password"' +fi diff --git a/week3/e2e/src/app.e2e-spec.ts b/week3/e2e/src/app.e2e-spec.ts new file mode 100644 index 0000000..9dac7cb --- /dev/null +++ b/week3/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('week2 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/week3/e2e/src/app.po.ts b/week3/e2e/src/app.po.ts new file mode 100644 index 0000000..b68475e --- /dev/null +++ b/week3/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/week3/e2e/tsconfig.json b/week3/e2e/tsconfig.json new file mode 100644 index 0000000..1807fd6 --- /dev/null +++ b/week3/e2e/tsconfig.json @@ -0,0 +1,14 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es2018", + "types": [ + "jasmine", + "jasminewd2", + "node" + ] + } +} diff --git a/week3/karma.conf.js b/week3/karma.conf.js new file mode 100644 index 0000000..f06d4ba --- /dev/null +++ b/week3/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/week2'), + 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/week3/package.json b/week3/package.json new file mode 100644 index 0000000..d7033b4 --- /dev/null +++ b/week3/package.json @@ -0,0 +1,48 @@ +{ + "name": "week2", + "version": "0.0.0", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e" + }, + "private": true, + "dependencies": { + "@angular/animations": "~10.0.4", + "@angular/cdk": "^10.2.0", + "@angular/common": "~10.0.4", + "@angular/compiler": "~10.0.4", + "@angular/core": "~10.0.4", + "@angular/forms": "~10.0.4", + "@angular/material": "^10.2.0", + "@angular/platform-browser": "~10.0.4", + "@angular/platform-browser-dynamic": "~10.0.4", + "@angular/router": "~10.0.4", + "rxjs": "~6.5.5", + "tslib": "^2.0.0", + "zone.js": "~0.10.3" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.1000.3", + "@angular/cli": "~10.0.3", + "@angular/compiler-cli": "~10.0.4", + "@types/node": "^12.11.1", + "@types/jasmine": "~3.5.0", + "@types/jasminewd2": "~2.0.3", + "codelyzer": "^6.0.0", + "jasmine-core": "~3.5.0", + "jasmine-spec-reporter": "~5.0.0", + "karma": "~5.0.0", + "karma-chrome-launcher": "~3.1.0", + "karma-coverage-istanbul-reporter": "~3.0.2", + "karma-jasmine": "~3.3.0", + "karma-jasmine-html-reporter": "^1.5.0", + "protractor": "~7.0.0", + "ts-node": "~8.3.0", + "tslint": "~6.1.0", + "typescript": "~3.9.5" + } +} diff --git a/week3/src/app/app-routing.module.ts b/week3/src/app/app-routing.module.ts new file mode 100644 index 0000000..106f003 --- /dev/null +++ b/week3/src/app/app-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { LoginComponent } from './login/login.component'; +import { MessageComponent } from './message/message.component'; + +const routes: Routes = [ + { path: '', component: LoginComponent }, + { path: 'message', component: MessageComponent }, +]; + +@NgModule({ + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule] +}) +export class AppRoutingModule { } diff --git a/week3/src/app/app.component.html b/week3/src/app/app.component.html new file mode 100644 index 0000000..bb8aa54 --- /dev/null +++ b/week3/src/app/app.component.html @@ -0,0 +1,28 @@ + + + Planet Learning + + Message + LogOut + + + +
+ + + + + +
+ + +
{{notification}}
+
+ +
+ +
diff --git a/week3/src/app/app.component.scss b/week3/src/app/app.component.scss new file mode 100644 index 0000000..dd2ce7e --- /dev/null +++ b/week3/src/app/app.component.scss @@ -0,0 +1,5 @@ +mat-toolbar { + .mat-raised-button { + margin-left: 10px; + } +} \ No newline at end of file diff --git a/week3/src/app/app.component.spec.ts b/week3/src/app/app.component.spec.ts new file mode 100644 index 0000000..f747de7 --- /dev/null +++ b/week3/src/app/app.component.spec.ts @@ -0,0 +1,35 @@ +import { TestBed, async } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + RouterTestingModule + ], + declarations: [ + AppComponent + ], + }).compileComponents(); + })); + + it('should create the app', () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app).toBeTruthy(); + }); + + it(`should have as title 'week2'`, () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app.title).toEqual('week2'); + }); + + it('should render title', () => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.nativeElement; + expect(compiled.querySelector('.content span').textContent).toContain('week2 app is running!'); + }); +}); diff --git a/week3/src/app/app.component.ts b/week3/src/app/app.component.ts new file mode 100644 index 0000000..8e4a8dc --- /dev/null +++ b/week3/src/app/app.component.ts @@ -0,0 +1,31 @@ +import { Component } from '@angular/core'; +import { SessionStorageService } from './session-storage.service'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.scss'] +}) +export class AppComponent { + + title = 'week2'; + loggedIn: boolean = false; + notifications = []; + + constructor( + private sessionStorageService: SessionStorageService, + private router: Router + ) { + this.router.events.subscribe(() => { + this.loggedIn = this.sessionStorageService.isLoggedIn(); + }); + } + + logout() { + this.sessionStorageService.setToken(Date.now()-1000); + this.loggedIn = this.sessionStorageService.isLoggedIn(); + this.router.navigate([ '/' ]); + } + +} diff --git a/week3/src/app/app.module.ts b/week3/src/app/app.module.ts new file mode 100644 index 0000000..1a96de8 --- /dev/null +++ b/week3/src/app/app.module.ts @@ -0,0 +1,44 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; + +import { AppRoutingModule } from './app-routing.module'; +import { AppComponent } from './app.component'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; + +import { HttpClientModule } from '@angular/common/http'; + +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatButtonModule } from '@angular/material/button'; +import { ReactiveFormsModule } from '@angular/forms'; +import { MatMenuModule } from '@angular/material/menu'; +import { MatListModule } from '@angular/material/list'; +import { LoginComponent } from './login/login.component'; +import { MessageComponent } from './message/message.component'; + +@NgModule({ + declarations: [ + AppComponent, + LoginComponent, + MessageComponent + ], + imports: [ + BrowserModule, + AppRoutingModule, + BrowserAnimationsModule, + HttpClientModule, + MatFormFieldModule, + MatIconModule, + MatInputModule, + MatToolbarModule, + MatButtonModule, + MatMenuModule, + MatListModule, + ReactiveFormsModule + ], + providers: [], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/week3/src/app/login/login.component.spec.ts b/week3/src/app/login/login.component.spec.ts new file mode 100644 index 0000000..d6d85a8 --- /dev/null +++ b/week3/src/app/login/login.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LoginComponent } from './login.component'; + +describe('LoginComponent', () => { + let component: LoginComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ LoginComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(LoginComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/week3/src/app/login/login.component.ts b/week3/src/app/login/login.component.ts new file mode 100644 index 0000000..20d5a29 --- /dev/null +++ b/week3/src/app/login/login.component.ts @@ -0,0 +1,57 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpHeaders, HttpClient } from '@angular/common/http'; +import { FormGroup, FormControl, Validators } from '@angular/forms'; +import { SessionStorageService } from '../session-storage.service'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'app-login', + template: ` +
+
+
+ + Username + + + + Password + + + +
+
+
`, + styles: [] +}) +export class LoginComponent implements OnInit { + + loggedIn: boolean; + loginForm = new FormGroup({ + username: new FormControl('user', Validators.required), + password: new FormControl('', Validators.required), + }); + + constructor( + private http: HttpClient, + private sessionStorageService: SessionStorageService, + private router: Router + ) { } + + ngOnInit(): void { + this.loggedIn = this.sessionStorageService.isLoggedIn(); + } + + login() { + const httpOpts = { headers: new HttpHeaders().set('Content-Type', 'application/json'), withCredentials: true}; + this.http.post('http://localhost:5200/_session', { name: this.loginForm.value.username, password: this.loginForm.value.password }, httpOpts) + .subscribe((res: any) => { + if(res.ok) { + this.sessionStorageService.setToken(Date.now()+(2000*1000)); + this.loggedIn = this.sessionStorageService.isLoggedIn(); + this.router.navigate([ '/message' ]); + } + }); + } + +} diff --git a/week3/src/app/message/message.component.html b/week3/src/app/message/message.component.html new file mode 100644 index 0000000..6f403b0 --- /dev/null +++ b/week3/src/app/message/message.component.html @@ -0,0 +1,24 @@ +
+
+
+ + Name + + + + Message + + + +
+
+
+
+ + +
{{msg.name}}
+
{{msg.message}}
+ +
+
+
diff --git a/week3/src/app/message/message.component.scss b/week3/src/app/message/message.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/week3/src/app/message/message.component.spec.ts b/week3/src/app/message/message.component.spec.ts new file mode 100644 index 0000000..e860163 --- /dev/null +++ b/week3/src/app/message/message.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MessageComponent } from './message.component'; + +describe('MessageComponent', () => { + let component: MessageComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MessageComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MessageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/week3/src/app/message/message.component.ts b/week3/src/app/message/message.component.ts new file mode 100644 index 0000000..214316e --- /dev/null +++ b/week3/src/app/message/message.component.ts @@ -0,0 +1,54 @@ +import { Component, OnInit, Output, EventEmitter } from '@angular/core'; +import { HttpHeaders, HttpClient } from '@angular/common/http'; +import { FormGroup, FormControl, Validators } from '@angular/forms'; +import { SessionStorageService } from '../session-storage.service'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'app-message', + templateUrl: './message.component.html', + styleUrls: ['./message.component.scss'] +}) +export class MessageComponent implements OnInit { + + messageForm = new FormGroup({ + name: new FormControl('', Validators.required), + message: new FormControl('', Validators.required), + }); + + data: Array<{ + name: string, + message: string + }> = []; + + constructor( + private http: HttpClient, + private sessionStorageService: SessionStorageService, + private router: Router + ) { } + + ngOnInit(): void { + if (this.sessionStorageService.isLoggedIn()) { + this.getMessages(); + } else { + this.router.navigate([ '/' ]); + } + } + + message() { + const httpOpts = { headers: new HttpHeaders().set('Content-Type', 'application/json') }; + this.http.post('http://localhost:5200/messages', { name: this.messageForm.value.name, message: this.messageForm.value.message }, httpOpts) + .subscribe(() => { + this.data.push({ name: this.messageForm.value.name, message: this.messageForm.value.message }); + }); + } + + getMessages() { + const httpOpts = { headers: new HttpHeaders().set('Content-Type', 'application/json') }; + this.http.post('http://localhost:5200/messages/_all_docs?include_docs=true', httpOpts) + .subscribe((messages: any) => { + this.data = messages.rows.map((message) => message.doc); + }); + } + +} diff --git a/week3/src/app/session-storage.service.spec.ts b/week3/src/app/session-storage.service.spec.ts new file mode 100644 index 0000000..78a1335 --- /dev/null +++ b/week3/src/app/session-storage.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { SessionStorageService } from './session-storage.service'; + +describe('SessionStorageService', () => { + let service: SessionStorageService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(SessionStorageService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/week3/src/app/session-storage.service.ts b/week3/src/app/session-storage.service.ts new file mode 100644 index 0000000..74274e6 --- /dev/null +++ b/week3/src/app/session-storage.service.ts @@ -0,0 +1,22 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class SessionStorageService { + + constructor() { } + + setToken(expiresIn){ + sessionStorage.setItem('expiryTime', expiresIn.toString()); + } + + getToken(){ + return Number.parseInt(sessionStorage.getItem('expiryTime')); + } + + isLoggedIn() { + return this.getToken() > Date.now(); + } + +} diff --git a/week3/src/assets/.gitkeep b/week3/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/week3/src/assets/cropped-ole-ico-logo-32x32.png b/week3/src/assets/cropped-ole-ico-logo-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..aafe29fb672578dbf07cfa22a112fef9af172312 GIT binary patch literal 1683 zcmV;E25k9>P)M29b!>jgzE!p!ABl9WUW2$Xj?{lWFqp9I3>yPf@Zo_(L^ zzV7?JuIs)V4s^x(ntotXU*7FL!fzRVs{1{hb6=o*j z8Tb!w#LBei6WE4-9*hbO!(?>fdS!jSvL2zVkH@k3;GeMo8*o|fPR2lNL?`Y|wxw^*>uZ$t zBxQZHver=6=U@mn2f!pu!4uK_$v81;=$oM3$@*?wf?29!OOol43N%vLo&o#qeE)m+ z8RlR_18>8Ol<>3=>^58+^O=HKn2&oSu^TWk!5>f+J6fvRE7F60Y0<>AZ9sta#)mPz zfuCYJPQh>REeyrWs^Za*?y6L#8T6aDzoWf#XGeSIn2vd)kL#E>x=G%)WGw+th>`W) ztNm?gZ>WmhSc)%VaWbBZ3zc;*RY6tkQWaZN#paIo&K@1@o$v2x@9dk_&A~M-L3f6H z5_CAW?}vli_K>hDn#S@~+!a5ciK~?LtA3v>Cxwh1alZk042_O?qmLPL%7R^39-g#? z)W1t>ThC71{+bc(0nudi<8iX-xI$SUmRsFeg5SsEC*_^K0etI8$1Xh*zin~9QSpfD z@%L0`b?)EtdMDfiVmWRO;{KU>XGdOb88SB|tBW#dzK+uqs4pIggEo2a@i70q%!iL) zDpoh5(LT!hG-drkyd%0_kcSs z9zylQJJb6C_*2X1J@e`3N3F|Dm>R=53ctt<7#1lv+qna?^R0i!nmaM56+|P`tmj?~ zJpyC!#}+mZTk^~~J-Ws(S(|64VqN~4#&t*6_$A#fAhyIuu8h<#$aeMWI@j3Gve9(3 zC$OcZ3QeH9(zc7SqHEE#ZC#6|E$&)0ZKtyCtE_t~>mJIQs@RTsnT|7(*i4L6){O=p zPDZU~YozvUdMJaX8@k3X>Fyf8WNp`?X-m5nP3sv}-<)>b8AqLsFDdKyq_ry|#R=IP zrsK1XNa+3q-5sLMLXH2nxZ1y7=V*Jp;avPOThP>ed|c#qS%^75g#Jug`t9qA zcc_Y4s^URa@k*rBGb42!9#a*Rb*~Jk={Pz;*W$ALkGW|ax0Y-&8t5wCS7|-4Dg-cs^%mV>1!G9_Wd=Brzud^4-j~RU-1k*Bx zFNs|{n4NH6=kQqTEUd-5y|(vH!SXDi&Bb+J?+-l`0K@HBsqcyHPL71G! zyuUpb{H6i?BMaoFaN(pde|1Z6k=ndSR?FV-aLnvY0;q}?RK;@%HZ(z=+$(s~HE&9* zUW$L*nT2J|fdKpu3W?&Z>5BAr0000bbVXQnWMOn=I%9HWVRU5xGB7bWEig4LGcZ&! zFgi3gIx;dXFgH3dFw9Jt@&Et;C3HntbYx+4WjbwdWNBu305UK!H!UzVEi*7wF)%tb dHaapgEigAaFfhFlAWi@P002ovPDHLkV1kBSD>DE9 literal 0 HcmV?d00001 diff --git a/week3/src/environments/environment.prod.ts b/week3/src/environments/environment.prod.ts new file mode 100644 index 0000000..3612073 --- /dev/null +++ b/week3/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/week3/src/environments/environment.ts b/week3/src/environments/environment.ts new file mode 100644 index 0000000..7b4f817 --- /dev/null +++ b/week3/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/week3/src/favicon.ico b/week3/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 + + + + week2 + + + + + + + + + + diff --git a/week3/src/main.ts b/week3/src/main.ts new file mode 100644 index 0000000..c7b673c --- /dev/null +++ b/week3/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/week3/src/polyfills.ts b/week3/src/polyfills.ts new file mode 100644 index 0000000..03711e5 --- /dev/null +++ b/week3/src/polyfills.ts @@ -0,0 +1,63 @@ +/** + * 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 + */ diff --git a/week3/src/styles.scss b/week3/src/styles.scss new file mode 100644 index 0000000..022444b --- /dev/null +++ b/week3/src/styles.scss @@ -0,0 +1,174 @@ +/* You can add global styles to this file, and also import other style files */ + +html, body { height: 100%; } +body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } + +h1, h2, h3, h4, h5, h6 { + margin: 8px 0; +} + +p { + margin: 0; +} + +.spacer { + flex: 1; +} + +.mat-toolbar { + position: absolute; + top: 0; + left: 0; + right: 0; + height: 60px; + display: flex; + align-items: center; + background-color: #1976d2; + color: white; + font-weight: 600; + + img { + margin: 0 16px; + } +} + +.content { + display: flex; + margin: 82px auto 32px; + padding: 0 16px; + max-width: 960px; + flex-direction: column; + align-items: center; +} + +svg.material-icons { + height: 24px; + width: auto; +} + +svg.material-icons:not(:last-child) { + margin-right: 8px; +} + +.card svg.material-icons path { + fill: #888; +} + +.card-container { + display: flex; + flex-wrap: wrap; + justify-content: center; + margin-top: 16px; +} + +.card { + border-radius: 4px; + border: 1px solid #eee; + background-color: #fafafa; + height: 40px; + width: 200px; + margin: 0 8px 16px; + padding: 16px; + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + transition: all 0.2s ease-in-out; + line-height: 24px; +} + +.card-container .card:not(:last-child) { + margin-right: 0; +} + +.card.card-small { + height: 16px; + width: 168px; +} + +.card-container .card:not(.highlight-card) { + cursor: pointer; +} + +.card-container .card:not(.highlight-card):hover { + transform: translateY(-3px); + box-shadow: 0 4px 17px rgba(0, 0, 0, 0.35); + .material-icons path { + fill: rgb(105, 103, 103); + } +} + +.card.highlight-card { + background-color: #1976d2; + color: white; + font-weight: 600; + border: none; + width: auto; + min-width: 30%; + position: relative; + + span { + margin-left: 60px; + } +} + +a, +a:visited, +a:hover { + color: #1976d2; + text-decoration: none; +} + +a:hover { + color: #125699; +} + +.circle-link { + height: 40px; + width: 40px; + border-radius: 40px; + margin: 8px; + background-color: white; + border: 1px solid #eeeeee; + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); + transition: 1s ease-out; +} + +.circle-link:hover { + transform: translateY(-0.25rem); + box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2); +} + +footer { + margin-top: 8px; + display: flex; + align-items: center; + line-height: 20px; + + a { + display: flex; + align-items: center; + } +} + +/* Responsive Styles */ +@media screen and (max-width: 767px) { + + .card-container > *:not(.circle-link) { + width: 100%; + } + + .card:not(.highlight-card) { + height: 16px; + margin: 8px 0; + } + + .card.highlight-card span { + margin-left: 72px; + } + +} diff --git a/week3/src/test.ts b/week3/src/test.ts new file mode 100644 index 0000000..50193eb --- /dev/null +++ b/week3/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/week3/tsconfig.app.json b/week3/tsconfig.app.json new file mode 100644 index 0000000..232c3a5 --- /dev/null +++ b/week3/tsconfig.app.json @@ -0,0 +1,15 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/week3/tsconfig.base.json b/week3/tsconfig.base.json new file mode 100644 index 0000000..f69f654 --- /dev/null +++ b/week3/tsconfig.base.json @@ -0,0 +1,20 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "moduleResolution": "node", + "importHelpers": true, + "target": "es2015", + "module": "es2020", + "lib": [ + "es2018", + "dom" + ] + } +} diff --git a/week3/tsconfig.json b/week3/tsconfig.json new file mode 100644 index 0000000..2338536 --- /dev/null +++ b/week3/tsconfig.json @@ -0,0 +1,17 @@ +/* + This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience. + It is not intended to be used to perform a compilation. + + To learn more about this file see: https://angular.io/config/solution-tsconfig. +*/ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.spec.json" + } +] +} diff --git a/week3/tsconfig.spec.json b/week3/tsconfig.spec.json new file mode 100644 index 0000000..729a6d6 --- /dev/null +++ b/week3/tsconfig.spec.json @@ -0,0 +1,18 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "outDir": "./out-tsc/spec", + "types": [ + "jasmine" + ] + }, + "files": [ + "src/test.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/week3/tslint.json b/week3/tslint.json new file mode 100644 index 0000000..67bcdea --- /dev/null +++ b/week3/tslint.json @@ -0,0 +1,152 @@ +{ + "extends": "tslint:recommended", + "rules": { + "align": { + "options": [ + "parameters", + "statements" + ] + }, + "array-type": false, + "arrow-return-shorthand": true, + "curly": true, + "deprecation": { + "severity": "warning" + }, + "component-class-suffix": true, + "contextual-lifecycle": true, + "directive-class-suffix": true, + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], + "eofline": true, + "import-blacklist": [ + true, + "rxjs/Rx" + ], + "import-spacing": true, + "indent": { + "options": [ + "spaces" + ] + }, + "max-classes-per-file": false, + "max-line-length": [ + true, + 140 + ], + "member-ordering": [ + true, + { + "order": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } + ], + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-empty": false, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-non-null-assertion": true, + "no-redundant-jsdoc": true, + "no-switch-case-fall-through": true, + "no-var-requires": false, + "object-literal-key-quotes": [ + true, + "as-needed" + ], + "quotemark": [ + true, + "single" + ], + "semicolon": { + "options": [ + "always" + ] + }, + "space-before-function-paren": { + "options": { + "anonymous": "never", + "asyncArrow": "always", + "constructor": "never", + "method": "never", + "named": "never" + } + }, + "typedef": [ + true, + "call-signature" + ], + "typedef-whitespace": { + "options": [ + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + } + ] + }, + "variable-name": { + "options": [ + "ban-keywords", + "check-format", + "allow-pascal-case" + ] + }, + "whitespace": { + "options": [ + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type", + "check-typecast" + ] + }, + "no-conflicting-lifecycle": true, + "no-host-metadata-property": true, + "no-input-rename": true, + "no-inputs-metadata-property": true, + "no-output-native": true, + "no-output-on-prefix": true, + "no-output-rename": true, + "no-outputs-metadata-property": true, + "template-banana-in-box": true, + "template-no-negated-async": true, + "use-lifecycle-interface": true, + "use-pipe-transform-interface": true + }, + "rulesDirectory": [ + "codelyzer" + ] +} \ No newline at end of file From 44f6972f15f969171c9542b4fc46ff1136ff872d Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Sun, 4 Oct 2020 21:15:38 +0545 Subject: [PATCH 11/12] readme update --- week3/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week3/README.md b/week3/README.md index ae88bf2..51db728 100644 --- a/week3/README.md +++ b/week3/README.md @@ -1,4 +1,4 @@ -# week2 +# week3 This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.3. From 4f66d7998df73347943b6f600af5e96c552edd71 Mon Sep 17 00:00:00 2001 From: Laxman Maharjan Date: Sun, 4 Oct 2020 21:21:07 +0545 Subject: [PATCH 12/12] update week2 to week3 --- week3/angular.json | 16 ++++++++-------- week3/e2e/src/app.e2e-spec.ts | 2 +- week3/karma.conf.js | 2 +- week3/package.json | 2 +- week3/src/app/app.component.spec.ts | 6 +++--- week3/src/app/app.component.ts | 2 +- week3/src/index.html | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/week3/angular.json b/week3/angular.json index ce86bc9..06438fb 100644 --- a/week3/angular.json +++ b/week3/angular.json @@ -3,7 +3,7 @@ "version": 1, "newProjectRoot": "projects", "projects": { - "week2": { + "week3": { "projectType": "application", "schematics": { "@schematics/angular:component": { @@ -17,7 +17,7 @@ "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist/week2", + "outputPath": "dist/week3", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", @@ -67,18 +67,18 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "week2:build" + "browserTarget": "week3:build" }, "configurations": { "production": { - "browserTarget": "week2:build:production" + "browserTarget": "week3:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "week2:build" + "browserTarget": "week3:build" } }, "test": { @@ -116,18 +116,18 @@ "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "week2:serve" + "devServerTarget": "week3:serve" }, "configurations": { "production": { - "devServerTarget": "week2:serve:production" + "devServerTarget": "week3:serve:production" } } } } } }, - "defaultProject": "week2", + "defaultProject": "week3", "cli": { "analytics": false } diff --git a/week3/e2e/src/app.e2e-spec.ts b/week3/e2e/src/app.e2e-spec.ts index 9dac7cb..6160e06 100644 --- a/week3/e2e/src/app.e2e-spec.ts +++ b/week3/e2e/src/app.e2e-spec.ts @@ -10,7 +10,7 @@ describe('workspace-project App', () => { it('should display welcome message', () => { page.navigateTo(); - expect(page.getTitleText()).toEqual('week2 app is running!'); + expect(page.getTitleText()).toEqual('week3 app is running!'); }); afterEach(async () => { diff --git a/week3/karma.conf.js b/week3/karma.conf.js index f06d4ba..7d8bdd2 100644 --- a/week3/karma.conf.js +++ b/week3/karma.conf.js @@ -16,7 +16,7 @@ module.exports = function (config) { clearContext: false // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { - dir: require('path').join(__dirname, './coverage/week2'), + dir: require('path').join(__dirname, './coverage/week3'), reports: ['html', 'lcovonly', 'text-summary'], fixWebpackSourcePaths: true }, diff --git a/week3/package.json b/week3/package.json index d7033b4..4a28be6 100644 --- a/week3/package.json +++ b/week3/package.json @@ -1,5 +1,5 @@ { - "name": "week2", + "name": "week3", "version": "0.0.0", "scripts": { "ng": "ng", diff --git a/week3/src/app/app.component.spec.ts b/week3/src/app/app.component.spec.ts index f747de7..014ba88 100644 --- a/week3/src/app/app.component.spec.ts +++ b/week3/src/app/app.component.spec.ts @@ -20,16 +20,16 @@ describe('AppComponent', () => { expect(app).toBeTruthy(); }); - it(`should have as title 'week2'`, () => { + it(`should have as title 'week3'`, () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; - expect(app.title).toEqual('week2'); + expect(app.title).toEqual('week3'); }); it('should render title', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.nativeElement; - expect(compiled.querySelector('.content span').textContent).toContain('week2 app is running!'); + expect(compiled.querySelector('.content span').textContent).toContain('week3 app is running!'); }); }); diff --git a/week3/src/app/app.component.ts b/week3/src/app/app.component.ts index 8e4a8dc..d126d84 100644 --- a/week3/src/app/app.component.ts +++ b/week3/src/app/app.component.ts @@ -9,7 +9,7 @@ import { Router } from '@angular/router'; }) export class AppComponent { - title = 'week2'; + title = 'week3'; loggedIn: boolean = false; notifications = []; diff --git a/week3/src/index.html b/week3/src/index.html index 6c4d687..27ee639 100644 --- a/week3/src/index.html +++ b/week3/src/index.html @@ -2,7 +2,7 @@ - week2 + week3