├── .gitignore
├── README.md
├── basic-webpage
├── .angular-cli.json
├── .editorconfig
├── e2e
│ ├── app.e2e-spec.ts
│ ├── app.po.ts
│ └── tsconfig.e2e.json
├── karma.conf.js
├── package.json
├── protractor.conf.js
├── server.js
├── src
│ ├── app
│ │ ├── aboutpage
│ │ │ ├── aboutpage.component.css
│ │ │ ├── aboutpage.component.html
│ │ │ ├── aboutpage.component.spec.ts
│ │ │ └── aboutpage.component.ts
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── homepage
│ │ │ ├── homepage.component.css
│ │ │ ├── homepage.component.html
│ │ │ ├── homepage.component.spec.ts
│ │ │ └── homepage.component.ts
│ │ ├── jumbotron
│ │ │ ├── jumbotron.component.css
│ │ │ ├── jumbotron.component.html
│ │ │ ├── jumbotron.component.spec.ts
│ │ │ └── jumbotron.component.ts
│ │ └── navbar
│ │ │ ├── navbar.component.css
│ │ │ ├── navbar.component.html
│ │ │ ├── navbar.component.spec.ts
│ │ │ └── navbar.component.ts
│ ├── assets
│ │ └── .gitkeep
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── main.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── typings.d.ts
├── tsconfig.json
└── tslint.json
├── firebase-biz-list
├── .angular-cli.json
├── .editorconfig
├── e2e
│ ├── app.e2e-spec.ts
│ ├── app.po.ts
│ └── tsconfig.e2e.json
├── karma.conf.js
├── package.json
├── protractor.conf.js
├── server.js
├── src
│ ├── app
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── firebase.service.spec.ts
│ │ └── firebase.service.ts
│ ├── assets
│ │ └── .gitkeep
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── interfaces
│ │ ├── business.ts
│ │ └── category.ts
│ ├── main.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── typings.d.ts
├── tsconfig.json
└── tslint.json
├── github-search
├── .angular-cli.json
├── .editorconfig
├── e2e
│ ├── app.e2e-spec.ts
│ ├── app.po.ts
│ └── tsconfig.e2e.json
├── karma.conf.js
├── package.json
├── protractor.conf.js
├── server.js
├── src
│ ├── app
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── github.service.spec.ts
│ │ ├── github.service.ts
│ │ ├── navbar
│ │ │ ├── navbar.component.css
│ │ │ ├── navbar.component.html
│ │ │ ├── navbar.component.spec.ts
│ │ │ └── navbar.component.ts
│ │ └── profile
│ │ │ ├── profile.component.css
│ │ │ ├── profile.component.html
│ │ │ ├── profile.component.spec.ts
│ │ │ └── profile.component.ts
│ ├── assets
│ │ └── .gitkeep
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── main.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── typings.d.ts
├── tsconfig.json
└── tslint.json
├── mean-todo
├── .angular-cli.json
├── .editorconfig
├── e2e
│ ├── app.e2e-spec.ts
│ ├── app.po.ts
│ └── tsconfig.e2e.json
├── karma.conf.js
├── package.json
├── protractor.conf.js
├── server.js
├── server
│ ├── models
│ │ └── Todo.js
│ └── routes
│ │ └── api.js
├── src
│ ├── app
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── todos.service.spec.ts
│ │ ├── todos.service.ts
│ │ └── todos
│ │ │ ├── todos.component.css
│ │ │ ├── todos.component.html
│ │ │ ├── todos.component.spec.ts
│ │ │ └── todos.component.ts
│ ├── assets
│ │ └── .gitkeep
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── main.ts
│ ├── models
│ │ └── Todo.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── typings.d.ts
├── tsconfig.json
└── tslint.json
├── meteor-todo
├── .meteor
│ ├── .finished-upgraders
│ ├── .gitignore
│ ├── .id
│ ├── packages
│ ├── platforms
│ ├── release
│ └── versions
├── client
│ ├── main.css
│ ├── main.html
│ └── main.js
├── imports
│ ├── api
│ │ └── tasks.js
│ ├── components
│ │ └── todoList
│ │ │ ├── todoList.html
│ │ │ └── todoList.js
│ └── startup
│ │ └── accounts-config.js
├── package.json
└── server
│ └── main.js
├── ng-spotify
├── .angular-cli.json
├── .editorconfig
├── e2e
│ ├── app.e2e-spec.ts
│ ├── app.po.ts
│ └── tsconfig.e2e.json
├── karma.conf.js
├── package.json
├── protractor.conf.js
├── server.js
├── src
│ ├── app
│ │ ├── about
│ │ │ ├── about.component.css
│ │ │ ├── about.component.html
│ │ │ ├── about.component.spec.ts
│ │ │ └── about.component.ts
│ │ ├── album
│ │ │ ├── album.component.css
│ │ │ ├── album.component.html
│ │ │ ├── album.component.spec.ts
│ │ │ └── album.component.ts
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── app.routes.ts
│ │ ├── artist
│ │ │ ├── artist.component.css
│ │ │ ├── artist.component.html
│ │ │ ├── artist.component.spec.ts
│ │ │ └── artist.component.ts
│ │ ├── navbar
│ │ │ ├── navbar.component.css
│ │ │ ├── navbar.component.html
│ │ │ ├── navbar.component.spec.ts
│ │ │ └── navbar.component.ts
│ │ ├── search
│ │ │ ├── search.component.css
│ │ │ ├── search.component.html
│ │ │ ├── search.component.spec.ts
│ │ │ └── search.component.ts
│ │ ├── spotify.service.spec.ts
│ │ └── spotify.service.ts
│ ├── assets
│ │ └── .gitkeep
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── main.ts
│ ├── models
│ │ ├── Album.ts
│ │ └── Artist.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── typings.d.ts
├── tsconfig.json
└── tslint.json
├── socketchat
├── .angular-cli.json
├── .editorconfig
├── README.md
├── e2e
│ ├── app.e2e-spec.ts
│ ├── app.po.ts
│ └── tsconfig.e2e.json
├── karma.conf.js
├── package-lock.json
├── package.json
├── protractor.conf.js
├── server.js
├── src
│ ├── app
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── chat.service.spec.ts
│ │ ├── chat.service.ts
│ │ └── chat
│ │ │ ├── chat.component.css
│ │ │ ├── chat.component.html
│ │ │ ├── chat.component.spec.ts
│ │ │ └── chat.component.ts
│ ├── assets
│ │ └── .gitkeep
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── main.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── typings.d.ts
├── tsconfig.json
└── tslint.json
└── workouts-app
├── .editorconfig
├── README.md
├── config.xml
├── ionic.config.json
├── package.json
├── resources
├── android
│ ├── icon
│ │ ├── drawable-hdpi-icon.png
│ │ ├── drawable-ldpi-icon.png
│ │ ├── drawable-mdpi-icon.png
│ │ ├── drawable-xhdpi-icon.png
│ │ ├── drawable-xxhdpi-icon.png
│ │ └── drawable-xxxhdpi-icon.png
│ └── splash
│ │ ├── drawable-land-hdpi-screen.png
│ │ ├── drawable-land-ldpi-screen.png
│ │ ├── drawable-land-mdpi-screen.png
│ │ ├── drawable-land-xhdpi-screen.png
│ │ ├── drawable-land-xxhdpi-screen.png
│ │ ├── drawable-land-xxxhdpi-screen.png
│ │ ├── drawable-port-hdpi-screen.png
│ │ ├── drawable-port-ldpi-screen.png
│ │ ├── drawable-port-mdpi-screen.png
│ │ ├── drawable-port-xhdpi-screen.png
│ │ ├── drawable-port-xxhdpi-screen.png
│ │ └── drawable-port-xxxhdpi-screen.png
├── icon.png
├── ios
│ ├── icon
│ │ ├── icon-40.png
│ │ ├── icon-40@2x.png
│ │ ├── icon-40@3x.png
│ │ ├── icon-50.png
│ │ ├── icon-50@2x.png
│ │ ├── icon-60.png
│ │ ├── icon-60@2x.png
│ │ ├── icon-60@3x.png
│ │ ├── icon-72.png
│ │ ├── icon-72@2x.png
│ │ ├── icon-76.png
│ │ ├── icon-76@2x.png
│ │ ├── icon-83.5@2x.png
│ │ ├── icon-small.png
│ │ ├── icon-small@2x.png
│ │ ├── icon-small@3x.png
│ │ ├── icon.png
│ │ └── icon@2x.png
│ └── splash
│ │ ├── Default-568h@2x~iphone.png
│ │ ├── Default-667h.png
│ │ ├── Default-736h.png
│ │ ├── Default-Landscape-736h.png
│ │ ├── Default-Landscape@2x~ipad.png
│ │ ├── Default-Landscape@~ipadpro.png
│ │ ├── Default-Landscape~ipad.png
│ │ ├── Default-Portrait@2x~ipad.png
│ │ ├── Default-Portrait@~ipadpro.png
│ │ ├── Default-Portrait~ipad.png
│ │ ├── Default@2x~iphone.png
│ │ └── Default~iphone.png
└── splash.png
├── src
├── app
│ ├── app.component.ts
│ ├── app.html
│ ├── app.module.ts
│ ├── app.scss
│ └── main.ts
├── assets
│ └── icon
│ │ └── favicon.ico
├── index.html
├── manifest.json
├── pages
│ ├── about
│ │ ├── about.html
│ │ ├── about.scss
│ │ └── about.ts
│ ├── add
│ │ ├── add.html
│ │ ├── add.module.ts
│ │ ├── add.scss
│ │ └── add.ts
│ ├── tabs
│ │ ├── tabs.html
│ │ └── tabs.ts
│ ├── workout-details
│ │ ├── workout-details.html
│ │ ├── workout-details.module.ts
│ │ ├── workout-details.scss
│ │ └── workout-details.ts
│ └── workouts
│ │ ├── workouts.html
│ │ ├── workouts.module.ts
│ │ ├── workouts.scss
│ │ └── workouts.ts
├── providers
│ └── workouts
│ │ └── workouts.ts
├── service-worker.js
└── theme
│ └── variables.scss
├── tsconfig.json
└── tslint.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # compiled output
2 | */dist
3 | */tmp
4 |
5 | # dependencies
6 | */.meteor/local
7 | */node_modules
8 | */bower_components
9 |
10 | # IDEs and editors
11 | */.idea
12 | */.vscode
13 | */.project
14 | */.classpath
15 | */.launch
16 | */.settings/
17 | */.tmp/
18 | */.versions/
19 |
20 | # misc
21 | */.sass-cache
22 | */connect.lock
23 | */coverage/*
24 | */libpeerconnection.log
25 | */npm-debug.log
26 | */testem.log
27 | */typings
28 | */www
29 | */hooks
30 | */platforms
31 | */plugins
32 |
33 | # e2e
34 | */e2e/*.js
35 | */e2e/*.map
36 |
37 | #System Files
38 | .DS_Store
39 | Thumbs.db
40 |
41 | */*.log
42 | */*.tmp
43 | */*.tmp.*
44 | */log.txt
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Angular Projects
2 |
3 | A collection of projects built on the Angular Framework, using the Angular CLI and Express server.
4 |
5 | ## Projects
6 | 1. **basic-webpage** : Basic single page site build using components and routes.
7 | 2. **github-search** : SPA to search and find github users and also list their repos.
8 | 3. **ng-spotify** : SPA which uses the Spotify Web API to find artists, albums and also list tracks.
9 | 4. **mean-todo** : Basic CRUD WebApp built on the Mongo-Express-Angular-Node Stack to manage todos.
10 | 5. **firebase-biz-list** : Business orgs details listing SPA with CRUD functionality implemented using Firebase, uses Foundation for styling.
11 | 6. **workouts-app** : An workout tracker mobile app which lets you save and manage workouts, built on Ionic 3.
12 | 7. **socketchat** : A chat app built using Angular with Socket.io
13 | 8. **meteor-todo [WIP]** : An Angular-Meteor web application
14 |
15 | ## Set up.
16 | For Angular apps, follow Angular CLI - Express build setup. For Ionic use Ionic CLI to serve/deploy
17 |
18 | ## Screenshots
19 | [WIP]
20 |
--------------------------------------------------------------------------------
/basic-webpage/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "ng2-mean"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json"
40 | },
41 | {
42 | "project": "src/tsconfig.spec.json"
43 | },
44 | {
45 | "project": "e2e/tsconfig.e2e.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "css",
55 | "component": {}
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/basic-webpage/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/basic-webpage/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { Ng2MeanPage } from './app.po';
2 |
3 | describe('ng2-mean App', () => {
4 | let page: Ng2MeanPage;
5 |
6 | beforeEach(() => {
7 | page = new Ng2MeanPage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/basic-webpage/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, element, by } from 'protractor';
2 |
3 | export class Ng2MeanPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/basic-webpage/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types":[
8 | "jasmine",
9 | "node"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/basic-webpage/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | files: [
19 | { pattern: './src/test.ts', watched: false }
20 | ],
21 | preprocessors: {
22 | './src/test.ts': ['@angular/cli']
23 | },
24 | mime: {
25 | 'text/x-typescript': ['ts','tsx']
26 | },
27 | coverageIstanbulReporter: {
28 | reports: [ 'html', 'lcovonly' ],
29 | fixWebpackSourcePaths: true
30 | },
31 | angularCli: {
32 | environment: 'dev'
33 | },
34 | reporters: config.angularCli && config.angularCli.codeCoverage
35 | ? ['progress', 'coverage-istanbul']
36 | : ['progress', 'kjhtml'],
37 | port: 9876,
38 | colors: true,
39 | logLevel: config.LOG_INFO,
40 | autoWatch: true,
41 | browsers: ['Chrome'],
42 | singleRun: false
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/basic-webpage/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "basic-webpage",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/common": "^4.0.0",
16 | "@angular/compiler": "^4.0.0",
17 | "@angular/core": "^4.0.0",
18 | "@angular/forms": "^4.0.0",
19 | "@angular/http": "^4.0.0",
20 | "@angular/platform-browser": "^4.0.0",
21 | "@angular/platform-browser-dynamic": "^4.0.0",
22 | "@angular/router": "^4.0.0",
23 | "body-parser": "^1.17.2",
24 | "core-js": "^2.4.1",
25 | "express": "^4.15.3",
26 | "rxjs": "^5.1.0",
27 | "zone.js": "^0.8.4"
28 | },
29 | "devDependencies": {
30 | "@angular/cli": "1.0.1",
31 | "@angular/compiler-cli": "^4.0.0",
32 | "@types/jasmine": "2.5.38",
33 | "@types/node": "~6.0.60",
34 | "codelyzer": "~2.0.0",
35 | "jasmine-core": "~2.5.2",
36 | "jasmine-spec-reporter": "~3.2.0",
37 | "karma": "~1.4.1",
38 | "karma-chrome-launcher": "~2.0.0",
39 | "karma-cli": "~1.0.1",
40 | "karma-jasmine": "~1.1.0",
41 | "karma-jasmine-html-reporter": "^0.2.2",
42 | "karma-coverage-istanbul-reporter": "^0.2.0",
43 | "protractor": "~5.1.0",
44 | "ts-node": "~2.0.0",
45 | "tslint": "~4.5.0",
46 | "typescript": "~2.2.0"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/basic-webpage/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | beforeLaunch: function() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | },
27 | onPrepare() {
28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/basic-webpage/server.js:
--------------------------------------------------------------------------------
1 | // Get dependencies
2 | const express = require('express');
3 | const path = require('path');
4 | const http = require('http');
5 |
6 | // Get our API routes
7 | const app = express();
8 |
9 | // Point static path to dist
10 | app.use(express.static(path.join(__dirname, 'dist')));
11 |
12 |
13 | // Catch all other routes and return the index file
14 | app.get('*', (req, res) => {
15 | res.sendFile(path.join(__dirname, 'dist/index.html'));
16 | });
17 |
18 | /**
19 | * Get port from environment and store in Express.
20 | */
21 | const port = process.env.PORT || '3000';
22 | app.set('port', port);
23 |
24 | /**
25 | * Create HTTP server.
26 | */
27 | const server = http.createServer(app);
28 |
29 | /**
30 | * Listen on provided port, on all network interfaces.
31 | */
32 | server.listen(port, () => console.log(`API running on localhost:${port}`));
33 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/aboutpage/aboutpage.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/basic-webpage/src/app/aboutpage/aboutpage.component.css
--------------------------------------------------------------------------------
/basic-webpage/src/app/aboutpage/aboutpage.component.html:
--------------------------------------------------------------------------------
1 |
2 | aboutpage works!
3 |
4 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/aboutpage/aboutpage.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { AboutpageComponent } from './aboutpage.component';
4 |
5 | describe('AboutpageComponent', () => {
6 | let component: AboutpageComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ AboutpageComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(AboutpageComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/aboutpage/aboutpage.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-aboutpage',
5 | templateUrl: './aboutpage.component.html',
6 | styleUrls: ['./aboutpage.component.css']
7 | })
8 | export class AboutpageComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/basic-webpage/src/app/app.component.css
--------------------------------------------------------------------------------
/basic-webpage/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 |
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | }).compileComponents();
12 | }));
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app works!'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app works!');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'app works!';
10 | }
11 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { HttpModule } from '@angular/http';
5 | import { RouterModule } from '@angular/router';
6 |
7 | import { AppComponent } from './app.component';
8 | import { JumbotronComponent } from './jumbotron/jumbotron.component';
9 | import { NavbarComponent } from './navbar/navbar.component';
10 | import { HomepageComponent } from './homepage/homepage.component';
11 | import { AboutpageComponent } from './aboutpage/aboutpage.component';
12 |
13 | // Define routes
14 | const routes = [
15 | {
16 | path: '',
17 | redirectTo: 'home',
18 | pathMatch: 'full'
19 | },
20 | {
21 | path: 'home',
22 | component: HomepageComponent
23 | },
24 | {
25 | path: 'about',
26 | component: AboutpageComponent
27 | }
28 | ];
29 |
30 |
31 | @NgModule({
32 | // Specify all components
33 | declarations: [
34 | AppComponent,
35 | JumbotronComponent,
36 | NavbarComponent,
37 | HomepageComponent,
38 | AboutpageComponent,
39 | ],
40 | // Specify all imports from Angular
41 | imports: [
42 | BrowserModule,
43 | FormsModule,
44 | HttpModule,
45 | RouterModule.forRoot(routes)
46 | ],
47 | providers: [], // To specify services if any
48 | bootstrap: [AppComponent]
49 | })
50 | export class AppModule { }
51 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/homepage/homepage.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/basic-webpage/src/app/homepage/homepage.component.css
--------------------------------------------------------------------------------
/basic-webpage/src/app/homepage/homepage.component.html:
--------------------------------------------------------------------------------
1 |
2 | homepage works!
3 |
4 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/homepage/homepage.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { HomepageComponent } from './homepage.component';
4 |
5 | describe('HomepageComponent', () => {
6 | let component: HomepageComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ HomepageComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(HomepageComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/homepage/homepage.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-homepage',
5 | templateUrl: './homepage.component.html',
6 | styleUrls: ['./homepage.component.css']
7 | })
8 | export class HomepageComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/jumbotron/jumbotron.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/basic-webpage/src/app/jumbotron/jumbotron.component.css
--------------------------------------------------------------------------------
/basic-webpage/src/app/jumbotron/jumbotron.component.html:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/jumbotron/jumbotron.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { JumbotronComponent } from './jumbotron.component';
4 |
5 | describe('JumbotronComponent', () => {
6 | let component: JumbotronComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ JumbotronComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(JumbotronComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/jumbotron/jumbotron.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-jumbotron',
5 | templateUrl: './jumbotron.component.html',
6 | styleUrls: ['./jumbotron.component.css']
7 | })
8 | export class JumbotronComponent implements OnInit {
9 | // Declare variablename:type
10 | private jbtHeading:string;
11 | private jbtText:string;
12 | private jbtBtnText:string;
13 | private jbtBtnUrl:string;
14 |
15 | constructor() {
16 | // Initalize variables
17 | this.jbtHeading = 'Hello World';
18 | this.jbtText = 'This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.';
19 | this.jbtBtnText = 'Read More';
20 | this.jbtBtnUrl = 'http://test.com';
21 | }
22 |
23 | ngOnInit() {
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/navbar/navbar.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/basic-webpage/src/app/navbar/navbar.component.css
--------------------------------------------------------------------------------
/basic-webpage/src/app/navbar/navbar.component.html:
--------------------------------------------------------------------------------
1 |
2 |
23 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/navbar/navbar.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NavbarComponent } from './navbar.component';
4 |
5 | describe('NavbarComponent', () => {
6 | let component: NavbarComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ NavbarComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NavbarComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/basic-webpage/src/app/navbar/navbar.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-navbar',
5 | templateUrl: './navbar.component.html',
6 | styleUrls: ['./navbar.component.css']
7 | })
8 | export class NavbarComponent implements OnInit {
9 | private projectName:string;
10 |
11 | constructor(){
12 | this.projectName = 'A2Website';
13 | }
14 |
15 | ngOnInit() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/basic-webpage/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/basic-webpage/src/assets/.gitkeep
--------------------------------------------------------------------------------
/basic-webpage/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/basic-webpage/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/basic-webpage/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/basic-webpage/src/favicon.ico
--------------------------------------------------------------------------------
/basic-webpage/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | A2Website
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Loading...
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/basic-webpage/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/basic-webpage/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/basic-webpage/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare var __karma__: any;
17 | declare var require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/basic-webpage/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "baseUrl": "",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/basic-webpage/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "baseUrl": "",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/basic-webpage/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/basic-webpage/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "baseUrl": "src",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2016",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/firebase-biz-list/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "ng2-mean"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json"
40 | },
41 | {
42 | "project": "src/tsconfig.spec.json"
43 | },
44 | {
45 | "project": "e2e/tsconfig.e2e.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "css",
55 | "component": {}
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/firebase-biz-list/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/firebase-biz-list/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { Ng2MeanPage } from './app.po';
2 |
3 | describe('ng2-mean App', () => {
4 | let page: Ng2MeanPage;
5 |
6 | beforeEach(() => {
7 | page = new Ng2MeanPage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/firebase-biz-list/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, element, by } from 'protractor';
2 |
3 | export class Ng2MeanPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/firebase-biz-list/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types":[
8 | "jasmine",
9 | "node"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/firebase-biz-list/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | files: [
19 | { pattern: './src/test.ts', watched: false }
20 | ],
21 | preprocessors: {
22 | './src/test.ts': ['@angular/cli']
23 | },
24 | mime: {
25 | 'text/x-typescript': ['ts','tsx']
26 | },
27 | coverageIstanbulReporter: {
28 | reports: [ 'html', 'lcovonly' ],
29 | fixWebpackSourcePaths: true
30 | },
31 | angularCli: {
32 | environment: 'dev'
33 | },
34 | reporters: config.angularCli && config.angularCli.codeCoverage
35 | ? ['progress', 'coverage-istanbul']
36 | : ['progress', 'kjhtml'],
37 | port: 9876,
38 | colors: true,
39 | logLevel: config.LOG_INFO,
40 | autoWatch: true,
41 | browsers: ['Chrome'],
42 | singleRun: false
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/firebase-biz-list/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firebase-biz-list",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/common": "^4.0.0",
16 | "@angular/compiler": "^4.0.0",
17 | "@angular/core": "^4.0.0",
18 | "@angular/forms": "^4.0.0",
19 | "@angular/http": "^4.0.0",
20 | "@angular/platform-browser": "^4.0.0",
21 | "@angular/platform-browser-dynamic": "^4.0.0",
22 | "@angular/router": "^4.0.0",
23 | "angularfire2": "^4.0.0-rc.1",
24 | "body-parser": "^1.17.2",
25 | "core-js": "^2.4.1",
26 | "express": "^4.15.3",
27 | "firebase": "^4.1.1",
28 | "rxjs": "^5.1.0",
29 | "zone.js": "^0.8.4"
30 | },
31 | "devDependencies": {
32 | "@angular/cli": "1.0.1",
33 | "@angular/compiler-cli": "^4.0.0",
34 | "@types/jasmine": "2.5.38",
35 | "@types/node": "~6.0.60",
36 | "codelyzer": "~2.0.0",
37 | "jasmine-core": "~2.5.2",
38 | "jasmine-spec-reporter": "~3.2.0",
39 | "karma": "~1.4.1",
40 | "karma-chrome-launcher": "~2.0.0",
41 | "karma-cli": "~1.0.1",
42 | "karma-jasmine": "~1.1.0",
43 | "karma-jasmine-html-reporter": "^0.2.2",
44 | "karma-coverage-istanbul-reporter": "^0.2.0",
45 | "protractor": "~5.1.0",
46 | "ts-node": "~2.0.0",
47 | "tslint": "~4.5.0",
48 | "typescript": "~2.2.0"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/firebase-biz-list/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | beforeLaunch: function() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | },
27 | onPrepare() {
28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/firebase-biz-list/server.js:
--------------------------------------------------------------------------------
1 | // Get dependencies
2 | const express = require('express');
3 | const path = require('path');
4 | const http = require('http');
5 |
6 | // Get our API routes
7 | const app = express();
8 |
9 | // Point static path to dist
10 | app.use(express.static(path.join(__dirname, 'dist')));
11 |
12 |
13 | // Catch all other routes and return the index file
14 | app.get('*', (req, res) => {
15 | res.sendFile(path.join(__dirname, 'dist/index.html'));
16 | });
17 |
18 | /**
19 | * Get port from environment and store in Express.
20 | */
21 | const port = process.env.PORT || '3000';
22 | app.set('port', port);
23 |
24 | /**
25 | * Create HTTP server.
26 | */
27 | const server = http.createServer(app);
28 |
29 | /**
30 | * Listen on provided port, on all network interfaces.
31 | */
32 | server.listen(port, () => console.log(`API running on localhost:${port}`));
33 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/firebase-biz-list/src/app/app.component.css
--------------------------------------------------------------------------------
/firebase-biz-list/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 |
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | }).compileComponents();
12 | }));
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app works!'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app works!');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { HttpModule } from '@angular/http';
5 | import { RouterModule } from '@angular/router';
6 |
7 | import { AngularFireModule } from 'angularfire2';
8 | import { AngularFireDatabaseModule } from 'angularfire2/database';
9 | import { AngularFireAuthModule } from 'angularfire2/auth';
10 |
11 | import { environment } from '../environments/environment';
12 | import { AppComponent } from './app.component';
13 | import { FirebaseService } from './firebase.service';
14 |
15 | // Import components and modules, include firebase ones as well
16 | @NgModule({
17 | declarations: [
18 | AppComponent
19 | ],
20 | imports: [
21 | BrowserModule,
22 | FormsModule,
23 | HttpModule,
24 | AngularFireModule.initializeApp(environment.firebase, 'my-app-name'),
25 | AngularFireAuthModule,
26 | AngularFireDatabaseModule,
27 | ],
28 | providers: [FirebaseService],
29 | bootstrap: [AppComponent]
30 | })
31 | export class AppModule { }
32 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/app/firebase.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { FirebaseService } from './firebase.service';
4 |
5 | describe('FirebaseService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [FirebaseService]
9 | });
10 | });
11 |
12 | it('should ...', inject([FirebaseService], (service: FirebaseService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/app/firebase.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import {AngularFireDatabase, FirebaseListObservable} from 'angularfire2/database';
3 | import 'rxjs/add/operator/map';
4 |
5 | import { Business } from '../interfaces/business';
6 | import { Category } from '../interfaces/category';
7 |
8 | @Injectable()
9 | export class FirebaseService {
10 | // Intialize firebase observables
11 | businesses: FirebaseListObservable;
12 | categories: FirebaseListObservable;
13 |
14 | constructor(private db:AngularFireDatabase) { }
15 |
16 | // Get businesses
17 | getBusinesses(category:string = null) {
18 | if(category != null) {
19 | // Query by category if specified
20 | this.businesses = this.db.list('/businesses', {
21 | query:{
22 | orderByChild: 'category',
23 | equalTo: category
24 | }
25 | }) as FirebaseListObservable
26 | } else {
27 | this.businesses = this.db.list('/businesses') as FirebaseListObservable
28 | }
29 | return this.businesses;
30 | }
31 |
32 | // Function names are self explanatory from here
33 |
34 | getCategories() {
35 | this.categories = this.db.list('/categories') as FirebaseListObservable
36 | return this.categories;
37 | }
38 |
39 | addBusiness(newBusiness){
40 | const promise = this.businesses.push(newBusiness);
41 | promise
42 | .then(_ => console.log('success'))
43 | .catch(err => console.log(err, 'You do not have access!'));
44 | }
45 |
46 |
47 | deleteBusiness(key) {
48 | const promise = this.businesses.remove(key);
49 | promise
50 | .then(_ => console.log('success'))
51 | .catch(err => console.log(err, 'You do not have access!'));
52 | }
53 |
54 | updateBusiness(key, updBusiness) {
55 | const promise = this.businesses.update(key, updBusiness);
56 | promise
57 | .then(_ => console.log('success'))
58 | .catch(err => console.log(err, 'You do not have access!'));
59 | }
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/firebase-biz-list/src/assets/.gitkeep
--------------------------------------------------------------------------------
/firebase-biz-list/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false,
8 | firebase: {
9 | apiKey: "",
10 | authDomain: "",
11 | databaseURL: "",
12 | projectId: "",
13 | storageBucket: "",
14 | messagingSenderId: ""
15 | }
16 |
17 |
18 | };
19 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/firebase-biz-list/src/favicon.ico
--------------------------------------------------------------------------------
/firebase-biz-list/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | fire-biz-list
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Loading...
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/interfaces/business.ts:
--------------------------------------------------------------------------------
1 | export interface Business {
2 | $key?: string;
3 | company?: string;
4 | description?:string;
5 | category:string;
6 | years_in_business?:number;
7 | street_address?:string;
8 | city:string;
9 | state?:string;
10 | zipcode?:string;
11 | phone?:string;
12 | email?:string;
13 | created_at:string;
14 | }
--------------------------------------------------------------------------------
/firebase-biz-list/src/interfaces/category.ts:
--------------------------------------------------------------------------------
1 |
2 | export interface Category{
3 | $key?: string;
4 | name?: string;
5 | }
--------------------------------------------------------------------------------
/firebase-biz-list/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare var __karma__: any;
17 | declare var require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "baseUrl": "",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "baseUrl": "",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/firebase-biz-list/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/firebase-biz-list/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "baseUrl": "src",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2016",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/github-search/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "ng2-mean"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json"
40 | },
41 | {
42 | "project": "src/tsconfig.spec.json"
43 | },
44 | {
45 | "project": "e2e/tsconfig.e2e.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "css",
55 | "component": {}
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/github-search/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/github-search/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { Ng2MeanPage } from './app.po';
2 |
3 | describe('ng2-mean App', () => {
4 | let page: Ng2MeanPage;
5 |
6 | beforeEach(() => {
7 | page = new Ng2MeanPage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/github-search/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, element, by } from 'protractor';
2 |
3 | export class Ng2MeanPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/github-search/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types":[
8 | "jasmine",
9 | "node"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/github-search/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | files: [
19 | { pattern: './src/test.ts', watched: false }
20 | ],
21 | preprocessors: {
22 | './src/test.ts': ['@angular/cli']
23 | },
24 | mime: {
25 | 'text/x-typescript': ['ts','tsx']
26 | },
27 | coverageIstanbulReporter: {
28 | reports: [ 'html', 'lcovonly' ],
29 | fixWebpackSourcePaths: true
30 | },
31 | angularCli: {
32 | environment: 'dev'
33 | },
34 | reporters: config.angularCli && config.angularCli.codeCoverage
35 | ? ['progress', 'coverage-istanbul']
36 | : ['progress', 'kjhtml'],
37 | port: 9876,
38 | colors: true,
39 | logLevel: config.LOG_INFO,
40 | autoWatch: true,
41 | browsers: ['Chrome'],
42 | singleRun: false
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/github-search/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "github-search",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/common": "^4.0.0",
16 | "@angular/compiler": "^4.0.0",
17 | "@angular/core": "^4.0.0",
18 | "@angular/forms": "^4.0.0",
19 | "@angular/http": "^4.0.0",
20 | "@angular/platform-browser": "^4.0.0",
21 | "@angular/platform-browser-dynamic": "^4.0.0",
22 | "@angular/router": "^4.0.0",
23 | "body-parser": "^1.17.2",
24 | "core-js": "^2.4.1",
25 | "express": "^4.15.3",
26 | "rxjs": "^5.1.0",
27 | "zone.js": "^0.8.4"
28 | },
29 | "devDependencies": {
30 | "@angular/cli": "1.0.1",
31 | "@angular/compiler-cli": "^4.0.0",
32 | "@types/jasmine": "2.5.38",
33 | "@types/node": "~6.0.60",
34 | "codelyzer": "~2.0.0",
35 | "jasmine-core": "~2.5.2",
36 | "jasmine-spec-reporter": "~3.2.0",
37 | "karma": "~1.4.1",
38 | "karma-chrome-launcher": "~2.0.0",
39 | "karma-cli": "~1.0.1",
40 | "karma-jasmine": "~1.1.0",
41 | "karma-jasmine-html-reporter": "^0.2.2",
42 | "karma-coverage-istanbul-reporter": "^0.2.0",
43 | "protractor": "~5.1.0",
44 | "ts-node": "~2.0.0",
45 | "tslint": "~4.5.0",
46 | "typescript": "~2.2.0"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/github-search/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | beforeLaunch: function() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | },
27 | onPrepare() {
28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/github-search/server.js:
--------------------------------------------------------------------------------
1 | // Get dependencies
2 | const express = require('express');
3 | const path = require('path');
4 | const http = require('http');
5 |
6 | // Get our API routes
7 | const app = express();
8 |
9 | // Point static path to dist
10 | app.use(express.static(path.join(__dirname, 'dist')));
11 |
12 |
13 | // Catch all other routes and return the index file
14 | app.get('*', (req, res) => {
15 | res.sendFile(path.join(__dirname, 'dist/index.html'));
16 | });
17 |
18 | /**
19 | * Get port from environment and store in Express.
20 | */
21 | const port = process.env.PORT || '3000';
22 | app.set('port', port);
23 |
24 | /**
25 | * Create HTTP server.
26 | */
27 | const server = http.createServer(app);
28 |
29 | /**
30 | * Listen on provided port, on all network interfaces.
31 | */
32 | server.listen(port, () => console.log(`API running on localhost:${port}`));
33 |
--------------------------------------------------------------------------------
/github-search/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/github-search/src/app/app.component.css
--------------------------------------------------------------------------------
/github-search/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/github-search/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 |
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | }).compileComponents();
12 | }));
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app works!'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app works!');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/github-search/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | }
10 |
--------------------------------------------------------------------------------
/github-search/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { HttpModule } from '@angular/http';
5 | import { RouterModule } from '@angular/router';
6 |
7 | import { AppComponent } from './app.component';
8 | import { ProfileComponent } from './profile/profile.component';
9 | import { NavbarComponent } from './navbar/navbar.component';
10 | import { GithubService } from './github.service';
11 |
12 |
13 | @NgModule({
14 | declarations: [
15 | AppComponent,
16 | ProfileComponent,
17 | NavbarComponent
18 | ],
19 | imports: [
20 | BrowserModule,
21 | FormsModule,
22 | HttpModule,
23 | ],
24 | providers: [GithubService],
25 | bootstrap: [AppComponent]
26 | })
27 | export class AppModule { }
28 |
--------------------------------------------------------------------------------
/github-search/src/app/github.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { GithubService } from './github.service';
4 |
5 | describe('GithubService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [GithubService]
9 | });
10 | });
11 |
12 | it('should ...', inject([GithubService], (service: GithubService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/github-search/src/app/github.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Http, Headers } from '@angular/http';
3 | import 'rxjs/add/operator/map';
4 |
5 | @Injectable()
6 | export class GithubService {
7 | private username:string;
8 |
9 | constructor(private http:Http) {
10 | console.log('Service Ready');
11 | }
12 |
13 | // Get user by name
14 | getUser() {
15 | return this.http.get('http://api.github.com/users/'+this.username)
16 | .map(res => res.json());
17 | }
18 |
19 | // Get user repos
20 | getRepos() {
21 | return this.http.get('http://api.github.com/users/'+this.username+'/repos')
22 | .map(res => res.json());
23 | }
24 |
25 |
26 | // Update username as user types in search
27 | updateUser(username:string) {
28 | this.username = username;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/github-search/src/app/navbar/navbar.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/github-search/src/app/navbar/navbar.component.css
--------------------------------------------------------------------------------
/github-search/src/app/navbar/navbar.component.html:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/github-search/src/app/navbar/navbar.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NavbarComponent } from './navbar.component';
4 |
5 | describe('NavbarComponent', () => {
6 | let component: NavbarComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ NavbarComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NavbarComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/github-search/src/app/navbar/navbar.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'navbar',
5 | templateUrl: './navbar.component.html',
6 | styleUrls: ['./navbar.component.css']
7 | })
8 | export class NavbarComponent implements OnInit {
9 | title="GithubSearch";
10 |
11 | constructor() { }
12 |
13 | ngOnInit() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/github-search/src/app/profile/profile.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/github-search/src/app/profile/profile.component.css
--------------------------------------------------------------------------------
/github-search/src/app/profile/profile.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ProfileComponent } from './profile.component';
4 |
5 | describe('ProfileComponent', () => {
6 | let component: ProfileComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ProfileComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ProfileComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/github-search/src/app/profile/profile.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { GithubService } from '../github.service'
3 |
4 | @Component({
5 | selector: 'profile',
6 | templateUrl: './profile.component.html',
7 | styleUrls: ['./profile.component.css']
8 | })
9 | export class ProfileComponent implements OnInit {
10 | // Declare variables
11 | user:any = [];
12 | repos:any = [];
13 | username:string;
14 |
15 | constructor(private githubService:GithubService) {
16 | // Initialize with false so that it doesn't display with *ngIf
17 | this.user = false;
18 | }
19 |
20 | ngOnInit() {
21 | }
22 |
23 | searchUser() {
24 | this.githubService.updateUser(this.username);
25 |
26 | // Get user calling githubService
27 | this.githubService.getUser().subscribe( user => {
28 | this.user = user;
29 | });
30 |
31 | // Get repos calling githubService
32 | this.githubService.getRepos().subscribe( repos => {
33 | this.repos = repos;
34 | });
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/github-search/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/github-search/src/assets/.gitkeep
--------------------------------------------------------------------------------
/github-search/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/github-search/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/github-search/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/github-search/src/favicon.ico
--------------------------------------------------------------------------------
/github-search/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Github Searcher
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Loading...
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/github-search/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/github-search/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/github-search/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare var __karma__: any;
17 | declare var require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/github-search/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "baseUrl": "",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/github-search/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "baseUrl": "",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/github-search/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/github-search/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "baseUrl": "src",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2016",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/mean-todo/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "ng2-mean"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json"
40 | },
41 | {
42 | "project": "src/tsconfig.spec.json"
43 | },
44 | {
45 | "project": "e2e/tsconfig.e2e.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "css",
55 | "component": {}
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/mean-todo/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/mean-todo/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { Ng2MeanPage } from './app.po';
2 |
3 | describe('ng2-mean App', () => {
4 | let page: Ng2MeanPage;
5 |
6 | beforeEach(() => {
7 | page = new Ng2MeanPage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/mean-todo/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, element, by } from 'protractor';
2 |
3 | export class Ng2MeanPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/mean-todo/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types":[
8 | "jasmine",
9 | "node"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/mean-todo/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | files: [
19 | { pattern: './src/test.ts', watched: false }
20 | ],
21 | preprocessors: {
22 | './src/test.ts': ['@angular/cli']
23 | },
24 | mime: {
25 | 'text/x-typescript': ['ts','tsx']
26 | },
27 | coverageIstanbulReporter: {
28 | reports: [ 'html', 'lcovonly' ],
29 | fixWebpackSourcePaths: true
30 | },
31 | angularCli: {
32 | environment: 'dev'
33 | },
34 | reporters: config.angularCli && config.angularCli.codeCoverage
35 | ? ['progress', 'coverage-istanbul']
36 | : ['progress', 'kjhtml'],
37 | port: 9876,
38 | colors: true,
39 | logLevel: config.LOG_INFO,
40 | autoWatch: true,
41 | browsers: ['Chrome'],
42 | singleRun: false
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/mean-todo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mean-todo",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/common": "^4.0.0",
16 | "@angular/compiler": "^4.0.0",
17 | "@angular/core": "^4.0.0",
18 | "@angular/forms": "^4.0.0",
19 | "@angular/http": "^4.0.0",
20 | "@angular/platform-browser": "^4.0.0",
21 | "@angular/platform-browser-dynamic": "^4.0.0",
22 | "@angular/router": "^4.0.0",
23 | "body-parser": "^1.17.2",
24 | "core-js": "^2.4.1",
25 | "express": "^4.15.3",
26 | "mongoose": "^4.10.0",
27 | "rxjs": "^5.1.0",
28 | "zone.js": "^0.8.4"
29 | },
30 | "devDependencies": {
31 | "@angular/cli": "1.0.1",
32 | "@angular/compiler-cli": "^4.0.0",
33 | "@types/jasmine": "2.5.38",
34 | "@types/node": "~6.0.60",
35 | "codelyzer": "~2.0.0",
36 | "jasmine-core": "~2.5.2",
37 | "jasmine-spec-reporter": "~3.2.0",
38 | "karma": "~1.4.1",
39 | "karma-chrome-launcher": "~2.0.0",
40 | "karma-cli": "~1.0.1",
41 | "karma-jasmine": "~1.1.0",
42 | "karma-jasmine-html-reporter": "^0.2.2",
43 | "karma-coverage-istanbul-reporter": "^0.2.0",
44 | "protractor": "~5.1.0",
45 | "ts-node": "~2.0.0",
46 | "tslint": "~4.5.0",
47 | "typescript": "~2.2.0"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/mean-todo/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | beforeLaunch: function() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | },
27 | onPrepare() {
28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/mean-todo/server.js:
--------------------------------------------------------------------------------
1 | // Get dependencies
2 | const express = require('express');
3 | const path = require('path');
4 | const http = require('http');
5 | const bodyParser = require('body-parser');
6 |
7 | // Get our API routes
8 | const app = express();
9 |
10 | // load mongoose package
11 | var mongoose = require('mongoose');
12 | // Use native Node promises
13 | mongoose.Promise = global.Promise;
14 | // connect to MongoDB
15 | mongoose.connect('mongodb://localhost/meanTodo')
16 | .then(() => console.log('Mongo Connection Successful'))
17 | .catch((err) => console.error(err));
18 |
19 |
20 | // Parsers for POST data
21 | app.use(bodyParser.json());
22 | app.use(bodyParser.urlencoded({ extended: false }));
23 |
24 | // Specify routing
25 | // NOTE: Always do this after intializing parsers
26 | const api = require('./server/routes/api');
27 | app.use('/api', api);
28 |
29 | // Point static path to dist
30 | app.use(express.static(path.join(__dirname, 'dist')));
31 |
32 |
33 | // Catch all other routes and return the index file
34 | app.get('*', (req, res) => {
35 | res.sendFile(path.join(__dirname, 'dist/index.html'));
36 | });
37 |
38 |
39 |
40 | /**
41 | * Get port from environment and store in Express.
42 | */
43 | const port = process.env.PORT || '3000';
44 | app.set('port', port);
45 |
46 | /**
47 | * Create HTTP server.
48 | */
49 | const server = http.createServer(app);
50 |
51 | /**
52 | * Listen on provided port, on all network interfaces.
53 | */
54 | server.listen(port, () => console.log(`API running on localhost:${port}`));
55 |
--------------------------------------------------------------------------------
/mean-todo/server/models/Todo.js:
--------------------------------------------------------------------------------
1 | // Create Mongoose Schema for Todos stored in MongoDB
2 | var mongoose = require('mongoose');
3 |
4 | var TodoSchema = mongoose.Schema({
5 | text: String,
6 | isCompleted: Boolean
7 | });
8 |
9 | module.exports = mongoose.model('Todo', TodoSchema)
10 |
--------------------------------------------------------------------------------
/mean-todo/server/routes/api.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const Todo = require('../models/Todo');
4 |
5 | // GET all Todos
6 | router.get('/todos', function (req, res, next) {
7 | Todo.find(function (err, result) {
8 | if (err) return next(err);
9 | res.json(result);
10 | });
11 | });
12 |
13 | // GET single Todo
14 | router.get('/todo/:id', function (req, res, next) {
15 | Todo.findById(req.params.id, function (err, result) { // req.params.id finds id from url
16 | if (err) return next(err);
17 | res.json(result);
18 | });
19 | });
20 |
21 | // POST Todo
22 | router.post('/todo', function (req, res, next) {
23 | var todo = req.body; // Gets HTTP post data, if undefined, it's an error
24 | Todo.create(todo, function (err, result) {
25 | if (err) {
26 | res.send(err);
27 | } else {
28 | res.json(result);
29 | }
30 | })
31 | });
32 |
33 | // Edit Todo
34 | router.put('/todo/:id', function (req, res, next) {
35 | Todo.findOneAndUpdate({
36 | _id: req.params.id
37 | }, req.body, function (err, result) {
38 | if (err) {
39 | res.send(err);
40 | } else {
41 | res.json(result);
42 | }
43 | });
44 | });
45 |
46 |
47 | // Delete Todo
48 | router.delete('/todo/:id', function (req, res, next) {
49 | Todo.remove({
50 | _id: req.params.id
51 | }, function (err, result) {
52 | if (err) {
53 | res.send(err);
54 | } else {
55 | res.json(result);
56 | }
57 | });
58 | });
59 |
60 | module.exports = router;
61 |
--------------------------------------------------------------------------------
/mean-todo/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/mean-todo/src/app/app.component.css
--------------------------------------------------------------------------------
/mean-todo/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
30 |
--------------------------------------------------------------------------------
/mean-todo/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 |
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | }).compileComponents();
12 | }));
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app works!'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app works!');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/mean-todo/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | }
10 |
--------------------------------------------------------------------------------
/mean-todo/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { HttpModule } from '@angular/http';
5 | import { RouterModule } from '@angular/router';
6 |
7 | import { AppComponent } from './app.component';
8 | import { TodosComponent } from './todos/todos.component';
9 | import { TodosService } from './todos.service'
10 |
11 | // Import components and modules
12 | @NgModule({
13 | declarations: [
14 | AppComponent,
15 | TodosComponent
16 | ],
17 | imports: [
18 | BrowserModule,
19 | FormsModule,
20 | HttpModule,
21 | ],
22 | providers: [TodosService], // Specify services
23 | bootstrap: [AppComponent]
24 | })
25 | export class AppModule { }
26 |
--------------------------------------------------------------------------------
/mean-todo/src/app/todos.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { TodosService } from './todos.service';
4 |
5 | describe('TodosService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [TodosService]
9 | });
10 | });
11 |
12 | it('should ...', inject([TodosService], (service: TodosService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/mean-todo/src/app/todos.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Http, Headers } from '@angular/http';
3 | import 'rxjs/add/operator/map';
4 |
5 | @Injectable()
6 | export class TodosService {
7 |
8 | constructor(public http:Http) { }
9 |
10 | // Get all todos
11 | getTodos(){
12 | return this.http.get('/api/todos');
13 | }
14 |
15 | // Post todo
16 | saveTodo(todo) {
17 | var headers = new Headers();
18 | headers.append('Content-Type','application/json');
19 | return this.http.post('/api/todo', JSON.stringify(todo),{headers: headers})
20 | .map(res => res.json());
21 | }
22 |
23 | // Edit todo
24 | updateTodo(todo){
25 | var headers = new Headers();
26 | headers.append('Content-Type','application/json');
27 | return this.http.put('/api/todo/'+todo._id, JSON.stringify(todo),{headers: headers});
28 | }
29 |
30 | // Delete todo
31 | deleteTodo(id){
32 | return this.http.delete('/api/todo/'+id);
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/mean-todo/src/app/todos/todos.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/mean-todo/src/app/todos/todos.component.css
--------------------------------------------------------------------------------
/mean-todo/src/app/todos/todos.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Add Todo
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
0">
12 |
No Todos
13 |
14 |
15 |
16 |
32 |
33 |
--------------------------------------------------------------------------------
/mean-todo/src/app/todos/todos.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { TodosComponent } from './todos.component';
4 |
5 | describe('TodosComponent', () => {
6 | let component: TodosComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ TodosComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(TodosComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/mean-todo/src/app/todos/todos.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { TodosService } from '../todos.service';
3 | import { Todo } from '../../models/Todo';
4 | import 'rxjs/add/operator/map';
5 |
6 | @Component({
7 | selector: 'todos',
8 | templateUrl: './todos.component.html',
9 | styleUrls: ['./todos.component.css']
10 | })
11 | export class TodosComponent implements OnInit {
12 | todos: Todo[];
13 | constructor( private todoService:TodosService) { }
14 |
15 | // Get all todos on init
16 | ngOnInit() {
17 | this.todoService.getTodos()
18 | .map(res => res.json())
19 | .subscribe(todos => this.todos = todos)
20 | }
21 |
22 |
23 | // Add new todo
24 | addTodo($event, todoText){
25 | // if event is click
26 | if($event.which === 1){
27 | var result;
28 | var newTodo = {
29 | text: todoText.value,
30 | isCompleted: false
31 | };
32 | // Create new todo and save
33 | result = this.todoService.saveTodo(newTodo);
34 | result.subscribe(x => {
35 | this.todos.push(newTodo)
36 | })
37 | todoText.value = ''; // Clear input
38 | }
39 | }
40 |
41 | // Edit todo status
42 | updateStatus(todo) {
43 | var temp = {
44 | _id: todo._id,
45 | text: todo.text,
46 | isCompleted: !todo.isCompleted
47 | };
48 |
49 | this.todoService.updateTodo(temp)
50 | .map(res => res.json)
51 | .subscribe( data => {todo.isCompleted = !todo.isCompleted});
52 | }
53 |
54 | // Function to switch edit states
55 | setEditState(todo, state) {
56 | if(state)
57 | todo.isEditMode = state;
58 | else
59 | delete todo.isEditMode;
60 | }
61 |
62 |
63 | // Edit todo text
64 | updateTodoText($event, todo) {
65 | // Enter key is pressed
66 | if($event.which === 13) {
67 | todo.text = $event.target.value;
68 | var temp = {
69 | _id: todo._id,
70 | text: todo.text,
71 | isCompleted: todo.isCompleted
72 | };
73 |
74 | // Save and change edit state
75 | this.todoService.updateTodo(temp)
76 | .map(res => res.json())
77 | .subscribe(data => {
78 | this.setEditState(todo, false);
79 | });
80 | }
81 | }
82 |
83 | /*
84 | deleteTodo(todo) {
85 | var todos = this.todos;
86 | this.todoService.deleteTodo(todo._id)
87 | .map(res => res.json)
88 | .subscribe( data => {
89 | if(data.n == 1){
90 | for(var i = 0;i < todos.length;i++){
91 | if(todos[i]._id == todo._id){
92 | todos.splice(i, 1);
93 | }
94 | }
95 | }
96 | });
97 | }
98 | */
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/mean-todo/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/mean-todo/src/assets/.gitkeep
--------------------------------------------------------------------------------
/mean-todo/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/mean-todo/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/mean-todo/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/mean-todo/src/favicon.ico
--------------------------------------------------------------------------------
/mean-todo/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MeanTodo
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Loading...
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/mean-todo/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/mean-todo/src/models/Todo.ts:
--------------------------------------------------------------------------------
1 | export class Todo{
2 | text: string;
3 | isCompleted: boolean;
4 | }
--------------------------------------------------------------------------------
/mean-todo/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/set';
35 |
36 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
37 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
38 |
39 | /** IE10 and IE11 requires the following to support `@angular/animation`. */
40 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
41 |
42 |
43 | /** Evergreen browsers require these. **/
44 | import 'core-js/es6/reflect';
45 | import 'core-js/es7/reflect';
46 |
47 |
48 | /** ALL Firefox browsers require the following to support `@angular/animation`. **/
49 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
50 |
51 |
52 |
53 | /***************************************************************************************************
54 | * Zone JS is required by Angular itself.
55 | */
56 | import 'zone.js/dist/zone'; // Included with Angular CLI.
57 |
58 |
59 |
60 | /***************************************************************************************************
61 | * APPLICATION IMPORTS
62 | */
63 |
64 | /**
65 | * Date, currency, decimal and percent pipes.
66 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
67 | */
68 | // import 'intl'; // Run `npm install --save intl`.
69 |
--------------------------------------------------------------------------------
/mean-todo/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/mean-todo/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare var __karma__: any;
17 | declare var require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/mean-todo/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "baseUrl": "",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/mean-todo/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "baseUrl": "",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/mean-todo/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/mean-todo/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "baseUrl": "src",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2016",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/meteor-todo/.meteor/.finished-upgraders:
--------------------------------------------------------------------------------
1 | # This file contains information which helps Meteor properly upgrade your
2 | # app when you run 'meteor update'. You should check it into version control
3 | # with your project.
4 |
5 | notices-for-0.9.0
6 | notices-for-0.9.1
7 | 0.9.4-platform-file
8 | notices-for-facebook-graph-api-2
9 | 1.2.0-standard-minifiers-package
10 | 1.2.0-meteor-platform-split
11 | 1.2.0-cordova-changes
12 | 1.2.0-breaking-changes
13 | 1.3.0-split-minifiers-package
14 | 1.4.0-remove-old-dev-bundle-link
15 | 1.4.1-add-shell-server-package
16 | 1.4.3-split-account-service-packages
17 | 1.5-add-dynamic-import-package
18 |
--------------------------------------------------------------------------------
/meteor-todo/.meteor/.gitignore:
--------------------------------------------------------------------------------
1 | local
2 |
--------------------------------------------------------------------------------
/meteor-todo/.meteor/.id:
--------------------------------------------------------------------------------
1 | # This file contains a token that is unique to your project.
2 | # Check it into your repository along with the rest of this directory.
3 | # It can be used for purposes such as:
4 | # - ensuring you don't accidentally deploy one app on top of another
5 | # - providing package authors with aggregated statistics
6 |
7 | 1004ykn1sfgcx1szjnwn
8 |
--------------------------------------------------------------------------------
/meteor-todo/.meteor/packages:
--------------------------------------------------------------------------------
1 | # Meteor packages used by this project, one per line.
2 | # Check this file (and the other files in this directory) into your repository.
3 | #
4 | # 'meteor add' and 'meteor remove' will edit this file for you,
5 | # but you can also edit it by hand.
6 |
7 | meteor-base@1.1.0 # Packages every Meteor app needs to have
8 | mobile-experience@1.0.4 # Packages for a great mobile UX
9 | mongo@1.1.18 # The database Meteor supports right now
10 | reactive-var@1.0.11 # Reactive variable for tracker
11 | tracker@1.1.3 # Meteor's client-side reactive programming library
12 |
13 | standard-minifier-css@1.3.4 # CSS minifier run for production mode
14 | standard-minifier-js@2.1.0 # JS minifier run for production mode
15 | es5-shim@4.6.15 # ECMAScript 5 compatibility for older browsers
16 | ecmascript@0.8.0 # Enable ECMAScript2015+ syntax in app code
17 | shell-server@0.2.3 # Server-side component of the `meteor shell` command
18 |
19 | angular-templates
20 | accounts-password
21 | dotansimha:accounts-ui-angular
22 |
--------------------------------------------------------------------------------
/meteor-todo/.meteor/platforms:
--------------------------------------------------------------------------------
1 | android
2 | browser
3 | server
4 |
--------------------------------------------------------------------------------
/meteor-todo/.meteor/release:
--------------------------------------------------------------------------------
1 | METEOR@1.5
2 |
--------------------------------------------------------------------------------
/meteor-todo/.meteor/versions:
--------------------------------------------------------------------------------
1 | accounts-base@1.3.0
2 | accounts-password@1.3.7
3 | accounts-ui@1.1.9
4 | accounts-ui-unstyled@1.2.1
5 | allow-deny@1.0.5
6 | angular-templates@1.0.9
7 | autoupdate@1.3.12
8 | babel-compiler@6.19.1
9 | babel-runtime@1.0.1
10 | base64@1.0.10
11 | binary-heap@1.0.10
12 | blaze@2.3.2
13 | blaze-html-templates@1.0.5
14 | blaze-tools@1.0.10
15 | boilerplate-generator@1.1.0
16 | caching-compiler@1.1.9
17 | caching-html-compiler@1.0.7
18 | callback-hook@1.0.10
19 | check@1.2.5
20 | ddp@1.2.5
21 | ddp-client@1.3.4
22 | ddp-common@1.2.8
23 | ddp-rate-limiter@1.0.7
24 | ddp-server@1.3.14
25 | deps@1.0.12
26 | diff-sequence@1.0.7
27 | dotansimha:accounts-ui-angular@0.0.4
28 | dynamic-import@0.1.0
29 | ecmascript@0.8.0
30 | ecmascript-runtime@0.4.1
31 | ecmascript-runtime-client@0.4.1
32 | ecmascript-runtime-server@0.4.1
33 | ejson@1.0.13
34 | email@1.2.3
35 | es5-shim@4.6.15
36 | fastclick@1.0.13
37 | geojson-utils@1.0.10
38 | hot-code-push@1.0.4
39 | html-tools@1.0.11
40 | htmljs@1.0.11
41 | http@1.2.12
42 | id-map@1.0.9
43 | jquery@1.11.10
44 | launch-screen@1.1.1
45 | less@2.7.9
46 | livedata@1.0.18
47 | localstorage@1.1.0
48 | logging@1.1.17
49 | meteor@1.6.1
50 | meteor-base@1.1.0
51 | minifier-css@1.2.16
52 | minifier-js@2.1.0
53 | minimongo@1.2.0
54 | mobile-experience@1.0.4
55 | mobile-status-bar@1.0.14
56 | modules@0.9.0
57 | modules-runtime@0.8.0
58 | mongo@1.1.18
59 | mongo-id@1.0.6
60 | npm-bcrypt@0.9.3
61 | npm-mongo@2.2.24
62 | observe-sequence@1.0.16
63 | ordered-dict@1.0.9
64 | promise@0.8.9
65 | random@1.0.10
66 | rate-limit@1.0.8
67 | reactive-dict@1.1.9
68 | reactive-var@1.0.11
69 | reload@1.1.11
70 | retry@1.0.9
71 | routepolicy@1.0.12
72 | service-configuration@1.0.11
73 | session@1.1.7
74 | sha@1.0.9
75 | shell-server@0.2.3
76 | spacebars@1.0.15
77 | spacebars-compiler@1.1.2
78 | srp@1.0.10
79 | standard-minifier-css@1.3.4
80 | standard-minifier-js@2.1.0
81 | templating@1.2.15
82 | templating-compiler@1.2.15
83 | templating-runtime@1.2.15
84 | templating-tools@1.1.2
85 | tmeasday:check-npm-versions@0.1.1
86 | tracker@1.1.3
87 | ui@1.0.13
88 | underscore@1.0.10
89 | urigo:static-html-compiler@0.1.8
90 | url@1.1.0
91 | webapp@1.3.16
92 | webapp-hashing@1.0.9
93 |
--------------------------------------------------------------------------------
/meteor-todo/client/main.css:
--------------------------------------------------------------------------------
1 | /* CSS declarations go here */
2 | body {
3 | font-family: sans-serif;
4 | background-color: #315481;
5 | background-image: linear-gradient(to bottom, #315481, #918e82 100%);
6 | background-attachment: fixed;
7 |
8 | position: absolute;
9 | top: 0;
10 | bottom: 0;
11 | left: 0;
12 | right: 0;
13 |
14 | padding: 0;
15 | margin: 0;
16 |
17 | font-size: 14px;
18 | }
19 |
20 | .container {
21 | max-width: 600px;
22 | margin: 0 auto;
23 | min-height: 100%;
24 | background: white;
25 | }
26 |
27 | header {
28 | background: #d2edf4;
29 | background-image: linear-gradient(to bottom, #d0edf5, #e1e5f0 100%);
30 | padding: 20px 15px 15px 15px;
31 | position: relative;
32 | }
33 |
34 | #login-buttons {
35 | display: block;
36 | }
37 |
38 | h1 {
39 | font-size: 1.5em;
40 | margin: 0;
41 | margin-bottom: 10px;
42 | display: inline-block;
43 | margin-right: 1em;
44 | }
45 |
46 | form {
47 | margin-top: 10px;
48 | margin-bottom: -10px;
49 | position: relative;
50 | }
51 |
52 | .new-task input {
53 | box-sizing: border-box;
54 | padding: 10px 0;
55 | background: transparent;
56 | border: none;
57 | width: 100%;
58 | padding-right: 80px;
59 | font-size: 1em;
60 | }
61 |
62 | .new-task input:focus{
63 | outline: 0;
64 | }
65 |
66 | ul {
67 | margin: 0;
68 | padding: 0;
69 | background: white;
70 | }
71 |
72 | .delete {
73 | float: right;
74 | font-weight: bold;
75 | background: none;
76 | font-size: 1em;
77 | border: none;
78 | position: relative;
79 | }
80 |
81 | li {
82 | position: relative;
83 | list-style: none;
84 | padding: 15px;
85 | border-bottom: #eee solid 1px;
86 | }
87 |
88 | li .text {
89 | margin-left: 10px;
90 | }
91 |
92 | li.checked {
93 | color: #888;
94 | }
95 |
96 | li.checked .text {
97 | text-decoration: line-through;
98 | }
99 |
100 | li.private {
101 | background: #eee;
102 | border-color: #ddd;
103 | }
104 |
105 | header .hide-completed {
106 | float: right;
107 | }
108 |
109 | .toggle-private {
110 | margin-left: 5px;
111 | }
112 |
113 | @media (max-width: 600px) {
114 | li {
115 | padding: 12px 15px;
116 | }
117 |
118 | .search {
119 | width: 150px;
120 | clear: both;
121 | }
122 |
123 | .new-task input {
124 | padding-bottom: 5px;
125 | }
126 | }
--------------------------------------------------------------------------------
/meteor-todo/client/main.html:
--------------------------------------------------------------------------------
1 |
2 | meteor-todo
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/meteor-todo/client/main.js:
--------------------------------------------------------------------------------
1 |
2 | import angular from 'angular';
3 | import angularMeteor from 'angular-meteor';
4 | import todoList from '../imports/components/todoList/todoList';
5 | import '../imports/startup/accounts-config.js';
6 |
7 | angular.module('meteor-todo', [
8 | angularMeteor,
9 | todoList.name,
10 | 'accounts.ui'
11 | ]);
12 |
13 | function onReady() {
14 | angular.bootstrap(document, ['meteor-todo']);
15 | }
16 |
17 | if (Meteor.isCordova) {
18 | angular.element(document).on('deviceready', onReady);
19 | } else {
20 | angular.element(document).ready(onReady);
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/meteor-todo/imports/api/tasks.js:
--------------------------------------------------------------------------------
1 | import { Meteor } from 'meteor/meteor';
2 | import { Mongo } from 'meteor/mongo';
3 | import { check } from 'meteor/check';
4 |
5 | export const Tasks = new Mongo.Collection('tasks');
6 |
7 | if(Meteor.isServer) {
8 | Meteor.publish('tasks', function tasksPublication() {
9 | return Tasks.find();
10 | })
11 | }
12 |
13 | Meteor.methods({
14 | 'tasks.insert' (text) {
15 | check(text, String);
16 |
17 | if (!Meteor.userId()) {
18 | throw new Meteor.error('not-authorized');
19 | }
20 |
21 | Tasks.insert({
22 | text,
23 | createdAt: new Date(),
24 | owner: Meteor.userId(),
25 | username: Meteor.user().username,
26 | });
27 | },
28 | 'tasks.remove' (taskId) {
29 | check(taskId, String);
30 |
31 | Tasks.remove(taskId);
32 | },
33 | 'tasks.setChecked' (taskId, setChecked) {
34 | check(taskId, String);
35 | check(setChecked, Boolean);
36 |
37 | Tasks.update(taskId, {
38 | $set: {
39 | checked: setChecked
40 | }
41 | })
42 | }
43 | })
--------------------------------------------------------------------------------
/meteor-todo/imports/components/todoList/todoList.html:
--------------------------------------------------------------------------------
1 |
2 | Todo List ( {{$ctrl.incompleteCount}} )
3 |
4 |
5 |
9 |
10 |
11 |
12 |
15 |
16 |
25 |
--------------------------------------------------------------------------------
/meteor-todo/imports/components/todoList/todoList.js:
--------------------------------------------------------------------------------
1 | import angular from 'angular';
2 | import angularMeteor from 'angular-meteor';
3 |
4 | import template from './todoList.html';
5 | import { Tasks } from '../../api/tasks.js';
6 |
7 | class TodoListCtrl {
8 | constructor($scope) {
9 | $scope.viewModel(this);
10 | this.hideCompleted = false;
11 | this.subscribe('tasks');
12 |
13 | this.helpers({
14 | tasks() {
15 | const selector = {};
16 |
17 | if(this.getReactively('hideCompleted')) {
18 | selector.checked = {
19 | $ne: true
20 | };
21 | }
22 |
23 | return Tasks.find(selector, {
24 | sort: {
25 | createdAt: -1
26 | }
27 | });
28 | },
29 | incompleteCount() {
30 | return Tasks.find({
31 | checked: {
32 | $ne: true
33 | }
34 | }).count();
35 | },
36 | currentUser() {
37 | return Meteor.user();
38 | }
39 | })
40 | }
41 |
42 | addTask(newTask) {
43 | Meteor.call('tasks.insert', newTask);
44 | this.newTask = '';
45 | }
46 |
47 | setChecked(task) {
48 | Meteor.call('tasks.setChecked', task._id, !task.checked);
49 | }
50 |
51 | removeTask(task) {
52 | Meteor.call('tasks.remove', task._id)
53 | }
54 | }
55 |
56 | export default angular.module('todoList', [
57 | angularMeteor
58 | ])
59 | .component('todoList', {
60 | templateUrl: 'imports/components/todoList/todoList.html',
61 | controller: ['$scope', TodoListCtrl]
62 | });
63 |
--------------------------------------------------------------------------------
/meteor-todo/imports/startup/accounts-config.js:
--------------------------------------------------------------------------------
1 | import { Accounts } from 'meteor/accounts-base';
2 |
3 | Accounts.ui.config({
4 | passwordSignupFields: 'USERNAME_ONLY',
5 | });
--------------------------------------------------------------------------------
/meteor-todo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "meteor-todo",
3 | "private": true,
4 | "scripts": {
5 | "start": "meteor run"
6 | },
7 | "dependencies": {
8 | "angular": "^1.6.4",
9 | "angular-meteor": "^1.3.12",
10 | "babel-runtime": "^6.20.0",
11 | "bcrypt": "^1.0.2",
12 | "meteor-node-stubs": "~0.2.4"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/meteor-todo/server/main.js:
--------------------------------------------------------------------------------
1 | import { Meteor } from 'meteor/meteor';
2 | import '../imports/api/tasks.js'
3 |
4 | Meteor.startup(() => {
5 | // code to run on server at startup
6 | });
7 |
--------------------------------------------------------------------------------
/ng-spotify/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "ng2-mean"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json"
40 | },
41 | {
42 | "project": "src/tsconfig.spec.json"
43 | },
44 | {
45 | "project": "e2e/tsconfig.e2e.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "css",
55 | "component": {}
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ng-spotify/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/ng-spotify/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { Ng2MeanPage } from './app.po';
2 |
3 | describe('ng2-mean App', () => {
4 | let page: Ng2MeanPage;
5 |
6 | beforeEach(() => {
7 | page = new Ng2MeanPage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/ng-spotify/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, element, by } from 'protractor';
2 |
3 | export class Ng2MeanPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ng-spotify/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types":[
8 | "jasmine",
9 | "node"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ng-spotify/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | files: [
19 | { pattern: './src/test.ts', watched: false }
20 | ],
21 | preprocessors: {
22 | './src/test.ts': ['@angular/cli']
23 | },
24 | mime: {
25 | 'text/x-typescript': ['ts','tsx']
26 | },
27 | coverageIstanbulReporter: {
28 | reports: [ 'html', 'lcovonly' ],
29 | fixWebpackSourcePaths: true
30 | },
31 | angularCli: {
32 | environment: 'dev'
33 | },
34 | reporters: config.angularCli && config.angularCli.codeCoverage
35 | ? ['progress', 'coverage-istanbul']
36 | : ['progress', 'kjhtml'],
37 | port: 9876,
38 | colors: true,
39 | logLevel: config.LOG_INFO,
40 | autoWatch: true,
41 | browsers: ['Chrome'],
42 | singleRun: false
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/ng-spotify/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ng-spotify",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/common": "^4.0.0",
16 | "@angular/compiler": "^4.0.0",
17 | "@angular/core": "^4.0.0",
18 | "@angular/forms": "^4.0.0",
19 | "@angular/http": "^4.0.0",
20 | "@angular/platform-browser": "^4.0.0",
21 | "@angular/platform-browser-dynamic": "^4.0.0",
22 | "@angular/router": "^4.0.0",
23 | "body-parser": "^1.17.2",
24 | "core-js": "^2.4.1",
25 | "express": "^4.15.3",
26 | "mongoose": "^4.10.0",
27 | "rxjs": "^5.1.0",
28 | "zone.js": "^0.8.4"
29 | },
30 | "devDependencies": {
31 | "@angular/cli": "1.0.1",
32 | "@angular/compiler-cli": "^4.0.0",
33 | "@types/jasmine": "2.5.38",
34 | "@types/node": "~6.0.60",
35 | "codelyzer": "~2.0.0",
36 | "jasmine-core": "~2.5.2",
37 | "jasmine-spec-reporter": "~3.2.0",
38 | "karma": "~1.4.1",
39 | "karma-chrome-launcher": "~2.0.0",
40 | "karma-cli": "~1.0.1",
41 | "karma-jasmine": "~1.1.0",
42 | "karma-jasmine-html-reporter": "^0.2.2",
43 | "karma-coverage-istanbul-reporter": "^0.2.0",
44 | "protractor": "~5.1.0",
45 | "ts-node": "~2.0.0",
46 | "tslint": "~4.5.0",
47 | "typescript": "~2.2.0"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ng-spotify/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | beforeLaunch: function() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | },
27 | onPrepare() {
28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/ng-spotify/server.js:
--------------------------------------------------------------------------------
1 | // Get dependencies
2 | const express = require('express');
3 | const path = require('path');
4 | const http = require('http');
5 |
6 | // Get our API routes
7 | const app = express();
8 |
9 | // Point static path to dist
10 | app.use(express.static(path.join(__dirname, 'dist')));
11 |
12 |
13 | // Catch all other routes and return the index file
14 | app.get('*', (req, res) => {
15 | res.sendFile(path.join(__dirname, 'dist/index.html'));
16 | });
17 |
18 | /**
19 | * Get port from environment and store in Express.
20 | */
21 | const port = process.env.PORT || '3000';
22 | app.set('port', port);
23 |
24 | /**
25 | * Create HTTP server.
26 | */
27 | const server = http.createServer(app);
28 |
29 | /**
30 | * Listen on provided port, on all network interfaces.
31 | */
32 | server.listen(port, () => console.log(`API running on localhost:${port}`));
33 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/about/about.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/ng-spotify/src/app/about/about.component.css
--------------------------------------------------------------------------------
/ng-spotify/src/app/about/about.component.html:
--------------------------------------------------------------------------------
1 | About
2 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/about/about.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { AboutComponent } from './about.component';
4 |
5 | describe('AboutComponent', () => {
6 | let component: AboutComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ AboutComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(AboutComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/about/about.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'about',
5 | templateUrl: './about.component.html',
6 | styleUrls: ['./about.component.css']
7 | })
8 | export class AboutComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/album/album.component.css:
--------------------------------------------------------------------------------
1 | .album{
2 | text-align: center;
3 | background: #333;
4 | padding: 10px 20px;
5 | border:#666 1px solid;
6 | }
7 |
8 | .album-thumb{
9 | width:100%;
10 | }
--------------------------------------------------------------------------------
/ng-spotify/src/app/album/album.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
21 |
22 |
23 |
Album Tracks
24 |
25 |
26 |
{{track.track_number}} - {{track.name}}
27 |
28 |
Preview Track
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/album/album.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { AlbumComponent } from './album.component';
4 |
5 | describe('AlbumComponent', () => {
6 | let component: AlbumComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ AlbumComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(AlbumComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/album/album.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { SpotifyService } from '../spotify.service';
3 | import { Artist } from '../../models/Artist';
4 | import { Album } from '../../models/Album';
5 | import { ActivatedRoute } from '@angular/router'
6 |
7 | @Component({
8 | selector: 'album',
9 | templateUrl: './album.component.html',
10 | styleUrls: ['./album.component.css']
11 | })
12 | export class AlbumComponent implements OnInit {
13 | id:string;
14 | album:Album[];
15 |
16 | constructor(private spotifyService:SpotifyService, private route:ActivatedRoute) { }
17 |
18 | // Get albums on initialization
19 | ngOnInit() {
20 | // Get id from route parameters and get Album details
21 | this.route.params
22 | .map( params => params['id'])
23 | .subscribe((id) => {
24 | this.spotifyService.getAlbum(id)
25 | .subscribe(album => {
26 | this.album = album;
27 | })
28 | })
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/ng-spotify/src/app/app.component.css
--------------------------------------------------------------------------------
/ng-spotify/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 |
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | }).compileComponents();
12 | }));
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app works!'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app works!');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | }
10 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { HttpModule } from '@angular/http';
5 | import { RouterModule } from '@angular/router';
6 |
7 | import { AppComponent } from './app.component';
8 | import { NavbarComponent } from './navbar/navbar.component';
9 | import { AboutComponent } from './about/about.component';
10 | import { SearchComponent } from './search/search.component';
11 | import { ArtistComponent } from './artist/artist.component';
12 | import { AlbumComponent } from './album/album.component';
13 |
14 | import { SpotifyService } from './spotify.service';
15 | import { routing } from './app.routes'; // Contains all routing information
16 |
17 |
18 | @NgModule({
19 | // Specify components
20 | declarations: [
21 | AppComponent,
22 | NavbarComponent,
23 | AboutComponent,
24 | SearchComponent,
25 | ArtistComponent,
26 | AlbumComponent
27 | ],
28 | // Specify modules used
29 | imports: [
30 | BrowserModule,
31 | FormsModule,
32 | HttpModule,
33 | routing
34 | ],
35 | providers: [SpotifyService], // Import service
36 | bootstrap: [AppComponent]
37 | })
38 | export class AppModule { }
39 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/app.routes.ts:
--------------------------------------------------------------------------------
1 | import { ModuleWithProviders } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { AboutComponent } from './about/about.component';
4 | import { SearchComponent } from './search/search.component';
5 | import { ArtistComponent } from './artist/artist.component';
6 | import { AlbumComponent } from './album/album.component';
7 |
8 |
9 | // Route Configuration
10 | export const routes: Routes = [
11 | { path: '', component: SearchComponent },
12 | { path: 'about', component: AboutComponent },
13 | { path: 'artist/:id', component: ArtistComponent },
14 | { path: 'album/:id', component: AlbumComponent }
15 | ];
16 |
17 |
18 | export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
--------------------------------------------------------------------------------
/ng-spotify/src/app/artist/artist.component.css:
--------------------------------------------------------------------------------
1 | .artist-header{
2 | padding-bottom:20px;
3 | margin-bottom:20px;
4 | border-bottom:solid 1px #333;
5 | }
6 |
7 | .artist-thumb{
8 | width:80px;
9 | height:auto;
10 | float:left;
11 | margin-right:10px;
12 | }
13 |
14 | .artist-albums .well{
15 | margin-bottom:20px;
16 | overflow:auto;
17 | min-height:400px;
18 | }
19 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/artist/artist.component.html:
--------------------------------------------------------------------------------
1 |
2 |
32 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/artist/artist.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ArtistComponent } from './artist.component';
4 |
5 | describe('ArtistComponent', () => {
6 | let component: ArtistComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ArtistComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ArtistComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/artist/artist.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { SpotifyService } from '../spotify.service';
3 | import { Artist } from '../../models/Artist';
4 | import { Album } from '../../models/Album';
5 | import { ActivatedRoute } from '@angular/router'
6 |
7 | @Component({
8 | selector: 'artist',
9 | templateUrl: './artist.component.html',
10 | styleUrls: ['./artist.component.css']
11 | })
12 | export class ArtistComponent implements OnInit {
13 | // Declare variables
14 | id:string;
15 | artist:Artist[];
16 | albums:Album[];
17 |
18 | constructor(private spotifyService:SpotifyService, private route:ActivatedRoute) { }
19 |
20 | // Load artists on intializatoin
21 | ngOnInit() {
22 | // Get id from route parameter and query Artist and albums
23 | this.route.params
24 | .map( params => params['id'])
25 | .subscribe((id) => {
26 | this.spotifyService.getArtist(id)
27 | .subscribe(artist => {
28 | this.artist = artist;
29 | })
30 |
31 | this.spotifyService.getAlbums(id)
32 | .subscribe(albums => {
33 | this.albums = albums.items;
34 | })
35 | })
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/navbar/navbar.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/ng-spotify/src/app/navbar/navbar.component.css
--------------------------------------------------------------------------------
/ng-spotify/src/app/navbar/navbar.component.html:
--------------------------------------------------------------------------------
1 |
2 |
27 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/navbar/navbar.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NavbarComponent } from './navbar.component';
4 |
5 | describe('NavbarComponent', () => {
6 | let component: NavbarComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ NavbarComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NavbarComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/navbar/navbar.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { RouterModule } from '@angular/router';
3 |
4 | @Component({
5 | selector: 'navbar',
6 | templateUrl: './navbar.component.html',
7 | styleUrls: ['./navbar.component.css']
8 | })
9 | export class NavbarComponent implements OnInit {
10 |
11 | constructor() { }
12 |
13 | ngOnInit() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/search/search.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/ng-spotify/src/app/search/search.component.css
--------------------------------------------------------------------------------
/ng-spotify/src/app/search/search.component.html:
--------------------------------------------------------------------------------
1 | Need Music?
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Genres:
16 | {{genre}}
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/search/search.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { SearchComponent } from './search.component';
4 |
5 | describe('SearchComponent', () => {
6 | let component: SearchComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ SearchComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(SearchComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/search/search.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { SpotifyService } from '../spotify.service';
3 | import { Artist } from '../../models/Artist';
4 |
5 | @Component({
6 | selector: 'search',
7 | templateUrl: './search.component.html',
8 | styleUrls: ['./search.component.css']
9 | })
10 | export class SearchComponent implements OnInit {
11 | searchRes:Artist;
12 | searchStr:string;
13 | constructor(private spotifyService:SpotifyService) { }
14 |
15 | ngOnInit() {
16 | }
17 |
18 | searchMusic() {
19 | this.spotifyService.searchMusic(this.searchStr)
20 | .subscribe( res => {
21 | this.searchRes = res.artists.items;
22 | });
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/spotify.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { SpotifyService } from './spotify.service';
4 |
5 | describe('SpotifyService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [SpotifyService]
9 | });
10 | });
11 |
12 | it('should ...', inject([SpotifyService], (service: SpotifyService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/ng-spotify/src/app/spotify.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Http, Headers } from '@angular/http';
3 | import 'rxjs/add/operator/map';
4 |
5 | @Injectable()
6 | export class SpotifyService {
7 | // Declare variablename:type
8 | private searchUrl:string;
9 | private artistUrl:string;
10 | private albumsUrl:string;
11 | private albumUrl:string;
12 |
13 | constructor(private http:Http) { }
14 |
15 | // Query Spotify Web API to get artists
16 | searchMusic(str:string, type = 'artist') {
17 | this.searchUrl = 'https://api.spotify.com/v1/search?query='+str+'&offset=0&limit=20&type='+type+'&market=US';
18 | return this.http.get(this.searchUrl)
19 | .map( res => res.json());
20 | }
21 |
22 | // Query artist details by id
23 | getArtist(id:string) {
24 | this.artistUrl = 'https://api.spotify.com/v1/artists/'+id;
25 | return this.http.get(this.artistUrl)
26 | .map( res => res.json());
27 | }
28 |
29 | // Query albums by artist using artist id
30 | getAlbums(artistId:string) {
31 | this.albumsUrl = 'https://api.spotify.com/v1/artists/'+artistId+'/albums';
32 | return this.http.get(this.albumsUrl)
33 | .map( res => res.json());
34 | }
35 |
36 |
37 | // Query album details by id
38 | getAlbum(id:string) {
39 | this.albumsUrl = 'https://api.spotify.com/v1/albums/'+id;
40 | return this.http.get(this.albumUrl)
41 | .map( res => res.json());
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/ng-spotify/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/ng-spotify/src/assets/.gitkeep
--------------------------------------------------------------------------------
/ng-spotify/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/ng-spotify/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/ng-spotify/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/ng-spotify/src/favicon.ico
--------------------------------------------------------------------------------
/ng-spotify/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ngSpotify
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Loading...
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ng-spotify/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/ng-spotify/src/models/Album.ts:
--------------------------------------------------------------------------------
1 | export class Album {
2 | id: number;
3 | }
--------------------------------------------------------------------------------
/ng-spotify/src/models/Artist.ts:
--------------------------------------------------------------------------------
1 | import { Album } from './Album'
2 |
3 | export class Artist {
4 | id: number;
5 | name: string;
6 | genres: any;
7 | albums: Album[];
8 | }
--------------------------------------------------------------------------------
/ng-spotify/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/ng-spotify/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare var __karma__: any;
17 | declare var require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/ng-spotify/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "baseUrl": "",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/ng-spotify/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "baseUrl": "",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/ng-spotify/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/ng-spotify/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "baseUrl": "src",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2016",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/socketchat/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "socketchat"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json"
40 | },
41 | {
42 | "project": "src/tsconfig.spec.json"
43 | },
44 | {
45 | "project": "e2e/tsconfig.e2e.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "css",
55 | "component": {}
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/socketchat/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/socketchat/README.md:
--------------------------------------------------------------------------------
1 | # Socketchat
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.1.3.
4 |
5 | ## Development server
6 |
7 | 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.
8 |
9 | ## Code scaffolding
10 |
11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`.
12 |
13 | ## Build
14 |
15 | 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.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24 | Before running the tests make sure you are serving the app via `ng serve`.
25 |
26 | ## Further help
27 |
28 | 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).
29 |
--------------------------------------------------------------------------------
/socketchat/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { SocketchatPage } from './app.po';
2 |
3 | describe('socketchat App', () => {
4 | let page: SocketchatPage;
5 |
6 | beforeEach(() => {
7 | page = new SocketchatPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to app!!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/socketchat/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class SocketchatPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/socketchat/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "node"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/socketchat/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | reports: [ 'html', 'lcovonly' ],
20 | fixWebpackSourcePaths: true
21 | },
22 | angularCli: {
23 | environment: 'dev'
24 | },
25 | reporters: ['progress', 'kjhtml'],
26 | port: 9876,
27 | colors: true,
28 | logLevel: config.LOG_INFO,
29 | autoWatch: true,
30 | browsers: ['Chrome'],
31 | singleRun: false
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/socketchat/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "socketchat",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/animations": "^4.0.0",
16 | "@angular/common": "^4.0.0",
17 | "@angular/compiler": "^4.0.0",
18 | "@angular/core": "^4.0.0",
19 | "@angular/forms": "^4.0.0",
20 | "@angular/http": "^4.0.0",
21 | "@angular/platform-browser": "^4.0.0",
22 | "@angular/platform-browser-dynamic": "^4.0.0",
23 | "@angular/router": "^4.0.0",
24 | "body-parser": "^1.17.2",
25 | "core-js": "^2.4.1",
26 | "express": "^4.15.3",
27 | "rxjs": "^5.1.0",
28 | "socket.io": "^2.0.3",
29 | "socket.io-client": "^2.0.3",
30 | "zone.js": "^0.8.4"
31 | },
32 | "devDependencies": {
33 | "@angular/cli": "1.1.3",
34 | "@angular/compiler-cli": "^4.0.0",
35 | "@angular/language-service": "^4.0.0",
36 | "@types/jasmine": "2.5.45",
37 | "@types/node": "~6.0.60",
38 | "codelyzer": "~3.0.1",
39 | "jasmine-core": "~2.6.2",
40 | "jasmine-spec-reporter": "~4.1.0",
41 | "karma": "~1.7.0",
42 | "karma-chrome-launcher": "~2.1.1",
43 | "karma-cli": "~1.0.1",
44 | "karma-coverage-istanbul-reporter": "^1.2.1",
45 | "karma-jasmine": "~1.1.0",
46 | "karma-jasmine-html-reporter": "^0.2.2",
47 | "protractor": "~5.1.2",
48 | "ts-node": "~3.0.4",
49 | "tslint": "~5.3.2",
50 | "typescript": "~2.3.3"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/socketchat/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/socketchat/server.js:
--------------------------------------------------------------------------------
1 | var app = require('express')();
2 | var http = require('http').Server(app);
3 | var io = require('socket.io')(http);
4 |
5 | // Setup basic socket server
6 | io.on('connection', (socket) => {
7 | // Detect connection
8 | console.log('User Connected...');
9 |
10 | // Detect disconnect
11 | socket.on('disconnect', function(){
12 | console.log('User Disconnected...');
13 | });
14 |
15 | // Add messages realtime, return as objects
16 | socket.on('add-message', (message, username) => {
17 | io.emit('message', {type:'new-message', text: message, username: username});
18 | });
19 | });
20 |
21 | // Listen on port 8000
22 | http.listen(8000, () => {
23 | console.log('Server Running On Port 8000');
24 | })
25 |
--------------------------------------------------------------------------------
/socketchat/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/socketchat/src/app/app.component.css
--------------------------------------------------------------------------------
/socketchat/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/socketchat/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 |
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | }).compileComponents();
12 | }));
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/socketchat/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'app';
10 | }
11 |
--------------------------------------------------------------------------------
/socketchat/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 |
5 | import { AppComponent } from './app.component';
6 | import { ChatComponent } from './chat/chat.component';
7 |
8 | import { ChatService } from './chat.service';
9 |
10 | // Import required components for the app here
11 | @NgModule({
12 | declarations: [
13 | AppComponent,
14 | ChatComponent
15 | ],
16 | imports: [
17 | BrowserModule,
18 | FormsModule
19 | ],
20 | providers: [ChatService],
21 | bootstrap: [AppComponent]
22 | })
23 | export class AppModule { }
24 |
--------------------------------------------------------------------------------
/socketchat/src/app/chat.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { ChatService } from './chat.service';
4 |
5 | describe('ChatService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [ChatService]
9 | });
10 | });
11 |
12 | it('should be created', inject([ChatService], (service: ChatService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/socketchat/src/app/chat.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | // Imports for socket.io
4 | import { Subject } from 'rxjs/Subject';
5 | import { Observable } from 'rxjs/Observable';
6 | import * as io from 'socket.io-client';
7 |
8 | @Injectable()
9 | export class ChatService {
10 | // Init socket var and socket server url
11 | private socket:any;
12 | private url = 'http://localhost:8000';
13 |
14 | constructor() { }
15 |
16 | // Emit message to server
17 | sendMessage(message:string, username:string){
18 | this.socket.emit('add-message', message, username);
19 | }
20 |
21 | // Recieve messages from server
22 | getMessages() {
23 | let observable = new Observable((observer:any) => {
24 | this.socket = io(this.url);
25 | this.socket.on('message', (data:any) => {
26 | observer.next(data);
27 | });
28 | return () => {
29 | this.socket.disconnect();
30 | }
31 | })
32 | return observable;
33 | }
34 |
35 | // Get username from sessionStorage
36 | getUsername() {
37 | return sessionStorage.getItem('username');
38 | }
39 |
40 | // Store username in sessionStorage
41 | // sessionStorage is like localStorage except it's lifetime is the tab's lifetime
42 | setUsername(username:string) {
43 | sessionStorage.setItem('username', username);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/socketchat/src/app/chat/chat.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/socketchat/src/app/chat/chat.component.css
--------------------------------------------------------------------------------
/socketchat/src/app/chat/chat.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | SocketChat
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
{{message.username}}: {{message.text}}
20 |
21 |
22 |
23 |
24 |
25 | Please Log In To Chat
26 |
27 |
--------------------------------------------------------------------------------
/socketchat/src/app/chat/chat.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ChatComponent } from './chat.component';
4 |
5 | describe('ChatComponent', () => {
6 | let component: ChatComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ChatComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ChatComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should be created', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/socketchat/src/app/chat/chat.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, OnDestroy } from '@angular/core';
2 | import { ChatService } from '../chat.service';
3 |
4 | @Component({
5 | selector: 'app-chat',
6 | templateUrl: './chat.component.html',
7 | styleUrls: ['./chat.component.css']
8 | })
9 | export class ChatComponent implements OnInit {
10 | // Init var for messages, new message, socket connection and username
11 | messages:any = [];
12 | message:string;
13 | connection:any;
14 | username:string;
15 | alert:any = false;
16 |
17 | constructor(private _chatservice:ChatService) { }
18 |
19 | ngOnInit() {
20 | // Get username if already exists
21 | this.username = this._chatservice.getUsername();
22 |
23 | // Get messages from socket server
24 | this.connection = this._chatservice.getMessages().subscribe(
25 | message => {
26 | this.messages.push(message);
27 | }
28 | );
29 | }
30 |
31 | ngOnDestroy() {
32 | // Disconnect from server
33 | this.connection.unsubscribe();
34 | }
35 |
36 | // Function to set username
37 | setUsername(username) {
38 | this._chatservice.setUsername(username);
39 | this.alert = 'Username is set';
40 | }
41 |
42 | // Function to send message
43 | sendMessage() {
44 | this._chatservice.sendMessage(this.message, this.username);
45 | // Clears message input
46 | this.message = '';
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/socketchat/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/socketchat/src/assets/.gitkeep
--------------------------------------------------------------------------------
/socketchat/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/socketchat/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/socketchat/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/socketchat/src/favicon.ico
--------------------------------------------------------------------------------
/socketchat/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Socketchat
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/socketchat/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/socketchat/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/socketchat/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare const __karma__: any;
17 | declare const require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/socketchat/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "baseUrl": "",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/socketchat/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "baseUrl": "",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/socketchat/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/socketchat/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "baseUrl": "src",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2016",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/workouts-app/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs
2 | # editorconfig.org
3 |
4 | root = true
5 |
6 | [*]
7 | indent_style = space
8 | indent_size = 2
9 |
10 | # We recommend you to keep these unchanged
11 | end_of_line = lf
12 | charset = utf-8
13 | trim_trailing_whitespace = true
14 | insert_final_newline = true
15 |
16 | [*.md]
17 | trim_trailing_whitespace = false
--------------------------------------------------------------------------------
/workouts-app/README.md:
--------------------------------------------------------------------------------
1 | This is a starter template for [Ionic](http://ionicframework.com/docs/) projects.
2 |
3 | ## How to use this template
4 |
5 | *This template does not work on its own*. The shared files for each starter are found in the [ionic2-app-base repo](https://github.com/ionic-team/ionic2-app-base).
6 |
7 | To use this template, either create a new ionic project using the ionic node.js utility, or copy the files from this repository into the [Starter App Base](https://github.com/ionic-team/ionic2-app-base).
8 |
9 | ### With the Ionic CLI:
10 |
11 | Take the name after `ionic2-starter-`, and that is the name of the template to be used when using the `ionic start` command below:
12 |
13 | ```bash
14 | $ sudo npm install -g ionic cordova
15 | $ ionic start myTabs tabs
16 | ```
17 |
18 | Then, to run it, cd into `myTabs` and run:
19 |
20 | ```bash
21 | $ ionic cordova platform add ios
22 | $ ionic cordova run ios
23 | ```
24 |
25 | Substitute ios for android if not on a Mac.
26 |
27 |
--------------------------------------------------------------------------------
/workouts-app/ionic.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workouts-app",
3 | "app_id": "",
4 | "type": "ionic-angular"
5 | }
6 |
--------------------------------------------------------------------------------
/workouts-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workouts-app",
3 | "version": "0.0.1",
4 | "author": "Ionic Framework",
5 | "homepage": "http://ionicframework.com/",
6 | "private": true,
7 | "scripts": {
8 | "clean": "ionic-app-scripts clean",
9 | "build": "ionic-app-scripts build",
10 | "lint": "ionic-app-scripts lint",
11 | "ionic:build": "ionic-app-scripts build",
12 | "ionic:serve": "ionic-app-scripts serve"
13 | },
14 | "dependencies": {
15 | "@angular/common": "4.1.2",
16 | "@angular/compiler": "4.1.2",
17 | "@angular/compiler-cli": "4.1.2",
18 | "@angular/core": "4.1.2",
19 | "@angular/forms": "4.1.2",
20 | "@angular/http": "4.1.2",
21 | "@angular/platform-browser": "4.1.2",
22 | "@angular/platform-browser-dynamic": "4.1.2",
23 | "@ionic-native/core": "3.10.2",
24 | "@ionic-native/splash-screen": "3.10.2",
25 | "@ionic-native/status-bar": "3.10.2",
26 | "@ionic/storage": "2.0.1",
27 | "cordova-android": "^6.2.3",
28 | "cordova-plugin-console": "^1.0.5",
29 | "cordova-plugin-device": "^1.1.4",
30 | "cordova-plugin-splashscreen": "^4.0.3",
31 | "cordova-plugin-statusbar": "^2.2.2",
32 | "cordova-plugin-whitelist": "^1.3.1",
33 | "ionic-angular": "3.3.0",
34 | "ionic-plugin-keyboard": "^2.2.1",
35 | "ionicons": "3.0.0",
36 | "rxjs": "5.1.1",
37 | "sw-toolbox": "3.6.0",
38 | "zone.js": "0.8.11"
39 | },
40 | "devDependencies": {
41 | "@ionic/app-scripts": "1.3.7",
42 | "@ionic/cli-plugin-cordova": "1.3.0",
43 | "@ionic/cli-plugin-ionic-angular": "1.3.0",
44 | "typescript": "2.3.3"
45 | },
46 | "description": "An Ionic project",
47 | "cordova": {
48 | "plugins": {
49 | "cordova-plugin-console": {},
50 | "cordova-plugin-device": {},
51 | "cordova-plugin-splashscreen": {},
52 | "cordova-plugin-statusbar": {},
53 | "cordova-plugin-whitelist": {},
54 | "ionic-plugin-keyboard": {}
55 | },
56 | "platforms": [
57 | "android"
58 | ]
59 | }
60 | }
--------------------------------------------------------------------------------
/workouts-app/resources/android/icon/drawable-hdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/icon/drawable-hdpi-icon.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/icon/drawable-ldpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/icon/drawable-ldpi-icon.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/icon/drawable-mdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/icon/drawable-mdpi-icon.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/icon/drawable-xhdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/icon/drawable-xhdpi-icon.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/icon/drawable-xxhdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/icon/drawable-xxhdpi-icon.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/icon/drawable-xxxhdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/icon/drawable-xxxhdpi-icon.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-land-hdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-land-hdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-land-ldpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-land-ldpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-land-mdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-land-mdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-land-xhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-land-xhdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-land-xxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-land-xxhdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-land-xxxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-land-xxxhdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-port-hdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-port-hdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-port-ldpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-port-ldpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-port-mdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-port-mdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-port-xhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-port-xhdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-port-xxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-port-xxhdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/android/splash/drawable-port-xxxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/android/splash/drawable-port-xxxhdpi-screen.png
--------------------------------------------------------------------------------
/workouts-app/resources/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/icon.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-40.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-40@2x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-40@3x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-50.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-50@2x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-60.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-60@2x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-60@3x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-72.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-72@2x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-76.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-76@2x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-83.5@2x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-small.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-small@2x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon-small@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon-small@3x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/icon/icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/icon/icon@2x.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-568h@2x~iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-568h@2x~iphone.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-667h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-667h.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-736h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-736h.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-Landscape-736h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-Landscape-736h.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-Landscape@2x~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-Landscape@2x~ipad.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-Landscape@~ipadpro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-Landscape@~ipadpro.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-Landscape~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-Landscape~ipad.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-Portrait@2x~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-Portrait@2x~ipad.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-Portrait@~ipadpro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-Portrait@~ipadpro.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default-Portrait~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default-Portrait~ipad.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default@2x~iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default@2x~iphone.png
--------------------------------------------------------------------------------
/workouts-app/resources/ios/splash/Default~iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/ios/splash/Default~iphone.png
--------------------------------------------------------------------------------
/workouts-app/resources/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/resources/splash.png
--------------------------------------------------------------------------------
/workouts-app/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { Platform } from 'ionic-angular';
3 | import { StatusBar } from '@ionic-native/status-bar';
4 | import { SplashScreen } from '@ionic-native/splash-screen';
5 |
6 | import { TabsPage } from '../pages/tabs/tabs';
7 |
8 | @Component({
9 | templateUrl: 'app.html'
10 | })
11 | export class MyApp {
12 | rootPage:any = TabsPage;
13 |
14 | constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
15 | platform.ready().then(() => {
16 | // Okay, so the platform is ready and our plugins are available.
17 | // Here you can do any higher level native things you might need.
18 | statusBar.styleDefault();
19 | splashScreen.hide();
20 | });
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/workouts-app/src/app/app.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/workouts-app/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule, ErrorHandler } from '@angular/core';
2 | import { BrowserModule } from '@angular/platform-browser';
3 | import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
4 | import { MyApp } from './app.component';
5 | import { HttpModule} from '@angular/http';
6 |
7 | import { AboutPage } from '../pages/about/about';
8 | import { AddPage } from '../pages/add/add';
9 | import { WorkoutsPage } from '../pages/workouts/workouts';
10 | import { TabsPage } from '../pages/tabs/tabs';
11 | import { WorkoutDetailsPage } from '../pages/workout-details/workout-details';
12 |
13 | import { StatusBar } from '@ionic-native/status-bar';
14 | import { SplashScreen } from '@ionic-native/splash-screen';
15 | import { WorkoutsProvider } from '../providers/workouts/workouts';
16 |
17 | @NgModule({
18 | declarations: [
19 | MyApp,
20 | AboutPage,
21 | AddPage,
22 | WorkoutsPage,
23 | WorkoutDetailsPage,
24 | TabsPage
25 | ],
26 | imports: [
27 | HttpModule,
28 | BrowserModule,
29 | IonicModule.forRoot(MyApp)
30 | ],
31 | bootstrap: [IonicApp],
32 | entryComponents: [
33 | MyApp,
34 | AboutPage,
35 | AddPage,
36 | WorkoutsPage,
37 | WorkoutDetailsPage,
38 | TabsPage
39 | ],
40 | providers: [
41 | StatusBar,
42 | SplashScreen,
43 | {provide: ErrorHandler, useClass: IonicErrorHandler},
44 | WorkoutsProvider
45 | ]
46 | })
47 | export class AppModule {}
48 |
--------------------------------------------------------------------------------
/workouts-app/src/app/app.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 |
4 | // App Global Sass
5 | // --------------------------------------------------
6 | // Put style rules here that you want to apply globally. These
7 | // styles are for the entire app and not just one component.
8 | // Additionally, this file can be also used as an entry point
9 | // to import other Sass files to be included in the output CSS.
10 | //
11 | // Shared Sass variables, which can be used to adjust Ionic's
12 | // default Sass variables, belong in "theme/variables.scss".
13 | //
14 | // To declare rules for a specific mode, create a child rule
15 | // for the .md, .ios, or .wp mode classes. The mode class is
16 | // automatically applied to the element in the app.
17 |
--------------------------------------------------------------------------------
/workouts-app/src/app/main.ts:
--------------------------------------------------------------------------------
1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2 |
3 | import { AppModule } from './app.module';
4 |
5 | platformBrowserDynamic().bootstrapModule(AppModule);
6 |
--------------------------------------------------------------------------------
/workouts-app/src/assets/icon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajayns/angular-projects/bb1d2fb9cc3a11b68f2097cdba20266908eff3f6/workouts-app/src/assets/icon/favicon.ico
--------------------------------------------------------------------------------
/workouts-app/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ionic App
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/workouts-app/src/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Ionic",
3 | "short_name": "Ionic",
4 | "start_url": "index.html",
5 | "display": "standalone",
6 | "icons": [{
7 | "src": "assets/imgs/logo.png",
8 | "sizes": "512x512",
9 | "type": "image/png"
10 | }],
11 | "background_color": "#4e8ef7",
12 | "theme_color": "#4e8ef7"
13 | }
--------------------------------------------------------------------------------
/workouts-app/src/pages/about/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | About
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/about/about.scss:
--------------------------------------------------------------------------------
1 | page-about {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/about/about.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { NavController } from 'ionic-angular';
3 |
4 | @Component({
5 | selector: 'page-about',
6 | templateUrl: 'about.html'
7 | })
8 | export class AboutPage {
9 |
10 | constructor(public navCtrl: NavController) {
11 |
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/add/add.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Add a new workout
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/add/add.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { IonicPageModule } from 'ionic-angular';
3 | import { AddPage } from './add';
4 |
5 | @NgModule({
6 | declarations: [
7 | AddPage,
8 | ],
9 | imports: [
10 | IonicPageModule.forChild(AddPage),
11 | ],
12 | exports: [
13 | AddPage
14 | ]
15 | })
16 | export class AddPageModule {}
17 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/add/add.scss:
--------------------------------------------------------------------------------
1 | page-add {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/add/add.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { IonicPage, NavController, NavParams } from 'ionic-angular';
3 | import { WorkoutsProvider } from '../../providers/workouts/workouts';
4 | import { WorkoutsPage } from '../workouts/workouts';
5 |
6 | @IonicPage()
7 | @Component({
8 | selector: 'page-add',
9 | templateUrl: 'add.html',
10 | })
11 | export class AddPage {
12 | title:string;
13 | note:string;
14 | type:string;
15 | newWorkout:any;
16 |
17 | constructor(public navCtrl: NavController, public navParams: NavParams, private workoutsprovider:WorkoutsProvider) {
18 | }
19 |
20 | onSubmit() {
21 | this.newWorkout = {
22 | title: this.title,
23 | note: this.note,
24 | type: this.type
25 | }
26 |
27 | this.workoutsprovider.addWorkout(this.newWorkout).subscribe( data => {
28 | });
29 |
30 | this.navCtrl.setRoot(WorkoutsPage);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/tabs/tabs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/tabs/tabs.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | import { AboutPage } from '../about/about';
4 | import { AddPage } from '../add/add';
5 | import { WorkoutsPage } from '../workouts/workouts';
6 |
7 | @Component({
8 | templateUrl: 'tabs.html'
9 | })
10 | export class TabsPage {
11 |
12 | workoutsRoot = WorkoutsPage;
13 | aboutRoot = AboutPage;
14 | addRoot = AddPage;
15 |
16 | constructor() {
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/workout-details/workout-details.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Workout Details
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | {{workout.title}}
15 |
16 |
17 | Type: {{workout.type}}
18 |
19 | {{workout.note}}
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/workout-details/workout-details.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { IonicPageModule } from 'ionic-angular';
3 | import { WorkoutDetailsPage } from './workout-details';
4 |
5 | @NgModule({
6 | declarations: [
7 | WorkoutDetailsPage,
8 | ],
9 | imports: [
10 | IonicPageModule.forChild(WorkoutDetailsPage),
11 | ],
12 | exports: [
13 | WorkoutDetailsPage
14 | ]
15 | })
16 | export class WorkoutDetailsPageModule {}
17 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/workout-details/workout-details.scss:
--------------------------------------------------------------------------------
1 | page-workout-details {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/workout-details/workout-details.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { IonicPage, NavController, NavParams } from 'ionic-angular';
3 |
4 | import { WorkoutsPage } from '../workouts/workouts';
5 | import { WorkoutsProvider } from '../../providers/workouts/workouts';
6 |
7 | @IonicPage()
8 | @Component({
9 | selector: 'page-workout-details',
10 | templateUrl: 'workout-details.html',
11 | })
12 | export class WorkoutDetailsPage {
13 | workout:any;
14 |
15 | constructor(public navCtrl: NavController, public navParams: NavParams, private workoutsprovider:WorkoutsProvider) {
16 | this.workout = this.navParams.get('workout')
17 | }
18 |
19 | deleteWorkout(id) {
20 | this.workoutsprovider.deleteWorkout(id).subscribe();
21 | this.navCtrl.setRoot(WorkoutsPage);
22 | }
23 |
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/workouts/workouts.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Workouts
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{workout.title}}
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/workouts/workouts.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { IonicPageModule } from 'ionic-angular';
3 | import { WorkoutsPage } from './workouts';
4 |
5 | @NgModule({
6 | declarations: [
7 | WorkoutsPage,
8 | ],
9 | imports: [
10 | IonicPageModule.forChild(WorkoutsPage),
11 | ],
12 | exports: [
13 | WorkoutsPage
14 | ]
15 | })
16 | export class WorkoutsPageModule {}
17 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/workouts/workouts.scss:
--------------------------------------------------------------------------------
1 | page-workouts {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/workouts-app/src/pages/workouts/workouts.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { IonicPage, NavController, NavParams } from 'ionic-angular';
3 | import { WorkoutDetailsPage } from '../workout-details/workout-details';
4 |
5 | import { WorkoutsProvider } from '../../providers/workouts/workouts';
6 |
7 | @IonicPage()
8 | @Component({
9 | selector: 'page-workouts',
10 | templateUrl: 'workouts.html',
11 | })
12 | export class WorkoutsPage implements OnInit {
13 | workouts: any[];
14 |
15 | constructor(public navCtrl: NavController, public navParams: NavParams, private workoutsprovider:WorkoutsProvider) {
16 | this.workoutsprovider.getWorkouts().subscribe( workouts => {
17 | this.workouts = workouts;
18 | });
19 | }
20 |
21 | ngOnInit() {
22 | this.workoutsprovider.getWorkouts().subscribe( workouts => {
23 | this.workouts = workouts;
24 | });
25 | }
26 |
27 | workoutSelected(workout) {
28 | this.navCtrl.push(WorkoutDetailsPage, {
29 | workout: workout
30 | })
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/workouts-app/src/providers/workouts/workouts.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Http, Headers } from '@angular/http';
3 | import 'rxjs/add/operator/map';
4 |
5 | @Injectable()
6 |
7 | export class WorkoutsProvider {
8 | private apiKey:string;
9 | private dbUrl:string;
10 |
11 | constructor(private http:Http) {
12 | this.apiKey = 'EPo_UpbWahR11ulgA3M5_2JvsiJ7xm9q';
13 | this.dbUrl = 'https://api.mlab.com/api/1/databases/workouts-app/collections/workouts';
14 | }
15 |
16 | getWorkouts() {
17 | return this.http.get(this.dbUrl+'?apiKey='+this.apiKey)
18 | .map( res => res.json());
19 | }
20 |
21 | addWorkout(workout) {
22 | var headers = new Headers();
23 | headers.append('Content-Type', 'application/json');
24 | return this.http.post(this.dbUrl+'?apiKey='+this.apiKey,JSON.stringify(workout),{headers: headers})
25 | .map(res => res.json());
26 | }
27 |
28 | deleteWorkout(id) {
29 | return this.http.delete(this.dbUrl+'/'+id+'?apiKey='+this.apiKey)
30 | .map( res => res.json());
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/workouts-app/src/service-worker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Check out https://googlechrome.github.io/sw-toolbox/ for
3 | * more info on how to use sw-toolbox to custom configure your service worker.
4 | */
5 |
6 |
7 | 'use strict';
8 | importScripts('./build/sw-toolbox.js');
9 |
10 | self.toolbox.options.cache = {
11 | name: 'ionic-cache'
12 | };
13 |
14 | // pre-cache our key assets
15 | self.toolbox.precache(
16 | [
17 | './build/main.js',
18 | './build/main.css',
19 | './build/polyfills.js',
20 | 'index.html',
21 | 'manifest.json'
22 | ]
23 | );
24 |
25 | // dynamically cache any other local assets
26 | self.toolbox.router.any('/*', self.toolbox.cacheFirst);
27 |
28 | // for any other requests go to the network, cache,
29 | // and then only use that cached resource if your user goes offline
30 | self.toolbox.router.default = self.toolbox.networkFirst;
31 |
--------------------------------------------------------------------------------
/workouts-app/src/theme/variables.scss:
--------------------------------------------------------------------------------
1 | // Ionic Variables and Theming. For more info, please see:
2 | // http://ionicframework.com/docs/v2/theming/
3 | $font-path: "../assets/fonts";
4 |
5 | @import "ionic.globals";
6 |
7 |
8 | // Shared Variables
9 | // --------------------------------------------------
10 | // To customize the look and feel of this app, you can override
11 | // the Sass variables found in Ionic's source scss files.
12 | // To view all the possible Ionic variables, see:
13 | // http://ionicframework.com/docs/v2/theming/overriding-ionic-variables/
14 |
15 |
16 |
17 |
18 | // Named Color Variables
19 | // --------------------------------------------------
20 | // Named colors makes it easy to reuse colors on various components.
21 | // It's highly recommended to change the default colors
22 | // to match your app's branding. Ionic uses a Sass map of
23 | // colors so you can add, rename and remove colors as needed.
24 | // The "primary" color is the only required color in the map.
25 |
26 | $colors: (
27 | primary: #488aff,
28 | secondary: #32db64,
29 | danger: #f53d3d,
30 | light: #f4f4f4,
31 | dark: #222
32 | );
33 |
34 |
35 | // App iOS Variables
36 | // --------------------------------------------------
37 | // iOS only Sass variables can go here
38 |
39 |
40 |
41 |
42 | // App Material Design Variables
43 | // --------------------------------------------------
44 | // Material Design only Sass variables can go here
45 |
46 |
47 |
48 |
49 | // App Windows Variables
50 | // --------------------------------------------------
51 | // Windows only Sass variables can go here
52 |
53 |
54 |
55 |
56 | // App Theme
57 | // --------------------------------------------------
58 | // Ionic apps can have different themes applied, which can
59 | // then be future customized. This import comes last
60 | // so that the above variables are used and Ionic's
61 | // default are overridden.
62 |
63 | @import "ionic.theme.default";
64 |
65 |
66 | // Ionicons
67 | // --------------------------------------------------
68 | // The premium icon font for Ionic. For more info, please see:
69 | // http://ionicframework.com/docs/v2/ionicons/
70 |
71 | @import "ionic.ionicons";
72 |
73 |
74 | // Fonts
75 | // --------------------------------------------------
76 |
77 | @import "roboto";
78 | @import "noto-sans";
79 |
--------------------------------------------------------------------------------
/workouts-app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowSyntheticDefaultImports": true,
4 | "declaration": false,
5 | "emitDecoratorMetadata": true,
6 | "experimentalDecorators": true,
7 | "lib": [
8 | "dom",
9 | "es2015"
10 | ],
11 | "module": "es2015",
12 | "moduleResolution": "node",
13 | "sourceMap": true,
14 | "target": "es5"
15 | },
16 | "include": [
17 | "src/**/*.ts"
18 | ],
19 | "exclude": [
20 | "node_modules"
21 | ],
22 | "compileOnSave": false,
23 | "atom": {
24 | "rewriteTsconfig": false
25 | }
26 | }
--------------------------------------------------------------------------------
/workouts-app/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "no-duplicate-variable": true,
4 | "no-unused-variable": [
5 | true
6 | ]
7 | },
8 | "rulesDirectory": [
9 | "node_modules/tslint-eslint-rules/dist/rules"
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------