From 6b8794c22f91bb26e383963813fff7517e52a05e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Sep 2019 22:20:30 -0400 Subject: [PATCH 01/14] enabled arrow icons to jump to previous and next lessons --- .../angular-cli/angular-cli.component.html | 2 +- .../component-tree.component.html | 2 +- .../create-first-app.component.html | 2 +- .../dependency-injection.component.html | 2 +- .../angular/forms/forms.component.html | 2 +- .../angular/material/material.component.html | 2 +- .../angular/router/router.component.html | 2 +- .../templates/templates.component.html | 2 +- .../menu-shortcut-widget.component.ts | 4 +- .../src/lib/arrows/slides-arrows.component.ts | 26 +- package-lock.json | 261 +++++++++++++----- 11 files changed, 225 insertions(+), 82 deletions(-) diff --git a/apps/codelab/src/app/codelabs/angular/angular-cli/angular-cli.component.html b/apps/codelab/src/app/codelabs/angular/angular-cli/angular-cli.component.html index e2e15d39e..20bfa6f3e 100644 --- a/apps/codelab/src/app/codelabs/angular/angular-cli/angular-cli.component.html +++ b/apps/codelab/src/app/codelabs/angular/angular-cli/angular-cli.component.html @@ -1,6 +1,6 @@ - +
diff --git a/apps/codelab/src/app/codelabs/angular/component-tree/component-tree.component.html b/apps/codelab/src/app/codelabs/angular/component-tree/component-tree.component.html index 6f42f7788..9abcaf656 100644 --- a/apps/codelab/src/app/codelabs/angular/component-tree/component-tree.component.html +++ b/apps/codelab/src/app/codelabs/angular/component-tree/component-tree.component.html @@ -56,7 +56,7 @@ - + diff --git a/apps/codelab/src/app/codelabs/angular/create-first-app/create-first-app.component.html b/apps/codelab/src/app/codelabs/angular/create-first-app/create-first-app.component.html index a2de3486c..651f96a12 100644 --- a/apps/codelab/src/app/codelabs/angular/create-first-app/create-first-app.component.html +++ b/apps/codelab/src/app/codelabs/angular/create-first-app/create-first-app.component.html @@ -49,7 +49,7 @@
- +
- +
- +
diff --git a/apps/codelab/src/app/codelabs/angular/material/material.component.html b/apps/codelab/src/app/codelabs/angular/material/material.component.html index 0716eaffe..8572f49d2 100644 --- a/apps/codelab/src/app/codelabs/angular/material/material.component.html +++ b/apps/codelab/src/app/codelabs/angular/material/material.component.html @@ -29,7 +29,7 @@ - +
diff --git a/apps/codelab/src/app/codelabs/angular/router/router.component.html b/apps/codelab/src/app/codelabs/angular/router/router.component.html index 1adc5a8ef..f4b41b9e2 100644 --- a/apps/codelab/src/app/codelabs/angular/router/router.component.html +++ b/apps/codelab/src/app/codelabs/angular/router/router.component.html @@ -22,7 +22,7 @@
- +
diff --git a/apps/codelab/src/app/codelabs/angular/templates/templates.component.html b/apps/codelab/src/app/codelabs/angular/templates/templates.component.html index df21ca3c5..703543cf2 100644 --- a/apps/codelab/src/app/codelabs/angular/templates/templates.component.html +++ b/apps/codelab/src/app/codelabs/angular/templates/templates.component.html @@ -111,7 +111,7 @@
- +
diff --git a/apps/codelab/src/app/components/buttons-nav-bar/menu-shortcut-widget/menu-shortcut-widget.component.ts b/apps/codelab/src/app/components/buttons-nav-bar/menu-shortcut-widget/menu-shortcut-widget.component.ts index ba8fad613..93c4b916a 100644 --- a/apps/codelab/src/app/components/buttons-nav-bar/menu-shortcut-widget/menu-shortcut-widget.component.ts +++ b/apps/codelab/src/app/components/buttons-nav-bar/menu-shortcut-widget/menu-shortcut-widget.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject } from '@angular/core'; +import { Component, Inject, Optional } from '@angular/core'; import { MENU_ROUTES } from '../../../codelabs/angular/common'; @Component({ @@ -8,7 +8,7 @@ import { MENU_ROUTES } from '../../../codelabs/angular/common'; }) export class MenuShortcutWidgetComponent { constructor( - @Inject(MENU_ROUTES) readonly menuRoutes + @Optional() @Inject(MENU_ROUTES) readonly menuRoutes ) { } } diff --git a/libs/slides/src/lib/arrows/slides-arrows.component.ts b/libs/slides/src/lib/arrows/slides-arrows.component.ts index 9d974670b..5583e71a4 100644 --- a/libs/slides/src/lib/arrows/slides-arrows.component.ts +++ b/libs/slides/src/lib/arrows/slides-arrows.component.ts @@ -1,5 +1,6 @@ -import { Component, HostBinding } from '@angular/core'; +import { Component, HostBinding, Input } from '@angular/core'; import { SlidesDeckComponent } from '../deck/deck.component'; +import { Router } from '@angular/router'; /** * Slide arrows are used by slides deck for navigation. @@ -16,22 +17,35 @@ export class SlidesArrowsComponent { * from editable field keyboard navigation. */ @HostBinding('class.shortcuts-context') context = true; + @Input() previousLink: string; + @Input() nextLink: string; - constructor(private presentation: SlidesDeckComponent) {} + constructor( + private readonly router: Router, + private presentation: SlidesDeckComponent + ) {} goToPreviousSlide() { - this.presentation.previousSlide(); + if (this.presentation.canGoPrevious()) { + this.presentation.previousSlide(); + } else if (this.previousLink != null && this.previousLink !== '') { + this.router.navigateByUrl(this.previousLink); + } } goToNextSlide() { - this.presentation.nextSlide(); + if (this.presentation.canGoNext()) { + this.presentation.nextSlide(); + } else if (this.nextLink != null && this.nextLink !== '') { + this.router.navigateByUrl(this.nextLink); + } } canGoNext(): boolean { - return this.presentation.canGoNext(); + return this.presentation.canGoNext() || (this.nextLink != null && this.nextLink !== ''); } canGoPrevious(): boolean { - return this.presentation.canGoPrevious(); + return this.presentation.canGoPrevious() || (this.previousLink != null && this.previousLink !== ''); } } diff --git a/package-lock.json b/package-lock.json index fdd4cfe83..32f629425 100644 --- a/package-lock.json +++ b/package-lock.json @@ -927,7 +927,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -948,12 +949,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -968,17 +971,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -1095,7 +1101,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -1107,6 +1114,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1121,6 +1129,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1128,12 +1137,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -1152,6 +1163,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -1232,7 +1244,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -1244,6 +1257,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -1329,7 +1343,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -1365,6 +1380,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -1384,6 +1400,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -1427,12 +1444,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -1887,6 +1906,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz", "integrity": "sha512-3UYcJUj9kvSLbLbUIfQTqzcy5VX7GRZ/CCDrnOaZorFFM01aXp1+GJwuFGV4NDDoAS+mOUyHcO6UD/RfqOks3Q==", + "optional": true, "requires": { "@babel/types": "^7.0.0" } @@ -1979,6 +1999,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz", "integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==", + "optional": true, "requires": { "esutils": "^2.0.2", "lodash": "^4.17.13", @@ -2009,7 +2030,8 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "optional": true }, "ms": { "version": "2.1.2", @@ -2020,7 +2042,8 @@ "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "optional": true } } }, @@ -2049,7 +2072,8 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "optional": true }, "to-fast-properties": { "version": "2.0.0", @@ -2091,6 +2115,7 @@ "version": "7.4.4", "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.4.4.tgz", "integrity": "sha512-VYk2/H/BnYbZDDg39hr3t2kKyifAm1W6zHRfhx8jGjIHpQEBv9dry7oQ2f3+J703TLu69nYdxsovl0XYfcnK4w==", + "optional": true, "requires": { "@babel/types": "^7.4.4" }, @@ -2099,6 +2124,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz", "integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==", + "optional": true, "requires": { "esutils": "^2.0.2", "lodash": "^4.17.13", @@ -2108,12 +2134,14 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "optional": true }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "optional": true } } }, @@ -2121,6 +2149,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.5.5.tgz", "integrity": "sha512-5qZ3D1uMclSNqYcXqiHoA0meVdv+xUEex9em2fqMnrk/scphGlGgg66zjMrPJESPwrFJ6sbfFQYUSa0Mz7FabA==", + "optional": true, "requires": { "@babel/types": "^7.5.5" }, @@ -2129,6 +2158,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz", "integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==", + "optional": true, "requires": { "esutils": "^2.0.2", "lodash": "^4.17.13", @@ -2138,12 +2168,14 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "optional": true }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "optional": true } } }, @@ -2151,6 +2183,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz", "integrity": "sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A==", + "optional": true, "requires": { "@babel/types": "^7.0.0" } @@ -2159,6 +2192,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.5.5.tgz", "integrity": "sha512-jBeCvETKuJqeiaCdyaheF40aXnnU1+wkSiUs/IQg3tB85up1LyL8x77ClY8qJpuRJUcXQo+ZtdNESmZl4j56Pw==", + "optional": true, "requires": { "@babel/helper-module-imports": "^7.0.0", "@babel/helper-simple-access": "^7.1.0", @@ -2172,6 +2206,7 @@ "version": "7.4.4", "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", + "optional": true, "requires": { "@babel/types": "^7.4.4" } @@ -2179,12 +2214,14 @@ "@babel/parser": { "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz", - "integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==" + "integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==", + "optional": true }, "@babel/template": { "version": "7.4.4", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", "integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", + "optional": true, "requires": { "@babel/code-frame": "^7.0.0", "@babel/parser": "^7.4.4", @@ -2195,6 +2232,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz", "integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==", + "optional": true, "requires": { "esutils": "^2.0.2", "lodash": "^4.17.13", @@ -2204,12 +2242,14 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "optional": true }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "optional": true } } }, @@ -2217,6 +2257,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.0.0.tgz", "integrity": "sha512-u8nd9NQePYNQV8iPWu/pLLYBqZBa4ZaY1YWRFMuxrid94wKI1QNt67NEZ7GAe5Kc/0LLScbim05xZFWkAdrj9g==", + "optional": true, "requires": { "@babel/types": "^7.0.0" } @@ -2230,6 +2271,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.5.5.tgz", "integrity": "sha512-CkCYQLkfkiugbRDO8eZn6lRuR8kzZoGXCg3149iTk5se7g6qykSpy3+hELSwquhu+TgHn8nkLiBwHvNX8Hofcw==", + "optional": true, "requires": { "lodash": "^4.17.13" }, @@ -2237,7 +2279,8 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "optional": true } } }, @@ -2245,6 +2288,7 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz", "integrity": "sha512-3fOK0L+Fdlg8S5al8u/hWE6vhufGSn0bN09xm2LXMy//REAF8kDCrYoOBKYmA8m5Nom+sV9LyLCwrFynA8/slg==", + "optional": true, "requires": { "@babel/helper-annotate-as-pure": "^7.0.0", "@babel/helper-wrap-function": "^7.1.0", @@ -2257,6 +2301,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.5.5.tgz", "integrity": "sha512-XvRFWrNnlsow2u7jXDuH4jDDctkxbS7gXssrP4q2nUD606ukXHRvydj346wmNg+zAgpFx4MWf4+usfC93bElJg==", + "optional": true, "requires": { "@babel/helper-member-expression-to-functions": "^7.5.5", "@babel/helper-optimise-call-expression": "^7.0.0", @@ -2268,6 +2313,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "optional": true, "requires": { "@babel/highlight": "^7.0.0" } @@ -2276,6 +2322,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.5.tgz", "integrity": "sha512-ETI/4vyTSxTzGnU2c49XHv2zhExkv9JHLTwDAFz85kmcwuShvYG2H08FwgIguQf4JC75CBnXAUM5PqeF4fj0nQ==", + "optional": true, "requires": { "@babel/types": "^7.5.5", "jsesc": "^2.5.1", @@ -2288,6 +2335,7 @@ "version": "7.4.4", "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", + "optional": true, "requires": { "@babel/types": "^7.4.4" } @@ -2295,12 +2343,14 @@ "@babel/parser": { "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz", - "integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==" + "integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==", + "optional": true }, "@babel/traverse": { "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.5.tgz", "integrity": "sha512-MqB0782whsfffYfSjH4TM+LMjrJnhCNEDMDIjeTpl+ASaUvxcjoiVCo/sM1GhS1pHOXYfWVCYneLjMckuUxDaQ==", + "optional": true, "requires": { "@babel/code-frame": "^7.5.5", "@babel/generator": "^7.5.5", @@ -2317,6 +2367,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz", "integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==", + "optional": true, "requires": { "esutils": "^2.0.2", "lodash": "^4.17.13", @@ -2327,6 +2378,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "optional": true, "requires": { "ms": "^2.1.1" } @@ -2334,27 +2386,32 @@ "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "optional": true }, "jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "optional": true }, "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "optional": true }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "optional": true }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "optional": true } } }, @@ -2362,6 +2419,7 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz", "integrity": "sha512-Vk+78hNjRbsiu49zAPALxTb+JUQCz1aolpd8osOF16BGnLtseD21nbHgLPGUwrXEurZgiCOUmvs3ExTu4F5x6w==", + "optional": true, "requires": { "@babel/template": "^7.1.0", "@babel/types": "^7.0.0" @@ -2379,6 +2437,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.2.0.tgz", "integrity": "sha512-o9fP1BZLLSrYlxYEYyl2aS+Flun5gtjTIG8iln+XuEzQTs0PLagAGSXUcqruJwD5fM48jzIEggCKpIfWTcR7pQ==", + "optional": true, "requires": { "@babel/helper-function-name": "^7.1.0", "@babel/template": "^7.1.0", @@ -2390,6 +2449,7 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz", "integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==", + "optional": true, "requires": { "esutils": "^2.0.2", "lodash": "^4.17.13", @@ -2399,12 +2459,14 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "optional": true }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "optional": true } } }, @@ -2560,6 +2622,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.2.0.tgz", "integrity": "sha512-1ZrIRBv2t0GSlcwVoQ6VgSLpLgiN/FVQUzt9znxo7v2Ov4jJrs8RY8tv0wvDmFN3qIdMKWrmMMW6yZ0G19MfGg==", + "optional": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" } @@ -2568,6 +2631,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.2.0.tgz", "integrity": "sha512-mVxuJ0YroI/h/tbFTPGZR8cv6ai+STMKNBq0f8hFxsxWjl94qqhsb+wXbpNMDPU3cfR1TIsVFzU3nXyZMqyK4w==", + "optional": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" } @@ -2576,6 +2640,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.2.0.tgz", "integrity": "sha512-5UGYnMSLRE1dqqZwug+1LISpA403HzlSfsg6P9VXU6TBjcSHeNlw4DxDx7LgpF+iKZoOG/+uzqoRHTdcUpiZNg==", + "optional": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" } @@ -2600,6 +2665,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.2.0.tgz", "integrity": "sha512-bDe4xKNhb0LI7IvZHiA13kff0KEfaGX/Hv4lMA9+7TEc63hMNvfKo6ZFpXhKuEp+II/q35Gc4NoMeDZyaUbj9w==", + "optional": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" } @@ -4042,7 +4108,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true + "dev": true, + "optional": true }, "async": { "version": "1.0.0", @@ -4107,7 +4174,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true + "dev": true, + "optional": true }, "lodash": { "version": "4.17.5", @@ -4133,6 +4201,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, + "optional": true, "requires": { "is-fullwidth-code-point": "^2.0.0", "strip-ansi": "^4.0.0" @@ -4143,6 +4212,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^3.0.0" } @@ -4967,7 +5037,8 @@ "pify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "optional": true }, "pkg-dir": { "version": "3.0.0", @@ -5305,7 +5376,8 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true + "dev": true, + "optional": true }, "pkg-dir": { "version": "3.0.0", @@ -7254,6 +7326,7 @@ "resolved": "http://registry.npmjs.org/axios/-/axios-0.18.0.tgz", "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=", "dev": true, + "optional": true, "requires": { "follow-redirects": "^1.3.0", "is-buffer": "^1.1.5" @@ -7579,6 +7652,7 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz", "integrity": "sha512-o6qFkpeQEBxcqt0XYlWzAVxNCSCZdUgcR8IRlhD/8DylxjjO4foPcvTW0GGKa/cVt3rvxZ7o5ippJ+/0nvLhlQ==", + "optional": true, "requires": { "object.assign": "^4.1.0" } @@ -13457,6 +13531,7 @@ "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-1.2.4.tgz", "integrity": "sha512-LhBin5JU+iIQfqrIPu1VHoV3EpJ8HhupS05LbAXLc1aAsTNDOjxjrkU9C1X1KELf/HtbA3fRtIZ3ouH/xvt1UQ==", "dev": true, + "optional": true, "requires": { "extend": "^3.0.2", "https-proxy-agent": "^2.2.1", @@ -13467,7 +13542,8 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==", - "dev": true + "dev": true, + "optional": true } } }, @@ -13484,6 +13560,7 @@ "resolved": "http://registry.npmjs.org/gcp-metadata/-/gcp-metadata-0.6.3.tgz", "integrity": "sha512-MSmczZctbz91AxCvqp9GHBoZOSbJKAICV7Ow/AIWSJZRrRchUd5NL1b2P4OfP+4m490BEUPhhARfpHdqCxuCvg==", "dev": true, + "optional": true, "requires": { "axios": "^0.18.0", "extend": "^3.0.1", @@ -13792,6 +13869,7 @@ "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-1.6.1.tgz", "integrity": "sha512-jYiWC8NA9n9OtQM7ANn0Tk464do9yhKEtaJ72pKcaBiEwn4LwcGYIYOfwtfsSm3aur/ed3tlSxbmg24IAT6gAg==", "dev": true, + "optional": true, "requires": { "axios": "^0.18.0", "gcp-metadata": "^0.6.3", @@ -13807,6 +13885,7 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "dev": true, + "optional": true, "requires": { "pseudomap": "^1.0.2", "yallist": "^2.1.2" @@ -13882,6 +13961,7 @@ "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-1.0.3.tgz", "integrity": "sha512-KGnAiMMWaJp4j4tYVvAjfP3wCKZRLv9M1Nir2wRRNWUYO7j1aX8O9Qgz+a8/EQ5rAvuo4SIu79n6SIdkNl7Msg==", "dev": true, + "optional": true, "requires": { "node-forge": "^0.7.5", "pify": "^4.0.0" @@ -13891,7 +13971,8 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true + "dev": true, + "optional": true } } }, @@ -14516,6 +14597,7 @@ "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-2.3.2.tgz", "integrity": "sha512-F8EObUGyC8Qd3WXTloNULZBwfUsOABoHElihB1F6zGhT/cy38iPL09wGLRY712I+hQnOyA+sYlgPFX2cOKz0qg==", "dev": true, + "optional": true, "requires": { "gaxios": "^1.0.4", "google-p12-pem": "^1.0.0", @@ -14528,7 +14610,8 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true + "dev": true, + "optional": true } } }, @@ -16934,7 +17017,8 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -16958,13 +17042,15 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -16981,19 +17067,22 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -17124,7 +17213,8 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -17138,6 +17228,7 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -17154,6 +17245,7 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -17162,13 +17254,15 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "resolved": false, "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -17189,6 +17283,7 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -17277,7 +17372,8 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -17291,6 +17387,7 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -17386,7 +17483,8 @@ "version": "5.1.2", "resolved": false, "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -17428,6 +17526,7 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -17449,6 +17548,7 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -17497,13 +17597,15 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "resolved": false, "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } }, @@ -18405,7 +18507,6 @@ "integrity": "sha512-J9X76xnncMw+wIqb15HeWfPMqPwYxSpPY8yWPJ7rAZN/ZDzFkjCSZObryCyUe8zbrVRNiuCnIeQteCzMn7GnWw==", "requires": { "canvg": "1.5.3", - "file-saver": "github:eligrey/FileSaver.js#e865e37af9f9947ddcced76b549e27dc45c1cb2e", "html2canvas": "1.0.0-alpha.12", "omggif": "1.0.7", "promise-polyfill": "8.1.0", @@ -18414,7 +18515,7 @@ "dependencies": { "file-saver": { "version": "github:eligrey/FileSaver.js#e865e37af9f9947ddcced76b549e27dc45c1cb2e", - "from": "github:eligrey/FileSaver.js#1.3.8" + "from": "github:eligrey/FileSaver.js#e865e37af9f9947ddcced76b549e27dc45c1cb2e" }, "promise-polyfill": { "version": "8.1.0", @@ -21565,6 +21666,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "optional": true, "requires": { "define-properties": "^1.1.2", "function-bind": "^1.1.1", @@ -23546,6 +23648,7 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz", "integrity": "sha512-LGZzkgtLY79GeXLm8Dp0BVLdQlWICzBnJz/ipWUgo59qBaZ+BHtq51P2q1uVZlppMuUAT37SDk39qUbjTWB7bA==", + "optional": true, "requires": { "regenerate": "^1.4.0" } @@ -23899,7 +24002,8 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/retry-axios/-/retry-axios-0.3.2.tgz", "integrity": "sha512-jp4YlI0qyDFfXiXGhkCOliBN1G7fRH03Nqy8YdShzGqbY5/9S2x/IR6C88ls2DFkbWuL3ASkP7QD3pVrNpPgwQ==", - "dev": true + "dev": true, + "optional": true }, "retry-request": { "version": "3.3.2", @@ -25184,6 +25288,7 @@ "resolved": "https://registry.npmjs.org/stream-events/-/stream-events-1.0.5.tgz", "integrity": "sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg==", "dev": true, + "optional": true, "requires": { "stubs": "^3.0.0" } @@ -25343,7 +25448,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", "integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls=", - "dev": true + "dev": true, + "optional": true }, "style-loader": { "version": "0.23.1", @@ -27040,12 +27146,14 @@ "unicode-canonical-property-names-ecmascript": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", - "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==" + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", + "optional": true }, "unicode-match-property-ecmascript": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "optional": true, "requires": { "unicode-canonical-property-names-ecmascript": "^1.0.4", "unicode-property-aliases-ecmascript": "^1.0.4" @@ -27054,12 +27162,14 @@ "unicode-match-property-value-ecmascript": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.1.0.tgz", - "integrity": "sha512-hDTHvaBk3RmFzvSl0UVrUmC3PuW9wKVnpoUDYH0JDkSIovzw+J5viQmeYHxVSBptubnr7PbH2e0fnpDRQnQl5g==" + "integrity": "sha512-hDTHvaBk3RmFzvSl0UVrUmC3PuW9wKVnpoUDYH0JDkSIovzw+J5viQmeYHxVSBptubnr7PbH2e0fnpDRQnQl5g==", + "optional": true }, "unicode-property-aliases-ecmascript": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.5.tgz", - "integrity": "sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw==" + "integrity": "sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw==", + "optional": true }, "union-value": { "version": "1.0.0", @@ -27852,7 +27962,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -27873,12 +27984,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -27893,17 +28006,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -28020,7 +28136,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -28032,6 +28149,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -28046,6 +28164,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -28053,12 +28172,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -28077,6 +28198,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -28157,7 +28279,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -28169,6 +28292,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -28254,7 +28378,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -28290,6 +28415,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -28309,6 +28435,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -28352,12 +28479,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, From d3758f2b4a90fe799db25f9ea93e48d7ec9e861c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Sep 2019 11:39:38 -0400 Subject: [PATCH 02/14] Enabled next and previous buttons to navigate to different lessons on the first and last slides --- .../angular-cli/angular-cli.component.html | 2 +- .../component-tree.component.html | 2 +- .../create-first-app.component.html | 2 +- .../dependency-injection.component.html | 2 +- .../angular/forms/forms.component.html | 2 +- .../angular/material/material.component.html | 2 +- .../angular/router/router.component.html | 2 +- .../templates/templates.component.html | 2 +- .../codelab-closing-slide.component.ts | 16 ++++++- .../title-slide/title-slide.component.ts | 14 ++++++- .../src/lib/arrows/slides-arrows.component.ts | 14 +------ libs/slides/src/lib/deck/deck.component.ts | 42 ++++++++++++++++--- 12 files changed, 73 insertions(+), 29 deletions(-) diff --git a/apps/codelab/src/app/codelabs/angular/angular-cli/angular-cli.component.html b/apps/codelab/src/app/codelabs/angular/angular-cli/angular-cli.component.html index 20bfa6f3e..e2e15d39e 100644 --- a/apps/codelab/src/app/codelabs/angular/angular-cli/angular-cli.component.html +++ b/apps/codelab/src/app/codelabs/angular/angular-cli/angular-cli.component.html @@ -1,6 +1,6 @@ - +
diff --git a/apps/codelab/src/app/codelabs/angular/component-tree/component-tree.component.html b/apps/codelab/src/app/codelabs/angular/component-tree/component-tree.component.html index 9abcaf656..6f42f7788 100644 --- a/apps/codelab/src/app/codelabs/angular/component-tree/component-tree.component.html +++ b/apps/codelab/src/app/codelabs/angular/component-tree/component-tree.component.html @@ -56,7 +56,7 @@ - + diff --git a/apps/codelab/src/app/codelabs/angular/create-first-app/create-first-app.component.html b/apps/codelab/src/app/codelabs/angular/create-first-app/create-first-app.component.html index 651f96a12..a2de3486c 100644 --- a/apps/codelab/src/app/codelabs/angular/create-first-app/create-first-app.component.html +++ b/apps/codelab/src/app/codelabs/angular/create-first-app/create-first-app.component.html @@ -49,7 +49,7 @@
- +
- +
- +
diff --git a/apps/codelab/src/app/codelabs/angular/material/material.component.html b/apps/codelab/src/app/codelabs/angular/material/material.component.html index 8572f49d2..0716eaffe 100644 --- a/apps/codelab/src/app/codelabs/angular/material/material.component.html +++ b/apps/codelab/src/app/codelabs/angular/material/material.component.html @@ -29,7 +29,7 @@ - +
diff --git a/apps/codelab/src/app/codelabs/angular/router/router.component.html b/apps/codelab/src/app/codelabs/angular/router/router.component.html index f4b41b9e2..1adc5a8ef 100644 --- a/apps/codelab/src/app/codelabs/angular/router/router.component.html +++ b/apps/codelab/src/app/codelabs/angular/router/router.component.html @@ -22,7 +22,7 @@
- +
diff --git a/apps/codelab/src/app/codelabs/angular/templates/templates.component.html b/apps/codelab/src/app/codelabs/angular/templates/templates.component.html index 703543cf2..df21ca3c5 100644 --- a/apps/codelab/src/app/codelabs/angular/templates/templates.component.html +++ b/apps/codelab/src/app/codelabs/angular/templates/templates.component.html @@ -111,7 +111,7 @@
- +
diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index 064a1c8b8..4f6bcacc6 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -1,4 +1,6 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit, Inject, Optional } from '@angular/core'; +import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; +import { MENU_ROUTES } from '../../../codelabs/angular/common'; @Component({ selector: 'codelab-closing-slide', @@ -10,7 +12,17 @@ export class CodelabClosingSlideComponent implements OnInit { @Input() body: String; @Input() footer: String; - constructor() {} + constructor( + private readonly presentation: SlidesDeckComponent, + @Optional() @Inject(MENU_ROUTES) readonly menuRoutes + ) { + if (this.presentation != null) { + this.presentation.setupPreviousNext(menuRoutes.map(p => p.path)); + } + + } + + ngOnInit() {} } diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index aa76cc2b4..6da38be0e 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -1,4 +1,6 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, Optional, Inject } from '@angular/core'; +import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; +import { MENU_ROUTES } from '../../../codelabs/angular/common'; @Component({ selector: 'codelab-title-slide', @@ -9,4 +11,14 @@ export class TitleSlideComponent { @Input() title: string; @Input() description: string; @Input() prereqs: string; + + constructor( + private readonly presentation: SlidesDeckComponent, + @Optional() @Inject(MENU_ROUTES) readonly menuRoutes + ) { + if (this.presentation != null) { + this.presentation.setupPreviousNext(menuRoutes.map(p => p.path)); + } + + } } diff --git a/libs/slides/src/lib/arrows/slides-arrows.component.ts b/libs/slides/src/lib/arrows/slides-arrows.component.ts index 5583e71a4..3f2d7f448 100644 --- a/libs/slides/src/lib/arrows/slides-arrows.component.ts +++ b/libs/slides/src/lib/arrows/slides-arrows.component.ts @@ -17,8 +17,6 @@ export class SlidesArrowsComponent { * from editable field keyboard navigation. */ @HostBinding('class.shortcuts-context') context = true; - @Input() previousLink: string; - @Input() nextLink: string; constructor( private readonly router: Router, @@ -26,26 +24,18 @@ export class SlidesArrowsComponent { ) {} goToPreviousSlide() { - if (this.presentation.canGoPrevious()) { this.presentation.previousSlide(); - } else if (this.previousLink != null && this.previousLink !== '') { - this.router.navigateByUrl(this.previousLink); - } } goToNextSlide() { - if (this.presentation.canGoNext()) { this.presentation.nextSlide(); - } else if (this.nextLink != null && this.nextLink !== '') { - this.router.navigateByUrl(this.nextLink); - } } canGoNext(): boolean { - return this.presentation.canGoNext() || (this.nextLink != null && this.nextLink !== ''); + return this.presentation.canGoNext(); } canGoPrevious(): boolean { - return this.presentation.canGoPrevious() || (this.previousLink != null && this.previousLink !== ''); + return this.presentation.canGoPrevious(); } } diff --git a/libs/slides/src/lib/deck/deck.component.ts b/libs/slides/src/lib/deck/deck.component.ts index 18426832e..57f67e01f 100644 --- a/libs/slides/src/lib/deck/deck.component.ts +++ b/libs/slides/src/lib/deck/deck.component.ts @@ -11,7 +11,7 @@ import { TemplateRef } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; @Component({ selector: 'slide-deck', @@ -27,10 +27,13 @@ export class SlidesDeckComponent { @Output() slideAdded = new EventEmitter<{ index: number; id: string }>(); @HostBinding('class.has-milestone') hasMilestone = false; private milestone = ''; + private previousLink: string; + private nextLink: string; constructor( private readonly cdr: ChangeDetectorRef, - @Optional() private readonly route: ActivatedRoute + private readonly router: Router, + @Optional() private readonly route: ActivatedRoute ) { if (route) { this.milestone = route.snapshot.queryParams.milestone; @@ -51,18 +54,45 @@ export class SlidesDeckComponent { } nextSlide() { - this.goToSlide(this.activeSlideIndex + 1); + if (this.activeSlideIndex + 1 < this.slides.length) { + this.goToSlide(this.activeSlideIndex + 1); + } else if (this.nextLink != null && this.nextLink !== '') { + this.router.navigateByUrl(this.nextLink); + } } previousSlide() { - this.goToSlide(this.activeSlideIndex - 1); + if (this.activeSlideIndex > 0) { + this.goToSlide(this.activeSlideIndex - 1); + } else if (this.previousLink != null && this.previousLink !== '') { + this.router.navigateByUrl(this.previousLink); + } } canGoNext(): boolean { - return this.activeSlideIndex + 1 < this.slides.length; + return this.activeSlideIndex + 1 < this.slides.length || (this.nextLink != null && this.nextLink !== ''); } canGoPrevious(): boolean { - return this.activeSlideIndex > 0; + return this.activeSlideIndex > 0 || (this.previousLink != null && this.previousLink !== ''); + } + + public setupPreviousNext(allRoutes: string[]) { + this.previousLink = ''; + this.nextLink = ''; + let currentUrl = this.router.url; + if (currentUrl.startsWith('/')) { + currentUrl = currentUrl.substr(1); + } + const urlPaths = currentUrl.split('/'); + if (urlPaths.length > 1) { + const idx = allRoutes.indexOf(urlPaths[1]); + if (idx > 0) { + this.previousLink = `/${urlPaths[0]}/${allRoutes[idx - 1]}`; + } + if (idx < (allRoutes.length - 1)) { + this.nextLink = `/${urlPaths[0]}/${allRoutes[idx + 1]}`; + } + } } } From e3be0241ed2525d2f93bdacd4595f11aaae7f75e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Sep 2019 08:23:50 -0400 Subject: [PATCH 03/14] made presentation slide optional in constructor in title and closing slide --- .../slides/closing-slide/codelab-closing-slide.component.ts | 4 ++-- .../components/slides/title-slide/title-slide.component.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index 4f6bcacc6..252b9a6a7 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -1,6 +1,6 @@ import { Component, Input, OnInit, Inject, Optional } from '@angular/core'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; -import { MENU_ROUTES } from '../../../codelabs/angular/common'; +import { MENU_ROUTES } from '../../../common'; @Component({ selector: 'codelab-closing-slide', @@ -13,7 +13,7 @@ export class CodelabClosingSlideComponent implements OnInit { @Input() footer: String; constructor( - private readonly presentation: SlidesDeckComponent, + @Optional() private readonly presentation: SlidesDeckComponent, @Optional() @Inject(MENU_ROUTES) readonly menuRoutes ) { if (this.presentation != null) { diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index 6da38be0e..3d1b4c039 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -1,6 +1,6 @@ import { Component, Input, Optional, Inject } from '@angular/core'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; -import { MENU_ROUTES } from '../../../codelabs/angular/common'; +import { MENU_ROUTES } from '../../../common'; @Component({ selector: 'codelab-title-slide', @@ -13,7 +13,7 @@ export class TitleSlideComponent { @Input() prereqs: string; constructor( - private readonly presentation: SlidesDeckComponent, + @Optional() private readonly presentation: SlidesDeckComponent, @Optional() @Inject(MENU_ROUTES) readonly menuRoutes ) { if (this.presentation != null) { From bfc44b7c914e8527d0cbf16bc31d37396cd23622 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Oct 2019 08:22:19 -0400 Subject: [PATCH 04/14] added tests to title and closing slides --- .../codelab-closing-slide.component.spec.ts | 45 +++++++++++++++++- .../codelab-closing-slide.component.ts | 31 +++++++++++-- .../title-slide/title-slide.component.spec.ts | 46 +++++++++++++++++++ .../title-slide/title-slide.component.ts | 27 ++++++++++- libs/slides/src/lib/deck/deck.component.ts | 37 +++++++-------- 5 files changed, 157 insertions(+), 29 deletions(-) diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts index 9cbbd0035..e7ab2b150 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts @@ -1,13 +1,48 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - import { CodelabClosingSlideComponent } from './codelab-closing-slide.component'; +import { Router } from '@angular/router'; +import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; +import { MENU_ROUTES, MenuRoutes } from '../../../common'; describe('CodelabClosingSlideComponent', () => { let component: CodelabClosingSlideComponent; let fixture: ComponentFixture; + const routerStub = { + url: '/ngtest/currentlesson' + }; + + const slidesDeckComponentStub = { + previousLink: '', + nextLink: '', + + setPrevious(link) { + this.previousLink = link; + }, + + setNext(link) { + this.nextLink = link; + } + }; + + const menuRoutes: MenuRoutes = [ + { + path: 'previouslesson' + }, + { + path: 'currentlesson' + }, + { + path: 'nextlesson' + } + ]; beforeEach(async(() => { TestBed.configureTestingModule({ + providers: [ + { provide: Router, useValue: routerStub }, + { provide: SlidesDeckComponent, useFactory: ()=>{ return slidesDeckComponentStub; } }, + { provide: MENU_ROUTES, useValue: menuRoutes } + ], declarations: [CodelabClosingSlideComponent] }).compileComponents(); })); @@ -21,4 +56,12 @@ describe('CodelabClosingSlideComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should set previousLink', () => { + expect(slidesDeckComponentStub.previousLink).not.toBe(''); + }); + + it('should set nextLink', () => { + expect(slidesDeckComponentStub.nextLink).not.toBe(''); + }); }); diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index 252b9a6a7..fe78ae48b 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -1,6 +1,7 @@ import { Component, Input, OnInit, Inject, Optional } from '@angular/core'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; import { MENU_ROUTES } from '../../../common'; +import { Router } from '@angular/router'; @Component({ selector: 'codelab-closing-slide', @@ -13,16 +14,36 @@ export class CodelabClosingSlideComponent implements OnInit { @Input() footer: String; constructor( - @Optional() private readonly presentation: SlidesDeckComponent, + private readonly router: Router, + private readonly presentation: SlidesDeckComponent, @Optional() @Inject(MENU_ROUTES) readonly menuRoutes ) { - if (this.presentation != null) { - this.presentation.setupPreviousNext(menuRoutes.map(p => p.path)); + if (this.presentation != null && this.menuRoutes != null) { + this.setupPreviousNext(); } - } - + private setupPreviousNext() { + let previousLink = ''; + let nextLink = ''; + let allRoutes = this.menuRoutes.map(p => p.path); + let currentUrl = this.router.url; + if (currentUrl.startsWith('/')) { + currentUrl = currentUrl.substr(1); + } + const urlPaths = currentUrl.split('/'); + if (urlPaths.length > 1) { + const idx = allRoutes.indexOf(urlPaths[1]); + if (idx > 0) { + previousLink = `/${urlPaths[0]}/${allRoutes[idx - 1]}`; + } + if (idx < allRoutes.length - 1) { + nextLink = `/${urlPaths[0]}/${allRoutes[idx + 1]}`; + } + } + this.presentation.setPrevious(previousLink); + this.presentation.setNext(nextLink); + } ngOnInit() {} } diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts index 26f3c42f2..1382f1d87 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts @@ -1,15 +1,53 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; import { By } from '@angular/platform-browser'; import { TitleSlideComponent } from './title-slide.component'; import { CodelabRippleAnimationComponent } from './ripple-animation/codelab-ripple-animation.component'; +import { MenuRoutes, MENU_ROUTES } from '../../../common'; +import { Router } from '@angular/router'; +import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; describe('TitleSlideComponent', () => { let component: TitleSlideComponent; let fixture: ComponentFixture; + const routerStub = { + url: '/ngtest/currentlesson' + }; + + const slidesDeckComponentStub = { + previousLink: '', + nextLink: '', + + setPrevious(link) { + this.previousLink = link; + }, + + setNext(link) { + this.nextLink = link; + } + }; + + const menuRoutes: MenuRoutes = [ + { + path: 'previouslesson' + }, + { + path: 'currentlesson' + }, + { + path: 'nextlesson' + } + ]; beforeEach(async(() => { TestBed.configureTestingModule({ + providers: [ + { provide: Router, useValue: routerStub }, + { provide: SlidesDeckComponent, useFactory: () => { return slidesDeckComponentStub; } }, + { provide: MENU_ROUTES, useValue: menuRoutes } + ], + imports: [RouterTestingModule], declarations: [CodelabRippleAnimationComponent, TitleSlideComponent] }).compileComponents(); })); @@ -24,6 +62,14 @@ describe('TitleSlideComponent', () => { expect(component).toBeTruthy(); }); + it('should set previousLink', () => { + expect(slidesDeckComponentStub.previousLink).not.toBe(''); + }); + + it('should set nextLink', () => { + expect(slidesDeckComponentStub.nextLink).not.toBe(''); + }); + it('should render a title', () => { component.title = 'awesome title'; fixture.detectChanges(); diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index 3d1b4c039..1eea43e8f 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -1,6 +1,7 @@ import { Component, Input, Optional, Inject } from '@angular/core'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; import { MENU_ROUTES } from '../../../common'; +import { Router } from '@angular/router'; @Component({ selector: 'codelab-title-slide', @@ -13,12 +14,34 @@ export class TitleSlideComponent { @Input() prereqs: string; constructor( - @Optional() private readonly presentation: SlidesDeckComponent, + private readonly router: Router, + private readonly presentation: SlidesDeckComponent, @Optional() @Inject(MENU_ROUTES) readonly menuRoutes ) { if (this.presentation != null) { - this.presentation.setupPreviousNext(menuRoutes.map(p => p.path)); + this.setupPreviousNext(); } + } + private setupPreviousNext() { + let previousLink = ''; + let nextLink = ''; + let allRoutes = this.menuRoutes.map(p => p.path); + let currentUrl = this.router.url; + if (currentUrl.startsWith('/')) { + currentUrl = currentUrl.substr(1); + } + const urlPaths = currentUrl.split('/'); + if (urlPaths.length > 1) { + const idx = allRoutes.indexOf(urlPaths[1]); + if (idx > 0) { + previousLink = `/${urlPaths[0]}/${allRoutes[idx - 1]}`; + } + if (idx < allRoutes.length - 1) { + nextLink = `/${urlPaths[0]}/${allRoutes[idx + 1]}`; + } + } + this.presentation.setPrevious(previousLink); + this.presentation.setNext(nextLink); } } diff --git a/libs/slides/src/lib/deck/deck.component.ts b/libs/slides/src/lib/deck/deck.component.ts index 57f67e01f..c7b9abd52 100644 --- a/libs/slides/src/lib/deck/deck.component.ts +++ b/libs/slides/src/lib/deck/deck.component.ts @@ -56,7 +56,7 @@ export class SlidesDeckComponent { nextSlide() { if (this.activeSlideIndex + 1 < this.slides.length) { this.goToSlide(this.activeSlideIndex + 1); - } else if (this.nextLink != null && this.nextLink !== '') { + } else if (this.nextLink) { this.router.navigateByUrl(this.nextLink); } } @@ -64,35 +64,30 @@ export class SlidesDeckComponent { previousSlide() { if (this.activeSlideIndex > 0) { this.goToSlide(this.activeSlideIndex - 1); - } else if (this.previousLink != null && this.previousLink !== '') { + } else if (this.previousLink) { this.router.navigateByUrl(this.previousLink); } } canGoNext(): boolean { - return this.activeSlideIndex + 1 < this.slides.length || (this.nextLink != null && this.nextLink !== ''); + return ( + this.activeSlideIndex + 1 < this.slides.length || + (this.nextLink != null && this.nextLink !== '') + ); } canGoPrevious(): boolean { - return this.activeSlideIndex > 0 || (this.previousLink != null && this.previousLink !== ''); + return ( + this.activeSlideIndex > 0 || + (this.previousLink != null && this.previousLink !== '') + ); } - public setupPreviousNext(allRoutes: string[]) { - this.previousLink = ''; - this.nextLink = ''; - let currentUrl = this.router.url; - if (currentUrl.startsWith('/')) { - currentUrl = currentUrl.substr(1); - } - const urlPaths = currentUrl.split('/'); - if (urlPaths.length > 1) { - const idx = allRoutes.indexOf(urlPaths[1]); - if (idx > 0) { - this.previousLink = `/${urlPaths[0]}/${allRoutes[idx - 1]}`; - } - if (idx < (allRoutes.length - 1)) { - this.nextLink = `/${urlPaths[0]}/${allRoutes[idx + 1]}`; - } - } + public setPrevious(previousLink) { + this.previousLink = previousLink; + } + + public setNext(nextLink) { + this.nextLink = nextLink; } } From 89831ea5c4f0856c6f62e9f13e0e5159ec72d28f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Oct 2019 10:13:39 -0400 Subject: [PATCH 05/14] dropped calls to setPrevious from closing slide and calls to setNext from title slide. change tests to use spies instead of checking value --- .../codelab-closing-slide.component.spec.ts | 9 +++------ .../closing-slide/codelab-closing-slide.component.ts | 7 +------ .../slides/title-slide/title-slide.component.spec.ts | 9 +++------ .../slides/title-slide/title-slide.component.ts | 5 ----- libs/slides/src/lib/arrows/slides-arrows.component.ts | 6 +----- libs/slides/src/lib/deck/deck.component.ts | 10 ++-------- 6 files changed, 10 insertions(+), 36 deletions(-) diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts index e7ab2b150..cb3eb092a 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts @@ -48,6 +48,7 @@ describe('CodelabClosingSlideComponent', () => { })); beforeEach(() => { + spyOn(slidesDeckComponentStub, 'setNext'); fixture = TestBed.createComponent(CodelabClosingSlideComponent); component = fixture.componentInstance; fixture.detectChanges(); @@ -57,11 +58,7 @@ describe('CodelabClosingSlideComponent', () => { expect(component).toBeTruthy(); }); - it('should set previousLink', () => { - expect(slidesDeckComponentStub.previousLink).not.toBe(''); - }); - - it('should set nextLink', () => { - expect(slidesDeckComponentStub.nextLink).not.toBe(''); + it('should call setNextLink', () => { + expect(slidesDeckComponentStub.setNext).toHaveBeenCalled(); }); }); diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index fe78ae48b..9dd2f8fbc 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -18,13 +18,12 @@ export class CodelabClosingSlideComponent implements OnInit { private readonly presentation: SlidesDeckComponent, @Optional() @Inject(MENU_ROUTES) readonly menuRoutes ) { - if (this.presentation != null && this.menuRoutes != null) { + if (this.menuRoutes != null) { this.setupPreviousNext(); } } private setupPreviousNext() { - let previousLink = ''; let nextLink = ''; let allRoutes = this.menuRoutes.map(p => p.path); let currentUrl = this.router.url; @@ -34,14 +33,10 @@ export class CodelabClosingSlideComponent implements OnInit { const urlPaths = currentUrl.split('/'); if (urlPaths.length > 1) { const idx = allRoutes.indexOf(urlPaths[1]); - if (idx > 0) { - previousLink = `/${urlPaths[0]}/${allRoutes[idx - 1]}`; - } if (idx < allRoutes.length - 1) { nextLink = `/${urlPaths[0]}/${allRoutes[idx + 1]}`; } } - this.presentation.setPrevious(previousLink); this.presentation.setNext(nextLink); } diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts index 1382f1d87..467fab230 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts @@ -53,6 +53,7 @@ describe('TitleSlideComponent', () => { })); beforeEach(() => { + spyOn(slidesDeckComponentStub, 'setPrevious'); fixture = TestBed.createComponent(TitleSlideComponent); component = fixture.componentInstance; fixture.detectChanges(); @@ -62,12 +63,8 @@ describe('TitleSlideComponent', () => { expect(component).toBeTruthy(); }); - it('should set previousLink', () => { - expect(slidesDeckComponentStub.previousLink).not.toBe(''); - }); - - it('should set nextLink', () => { - expect(slidesDeckComponentStub.nextLink).not.toBe(''); + it('should call setPrevious', () => { + expect(slidesDeckComponentStub.setPrevious).toHaveBeenCalled(); }); it('should render a title', () => { diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index 1eea43e8f..628dbd608 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -25,7 +25,6 @@ export class TitleSlideComponent { private setupPreviousNext() { let previousLink = ''; - let nextLink = ''; let allRoutes = this.menuRoutes.map(p => p.path); let currentUrl = this.router.url; if (currentUrl.startsWith('/')) { @@ -37,11 +36,7 @@ export class TitleSlideComponent { if (idx > 0) { previousLink = `/${urlPaths[0]}/${allRoutes[idx - 1]}`; } - if (idx < allRoutes.length - 1) { - nextLink = `/${urlPaths[0]}/${allRoutes[idx + 1]}`; - } } this.presentation.setPrevious(previousLink); - this.presentation.setNext(nextLink); } } diff --git a/libs/slides/src/lib/arrows/slides-arrows.component.ts b/libs/slides/src/lib/arrows/slides-arrows.component.ts index 3f2d7f448..f028d2b6f 100644 --- a/libs/slides/src/lib/arrows/slides-arrows.component.ts +++ b/libs/slides/src/lib/arrows/slides-arrows.component.ts @@ -1,6 +1,5 @@ import { Component, HostBinding, Input } from '@angular/core'; import { SlidesDeckComponent } from '../deck/deck.component'; -import { Router } from '@angular/router'; /** * Slide arrows are used by slides deck for navigation. @@ -18,10 +17,7 @@ export class SlidesArrowsComponent { */ @HostBinding('class.shortcuts-context') context = true; - constructor( - private readonly router: Router, - private presentation: SlidesDeckComponent - ) {} + constructor(private presentation: SlidesDeckComponent) {} goToPreviousSlide() { this.presentation.previousSlide(); diff --git a/libs/slides/src/lib/deck/deck.component.ts b/libs/slides/src/lib/deck/deck.component.ts index c7b9abd52..60ec385a9 100644 --- a/libs/slides/src/lib/deck/deck.component.ts +++ b/libs/slides/src/lib/deck/deck.component.ts @@ -70,17 +70,11 @@ export class SlidesDeckComponent { } canGoNext(): boolean { - return ( - this.activeSlideIndex + 1 < this.slides.length || - (this.nextLink != null && this.nextLink !== '') - ); + return this.activeSlideIndex + 1 < this.slides.length || !!this.nextLink; } canGoPrevious(): boolean { - return ( - this.activeSlideIndex > 0 || - (this.previousLink != null && this.previousLink !== '') - ); + return this.activeSlideIndex > 0 || !!this.previousLink; } public setPrevious(previousLink) { From caeb0bc89ec93d5de13833c3a59755b8ab0b435a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Oct 2019 14:12:47 -0400 Subject: [PATCH 06/14] fixed linting errors --- .../closing-slide/codelab-closing-slide.component.spec.ts | 2 +- .../slides/closing-slide/codelab-closing-slide.component.ts | 2 +- .../components/slides/title-slide/title-slide.component.spec.ts | 2 +- .../app/components/slides/title-slide/title-slide.component.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts index cb3eb092a..464aa0b12 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts @@ -40,7 +40,7 @@ describe('CodelabClosingSlideComponent', () => { TestBed.configureTestingModule({ providers: [ { provide: Router, useValue: routerStub }, - { provide: SlidesDeckComponent, useFactory: ()=>{ return slidesDeckComponentStub; } }, + { provide: SlidesDeckComponent, useFactory: () => slidesDeckComponentStub }, { provide: MENU_ROUTES, useValue: menuRoutes } ], declarations: [CodelabClosingSlideComponent] diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index 9dd2f8fbc..1d8c2d481 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -25,7 +25,7 @@ export class CodelabClosingSlideComponent implements OnInit { private setupPreviousNext() { let nextLink = ''; - let allRoutes = this.menuRoutes.map(p => p.path); + const allRoutes = this.menuRoutes.map(p => p.path); let currentUrl = this.router.url; if (currentUrl.startsWith('/')) { currentUrl = currentUrl.substr(1); diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts index 467fab230..5648a483c 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts @@ -44,7 +44,7 @@ describe('TitleSlideComponent', () => { TestBed.configureTestingModule({ providers: [ { provide: Router, useValue: routerStub }, - { provide: SlidesDeckComponent, useFactory: () => { return slidesDeckComponentStub; } }, + { provide: SlidesDeckComponent, useFactory: () => slidesDeckComponentStub }, { provide: MENU_ROUTES, useValue: menuRoutes } ], imports: [RouterTestingModule], diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index 628dbd608..fe5cf0ad8 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -25,7 +25,7 @@ export class TitleSlideComponent { private setupPreviousNext() { let previousLink = ''; - let allRoutes = this.menuRoutes.map(p => p.path); + const allRoutes = this.menuRoutes.map(p => p.path); let currentUrl = this.router.url; if (currentUrl.startsWith('/')) { currentUrl = currentUrl.substr(1); From 60f6141f6ecba2fe397d4e3c202d0a43ae30fa3a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Oct 2019 08:36:38 -0400 Subject: [PATCH 07/14] Changed to createSpy in tests. Also changed some method names to more meaningful values --- .../codelab-closing-slide.component.spec.ts | 15 ++------------- .../codelab-closing-slide.component.ts | 6 +++--- .../title-slide/title-slide.component.spec.ts | 13 +------------ .../slides/title-slide/title-slide.component.ts | 6 +++--- 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts index 464aa0b12..669a94b41 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts @@ -14,20 +14,10 @@ describe('CodelabClosingSlideComponent', () => { const slidesDeckComponentStub = { previousLink: '', nextLink: '', - - setPrevious(link) { - this.previousLink = link; - }, - - setNext(link) { - this.nextLink = link; - } + setNext: jasmine.createSpy('setNext') }; const menuRoutes: MenuRoutes = [ - { - path: 'previouslesson' - }, { path: 'currentlesson' }, @@ -40,7 +30,7 @@ describe('CodelabClosingSlideComponent', () => { TestBed.configureTestingModule({ providers: [ { provide: Router, useValue: routerStub }, - { provide: SlidesDeckComponent, useFactory: () => slidesDeckComponentStub }, + { provide: SlidesDeckComponent, useValue: slidesDeckComponentStub }, { provide: MENU_ROUTES, useValue: menuRoutes } ], declarations: [CodelabClosingSlideComponent] @@ -48,7 +38,6 @@ describe('CodelabClosingSlideComponent', () => { })); beforeEach(() => { - spyOn(slidesDeckComponentStub, 'setNext'); fixture = TestBed.createComponent(CodelabClosingSlideComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index 1d8c2d481..4dcb53034 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -16,14 +16,14 @@ export class CodelabClosingSlideComponent implements OnInit { constructor( private readonly router: Router, private readonly presentation: SlidesDeckComponent, - @Optional() @Inject(MENU_ROUTES) readonly menuRoutes + @Inject(MENU_ROUTES) private readonly menuRoutes ) { if (this.menuRoutes != null) { - this.setupPreviousNext(); + this.setupNext(); } } - private setupPreviousNext() { + private setupNext() { let nextLink = ''; const allRoutes = this.menuRoutes.map(p => p.path); let currentUrl = this.router.url; diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts index 5648a483c..9727a2a98 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts @@ -18,14 +18,7 @@ describe('TitleSlideComponent', () => { const slidesDeckComponentStub = { previousLink: '', nextLink: '', - - setPrevious(link) { - this.previousLink = link; - }, - - setNext(link) { - this.nextLink = link; - } + setPrevious: jasmine.createSpy('setPrevious') }; const menuRoutes: MenuRoutes = [ @@ -34,9 +27,6 @@ describe('TitleSlideComponent', () => { }, { path: 'currentlesson' - }, - { - path: 'nextlesson' } ]; @@ -53,7 +43,6 @@ describe('TitleSlideComponent', () => { })); beforeEach(() => { - spyOn(slidesDeckComponentStub, 'setPrevious'); fixture = TestBed.createComponent(TitleSlideComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index fe5cf0ad8..b3a16b144 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -16,14 +16,14 @@ export class TitleSlideComponent { constructor( private readonly router: Router, private readonly presentation: SlidesDeckComponent, - @Optional() @Inject(MENU_ROUTES) readonly menuRoutes + @Inject(MENU_ROUTES) private readonly menuRoutes ) { if (this.presentation != null) { - this.setupPreviousNext(); + this.setupPrevious(); } } - private setupPreviousNext() { + private setupPrevious() { let previousLink = ''; const allRoutes = this.menuRoutes.map(p => p.path); let currentUrl = this.router.url; From 52958ef50a0879db4c8f3e3860ccc6d086fabb72 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Oct 2019 11:50:42 -0400 Subject: [PATCH 08/14] removed complicated code from title and closing slides --- apps/codelab/src/app/common.ts | 2 +- .../codelab-closing-slide.component.spec.ts | 20 ++++++++++++++--- .../codelab-closing-slide.component.ts | 22 ++++++++----------- .../title-slide/title-slide.component.spec.ts | 19 +++++++++++++--- .../title-slide/title-slide.component.ts | 22 ++++++++----------- libs/slides/src/lib/deck/deck.component.ts | 4 ++-- 6 files changed, 54 insertions(+), 35 deletions(-) diff --git a/apps/codelab/src/app/common.ts b/apps/codelab/src/app/common.ts index fe2d8a183..17f69241b 100644 --- a/apps/codelab/src/app/common.ts +++ b/apps/codelab/src/app/common.ts @@ -3,7 +3,7 @@ import { Route } from '@angular/router'; export type MenuRoutes = MenuRoute[]; -interface MenuRoute extends Route { +export interface MenuRoute extends Route { name?: string; description?: string; page?: string; diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts index 669a94b41..682d4255c 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts @@ -1,6 +1,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { CodelabClosingSlideComponent } from './codelab-closing-slide.component'; -import { Router } from '@angular/router'; +import { Router, ActivatedRoute } from '@angular/router'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; import { MENU_ROUTES, MenuRoutes } from '../../../common'; @@ -19,16 +19,30 @@ describe('CodelabClosingSlideComponent', () => { const menuRoutes: MenuRoutes = [ { - path: 'currentlesson' + path: 'currentlesson', + prod: true + }, { - path: 'nextlesson' + path: 'nextlesson', + prod: true } ]; + const activatedRouteStub = { + snapshot: { + pathFromRoot: [ + { + routeConfig: menuRoutes[0] + } + ] + } + }; + beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ + { provide: ActivatedRoute, useValue: activatedRouteStub }, { provide: Router, useValue: routerStub }, { provide: SlidesDeckComponent, useValue: slidesDeckComponentStub }, { provide: MENU_ROUTES, useValue: menuRoutes } diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index 4dcb53034..f88e4b1a0 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit, Inject, Optional } from '@angular/core'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; -import { MENU_ROUTES } from '../../../common'; -import { Router } from '@angular/router'; +import { MENU_ROUTES, MenuRoute } from '../../../common'; +import { Router, ActivatedRoute } from '@angular/router'; @Component({ selector: 'codelab-closing-slide', @@ -14,6 +14,7 @@ export class CodelabClosingSlideComponent implements OnInit { @Input() footer: String; constructor( + private readonly activeRoute: ActivatedRoute, private readonly router: Router, private readonly presentation: SlidesDeckComponent, @Inject(MENU_ROUTES) private readonly menuRoutes @@ -24,18 +25,13 @@ export class CodelabClosingSlideComponent implements OnInit { } private setupNext() { + const config = this.activeRoute.snapshot.pathFromRoot + .map(a => a.routeConfig) + .find(r => r && (r as MenuRoute).prod); + const index = this.menuRoutes.findIndex(c => c.path === config.path); let nextLink = ''; - const allRoutes = this.menuRoutes.map(p => p.path); - let currentUrl = this.router.url; - if (currentUrl.startsWith('/')) { - currentUrl = currentUrl.substr(1); - } - const urlPaths = currentUrl.split('/'); - if (urlPaths.length > 1) { - const idx = allRoutes.indexOf(urlPaths[1]); - if (idx < allRoutes.length - 1) { - nextLink = `/${urlPaths[0]}/${allRoutes[idx + 1]}`; - } + if (index < this.menuRoutes.length - 1) { + nextLink = '../../' + this.menuRoutes[index + 1].path; } this.presentation.setNext(nextLink); } diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts index 9727a2a98..7c3ffdfc4 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts @@ -5,7 +5,7 @@ import { By } from '@angular/platform-browser'; import { TitleSlideComponent } from './title-slide.component'; import { CodelabRippleAnimationComponent } from './ripple-animation/codelab-ripple-animation.component'; import { MenuRoutes, MENU_ROUTES } from '../../../common'; -import { Router } from '@angular/router'; +import { Router, ActivatedRoute } from '@angular/router'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; describe('TitleSlideComponent', () => { @@ -23,16 +23,29 @@ describe('TitleSlideComponent', () => { const menuRoutes: MenuRoutes = [ { - path: 'previouslesson' + path: 'previouslesson', + prod: true }, { - path: 'currentlesson' + path: 'currentlesson', + prod: true } ]; + const activatedRouteStub = { + snapshot: { + pathFromRoot: [ + { + routeConfig: menuRoutes[1] + } + ] + } + }; + beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ + { provide: ActivatedRoute, useValue: activatedRouteStub}, { provide: Router, useValue: routerStub }, { provide: SlidesDeckComponent, useFactory: () => slidesDeckComponentStub }, { provide: MENU_ROUTES, useValue: menuRoutes } diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index b3a16b144..4c434f4d9 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -1,7 +1,7 @@ import { Component, Input, Optional, Inject } from '@angular/core'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; -import { MENU_ROUTES } from '../../../common'; -import { Router } from '@angular/router'; +import { MENU_ROUTES, MenuRoutes, MenuRoute } from '../../../common'; +import { Router, ActivatedRoute } from '@angular/router'; @Component({ selector: 'codelab-title-slide', @@ -14,6 +14,7 @@ export class TitleSlideComponent { @Input() prereqs: string; constructor( + private readonly activeRoute: ActivatedRoute, private readonly router: Router, private readonly presentation: SlidesDeckComponent, @Inject(MENU_ROUTES) private readonly menuRoutes @@ -24,18 +25,13 @@ export class TitleSlideComponent { } private setupPrevious() { + const config = this.activeRoute.snapshot.pathFromRoot + .map(a => a.routeConfig) + .find((r) => r && (r as MenuRoute).prod); + const index = this.menuRoutes.findIndex(c => c.path === config.path); let previousLink = ''; - const allRoutes = this.menuRoutes.map(p => p.path); - let currentUrl = this.router.url; - if (currentUrl.startsWith('/')) { - currentUrl = currentUrl.substr(1); - } - const urlPaths = currentUrl.split('/'); - if (urlPaths.length > 1) { - const idx = allRoutes.indexOf(urlPaths[1]); - if (idx > 0) { - previousLink = `/${urlPaths[0]}/${allRoutes[idx - 1]}`; - } + if (index > 0) { + previousLink = '../../' + this.menuRoutes[index - 1].path; } this.presentation.setPrevious(previousLink); } diff --git a/libs/slides/src/lib/deck/deck.component.ts b/libs/slides/src/lib/deck/deck.component.ts index 60ec385a9..6b8167ece 100644 --- a/libs/slides/src/lib/deck/deck.component.ts +++ b/libs/slides/src/lib/deck/deck.component.ts @@ -57,7 +57,7 @@ export class SlidesDeckComponent { if (this.activeSlideIndex + 1 < this.slides.length) { this.goToSlide(this.activeSlideIndex + 1); } else if (this.nextLink) { - this.router.navigateByUrl(this.nextLink); + this.router.navigate([this.nextLink], { relativeTo: this.route }); } } @@ -65,7 +65,7 @@ export class SlidesDeckComponent { if (this.activeSlideIndex > 0) { this.goToSlide(this.activeSlideIndex - 1); } else if (this.previousLink) { - this.router.navigateByUrl(this.previousLink); + this.router.navigate([this.previousLink], {relativeTo: this.route}); } } From ef0f7d543e81fd4f47442ad353e9c4a5bd917ea5 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Nov 2019 19:49:33 -0500 Subject: [PATCH 09/14] added commit logs --- .../angular/menu-route.service.spec.ts | 58 +++++++++++++++++++ .../codelabs/angular/menu-route.service.ts | 27 ++++++--- .../codelab-closing-slide.component.spec.ts | 37 +++--------- .../codelab-closing-slide.component.ts | 5 +- .../title-slide/title-slide.component.spec.ts | 37 +++--------- .../title-slide/title-slide.component.ts | 11 +++- 6 files changed, 107 insertions(+), 68 deletions(-) create mode 100644 apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts diff --git a/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts b/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts new file mode 100644 index 000000000..e6b9e02c2 --- /dev/null +++ b/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts @@ -0,0 +1,58 @@ +import { TestBed } from '@angular/core/testing'; + +import { MenuRouteService } from './menu-route.service'; +import { ActivatedRoute } from '@angular/router'; +import { MENU_ROUTES, MenuRoutes } from '../../common'; + +describe('MenuRouteService', () => { + const menuRoutes: MenuRoutes = [ + { + path: 'previouslesson', + prod: true + }, + { + path: 'currentlesson', + prod: true + }, + { + path: 'nextlesson', + prod: true + } + ]; + + const activatedRouteStub = { + snapshot: { + pathFromRoot: [ + { + routeConfig: menuRoutes[1] + } + ] + } + }; + + beforeEach(() => + TestBed.configureTestingModule({ + providers: [ + { provide: ActivatedRoute, useValue: activatedRouteStub }, + { provide: MENU_ROUTES, useValue: menuRoutes } + ] + }) + ); + + it('should be created', () => { + const service: MenuRouteService = TestBed.inject(MenuRouteService); + expect(service).toBeTruthy(); + }); + + it('getPreviousLink should return previouslesson', () => { + const service: MenuRouteService = TestBed.inject(MenuRouteService); + const previousLink = service.getPreviousLink(); + expect(previousLink).toEqual(menuRoutes[0].path); + }); + + it('getNextLink should return nextlesson', () => { + const service: MenuRouteService = TestBed.inject(MenuRouteService); + const nextLink = service.getNextLink(); + expect(nextLink).toEqual(menuRoutes[2].path); + }); +}); diff --git a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts index 080679404..b175bc5b3 100644 --- a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts +++ b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts @@ -1,35 +1,46 @@ +import { Injectable, Inject } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { Inject } from '@angular/core'; import { MENU_ROUTES, MenuRoute } from '../../common'; +@Injectable({ + providedIn: 'root' +}) export class MenuRouteService { constructor( private readonly activeRoute: ActivatedRoute, @Inject(MENU_ROUTES) private readonly menuRoutes - ) {} + ) { + console.log('constructor', this.activeRoute); + } getPreviousLink(): string { const index = this.getCurrentIndex(); - let previousLink = ''; if (index > 0) { - previousLink = '../../' + this.menuRoutes[index - 1].path; + return this.menuRoutes[index - 1].path; } - return previousLink; + return ''; } getNextLink(): string { const index = this.getCurrentIndex(); - let nextLink = ''; if (index < this.menuRoutes.length - 1) { - nextLink = '../../' + this.menuRoutes[index + 1].path; + return this.menuRoutes[index + 1].path; } - return nextLink; + return ''; } private getCurrentIndex() { + const ck = this.activeRoute.snapshot.pathFromRoot.map(a => a.routeConfig); + + console.log('cks', ck); const config = this.activeRoute.snapshot.pathFromRoot .map(a => a.routeConfig) .find(r => r && (r as MenuRoute).prod); + console.log('menuroutes/config', this.menuRoutes, config, this.activeRoute); + if (config == null) { + console.log('return -1'); + return -1; + } const index = this.menuRoutes.findIndex(c => c.path === config.path); return index; } diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts index 6d59bd2ac..cd411b4b2 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts @@ -3,48 +3,27 @@ import { CodelabClosingSlideComponent } from './codelab-closing-slide.component' import { Router, ActivatedRoute } from '@angular/router'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; import { MENU_ROUTES, MenuRoutes } from '../../../common'; +import { MenuRouteService } from '../../../codelabs/angular/menu-route.service'; describe('CodelabClosingSlideComponent', () => { let component: CodelabClosingSlideComponent; let fixture: ComponentFixture; - const routerStub = { - url: '/ngtest/currentlesson' + + const menuRouteService = { + getNextLink: function() { + return 'nextlesson'; + } }; const slidesDeckComponentStub = { - previousLink: '', - nextLink: '', setNext: jasmine.createSpy('setNext') }; - const menuRoutes: MenuRoutes = [ - { - path: 'currentlesson', - prod: true - }, - { - path: 'nextlesson', - prod: true - } - ]; - - const activatedRouteStub = { - snapshot: { - pathFromRoot: [ - { - routeConfig: menuRoutes[0] - } - ] - } - }; - beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ - { provide: ActivatedRoute, useValue: activatedRouteStub }, - { provide: Router, useValue: routerStub }, - { provide: SlidesDeckComponent, useValue: slidesDeckComponentStub }, - { provide: MENU_ROUTES, useValue: menuRoutes } + { provide: MenuRouteService, useValue: menuRouteService }, + { provide: SlidesDeckComponent, useValue: slidesDeckComponentStub } ], declarations: [CodelabClosingSlideComponent] }).compileComponents(); diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index 49850c8b6..6996d7892 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -17,7 +17,10 @@ export class CodelabClosingSlideComponent implements OnInit { private readonly presentation: SlidesDeckComponent ) { if (this.presentation != null) { - const nextLink = this.menuRouteService.getPreviousLink(); + let nextLink = this.menuRouteService.getNextLink(); + if (nextLink) { + nextLink = '../../' + nextLink; + } this.presentation.setNext(nextLink); } } diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts index d5e286930..a1b1f29ca 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts @@ -4,15 +4,17 @@ import { By } from '@angular/platform-browser'; import { TitleSlideComponent } from './title-slide.component'; import { CodelabRippleAnimationComponent } from './ripple-animation/codelab-ripple-animation.component'; -import { MenuRoutes, MENU_ROUTES } from '../../../common'; -import { Router, ActivatedRoute } from '@angular/router'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; +import { MenuRouteService } from '../../../codelabs/angular/menu-route.service'; describe('TitleSlideComponent', () => { let component: TitleSlideComponent; let fixture: ComponentFixture; - const routerStub = { - url: '/ngtest/currentlesson' + + const menuRouteService = { + getPreviousLink: function() { + return 'previouslesson'; + } }; const slidesDeckComponentStub = { @@ -21,37 +23,14 @@ describe('TitleSlideComponent', () => { setPrevious: jasmine.createSpy('setPrevious') }; - const menuRoutes: MenuRoutes = [ - { - path: 'previouslesson', - prod: true - }, - { - path: 'currentlesson', - prod: true - } - ]; - - const activatedRouteStub = { - snapshot: { - pathFromRoot: [ - { - routeConfig: menuRoutes[1] - } - ] - } - }; - beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ - { provide: ActivatedRoute, useValue: activatedRouteStub }, - { provide: Router, useValue: routerStub }, + { provide: MenuRouteService, useValue: menuRouteService }, { provide: SlidesDeckComponent, useFactory: () => slidesDeckComponentStub - }, - { provide: MENU_ROUTES, useValue: menuRoutes } + } ], imports: [RouterTestingModule], declarations: [CodelabRippleAnimationComponent, TitleSlideComponent] diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index 026d5158c..4d09fd16b 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; import { MenuRouteService } from '../../../codelabs/angular/menu-route.service'; +import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'codelab-title-slide', @@ -13,11 +14,19 @@ export class TitleSlideComponent { @Input() prereqs: string; constructor( + private readonly activeRoute: ActivatedRoute, private readonly menuRouteService: MenuRouteService, private readonly presentation: SlidesDeckComponent ) { if (this.presentation != null) { - const previousLink = this.menuRouteService.getPreviousLink(); + console.log('title', this.activeRoute); + const ck = this.activeRoute.snapshot.pathFromRoot.map(a => a.routeConfig); + console.log('title ck', ck); + + let previousLink = this.menuRouteService.getPreviousLink(); + if (previousLink) { + previousLink = '../../' + previousLink; + } this.presentation.setPrevious(previousLink); } } From f524ec940ab0c1fd92dcb392bddc522cb7d7db20 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 24 Nov 2019 23:13:33 -0500 Subject: [PATCH 10/14] changed menu-route service to receive ActivatedRoute while getting next and previous links --- .../angular/menu-route.service.spec.ts | 9 +++---- .../codelabs/angular/menu-route.service.ts | 27 +++++++------------ .../codelab-closing-slide.component.ts | 4 ++- .../title-slide/title-slide.component.ts | 8 +++--- 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts b/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts index e6b9e02c2..456a373e5 100644 --- a/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts +++ b/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts @@ -32,10 +32,7 @@ describe('MenuRouteService', () => { beforeEach(() => TestBed.configureTestingModule({ - providers: [ - { provide: ActivatedRoute, useValue: activatedRouteStub }, - { provide: MENU_ROUTES, useValue: menuRoutes } - ] + providers: [{ provide: MENU_ROUTES, useValue: menuRoutes }] }) ); @@ -46,13 +43,13 @@ describe('MenuRouteService', () => { it('getPreviousLink should return previouslesson', () => { const service: MenuRouteService = TestBed.inject(MenuRouteService); - const previousLink = service.getPreviousLink(); + const previousLink = service.getPreviousLink(activatedRouteStub); expect(previousLink).toEqual(menuRoutes[0].path); }); it('getNextLink should return nextlesson', () => { const service: MenuRouteService = TestBed.inject(MenuRouteService); - const nextLink = service.getNextLink(); + const nextLink = service.getNextLink(activatedRouteStub); expect(nextLink).toEqual(menuRoutes[2].path); }); }); diff --git a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts index b175bc5b3..332e2bfc5 100644 --- a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts +++ b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts @@ -1,44 +1,35 @@ import { Injectable, Inject } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { MENU_ROUTES, MenuRoute } from '../../common'; @Injectable({ providedIn: 'root' }) export class MenuRouteService { - constructor( - private readonly activeRoute: ActivatedRoute, - @Inject(MENU_ROUTES) private readonly menuRoutes - ) { - console.log('constructor', this.activeRoute); - } + constructor(@Inject(MENU_ROUTES) private readonly menuRoutes) {} - getPreviousLink(): string { - const index = this.getCurrentIndex(); + getPreviousLink(activeRoute: ActivatedRoute): string { + const index = this.getCurrentIndex(activeRoute); if (index > 0) { return this.menuRoutes[index - 1].path; } return ''; } - getNextLink(): string { - const index = this.getCurrentIndex(); + getNextLink(activeRoute: ActivatedRoute): string { + const index = this.getCurrentIndex(activeRoute); if (index < this.menuRoutes.length - 1) { return this.menuRoutes[index + 1].path; } return ''; } - private getCurrentIndex() { - const ck = this.activeRoute.snapshot.pathFromRoot.map(a => a.routeConfig); - - console.log('cks', ck); - const config = this.activeRoute.snapshot.pathFromRoot + private getCurrentIndex(activeRoute: ActivatedRoute) { + // TODO: inject ActivatedRoute but figure out a way to fix snapshot update issue + const config = activeRoute.snapshot.pathFromRoot .map(a => a.routeConfig) .find(r => r && (r as MenuRoute).prod); - console.log('menuroutes/config', this.menuRoutes, config, this.activeRoute); if (config == null) { - console.log('return -1'); return -1; } const index = this.menuRoutes.findIndex(c => c.path === config.path); diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index 6996d7892..b3258f561 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -1,6 +1,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; import { MenuRouteService } from '../../../codelabs/angular/menu-route.service'; +import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'codelab-closing-slide', @@ -13,11 +14,12 @@ export class CodelabClosingSlideComponent implements OnInit { @Input() footer: String; constructor( + private readonly activeRoute: ActivatedRoute, private readonly menuRouteService: MenuRouteService, private readonly presentation: SlidesDeckComponent ) { if (this.presentation != null) { - let nextLink = this.menuRouteService.getNextLink(); + let nextLink = this.menuRouteService.getNextLink(this.activeRoute); if (nextLink) { nextLink = '../../' + nextLink; } diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index 4d09fd16b..2feb7945a 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -19,11 +19,9 @@ export class TitleSlideComponent { private readonly presentation: SlidesDeckComponent ) { if (this.presentation != null) { - console.log('title', this.activeRoute); - const ck = this.activeRoute.snapshot.pathFromRoot.map(a => a.routeConfig); - console.log('title ck', ck); - - let previousLink = this.menuRouteService.getPreviousLink(); + let previousLink = this.menuRouteService.getPreviousLink( + this.activeRoute + ); if (previousLink) { previousLink = '../../' + previousLink; } From 65c64031bb5f6cb0967d4b2d966b2940934cc70a Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 24 Nov 2019 23:52:54 -0500 Subject: [PATCH 11/14] fixed tests for menu-route.service.ts --- .../angular/menu-route.service.spec.ts | 2 +- .../codelab-closing-slide.component.spec.ts | 28 +++++++++++++++---- .../title-slide/title-slide.component.spec.ts | 28 +++++++++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts b/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts index 456a373e5..a8e9f3175 100644 --- a/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts +++ b/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts @@ -28,7 +28,7 @@ describe('MenuRouteService', () => { } ] } - }; + } as ActivatedRoute; beforeEach(() => TestBed.configureTestingModule({ diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts index cd411b4b2..c01e7e3d2 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.spec.ts @@ -1,8 +1,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { CodelabClosingSlideComponent } from './codelab-closing-slide.component'; -import { Router, ActivatedRoute } from '@angular/router'; +import { ActivatedRoute } from '@angular/router'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; -import { MENU_ROUTES, MenuRoutes } from '../../../common'; +import { MenuRoutes } from '../../../common'; import { MenuRouteService } from '../../../codelabs/angular/menu-route.service'; describe('CodelabClosingSlideComponent', () => { @@ -19,9 +19,29 @@ describe('CodelabClosingSlideComponent', () => { setNext: jasmine.createSpy('setNext') }; + const menuRoutes: MenuRoutes = [ + { + path: 'previouslesson', + prod: true + }, + { + path: 'currentlesson', + prod: true + }, + { + path: 'nextlesson', + prod: true + } + ]; + + const activatedRouteStub = { + snapshot: { pathFromRoot: [{ routeConfig: menuRoutes[1] }] } + }; + beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ + { provide: ActivatedRoute, useValue: activatedRouteStub }, { provide: MenuRouteService, useValue: menuRouteService }, { provide: SlidesDeckComponent, useValue: slidesDeckComponentStub } ], @@ -38,8 +58,4 @@ describe('CodelabClosingSlideComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); - - it('should call setNextLink', () => { - expect(slidesDeckComponentStub.setNext).toHaveBeenCalled(); - }); }); diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts index a1b1f29ca..43145b025 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.spec.ts @@ -6,6 +6,8 @@ import { TitleSlideComponent } from './title-slide.component'; import { CodelabRippleAnimationComponent } from './ripple-animation/codelab-ripple-animation.component'; import { SlidesDeckComponent } from '@codelab/slides/src/lib/deck/deck.component'; import { MenuRouteService } from '../../../codelabs/angular/menu-route.service'; +import { MenuRoutes } from '../../../common'; +import { ActivatedRoute } from '@angular/router'; describe('TitleSlideComponent', () => { let component: TitleSlideComponent; @@ -23,9 +25,35 @@ describe('TitleSlideComponent', () => { setPrevious: jasmine.createSpy('setPrevious') }; + const menuRoutes: MenuRoutes = [ + { + path: 'previouslesson', + prod: true + }, + { + path: 'currentlesson', + prod: true + }, + { + path: 'nextlesson', + prod: true + } + ]; + + const activatedRouteStub = { + snapshot: { + pathFromRoot: [ + { + routeConfig: menuRoutes[1] + } + ] + } + }; + beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ + { provide: ActivatedRoute, useValue: activatedRouteStub }, { provide: MenuRouteService, useValue: menuRouteService }, { provide: SlidesDeckComponent, From f5acd633c4fc870410c2a98c019042f669dc4bb3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Dec 2019 11:51:58 -0500 Subject: [PATCH 12/14] added more details to TODO action. moved redundant code into functions --- .../angular/menu-route.service.spec.ts | 4 +-- .../codelabs/angular/menu-route.service.ts | 33 ++++++++++++++++--- .../codelab-closing-slide.component.ts | 5 +-- .../title-slide/title-slide.component.ts | 5 +-- libs/slides/src/lib/deck/deck.component.ts | 12 ++++--- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts b/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts index a8e9f3175..50d2c7dce 100644 --- a/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts +++ b/apps/codelab/src/app/codelabs/angular/menu-route.service.spec.ts @@ -44,12 +44,12 @@ describe('MenuRouteService', () => { it('getPreviousLink should return previouslesson', () => { const service: MenuRouteService = TestBed.inject(MenuRouteService); const previousLink = service.getPreviousLink(activatedRouteStub); - expect(previousLink).toEqual(menuRoutes[0].path); + expect(previousLink).toEqual('../../' + menuRoutes[0].path); }); it('getNextLink should return nextlesson', () => { const service: MenuRouteService = TestBed.inject(MenuRouteService); const nextLink = service.getNextLink(activatedRouteStub); - expect(nextLink).toEqual(menuRoutes[2].path); + expect(nextLink).toEqual('../../' + menuRoutes[2].path); }); }); diff --git a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts index 332e2bfc5..3ce52643e 100644 --- a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts +++ b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts @@ -11,7 +11,7 @@ export class MenuRouteService { getPreviousLink(activeRoute: ActivatedRoute): string { const index = this.getCurrentIndex(activeRoute); if (index > 0) { - return this.menuRoutes[index - 1].path; + return this.getMenuRoutePathByIndex(index - 1); } return ''; } @@ -19,13 +19,19 @@ export class MenuRouteService { getNextLink(activeRoute: ActivatedRoute): string { const index = this.getCurrentIndex(activeRoute); if (index < this.menuRoutes.length - 1) { - return this.menuRoutes[index + 1].path; + return this.getMenuRoutePathByIndex(index + 1); } return ''; } - private getCurrentIndex(activeRoute: ActivatedRoute) { - // TODO: inject ActivatedRoute but figure out a way to fix snapshot update issue + private getCurrentIndex(activeRoute: ActivatedRoute): number { + // TODO: figure out a way to inject the ActivatedRoute instead of parameter + // This method gets the index of the current menuRoute. Ideally we should be able + // to inject in the ActivatedRoute in the constructor. However we noticed that + // probably because this is a service, activatedRoute has the value when the + // service is constructed and not the current activated route. We are using a + // workaround now which expects the calling method to pass the current activated + // route. Fix this to use DI. const config = activeRoute.snapshot.pathFromRoot .map(a => a.routeConfig) .find(r => r && (r as MenuRoute).prod); @@ -35,4 +41,23 @@ export class MenuRouteService { const index = this.menuRoutes.findIndex(c => c.path === config.path); return index; } + + private getMenuRouteByIndex(index: number) { + if (index >= 0 && index < this.menuRoutes.length) { + return this.menuRoutes[index]; + } + return null; + } + + private getMenuRoutePathByIndex(index: number): string { + const indexRoute = this.getMenuRouteByIndex(index); + if (indexRoute != null) { + let path = indexRoute.path; + if (path) { + path = '../../' + path; + } + return path; + } + return ''; + } } diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index b3258f561..afa5841b5 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -19,10 +19,7 @@ export class CodelabClosingSlideComponent implements OnInit { private readonly presentation: SlidesDeckComponent ) { if (this.presentation != null) { - let nextLink = this.menuRouteService.getNextLink(this.activeRoute); - if (nextLink) { - nextLink = '../../' + nextLink; - } + const nextLink = this.menuRouteService.getNextLink(this.activeRoute); this.presentation.setNext(nextLink); } } diff --git a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts index 2feb7945a..fc06ca9a5 100644 --- a/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts +++ b/apps/codelab/src/app/components/slides/title-slide/title-slide.component.ts @@ -19,12 +19,9 @@ export class TitleSlideComponent { private readonly presentation: SlidesDeckComponent ) { if (this.presentation != null) { - let previousLink = this.menuRouteService.getPreviousLink( + const previousLink = this.menuRouteService.getPreviousLink( this.activeRoute ); - if (previousLink) { - previousLink = '../../' + previousLink; - } this.presentation.setPrevious(previousLink); } } diff --git a/libs/slides/src/lib/deck/deck.component.ts b/libs/slides/src/lib/deck/deck.component.ts index e4275e430..68b1118f6 100644 --- a/libs/slides/src/lib/deck/deck.component.ts +++ b/libs/slides/src/lib/deck/deck.component.ts @@ -33,10 +33,10 @@ export class SlidesDeckComponent { constructor( private readonly cdr: ChangeDetectorRef, private readonly router: Router, - @Optional() private readonly route: ActivatedRoute + @Optional() private readonly activeRoute: ActivatedRoute ) { - if (route) { - this.milestone = route.snapshot.queryParams.milestone; + if (activeRoute) { + this.milestone = activeRoute.snapshot.queryParams.milestone; this.hasMilestone = !!this.milestone; } } @@ -57,7 +57,7 @@ export class SlidesDeckComponent { if (this.activeSlideIndex + 1 < this.slides.length) { this.goToSlide(this.activeSlideIndex + 1); } else if (this.nextLink) { - this.router.navigate([this.nextLink], { relativeTo: this.route }); + this.router.navigate([this.nextLink], { relativeTo: this.activeRoute }); } } @@ -65,7 +65,9 @@ export class SlidesDeckComponent { if (this.activeSlideIndex > 0) { this.goToSlide(this.activeSlideIndex - 1); } else if (this.previousLink) { - this.router.navigate([this.previousLink], { relativeTo: this.route }); + this.router.navigate([this.previousLink], { + relativeTo: this.activeRoute + }); } } From 5bde57bbfb8ffda0522ab5f7ae4287f726f2b17c Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Dec 2019 20:39:34 -0500 Subject: [PATCH 13/14] switched variables to direct returns. also removed an unecessary if condition --- .../src/app/codelabs/angular/menu-route.service.ts | 11 +++++------ .../closing-slide/codelab-closing-slide.component.ts | 4 +--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts index 3ce52643e..93ffb7ee4 100644 --- a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts +++ b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts @@ -38,15 +38,11 @@ export class MenuRouteService { if (config == null) { return -1; } - const index = this.menuRoutes.findIndex(c => c.path === config.path); - return index; + return this.menuRoutes.findIndex(c => c.path === config.path); } private getMenuRouteByIndex(index: number) { - if (index >= 0 && index < this.menuRoutes.length) { - return this.menuRoutes[index]; - } - return null; + return this.menuRoutes[index]; } private getMenuRoutePathByIndex(index: number): string { @@ -54,6 +50,9 @@ export class MenuRouteService { if (indexRoute != null) { let path = indexRoute.path; if (path) { + // TODO: This is a temporary work around. We need to + // make this more generic by using activatedRoute + // to figure out the current url. path = '../../' + path; } return path; diff --git a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts index afa5841b5..9df71f74d 100644 --- a/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts +++ b/apps/codelab/src/app/components/slides/closing-slide/codelab-closing-slide.component.ts @@ -8,7 +8,7 @@ import { ActivatedRoute } from '@angular/router'; templateUrl: './codelab-closing-slide.component.html', styleUrls: ['./codelab-closing-slide.component.css'] }) -export class CodelabClosingSlideComponent implements OnInit { +export class CodelabClosingSlideComponent { @Input() header: String; @Input() body: String; @Input() footer: String; @@ -23,6 +23,4 @@ export class CodelabClosingSlideComponent implements OnInit { this.presentation.setNext(nextLink); } } - - ngOnInit() {} } From 154b746bc968b1b86c1ffd8e07ec5e11cacc91d8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Dec 2019 21:09:26 -0500 Subject: [PATCH 14/14] removed a wrong TODO --- apps/codelab/src/app/codelabs/angular/menu-route.service.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts index 93ffb7ee4..bd3b87cd5 100644 --- a/apps/codelab/src/app/codelabs/angular/menu-route.service.ts +++ b/apps/codelab/src/app/codelabs/angular/menu-route.service.ts @@ -50,9 +50,6 @@ export class MenuRouteService { if (indexRoute != null) { let path = indexRoute.path; if (path) { - // TODO: This is a temporary work around. We need to - // make this more generic by using activatedRoute - // to figure out the current url. path = '../../' + path; } return path;