diff --git a/.angular-cli.json b/.angular-cli.json new file mode 100644 index 0000000000..0532308326 --- /dev/null +++ b/.angular-cli.json @@ -0,0 +1,64 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "project": { + "name": "ang-bell-app" + }, + "apps": [ + { + "root": "src", + "outDir": "dist", + "assets": [ + "assets", + "favicon.ico" + ], + "index": "index.html", + "main": "main.ts", + "polyfills": "polyfills.ts", + "test": "test.ts", + "tsconfig": "tsconfig.app.json", + "testTsconfig": "tsconfig.spec.json", + "prefix": "app", + "styles": [ + "styles.css", + "../node_modules/tether/dist/css/tether.min.css", + "../node_modules/bootstrap/dist/css/bootstrap.min.css", + "../node_modules/font-awesome/css/font-awesome.min.css" + ], + "scripts": [ + "../node_modules/jquery/dist/jquery.min.js", + "../node_modules/tether/dist/js/tether.min.js", + "../node_modules/bootstrap/dist/js/bootstrap.min.js" + ], + "environmentSource": "environments/environment.ts", + "environments": { + "dev": "environments/environment.ts", + "prod": "environments/environment.prod.ts" + } + } + ], + "e2e": { + "protractor": { + "config": "./protractor.conf.js" + } + }, + "lint": [ + { + "project": "src/tsconfig.app.json" + }, + { + "project": "src/tsconfig.spec.json" + }, + { + "project": "e2e/tsconfig.e2e.json" + } + ], + "test": { + "karma": { + "config": "./karma.conf.js" + } + }, + "defaults": { + "styleExt": "css", + "component": {} + } +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..6e87a003da --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..23b8d3d236 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +build/ +npm-debug.log diff --git a/README.md b/README.md new file mode 100644 index 0000000000..4e7a786d65 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# AngBellApp + +This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.2.1. + +## 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|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/). +Before running the tests make sure you are serving the app via `ng serve`. + +## 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 0000000000..340c52cffc --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,96 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure(2) do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "ole/jessie64" + config.vm.box_version = "0.1.6" + + config.vm.hostname = "planetangular" + + config.vm.define "planetangular" do |planetangular| + end + + config.vm.provider "virtualbox" do |vb| + vb.name = "planetangular" + end + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8082" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8082 + config.vm.network "forwarded_port", guest: 5984, host: 5984, auto_correct: true + config.vm.network "forwarded_port", guest: 5986, host: 5986, auto_correct: true + config.vm.network "forwarded_port", guest: 9000, host: 9000, auto_correct: true + config.vm.network "forwarded_port", guest: 22, host: 2222, host_ip: "0.0.0.0", id: "ssh", auto_correct: true + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + vb.memory = "666" + end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies + # such as FTP and Heroku are also available. See the documentation at + # https://docs.vagrantup.com/v2/push/atlas.html for more information. + # config.push.define "atlas" do |push| + # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" + # end + + # Enable provisioning with a shell script. Additional provisioners such as + # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the + # documentation for more information about their specific syntax and use. + config.vm.provision "shell", inline: <<-SHELL +# docker pull portainer/portainer +# sudo docker run -d -p 9000:9000 --name treehouse -v /var/run/docker.sock:/var/run/docker.sock portainer:portainer + docker pull klaemo/couchdb + sudo docker run -d -p 5984:5984 -p 5986:5986 --name planet -v /srv/data/bell:/usr/local/var/lib/couchdb -v /srv/log/bell:/usr/local/var/log/couchdb klaemo/couchdb + cd ~ + curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh + bash nodesource_setup.sh + apt-get -y install nodejs + cd /vagrant + echo "npm install" + echo "npm run watch" +# npm install +# npm run watch + SHELL +end diff --git a/e2e/app.e2e-spec.ts b/e2e/app.e2e-spec.ts new file mode 100644 index 0000000000..037b9f9cda --- /dev/null +++ b/e2e/app.e2e-spec.ts @@ -0,0 +1,14 @@ +import { AngBellAppPage } from './app.po'; + +describe('ang-bell-app App', () => { + let page: AngBellAppPage; + + beforeEach(() => { + page = new AngBellAppPage(); + }); + + it('should display welcome message', () => { + page.navigateTo(); + expect(page.getParagraphText()).toEqual('Welcome to app!'); + }); +}); diff --git a/e2e/app.po.ts b/e2e/app.po.ts new file mode 100644 index 0000000000..d59cd5cab8 --- /dev/null +++ b/e2e/app.po.ts @@ -0,0 +1,11 @@ +import { browser, by, element } from 'protractor'; + +export class AngBellAppPage { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.css('app-root h1')).getText(); + } +} diff --git a/e2e/tsconfig.e2e.json b/e2e/tsconfig.e2e.json new file mode 100644 index 0000000000..1d9e5edf09 --- /dev/null +++ b/e2e/tsconfig.e2e.json @@ -0,0 +1,14 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "baseUrl": "./", + "module": "commonjs", + "target": "es5", + "types": [ + "jasmine", + "jasminewd2", + "node" + ] + } +} diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000000..4d9ab9d948 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,33 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/0.13/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular/cli'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular/cli/plugins/karma') + ], + client:{ + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + reports: [ 'html', 'lcovonly' ], + fixWebpackSourcePaths: true + }, + angularCli: { + environment: 'dev' + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000000..a31f023a6c --- /dev/null +++ b/package.json @@ -0,0 +1,52 @@ +{ + "name": "ang-bell-app", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e" + }, + "private": true, + "dependencies": { + "@angular/animations": "^4.0.0", + "@angular/common": "^4.0.0", + "@angular/compiler": "^4.0.0", + "@angular/core": "^4.0.0", + "@angular/forms": "^4.0.0", + "@angular/http": "^4.0.0", + "@angular/platform-browser": "^4.0.0", + "@angular/platform-browser-dynamic": "^4.0.0", + "@angular/router": "^4.0.0", + "angularjs-datepicker": "^2.1.23", + "bootstrap": "^4.0.0-alpha.6", + "core-js": "^2.4.1", + "font-awesome": "^4.7.0", + "rxjs": "^5.1.0", + "zone.js": "^0.8.4" + }, + "devDependencies": { + "@angular/cli": "1.2.1", + "@angular/compiler-cli": "^4.0.0", + "@angular/language-service": "^4.0.0", + "@types/jasmine": "~2.5.53", + "@types/jasminewd2": "~2.0.2", + "@types/node": "~6.0.60", + "codelyzer": "~3.0.1", + "jasmine-core": "~2.6.2", + "jasmine-spec-reporter": "~4.1.0", + "karma": "~1.7.0", + "karma-chrome-launcher": "~2.1.1", + "karma-cli": "~1.0.1", + "karma-coverage-istanbul-reporter": "^1.2.1", + "karma-jasmine": "~1.1.0", + "karma-jasmine-html-reporter": "^0.2.2", + "protractor": "~5.1.2", + "ts-node": "~3.0.4", + "tslint": "~5.3.2", + "typescript": "~2.3.3" + } +} diff --git a/protractor.conf.js b/protractor.conf.js new file mode 100644 index 0000000000..7ee3b5ee86 --- /dev/null +++ b/protractor.conf.js @@ -0,0 +1,28 @@ +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/lib/config.ts + +const { SpecReporter } = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + './e2e/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + onPrepare() { + require('ts-node').register({ + project: 'e2e/tsconfig.e2e.json' + }); + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +}; diff --git a/src/app/app.component.css b/src/app/app.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/app.component.html b/src/app/app.component.html new file mode 100644 index 0000000000..90c6b64632 --- /dev/null +++ b/src/app/app.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts new file mode 100644 index 0000000000..9510495a2d --- /dev/null +++ b/src/app/app.component.spec.ts @@ -0,0 +1,32 @@ +import { TestBed, async } from '@angular/core/testing'; + +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ + AppComponent + ], + }).compileComponents(); + })); + + it('should create the app', async(() => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app).toBeTruthy(); + })); + + it(`should have as title 'app'`, async(() => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app.title).toEqual('app'); + })); + + it('should render title in a h1 tag', async(() => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); + })); +}); diff --git a/src/app/app.component.ts b/src/app/app.component.ts new file mode 100644 index 0000000000..4df0542ab5 --- /dev/null +++ b/src/app/app.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.css'] +}) +export class AppComponent { + title = 'app'; +} \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts new file mode 100644 index 0000000000..a8d317eeba --- /dev/null +++ b/src/app/app.module.ts @@ -0,0 +1,99 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; +import { FormsModule,ReactiveFormsModule } from "@angular/forms"; +import { HttpModule } from "@angular/http"; +import { HostBinding } from '@angular/core'; +import { RouterModule,Routes } from '@angular/router'; + +import { AppComponent } from './app.component'; +import { LoginComponent } from './login/login.component'; +import { NavComponent } from './nav/nav.component'; +import { FooterComponent } from './footer/footer.component'; + +import { CouchService } from './shared/couchdb.service'; +import { AuthService } from './shared/auth-guard.service'; +import { UserService } from './shared/user.service'; + +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; +import { DashboardComponent } from './dashboard/dashboard.component'; +import { RegisterComponent } from './register/register.component'; +import { MembersComponent } from './members/members.component'; +import { TestComponent } from './test/test.component'; +import { NgxPaginationModule } from 'ngx-pagination'; +import { MeetupsComponent } from './meetups/meetups.component'; +import { MeetupsaddComponent } from './meetupsadd/meetupsadd.component' + +// const appRoutes: Routes = [ + // { path: '', component: LoginComponent, pathMatch: 'full' } +// ]; + +@NgModule({ + declarations: [ + AppComponent, + // RouterModule, + LoginComponent, + NavComponent, + FooterComponent, + PageNotFoundComponent, + DashboardComponent, + RegisterComponent, + MembersComponent, + TestComponent, + MeetupsComponent, + MeetupsaddComponent + ], + imports: [ + BrowserModule, + FormsModule, + HttpModule, + ReactiveFormsModule, + NgxPaginationModule, + RouterModule.forRoot([ + { + path: '', + component: LoginComponent + }, + { + path: 'login', + component: LoginComponent + }, + { + path: 'dashboard', + canActivate: [AuthService], + component: DashboardComponent, + children: [ + { + path: 'test', + component: TestComponent + } + ] + }, + { + path: 'register', + component: RegisterComponent + }, + { + path: 'members', + canActivate: [AuthService], + component: MembersComponent + }, + { + path: 'meetups', + canActivate: [AuthService], + component: MeetupsComponent + }, + { + path: 'meetupsadd', + canActivate: [AuthService], + component: MeetupsaddComponent + }, + { + path: '**', + component: PageNotFoundComponent + } + ]) + ], + providers: [CouchService, AuthService, UserService], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/src/app/dashboard/dashboard.component.css b/src/app/dashboard/dashboard.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html new file mode 100644 index 0000000000..ead38ad551 --- /dev/null +++ b/src/app/dashboard/dashboard.component.html @@ -0,0 +1,4 @@ + + Welcome to the page !!! + + \ No newline at end of file diff --git a/src/app/dashboard/dashboard.component.spec.ts b/src/app/dashboard/dashboard.component.spec.ts new file mode 100644 index 0000000000..fea6bfb4db --- /dev/null +++ b/src/app/dashboard/dashboard.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DashboardComponent } from './dashboard.component'; + +describe('DashboardComponent', () => { + let component: DashboardComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DashboardComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DashboardComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts new file mode 100644 index 0000000000..ed34d83a28 --- /dev/null +++ b/src/app/dashboard/dashboard.component.ts @@ -0,0 +1,17 @@ +import { Component, OnInit } from '@angular/core'; +import { UserService } from '../shared/user.service'; + +@Component({ + selector: 'app-dashboard', + templateUrl: './dashboard.component.html', + styleUrls: ['./dashboard.component.css'] +}) +export class DashboardComponent implements OnInit { + + constructor(private userService: UserService) { } + + ngOnInit() { + console.log(this.userService.get()); + } + +} \ No newline at end of file diff --git a/src/app/footer/footer.component.css b/src/app/footer/footer.component.css new file mode 100644 index 0000000000..63ad7422c9 --- /dev/null +++ b/src/app/footer/footer.component.css @@ -0,0 +1,9 @@ +.footer { + position: absolute; + bottom: 0; + width: 100%; + height: 60px; + line-height: 60px; + background-color: #f5f5f5; + text-align: center; +} \ No newline at end of file diff --git a/src/app/footer/footer.component.html b/src/app/footer/footer.component.html new file mode 100644 index 0000000000..e8de13715e --- /dev/null +++ b/src/app/footer/footer.component.html @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/app/footer/footer.component.spec.ts b/src/app/footer/footer.component.spec.ts new file mode 100644 index 0000000000..01d35cc68f --- /dev/null +++ b/src/app/footer/footer.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FooterComponent } from './footer.component'; + +describe('FooterComponent', () => { + let component: FooterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FooterComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FooterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/footer/footer.component.ts b/src/app/footer/footer.component.ts new file mode 100644 index 0000000000..4e2739351a --- /dev/null +++ b/src/app/footer/footer.component.ts @@ -0,0 +1,17 @@ +import { Component, OnInit } from '@angular/core'; +import { UserService } from '../shared/user.service'; + +@Component({ + selector: 'app-footer', + templateUrl: './footer.component.html', + styleUrls: ['./footer.component.css'] +}) +export class FooterComponent implements OnInit { + + constructor(private userService: UserService) { } + + ngOnInit() { + console.log(this.userService.get()); + } + +} diff --git a/src/app/login/login.component.css b/src/app/login/login.component.css new file mode 100644 index 0000000000..d91dff8b65 --- /dev/null +++ b/src/app/login/login.component.css @@ -0,0 +1,83 @@ +.form-signin +{ + max-width: 330px; + padding: 15px; + margin: 0 auto; +} +.form-signin .form-signin-heading, .form-signin .checkbox +{ + margin-bottom: 10px; +} +.form-signin .checkbox +{ + font-weight: normal; +} +.form-signin .form-control +{ + position: relative; + font-size: 16px; + height: auto; + padding: 10px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.form-signin .form-control:focus +{ + z-index: 2; +} +.form-signin input[type="text"] +{ + margin-bottom: -1px; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} +.form-signin input[type="password"] +{ + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} +.account-wall +{ + margin-top: 20px; + padding: 40px 0px 20px 0px; + -moz-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3); + -webkit-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3); + box-shadow: 0px 2px 2px rgba(0, 0, 0, 0); +} +.login-title +{ + color: #555; + font-size: 18px; + font-weight: 400; + display: block; +} +.profile-img +{ + width: 96px; + height: 96px; + margin: 0 auto 10px; + display: block; + -moz-border-radius: 50%; + -webkit-border-radius: 50%; + border-radius: 50%; +} +.need-help +{ + margin-top: 10px; +} +.new-account +{ + display: block; + margin-top: 10px; +} +.image123{ + webkit-background-size: cover; + -moz-background-size: cover; +} +:host(.dark) { + background-color: #545454; + color: black; + font-size: 1.5em; +} \ No newline at end of file diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html new file mode 100644 index 0000000000..1b1f3f506a --- /dev/null +++ b/src/app/login/login.component.html @@ -0,0 +1,29 @@ + +
+
+
+ {{message}} + + + +
+
+
+ \ No newline at end of file diff --git a/src/app/login/login.component.spec.ts b/src/app/login/login.component.spec.ts new file mode 100644 index 0000000000..b9b2bc1876 --- /dev/null +++ b/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 be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts new file mode 100644 index 0000000000..25c8c6d5dc --- /dev/null +++ b/src/app/login/login.component.ts @@ -0,0 +1,53 @@ +import { Component, OnInit, Input, OnChanges, SimpleChange } from '@angular/core'; +// import { FormGroup, FormControl } from '@angular/forms'; +import { CouchService } from '../shared/couchdb.service'; +import { Router, CanActivate } from '@angular/router'; +import { UserService } from '../shared/user.service'; + +@Component({ + selector: 'app-login', + templateUrl: './login.component.html', + styleUrls: ['./login.component.css'], +}) +export class LoginComponent implements OnInit { + + // form; + + constructor( + private couchService: CouchService, + private userService: UserService, + private router: Router, + + ) { + document.body.style.backgroundImage = "url(../assets/planet_home.png)" + document.body.style.backgroundRepeat = "no-repeat"; + document.body.style.backgroundSize = "cover"; + document.body.style.backgroundPosition = "center center"; + document.body.style.backgroundAttachment = "fixed"; +} +ngOnDestroy(){ + document.body.style.backgroundImage = "none"; + } + + model = { name:'', password:'', repeatPassword:'' }; + message = ""; + + ngOnInit(){ + // this.form = new FormGroup({ + // UserName = new FormControl(), + // Password = new FormControl() + // }); + console.log(this.userService.get()); + } + + onSubmit = function(user){ + this.login(user); + } + + login(user) { + this.couchService.post('_session', {'name':user.UserName, 'password':user.Password}, { withCredentials:true }) + .then((data) => { + this.router.navigate(['/dashboard']); + },(error) => this.message = 'Username and/or password do not match'); + } +} diff --git a/src/app/meetups/meetups.component.css b/src/app/meetups/meetups.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/meetups/meetups.component.html b/src/app/meetups/meetups.component.html new file mode 100644 index 0000000000..d67d6fb4dc --- /dev/null +++ b/src/app/meetups/meetups.component.html @@ -0,0 +1,30 @@ + +
+

