Skip to content

Commit

Permalink
Merged code from part - 24
Browse files Browse the repository at this point in the history
  • Loading branch information
jitendraashutec committed Sep 21, 2018
1 parent 327a67c commit 33b1456
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 219 deletions.
22 changes: 21 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,33 @@ projects/trivia/src/**/*.js
# misc
/.sass-cache
/connect.lock
/coverage
/coverage/*
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# e2e
/e2e/*.js
/e2e/*.map

# System Files
.DS_Store
Thumbs.db


# System Files
.DS_Store
Thumbs.db
functions/node_modules/
functions/server/
functions/config/
functions/package-lock.json
functions/dist/
package-lock.json
firebase-debug.log
scheduler/node_modules/
scheduler/server/
scheduler/config/
scheduler/package-lock.json
131 changes: 117 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,130 @@
# Trivia
# rwa-trivia app

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.1.5.
This is part of building a new app for my series - Real World Angular @ https://blog.realworldfullstack.io/

## Development server
See it in action (still a work in progress) - https://bitwiser.io

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.
[Part 0: From zero to cli-ng](https://blog.realworldfullstack.io/real-world-angular-part-0-from-zero-to-cli-ng-a2ff646b90cc)

## Code scaffolding
[Part 1: Not another todo list app](https://blog.realworldfullstack.io/real-world-angular-part-1-not-another-todo-list-c2ea5020f944)

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
[Part 2: It's a Material world](https://blog.realworldfullstack.io/real-world-angular-part-2-its-a-material-world-2d70238ef8ef)

## Build
[Part 3: Form Formation](https://blog.realworldfullstack.io/real-world-angular-part-3-form-formation-f78d8462da70)

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.
[Part 4: State of my SPA](https://blog.realworldfullstack.io/real-world-angular-part-4-state-of-my-spa-10bf90c5a15)

## Running unit tests
[Part 5: Light my fire](https://blog.realworldfullstack.io/real-world-angular-part-5-light-my-fire-34b0bcb351a8)

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
[Part 6: 3Rs ... Rules, Roles & Routes](https://blog.realworldfullstack.io/real-world-angular-part-6-3rs-rules-roles-routes-9e7de5a3ea8e)

## Running end-to-end tests
[Part 6.1: Upgrading to 4.0.0-rc.2](https://blog.realworldfullstack.io/real-world-angular-part-6-1-upgrading-to-4-0-0-rc-2-fcaab81603fa)

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
[Part 7: Split my lazy loaded code](https://blog.realworldfullstack.io/real-world-angular-part-7-lazy-coding-load-splitting-4552f5f54ef7)

## Further help
[Part 8: Just Ahead of In Time](https://blog.realworldfullstack.io/real-world-angular-part-8-just-ahead-of-in-time-ae2d3cc89656)

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).
[Part 9: Unit Testing](https://blog.realworldfullstack.io/real-world-angular-part-9-unit-testing-c62ba20b1d93)

[Part 9.1: More Unit Testing](https://blog.realworldfullstack.io/real-world-angular-part-9-1-more-unit-testing-f0545ece586d)

[Part 9.2: Even More Unit Tests](https://blog.realworldfullstack.io/real-world-angular-part-9-2-even-more-unit-tests-f903df40530a)

[Part 10: Angular 4 upgrade](https://blog.realworldfullstack.io/real-world-angular-part-x-fantastic-4-c714b04640ab)

[Part 11: Gameplay with Angular](https://blog.realworldfullstack.io/real-world-app-part-11-gameplay-with-angular-2a660fad52c2)

[Part 12: Cloud Functions for Firebase](https://blog.realworldfullstack.io/real-world-app-part-12-cloud-functions-for-firebase-8359787e26f3)

[Part 13: Elasticsearch on Google Cloud with Firebase functions](https://blog.realworldfullstack.io/real-world-app-part-13-elasticsearch-on-google-cloud-with-firebase-functions-8a24fa2b95ed)

[Part 14: Faceted search with Elasticsearch and Angular Material data-table](https://blog.realworldfullstack.io/real-world-app-part-14-faceted-search-with-elasticsearch-and-angular-material-data-table-d90ebaf2ee4b)

[Part 15: Incorporate Material UI design into the app](https://blog.realworldfullstack.io/real-world-app-part-15-ui-design-with-angular-material-1a5c597c679e)

[Part 16: Migrating from Firebase to Firestore](https://blog.realworldfullstack.io/real-world-app-part-16-from-firebase-to-firestore-f6c494e80237)

[Part 17: Bulk upload and User profile settings using firebase cloud storage](https://blog.realworldfullstack.io/real-world-app-part-17-cloud-storage-with-firebase-and-angular-d3d2c9f5f27c)

[Part 18: Revisiting ngrx - Splitting store into feature modules, using action classes, selectors & router-store](https://blog.realworldfullstack.io/real-world-app-part-18-revisiting-ngrx-e20feed6312c)

[Part 19: Ready Player Two - Two player game play, computing stats, dashboard and other features](https://blog.realworldfullstack.io/real-world-app-part-19-ready-player-two-9e17c2e7c694)

[Part 20: Angular, ngrx & cli version 6 - Upgrading Angular, cli, ngrx, material & RxJS to version 6](https://blog.realworldfullstack.io/real-world-app-part-20-angular-ngrx-cli-version-6-a3490b64f0c7)

[Part 21: Service Workers (Progressive Web App) with Angular](https://blog.realworldfullstack.io/real-world-app-part-21-service-workers-pwa-with-angular-3ba5c7168f3f)

[Part 22: Angular Testing with Protractor, Jasmine and Jest](https://blog.realworldfullstack.io/real-world-app-part-22-angular-testing-with-protractor-jasmine-and-jest-6a0e03a89038)

## Quick Installation Instructions

* Install cli globally (version should match the one in package.json)

`npm install -g @angular/[email protected]`

* Install npm packages

`npm install`

* Setup your firebase instance @ https://firebase.google.com/

* Setup providers in Firebase Authentication

* Use the firebase configuration information and plug it in src/environment.ts

* Import src/db.json to your firebase database instance to get the initial set of test data

* Run the application using ng serve

`ng serve`

* Add yourself as a user using the application. Ensure you are added as a user in Authentication tab of firebase console.

* Add your user id as an admin in the firebase database (admins need to be added manually) -

Set: users/\<user id\>/roles/admin: true

* Use firebase-rules.json file to setup the firebase rules for your database

* Serve the application again. Ensure you have admin privileges

`ng serve`

## Deploy to Firebase Server

* Install firebase tools globally

`npm install -g firebase-tools`

* Authenticate with your firebase credentials

`firebase login`

* Setup firebase hosting configuration for the application, using "dist" instead of public as the public folder name

`firebase init`

* Create a build

`ng build`

* Serve up the app using firebase server locally

`firebase serve`

* Deploy Site to firebase

`firebase deploy --only hosting`

* Setup firebase functions - creates functions folder and installs dependencies

`firebase init`

* Deploy functions to firebase

`npm run deploy-functions`

## Testing
* Test the application using

`ng test`
6 changes: 2 additions & 4 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"with": "projects/shared-library/src/lib/environments/environment.dev.ts"
}
],
"serviceWorker": true,
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
Expand Down Expand Up @@ -346,9 +347,6 @@
},
"@schematics/angular:directive": {
"prefix": "app"
},
"cli": {
"defaultCollection": "@nativescript/schematics"
}
}
}
}
10 changes: 8 additions & 2 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
{
"source": "/app/**",
"function": "app"
},
},
{
"source": "/robots.txt",
"destination": "/robots.txt"
},
{
"source": "**",
"function": "ssr"
}
]
}
}
}


16 changes: 0 additions & 16 deletions functions/controllers/game.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,29 +163,13 @@ exports.checkGameOver = (req, res) => {
const millis = utils.getUTCTimeStamp();
const noPlayTimeBound = (millis > game.turnAt) ? millis - game.turnAt : game.turnAt - millis;
const playedHours = Math.floor((noPlayTimeBound) / (1000 * 60 * 60));
<<<<<<< HEAD

=======
>>>>>>> 5cb465b4d8adddf023929f77b9fd04dec8292b58
if (playedHours >= schedulerConstants.gamePlayDuration) {
game.gameOver = true;
game.winnerPlayerId = game.playerIds.filter(playerId => playerId !== game.nextTurnPlayerId)[0];
const dbGame = game.getDbModel();
gameControllerService.updateGame(dbGame).then((ref) => {
console.log('updated game', dbGame.id);
});
<<<<<<< HEAD
} else if (playedHours >= schedulerConstants.gameInvitationDuration
&& (game.GameStatus === GameStatus.WAITING_FOR_FRIEND_INVITATION_ACCEPTANCE ||
game.GameStatus === GameStatus.WAITING_FOR_RANDOM_PLAYER_INVITATION_ACCEPTANCE)) {
game.gameOver = true;
game.GameStatus = GameStatus.INVITATION_TIMEOUT;
const dbGame = game.getDbModel();
gameControllerService.updateGame(dbGame).then((ref) => {
console.log('invitation expires', dbGame.id);
});
=======
>>>>>>> 5cb465b4d8adddf023929f77b9fd04dec8292b58
}
});
res.send('scheduler check is completed');
Expand Down
19 changes: 0 additions & 19 deletions functions/controllers/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@

const userService = require('../services/user.service');
const sharp = require('sharp');
<<<<<<< HEAD
import { User, UserStats, UserControllerConstants } from '../../projects/shared-library/src/lib/shared/model';
import { ProfileImagesGenerator } from '../utils/profile-images-generator';
import { MailClient } from '../utils/mail-client';
=======
import { User, UserStats } from '../../projects/shared-library/src/lib/shared/model';
import { ProfileImagesGenerator } from '../utils/profile-images-generator';
>>>>>>> 5cb465b4d8adddf023929f77b9fd04dec8292b58

/**
* getUserById
Expand Down Expand Up @@ -79,7 +74,6 @@ exports.generateUserProfileImage = (req, res) => {
if (user.profilePicture) {
profileImagesGenerator.
getStoredImage(user.userId, user.profilePicture).then((status) => {
<<<<<<< HEAD
setUser(user, res);
})

Expand All @@ -99,16 +93,3 @@ function setUser(user, res) {
res.send({ 'status': 'Profile Data is saved !!' })
});
}
=======
userService.setUser(user).then((ref) => {
res.send({ 'status': 'Profile Data is saved !!' })
});
})

} else {
userService.setUser(user).then((ref) => {
res.send({ 'status': 'Profile Data is saved !!' })
});
}
};
>>>>>>> 5cb465b4d8adddf023929f77b9fd04dec8292b58
Loading

0 comments on commit 33b1456

Please sign in to comment.