From 36d485a3b712df8a17ec589824cd5072fd14d175 Mon Sep 17 00:00:00 2001 From: Jesus Date: Mon, 30 Mar 2020 19:52:02 +0100 Subject: [PATCH 1/5] readme added with title, code mortals logo, basic description of the project --- readme.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..0ba0a81 --- /dev/null +++ b/readme.md @@ -0,0 +1,5 @@ + Quiz platform + === +![Code mortals]( https://cdn.codemortals.io/mascot/5.png) + +This is a quiz platform developt using angular framework, Node and Firestore \ No newline at end of file From 4768aeeeff9307b3b4cd8250f69de1e004adea4a Mon Sep 17 00:00:00 2001 From: Jesus Date: Mon, 15 Jun 2020 23:06:58 +0100 Subject: [PATCH 2/5] update from codemortals master --- readme.md | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 0ba0a81..d67006a 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,28 @@ - Quiz platform - === -![Code mortals]( https://cdn.codemortals.io/mascot/5.png) +# Game Platform + +![Code Mortals](https://cdn.codemortals.io/mascot/5.png) -This is a quiz platform developt using angular framework, Node and Firestore \ No newline at end of file +## Getting Started + +This is a game platform developed using Angular framework with Node and Firestore + +- 1a. [optional] Fork the project +- 1b. Clone the project (or your fork if you did step 1) with `git clone {GITHUB_REPO_URL}` +- 1c. Navigate into the project directory `cd game-platform` + +### Local development for UI (Angular UI) + +- 2a. Navigate from the project directory in the **hosting** directory with `cd hosting` +- 3a. Install sub project dependencies with `npm install` +- 4a. Duplicate the `src/environments/environment.ts` file and name it `src/environments/environment.local.ts` +- 5a. In the `src/environments/environment.local.ts` replace it with your **Firebase** config +- 6a. Run the sub project (Angular UI) with `npm start` +- 7a. Open in the browser `http://localhost:4200` + +### Local development for Functions (Firebase) + +**prerequisite** [Firebase CLI](https://firebase.google.com/docs/cli) + +- 2b. Navigate from the project directory in the **functions** directory with `cd functions` +- 3b. Install sub project dependencies with `npm install` +- 4b. ... From b25b94f3e5d34943e584f8f142530d818f704ec8 Mon Sep 17 00:00:00 2001 From: Jesus Date: Fri, 19 Jun 2020 01:24:30 +0100 Subject: [PATCH 3/5] update round when question is added issue-bug #22 update round questions only when brand-expansion expands --- .../app/games/quiz/lobby/lobby.component.html | 2 +- .../app/games/quiz/lobby/lobby.component.ts | 37 +++++++++++++++---- hosting/src/app/games/quiz/round.service.ts | 2 +- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/hosting/src/app/games/quiz/lobby/lobby.component.html b/hosting/src/app/games/quiz/lobby/lobby.component.html index c8d2bb8..2b33ec1 100644 --- a/hosting/src/app/games/quiz/lobby/lobby.component.html +++ b/hosting/src/app/games/quiz/lobby/lobby.component.html @@ -63,7 +63,7 @@

Quiz Overview

- +
{{ question.text | slice: 0 : 30 }}
diff --git a/hosting/src/app/games/quiz/lobby/lobby.component.ts b/hosting/src/app/games/quiz/lobby/lobby.component.ts index d4abc8b..6ada8cb 100644 --- a/hosting/src/app/games/quiz/lobby/lobby.component.ts +++ b/hosting/src/app/games/quiz/lobby/lobby.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, OnDestroy, OnInit, ViewChildren, QueryList, ChangeDetectorRef } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { AbstractControl, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { DropdownOption } from '@brand/dropdown/dropdown-option'; @@ -10,6 +10,7 @@ import { Question, Round } from '../quiz.model'; import { RoundService } from '../round.service'; import { QuestionService } from '../question.service'; +import { BrandExpansionComponent } from 'projects/brand/src/lib/expansion/expansion.component'; @Component({ templateUrl: './lobby.component.html', @@ -31,11 +32,14 @@ export class LobbyComponent implements OnInit, OnDestroy { private isDestroyed = new Subject(); + @ViewChildren('expansions') expansionComponents: QueryList; + constructor( private route: ActivatedRoute, private forms: FormBuilder, private roundService: RoundService, private questionService: QuestionService, + private changeDetectorRef: ChangeDetectorRef ) { } public ngOnInit(): void { @@ -43,11 +47,9 @@ export class LobbyComponent implements OnInit, OnDestroy { .findAll(this.route.snapshot.params.gameId) .pipe(takeUntil(this.isDestroyed)) .subscribe((rounds) => { - this.rounds = [ - ...this.rounds, - ...rounds, - ]; + this.updateRoundDataKeepingExpandedPanels(rounds); this.availableRounds = this.rounds.map((round) => ({ id: round.uid, title: round.title })); + }); this.availableTypes = [ @@ -77,6 +79,18 @@ export class LobbyComponent implements OnInit, OnDestroy { this.isDestroyed.complete(); } + private updateRoundDataKeepingExpandedPanels(rounds): void { + let expandedList: boolean[] = this.expansionComponents.map(c => !c.collapsed); + this.rounds = [...rounds]; + if (this.expansionComponents.length != expandedList.length) return; + let iExpanded = 0; + this.changeDetectorRef.detectChanges(); + this.expansionComponents.forEach(comp => { + if (expandedList[iExpanded++]) + comp.toggle(); + }); + } + get formOptions(): FormArray { return this.questionForm.get('choices'); } @@ -103,7 +117,6 @@ export class LobbyComponent implements OnInit, OnDestroy { private checkQuestion(control: AbstractControl) { const choices = control.get('choices').value; const valid = choices.reduce((isValid, choice) => isValid || choice.correct, false); - if (!valid) { control.get('choices').setErrors({ answer: true }); } @@ -128,13 +141,21 @@ export class LobbyComponent implements OnInit, OnDestroy { this.questionService .create(gameId, roundId, question.text, question.type.id, question.choices) .subscribe( - () => this.questionForm.reset({ type: question.type }), + (questionUid) => { + this.questionForm.reset({ type: question.type, round: question.round }); + this.loadQuestions(this.rounds.find(r => r.uid = roundId)); + } ); } + public roundQuestionsToogle(round: Round, collapsing: any) { + if (!collapsing) {//if its geting collapsed we dont need new details. + this.loadQuestions(round); + } + } + public loadQuestions(round: Round): void { const gameId = this.route.snapshot.params.gameId; - this.questionService.findAll(gameId, round.uid) .pipe( take(1), diff --git a/hosting/src/app/games/quiz/round.service.ts b/hosting/src/app/games/quiz/round.service.ts index adfe7da..a9833a7 100644 --- a/hosting/src/app/games/quiz/round.service.ts +++ b/hosting/src/app/games/quiz/round.service.ts @@ -58,7 +58,7 @@ export class RoundService { return quizDoc .collection('rounds', (ref: firestore.Query) => ref.orderBy('created')) - .stateChanges([ 'added' ]) + .snapshotChanges() .pipe( map((rounds) => rounds .map((round: DocumentChangeAction) => round.payload.doc.data({ serverTimestamps: 'estimate' })), From 04362d6d5e3e4d49cad55c33d8a609dff70dc36f Mon Sep 17 00:00:00 2001 From: Jesus Sanchez Date: Sat, 20 Jun 2020 01:19:10 +0100 Subject: [PATCH 4/5] removed readme.md lowercase --- readme.md | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 readme.md diff --git a/readme.md b/readme.md deleted file mode 100644 index d67006a..0000000 --- a/readme.md +++ /dev/null @@ -1,28 +0,0 @@ -# Game Platform - -![Code Mortals](https://cdn.codemortals.io/mascot/5.png) - -## Getting Started - -This is a game platform developed using Angular framework with Node and Firestore - -- 1a. [optional] Fork the project -- 1b. Clone the project (or your fork if you did step 1) with `git clone {GITHUB_REPO_URL}` -- 1c. Navigate into the project directory `cd game-platform` - -### Local development for UI (Angular UI) - -- 2a. Navigate from the project directory in the **hosting** directory with `cd hosting` -- 3a. Install sub project dependencies with `npm install` -- 4a. Duplicate the `src/environments/environment.ts` file and name it `src/environments/environment.local.ts` -- 5a. In the `src/environments/environment.local.ts` replace it with your **Firebase** config -- 6a. Run the sub project (Angular UI) with `npm start` -- 7a. Open in the browser `http://localhost:4200` - -### Local development for Functions (Firebase) - -**prerequisite** [Firebase CLI](https://firebase.google.com/docs/cli) - -- 2b. Navigate from the project directory in the **functions** directory with `cd functions` -- 3b. Install sub project dependencies with `npm install` -- 4b. ... From 6937975d25c91586e917d94e81ec3ce723f7e16f Mon Sep 17 00:00:00 2001 From: Jesus Date: Sat, 20 Jun 2020 03:47:16 +0100 Subject: [PATCH 5/5] minor format fix --- hosting/src/app/games/quiz/lobby/lobby.component.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hosting/src/app/games/quiz/lobby/lobby.component.ts b/hosting/src/app/games/quiz/lobby/lobby.component.ts index 6ada8cb..11f0efa 100644 --- a/hosting/src/app/games/quiz/lobby/lobby.component.ts +++ b/hosting/src/app/games/quiz/lobby/lobby.component.ts @@ -49,7 +49,6 @@ export class LobbyComponent implements OnInit, OnDestroy { .subscribe((rounds) => { this.updateRoundDataKeepingExpandedPanels(rounds); this.availableRounds = this.rounds.map((round) => ({ id: round.uid, title: round.title })); - }); this.availableTypes = [ @@ -81,12 +80,12 @@ export class LobbyComponent implements OnInit, OnDestroy { private updateRoundDataKeepingExpandedPanels(rounds): void { let expandedList: boolean[] = this.expansionComponents.map(c => !c.collapsed); - this.rounds = [...rounds]; + this.rounds = [ ...rounds ]; if (this.expansionComponents.length != expandedList.length) return; let iExpanded = 0; this.changeDetectorRef.detectChanges(); this.expansionComponents.forEach(comp => { - if (expandedList[iExpanded++]) + if (expandedList[ iExpanded++ ]) comp.toggle(); }); }