{{message}}

+

Meetups

+ Meetup Add + + + + + + + + + + + + + + + +
TitleDescriptionActions
+ {{meetups.doc.title}} + + {{meetups.doc.description}} + + +
+ +
+ diff --git a/src/app/meetups/meetups.component.spec.ts b/src/app/meetups/meetups.component.spec.ts new file mode 100644 index 0000000000..65eb5d4742 --- /dev/null +++ b/src/app/meetups/meetups.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MeetupsComponent } from './meetups.component'; + +describe('MeetupsComponent', () => { + let component: MeetupsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MeetupsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MeetupsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/meetups/meetups.component.ts b/src/app/meetups/meetups.component.ts new file mode 100644 index 0000000000..a036820434 --- /dev/null +++ b/src/app/meetups/meetups.component.ts @@ -0,0 +1,28 @@ +import { Component, OnInit } from '@angular/core'; +import { CouchService } from '../shared/couchdb.service'; +import { Router, CanActivate } from '@angular/router'; +import { UserService } from '../shared/user.service'; + +@Component({ + selector: 'app-meetups', + templateUrl: './meetups.component.html', + styleUrls: ['./meetups.component.css'] +}) +export class MeetupsComponent implements OnInit { + message = ""; + obj = []; + constructor( + private couchService: CouchService, + private userService: UserService, + private router: Router + ) { } + + ngOnInit() { + this.couchService.get('meetups/_all_docs?include_docs=true') + .then((data) => { + this.obj = data.rows; + console.log(data); + }, (error) => this.message = ''); + } + +} diff --git a/src/app/meetupsadd/meetupsadd.component.css b/src/app/meetupsadd/meetupsadd.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/meetupsadd/meetupsadd.component.html b/src/app/meetupsadd/meetupsadd.component.html new file mode 100644 index 0000000000..c69fa4e815 --- /dev/null +++ b/src/app/meetupsadd/meetupsadd.component.html @@ -0,0 +1,41 @@ + +
+

{{message}}

+
+
+ + +Start a New Meetup + + +
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ + + + +
+ +
+ +
+
+ +
+
+
+ \ No newline at end of file diff --git a/src/app/meetupsadd/meetupsadd.component.spec.ts b/src/app/meetupsadd/meetupsadd.component.spec.ts new file mode 100644 index 0000000000..b998578a25 --- /dev/null +++ b/src/app/meetupsadd/meetupsadd.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MeetupsaddComponent } from './meetupsadd.component'; + +describe('MeetupsaddComponent', () => { + let component: MeetupsaddComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MeetupsaddComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MeetupsaddComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/meetupsadd/meetupsadd.component.ts b/src/app/meetupsadd/meetupsadd.component.ts new file mode 100644 index 0000000000..313a80bbf4 --- /dev/null +++ b/src/app/meetupsadd/meetupsadd.component.ts @@ -0,0 +1,38 @@ +import { Component, OnInit } from '@angular/core'; +import { CouchService } from '../shared/couchdb.service'; +import { Router, CanActivate } from '@angular/router'; +import { UserService } from '../shared/user.service'; + +@Component({ + selector: 'app-meetupsadd', + templateUrl: './meetupsadd.component.html', + styleUrls: ['./meetupsadd.component.css'] +}) +export class MeetupsaddComponent implements OnInit { + message = ""; + obj = []; + constructor( + private couchService: CouchService, + private userService: UserService, + private router: Router + ) { } + + model = { title:'', description:'' } + + ngOnInit() { + } + + onSubmit(meetup){ + if(meetup.description != '' && meetup.title != '') { + console.log(meetup.description,meetup.title) + this.couchService.post('meetups', {'title': meetup.title, 'description': meetup.description}) + .then((data) => { + this.message = 'meetup created: '; + //this.router.navigate(['']); + }, (error) => this.message = ''); + } else { + this.message = 'please fill up the form'; + } + } + +} diff --git a/src/app/members/members.component.css b/src/app/members/members.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/members/members.component.html b/src/app/members/members.component.html new file mode 100644 index 0000000000..c4c71a5b9c --- /dev/null +++ b/src/app/members/members.component.html @@ -0,0 +1,29 @@ + +
+

{{message}}

+

Members

+ + + + + + + + + + + + + + + +
MemberIDActions
+ {{member.doc.name}} + + {{member.id}} + + +
+ +
+ diff --git a/src/app/members/members.component.spec.ts b/src/app/members/members.component.spec.ts new file mode 100644 index 0000000000..fde4c39b4a --- /dev/null +++ b/src/app/members/members.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MembersComponent } from './members.component'; + +describe('MembersComponent', () => { + let component: MembersComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MembersComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MembersComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/members/members.component.ts b/src/app/members/members.component.ts new file mode 100644 index 0000000000..c23dfe7a58 --- /dev/null +++ b/src/app/members/members.component.ts @@ -0,0 +1,40 @@ +import { Component, OnInit } from '@angular/core'; +import { CouchService } from '../shared/couchdb.service'; +import { Router, CanActivate } from '@angular/router'; +import { UserService } from '../shared/user.service'; + +@Component({ + selector: 'app-members', + templateUrl: './members.component.html', + styleUrls: ['./members.component.css'] +}) +export class MembersComponent implements OnInit { + + message = ""; + obj = []; + constructor( + private couchService: CouchService, + private userService: UserService, + private router: Router + ) {} + + ngOnInit() { + this.couchService.get('_users/_all_docs?include_docs=true') + .then((data) => { + this.obj = data.rows; + console.log(data); + }, (error) => this.message = ''); + } + + onDelete(member_id,rev_id,index){ + if(member_id) { + this.couchService.delete('_users/'+member_id+'?rev='+rev_id) + .then((data) => { + this.obj.splice(index,1); + }, (error) => this.message = ''); + } else { + this.message = 'There is no member'; + } + } + +} diff --git a/src/app/members/members.module.ts b/src/app/members/members.module.ts new file mode 100644 index 0000000000..ed3b7335e9 --- /dev/null +++ b/src/app/members/members.module.ts @@ -0,0 +1,20 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; +import { FormsModule,ReactiveFormsModule } from "@angular/forms"; +import { HttpModule } from "@angular/http"; +import { AppModule } from '../app.module' +import { MembersComponent } from './members.component'; + +@NgModule({ + declarations: [ + MembersComponent + ], + imports: [ + BrowserModule, + FormsModule, + HttpModule, + ], + providers: [], + bootstrap: [MembersComponent] +}) +export class MembersModule { } \ No newline at end of file diff --git a/src/app/nav/nav.component.css b/src/app/nav/nav.component.css new file mode 100644 index 0000000000..f38c02e878 --- /dev/null +++ b/src/app/nav/nav.component.css @@ -0,0 +1 @@ +ul.nav a:hover, ul.nav a:focus, ul.nav a:active { color: #000; } \ No newline at end of file diff --git a/src/app/nav/nav.component.html b/src/app/nav/nav.component.html new file mode 100644 index 0000000000..430381e633 --- /dev/null +++ b/src/app/nav/nav.component.html @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/src/app/nav/nav.component.spec.ts b/src/app/nav/nav.component.spec.ts new file mode 100644 index 0000000000..eb300e40f3 --- /dev/null +++ b/src/app/nav/nav.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NavComponent } from './nav.component'; + +describe('NavComponent', () => { + let component: NavComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ NavComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(NavComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/nav/nav.component.ts b/src/app/nav/nav.component.ts new file mode 100644 index 0000000000..1ffb0f4fa8 --- /dev/null +++ b/src/app/nav/nav.component.ts @@ -0,0 +1,33 @@ +import { Component, OnInit } from '@angular/core'; +import { Router, CanActivate } from '@angular/router'; +import { UserService } from '../shared/user.service'; +import { CouchService } from '../shared/couchdb.service'; + +@Component({ + selector: 'app-nav', + templateUrl: './nav.component.html', + styleUrls: ['./nav.component.css'] +}) +export class NavComponent implements OnInit { + + isLoggedIn = ''; + + constructor( + private userService: UserService, + private router: Router, + private couchService: CouchService + ) { } + + ngOnInit() { + this.isLoggedIn = this.userService.get(); + } + + logout(){ + this.couchService.delete('_session',{ withCredentials:true }).then((data:any) => { + if(data.ok === true) { + this.router.navigate(['/login'], {}); + } + }); + } + +} diff --git a/src/app/page-not-found/page-not-found.component.css b/src/app/page-not-found/page-not-found.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/page-not-found/page-not-found.component.html b/src/app/page-not-found/page-not-found.component.html new file mode 100644 index 0000000000..aff4ba4a2f --- /dev/null +++ b/src/app/page-not-found/page-not-found.component.html @@ -0,0 +1,15 @@ +
+
+
+
+

+ Oops!

+

+ 404 Not Found

+
+ Sorry, an error has occured, Requested page not found! +
+
+
+
+
diff --git a/src/app/page-not-found/page-not-found.component.spec.ts b/src/app/page-not-found/page-not-found.component.spec.ts new file mode 100644 index 0000000000..391700861f --- /dev/null +++ b/src/app/page-not-found/page-not-found.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PageNotFoundComponent } from './page-not-found.component'; + +describe('PageNotFoundComponent', () => { + let component: PageNotFoundComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PageNotFoundComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PageNotFoundComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/page-not-found/page-not-found.component.ts b/src/app/page-not-found/page-not-found.component.ts new file mode 100644 index 0000000000..c5c55a794d --- /dev/null +++ b/src/app/page-not-found/page-not-found.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-page-not-found', + templateUrl: './page-not-found.component.html', + styleUrls: ['./page-not-found.component.css'] +}) +export class PageNotFoundComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/src/app/register/register.component.css b/src/app/register/register.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/register/register.component.html b/src/app/register/register.component.html new file mode 100644 index 0000000000..8b2a12ff0f --- /dev/null +++ b/src/app/register/register.component.html @@ -0,0 +1,56 @@ +
+

{{message}}

+
+
+ + +Register + + +
+ +
+ +
+ Name is required +
+
+
+ + +
+ +
+ +
+ password is required +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+ +
+ +
+
+ +
+
+
\ No newline at end of file diff --git a/src/app/register/register.component.spec.ts b/src/app/register/register.component.spec.ts new file mode 100644 index 0000000000..61394caaa5 --- /dev/null +++ b/src/app/register/register.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { RegisterComponent } from './register.component'; + +describe('RegisterComponent', () => { + let component: RegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ RegisterComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(RegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/register/register.component.ts b/src/app/register/register.component.ts new file mode 100644 index 0000000000..8244fe1efa --- /dev/null +++ b/src/app/register/register.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit } from '@angular/core'; +import { CouchService } from '../shared/couchdb.service'; +import { Router, CanActivate } from '@angular/router'; +import { UserService } from '../shared/user.service'; + +@Component({ + selector: 'app-register', + templateUrl: './register.component.html', + styleUrls: ['./register.component.css'] +}) +export class RegisterComponent implements OnInit { + + message = ""; + + constructor( + private couchService: CouchService, + private userService: UserService, + private router: Router + ) {} + + ngOnInit() { + } + model = { name:'', password:'', repeatPassword:'' } + + onSubmit(user){ + if(user.Password === user.password_confirm) { + this.couchService.put('_users/org.couchdb.user:' + user.UserName, {'name': user.UserName, 'password': user.Password, 'roles': [], 'type': 'user'}) + .then((data) => { + this.message = 'user created: ' + data.id.replace('org.couchdb.user:',''); + this.router.navigate(['']); + }, (error) => this.message = ''); + } else { + this.message = 'passwords do not match'; + } + } + +} diff --git a/src/app/shared/auth-guard.service.ts b/src/app/shared/auth-guard.service.ts new file mode 100644 index 0000000000..5f6316bf30 --- /dev/null +++ b/src/app/shared/auth-guard.service.ts @@ -0,0 +1,28 @@ +import { Injectable } from '@angular/core'; +import { CouchService } from './couchdb.service'; +import { UserService } from './user.service'; + +import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; + +@Injectable() +export class AuthService { + + constructor(private couchService: CouchService, private userService: UserService, private router: Router) {} + + private checkUser(): Promise { + return this.couchService + .get('_session',{ withCredentials:true }); + } + + canActivate(route: ActivatedRouteSnapshot, state:RouterStateSnapshot): Promise { + return this.checkUser().then((res:any) => { + if(res.userCtx.name) { + this.userService.set(res.userCtx); + return true; + } + this.router.navigate(['/login'], {queryParams: {returnUrl: state.url},replaceUrl:true}); + return false; + }); + } + +} \ No newline at end of file diff --git a/src/app/shared/couchdb.service.ts b/src/app/shared/couchdb.service.ts new file mode 100644 index 0000000000..c2513f92b1 --- /dev/null +++ b/src/app/shared/couchdb.service.ts @@ -0,0 +1,64 @@ +import { Injectable } from '@angular/core'; +import { Headers, Http } from '@angular/http'; + +import 'rxjs/add/operator/toPromise'; + +@Injectable() +export class CouchService { + private headers = new Headers({'Content-Type':'application/json'}); + private baseUrl = 'http://127.0.0.1:5986/'; + + constructor(private http: Http) {} + + put(db:string,data:any): Promise { + const url = this.baseUrl + db; + const putData = data ? JSON.stringify(data) : ''; + + return this.http + .put(url,putData,{headers:this.headers}) + .toPromise() + .then(this.handleRes) + .catch(this.handleError); + } + + post(db:string,data:any,opts?:any): Promise { + const url = this.baseUrl + db; + const postData = data ? JSON.stringify(data) : ''; + opts = Object.assign({},{headers:this.headers},opts) || {headers:this.headers}; + + return this.http + .post(url,postData,opts) + .toPromise() + .then(this.handleRes) + .catch(this.handleError); + } + + get(db:string,opts?:any): Promise { + const url = this.baseUrl + db; + opts = opts || {}; + + return this.http + .get(url,opts) + .toPromise() + .then(this.handleRes) + .catch(this.handleError); + } + + delete(db:string,opts?:any): Promise { + const url = this.baseUrl + db; + opts = opts || {}; + + return this.http + .delete(url,opts) + .toPromise() + .then(this.handleRes) + .catch(this.handleError); + } + + private handleRes = (res:any) => res.json(); + + private handleError(error: any): Promise { + return Promise.reject(error.json()); + } + +} \ No newline at end of file diff --git a/src/app/shared/user.service.ts b/src/app/shared/user.service.ts new file mode 100644 index 0000000000..57a80140f2 --- /dev/null +++ b/src/app/shared/user.service.ts @@ -0,0 +1,23 @@ +import { Injectable } from '@angular/core'; + +// Holds the currently logged in user information (object in userCtx property of response from a GET _session) +// User object = { 'name': , 'roles': [ ] } + +@Injectable() +export class UserService { + + private user:any; + + set(user:any):any { + this.user = user; + } + + get():any { + return this.user; + } + + unset():any { + this.user = ''; + } + +} \ No newline at end of file diff --git a/src/app/test/test.component.css b/src/app/test/test.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/test/test.component.html b/src/app/test/test.component.html new file mode 100644 index 0000000000..12d443fe7c --- /dev/null +++ b/src/app/test/test.component.html @@ -0,0 +1,4 @@ + + Welcome to the test !!! + + \ No newline at end of file diff --git a/src/app/test/test.component.spec.ts b/src/app/test/test.component.spec.ts new file mode 100644 index 0000000000..a57ea4b59d --- /dev/null +++ b/src/app/test/test.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TestComponent } from './test.component'; + +describe('TestComponent', () => { + let component: TestComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TestComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TestComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/test/test.component.ts b/src/app/test/test.component.ts new file mode 100644 index 0000000000..ff623a7f19 --- /dev/null +++ b/src/app/test/test.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-test', + templateUrl: './test.component.html', + styleUrls: ['./test.component.css'] +}) +export class TestComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/src/assets/.gitkeep b/src/assets/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/assets/BELL_invision_artboard-V-LeonardSnapsSplash-Screen.png.png b/src/assets/BELL_invision_artboard-V-LeonardSnapsSplash-Screen.png.png new file mode 100644 index 0000000000..6f65f0d029 Binary files /dev/null and b/src/assets/BELL_invision_artboard-V-LeonardSnapsSplash-Screen.png.png differ diff --git a/src/assets/planet_home.png b/src/assets/planet_home.png new file mode 100644 index 0000000000..1aef449cd5 Binary files /dev/null and b/src/assets/planet_home.png differ diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts new file mode 100644 index 0000000000..3612073bc3 --- /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 0000000000..b7f639aeca --- /dev/null +++ b/src/environments/environment.ts @@ -0,0 +1,8 @@ +// The file contents for the current environment will overwrite these during build. +// The build system defaults to the dev environment which uses `environment.ts`, but if you do +// `ng build --env=prod` then `environment.prod.ts` will be used instead. +// The list of which env maps to which file can be found in `.angular-cli.json`. + +export const environment = { + production: false +}; diff --git a/src/favicon.ico b/src/favicon.ico new file mode 100644 index 0000000000..8081c7ceaf Binary files /dev/null and b/src/favicon.ico differ diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000000..23ad68aae4 --- /dev/null +++ b/src/index.html @@ -0,0 +1,14 @@ + + + + + AngBellApp + + + + + + + + + diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000000..a9ca1caf8c --- /dev/null +++ b/src/main.ts @@ -0,0 +1,11 @@ +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); diff --git a/src/polyfills.ts b/src/polyfills.ts new file mode 100644 index 0000000000..7831e97b79 --- /dev/null +++ b/src/polyfills.ts @@ -0,0 +1,72 @@ +/** + * 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/docs/ts/latest/guide/browser-support.html + */ + +/*************************************************************************************************** + * BROWSER POLYFILLS + */ + +/** IE9, IE10 and IE11 requires all of the following polyfills. **/ +// import 'core-js/es6/symbol'; +// import 'core-js/es6/object'; +// import 'core-js/es6/function'; +// import 'core-js/es6/parse-int'; +// import 'core-js/es6/parse-float'; +// import 'core-js/es6/number'; +// import 'core-js/es6/math'; +// import 'core-js/es6/string'; +// import 'core-js/es6/date'; +// import 'core-js/es6/array'; +// import 'core-js/es6/regexp'; +// import 'core-js/es6/map'; +// import 'core-js/es6/weak-map'; +// import 'core-js/es6/set'; + +/** IE10 and IE11 requires the following for NgClass support on SVG elements */ +// import 'classlist.js'; // Run `npm install --save classlist.js`. + +/** Evergreen browsers require these. **/ +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; + + +/** + * Required to support Web Animations `@angular/animation`. + * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation + **/ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + + + +/*************************************************************************************************** + * Zone JS is required by Angular itself. + */ +import 'zone.js/dist/zone'; // Included with Angular CLI. + + + +/*************************************************************************************************** + * APPLICATION IMPORTS + */ + +/** + * Date, currency, decimal and percent pipes. + * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 + */ +// import 'intl'; // Run `npm install --save intl`. +/** + * Need to import at least one locale-data with intl. + */ +// import 'intl/locale-data/jsonp/en'; diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000000..26848411b2 --- /dev/null +++ b/src/styles.css @@ -0,0 +1,12 @@ +/* You can add global styles to this file, and also import other style files */ +body { + padding-top: 5rem; +} +.starter-template { + padding: 3rem 1.5rem; + text-align: center; +} +html { + position: relative; + min-height: 100%; +} diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 0000000000..cd612eeb0e --- /dev/null +++ b/src/test.ts @@ -0,0 +1,32 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/long-stack-trace-zone'; +import 'zone.js/dist/proxy.js'; +import 'zone.js/dist/sync-test'; +import 'zone.js/dist/jasmine-patch'; +import 'zone.js/dist/async-test'; +import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. +declare const __karma__: any; +declare const require: any; + +// Prevent Karma from running prematurely. +__karma__.loaded = function () {}; + +// 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); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json new file mode 100644 index 0000000000..39ba8dbacb --- /dev/null +++ b/src/tsconfig.app.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/app", + "baseUrl": "./", + "module": "es2015", + "types": [] + }, + "exclude": [ + "test.ts", + "**/*.spec.ts" + ] +} diff --git a/src/tsconfig.spec.json b/src/tsconfig.spec.json new file mode 100644 index 0000000000..63d89ff283 --- /dev/null +++ b/src/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/spec", + "baseUrl": "./", + "module": "commonjs", + "target": "es5", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/src/typings.d.ts b/src/typings.d.ts new file mode 100644 index 0000000000..ef5c7bd620 --- /dev/null +++ b/src/typings.d.ts @@ -0,0 +1,5 @@ +/* SystemJS module definition */ +declare var module: NodeModule; +interface NodeModule { + id: string; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..1f9b55851b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es5", + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2016", + "dom" + ] + } +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000000..0db5751c78 --- /dev/null +++ b/tslint.json @@ -0,0 +1,142 @@ +{ + "rulesDirectory": [ + "node_modules/codelyzer" + ], + "rules": { + "arrow-return-shorthand": true, + "callable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "import-blacklist": [ + true, + "rxjs" + ], + "import-spacing": true, + "indent": [ + true, + "spaces" + ], + "interface-over-type-literal": true, + "label-position": true, + "max-line-length": [ + true, + 140 + ], + "member-access": false, + "member-ordering": [ + true, + { + "order": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-super": true, + "no-empty": false, + "no-empty-interface": true, + "no-eval": true, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-misused-new": true, + "no-non-null-assertion": true, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unnecessary-initializer": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "prefer-const": true, + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "typeof-compare": true, + "unified-signatures": true, + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true + } +}