diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/package.json b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/package.json
index 17a82327..859d5f89 100755
--- a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/package.json
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/package.json
@@ -17,12 +17,13 @@
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/router": "~3.4.0",
+ "angular-in-memory-web-api": "^0.2.4",
"core-js": "~2.4.1",
+ "ng2-toastr": "~1.3.6",
+ "primeng": "~1.0.1",
"reflect-metadata": "~0.1.3",
"rxjs": "5.0.1",
- "zone.js": "~0.7.2",
- "ng2-toastr": "~1.3.6",
- "primeng": "~1.0.1"
+ "zone.js": "~0.7.2"
},
"devDependencies": {
"@angular/compiler-cli": "~2.4.0",
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/public/css/styles.css b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/public/css/styles.css
new file mode 100644
index 00000000..536b27ff
--- /dev/null
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/public/css/styles.css
@@ -0,0 +1,129 @@
+/* Master Styles */
+h1 {
+ color: #369;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 250%;
+}
+
+h2, h3 {
+ color: #444;
+ font-family: Arial, Helvetica, sans-serif;
+ font-weight: lighter;
+}
+
+body {
+ margin: 2em;
+}
+
+body, input[text], button {
+ color: #888;
+ font-family: Cambria, Georgia;
+}
+
+a {
+ cursor: pointer;
+ cursor: hand;
+}
+
+button {
+ font-family: Arial;
+ background-color: #eee;
+ border: none;
+ padding: 5px 10px;
+ border-radius: 4px;
+ cursor: pointer;
+ cursor: hand;
+}
+
+button:hover {
+ background-color: #cfd8dc;
+}
+
+button:disabled {
+ background-color: #eee;
+ color: #aaa;
+ cursor: auto;
+}
+
+/* Navigation link styles */
+nav a {
+ padding: 5px 10px;
+ text-decoration: none;
+ margin-right: 10px;
+ margin-top: 10px;
+ display: inline-block;
+ background-color: #eee;
+ border-radius: 4px;
+}
+
+nav a:visited, a:link {
+ color: #607D8B;
+}
+
+nav a:hover {
+ color: #039be5;
+ background-color: #CFD8DC;
+}
+
+nav a.active {
+ color: #039be5;
+}
+
+/* items class */
+.items {
+ margin: 0 0 2em 0;
+ list-style-type: none;
+ padding: 0;
+ width: 24em;
+}
+
+.items li {
+ cursor: pointer;
+ position: relative;
+ left: 0;
+ background-color: #EEE;
+ margin: .5em;
+ padding: .3em 0;
+ height: 1.6em;
+ border-radius: 4px;
+}
+
+.items li:hover {
+ color: #607D8B;
+ background-color: #DDD;
+ left: .1em;
+}
+
+.items li.selected {
+ background-color: #CFD8DC;
+ color: white;
+}
+
+.items li.selected:hover {
+ background-color: #BBD8DC;
+}
+
+.items .text {
+ position: relative;
+ top: -3px;
+}
+
+.items .badge {
+ display: inline-block;
+ font-size: small;
+ color: white;
+ padding: 0.8em 0.7em 0 0.7em;
+ background-color: #607D8B;
+ line-height: 1em;
+ position: relative;
+ left: -1px;
+ top: -4px;
+ height: 1.8em;
+ margin-right: .8em;
+ border-radius: 4px 0 0 4px;
+}
+
+/* everywhere else */
+* {
+ font-family: Arial, Helvetica, sans-serif;
+}
\ No newline at end of file
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app-routing.module.ts b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app-routing.module.ts
new file mode 100644
index 00000000..d311b057
--- /dev/null
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app-routing.module.ts
@@ -0,0 +1,22 @@
+import { NgModule } from '@angular/core';
+import { RouterModule, Routes } from '@angular/router';
+
+import { DashboardComponent } from './components/dashboard/dashboard.component';
+import { HeroesComponent } from './components/heroes/heroes.component';
+import { HeroDetailComponent } from './components/hero-detail/hero-detail.component';
+import { HeroEditComponent } from './components/hero-edit/hero-edit.component';
+
+const routes: Routes = [
+ { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
+ { path: 'dashboard', component: DashboardComponent },
+ { path: 'detail/:id', component: HeroDetailComponent },
+ { path: 'edit/:id', component: HeroEditComponent },
+ { path: 'heroes', component: HeroesComponent }
+];
+
+@NgModule({
+ imports: [ RouterModule.forRoot(routes) ],
+ exports: [ RouterModule ]
+})
+
+export class AppRoutingModule {}
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.html b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.html
index 3d1db8f3..88d6c2d3 100755
--- a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.html
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.html
@@ -1,12 +1,6 @@
-
My Heroes
-
-
- -
- {{hero.id}}
- {{hero.name}}
- mode_edit
-
-
-
-
-
+{{title}}
+
+
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.scss b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.scss
index 05c62b89..0ec3bd1d 100644
--- a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.scss
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.scss
@@ -1,61 +1,33 @@
-.selected {
- background-color: #CFD8DC !important;
- color: white;
+h1 {
+ font-size: 1.2em;
+ color: #999;
+ margin-bottom: 0;
}
-.heroes {
- margin: 0 0 2em 0;
- list-style-type: none;
- padding: 0;
- width: 15em;
-
- li {
- cursor: pointer;
- position: relative;
- left: 0;
- background-color: #EEE;
- margin: .5em;
- padding: .3em 0;
- height: 1.6em;
- border-radius: 4px;
-
- &.selected:hover {
- background-color: #BBD8DC !important;
- color: white;
- }
+h2 {
+ font-size: 2em;
+ margin-top: 0;
+ padding-top: 0;
+}
- &:hover {
- color: #607D8B;
- background-color: #DDD;
- left: .1em;
- }
+nav a {
+ padding: 5px 10px;
+ text-decoration: none;
+ margin-top: 10px;
+ display: inline-block;
+ background-color: #eee;
+ border-radius: 4px;
- i {
- position: absolute;
- right: 6px;
- color: darkgrey;
- border-left: 1px solid;
- padding-left: 5px;
- }
+ &:visited, &:link {
+ color: #607D8B;
}
- .text {
- position: relative;
- top: -3px;
+ &:hover {
+ color: #039be5;
+ background-color: #CFD8DC;
}
- .badge {
- display: inline-block;
- font-size: small;
- color: white;
- padding: 0.8em 0.7em 0 0.7em;
- background-color: #607D8B;
- line-height: 1em;
- position: relative;
- left: -1px;
- top: -4px;
- height: 1.8em;
- margin-right: .8em;
- border-radius: 4px 0 0 4px;
+ &.active {
+ color: #039be5;
}
-}
+}
\ No newline at end of file
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.ts b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.ts
old mode 100755
new mode 100644
index 58607b9b..f79306a8
--- a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.ts
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.component.ts
@@ -1,41 +1,11 @@
-import { Component, OnInit } from '@angular/core';
-
-import { Hero } from './shared/hero';
-import { HeroService } from './services/hero.service';
+import { Component } from '@angular/core';
@Component({
- selector: 'hero-app',
+ selector: 'my-app',
templateUrl: 'app.component.html',
- styleUrls: ['app.component.scss'],
+ styleUrls: ['app.component.scss']
})
-export class AppComponent implements OnInit {
- heroes: Hero[];
- selectedHero: Hero;
- editHero: Hero;
-
- constructor(private heroService: HeroService) {}
-
- getHeroes(): void {
- this.heroes = this.heroService.getHeroes();
- }
-
- ngOnInit(): void {
- this.getHeroes();
- }
-
- onSelect(hero: Hero): void {
- this.editHero = null;
- this.selectedHero = hero;
- }
-
- onEdit(hero: Hero): void {
- this.selectedHero = null;
- this.editHero = hero;
- }
-
- clear() {
- this.selectedHero = null;
- this.editHero = null;
- }
+export class AppComponent {
+ title = 'Tour of Heroes';
}
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.module.ts b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.module.ts
index ac6c6d01..60cbcc13 100755
--- a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.module.ts
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/app.module.ts
@@ -1,22 +1,37 @@
-import { NgModule } from '@angular/core';
-import { BrowserModule } from '@angular/platform-browser';
-import { FormsModule } from '@angular/forms';
+import { NgModule } from '@angular/core';
+import { BrowserModule } from '@angular/platform-browser';
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
+import { AppRoutingModule } from './app-routing.module';
+import { HttpModule } from '@angular/http';
-import { AppComponent } from './app.component';
-import { HeroDetailComponent } from './components/hero-detail/hero-detail.component';
-import { HeroEditComponent } from './components/hero-edit/hero-edit.component';
+import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
+import { InMemoryDataService } from './in-memory-data.service';
+
+import { AppComponent } from './app.component';
+import { HeroesComponent } from './components/heroes/heroes.component';
+import { HeroDetailComponent } from './components/hero-detail/hero-detail.component';
+import { HeroEditComponent } from './components/hero-edit/hero-edit.component';
+import { DashboardComponent } from './components/dashboard/dashboard.component';
+import { HeroSearchComponent } from './components/hero-search/hero-search.component';
import { HeroService } from './services/hero.service';
@NgModule({
declarations: [
AppComponent,
+ HeroesComponent,
HeroDetailComponent,
- HeroEditComponent
+ HeroEditComponent,
+ DashboardComponent,
+ HeroSearchComponent
],
imports: [
BrowserModule,
- FormsModule
+ FormsModule,
+ HttpModule,
+ InMemoryWebApiModule.forRoot(InMemoryDataService),
+ AppRoutingModule,
+ ReactiveFormsModule
],
bootstrap: [
AppComponent
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/dashboard/dashboard.component.html b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/dashboard/dashboard.component.html
new file mode 100644
index 00000000..56bf2804
--- /dev/null
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/dashboard/dashboard.component.html
@@ -0,0 +1,10 @@
+Top Heroes
+
+
+
\ No newline at end of file
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/dashboard/dashboard.component.scss b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/dashboard/dashboard.component.scss
new file mode 100644
index 00000000..d8029a7c
--- /dev/null
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/dashboard/dashboard.component.scss
@@ -0,0 +1,76 @@
+[class*='col-'] {
+ float: left;
+ padding-right: 20px;
+ padding-bottom: 20px;
+}
+
+[class*='col-']:last-of-type {
+ padding-right: 0;
+}
+
+a {
+ text-decoration: none;
+}
+
+*, *:after, *:before {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+h3 {
+ text-align: center;
+ margin-bottom: 0;
+}
+
+h4 {
+ position: relative;
+}
+
+.grid {
+ margin: 0;
+}
+
+.col-1-4 {
+ width: 25%;
+}
+
+.module {
+ padding: 20px;
+ text-align: center;
+ color: #eee;
+ max-height: 120px;
+ min-width: 120px;
+ background-color: #607D8B;
+ border-radius: 2px;
+
+ &:hover {
+ background-color: #EEE;
+ cursor: pointer;
+ color: #607d8b;
+ }
+}
+
+.grid-pad {
+ padding: 10px 0;
+}
+
+.grid-pad > [class*='col-']:last-of-type {
+ padding-right: 20px;
+}
+
+@media (max-width: 600px) {
+ .module {
+ font-size: 10px;
+ max-height: 75px;
+ }
+}
+
+@media (max-width: 1024px) {
+ .grid {
+ margin: 0;
+ }
+ .module {
+ min-width: 60px;
+ }
+}
\ No newline at end of file
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/dashboard/dashboard.component.ts b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/dashboard/dashboard.component.ts
new file mode 100644
index 00000000..b6fb4519
--- /dev/null
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/dashboard/dashboard.component.ts
@@ -0,0 +1,22 @@
+import { Component, OnInit } from '@angular/core';
+
+import { Hero } from '../../shared/hero';
+import { HeroService } from '../../services/hero.service';
+
+@Component({
+ selector: 'my-dashboard',
+ templateUrl: 'dashboard.component.html',
+ styleUrls: ['dashboard.component.scss']
+})
+
+export class DashboardComponent implements OnInit {
+ heroes: Hero[] = [];
+
+ constructor(private heroService: HeroService) {
+ }
+
+ ngOnInit(): void {
+ this.heroService.getHeroes()
+ .then(heroes => this.heroes = heroes.slice(1, 5));
+ }
+}
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.html b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.html
index 4e2898de..b9f0338d 100644
--- a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.html
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.html
@@ -3,4 +3,7 @@ {{hero.name}} details!
{{hero.id}}
{{hero.name}}
+
+
+
\ No newline at end of file
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.scss b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.scss
index 9e645ba2..25bcc263 100644
--- a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.scss
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.scss
@@ -1,8 +1,39 @@
label {
+ display: inline-block;
+ width: 3em;
+ margin: .5em 0;
+ color: #607D8B;
font-weight: bold;
}
+input {
+ height: 2em;
+ font-size: 1em;
+ padding-left: .4em;
+}
+
+button {
+ margin-top: 20px;
+ font-family: Arial, sans-serif;
+ background-color: #eee;
+ border: none;
+ padding: 5px 10px;
+ border-radius: 4px;
+ cursor: pointer;
+
+ &:hover {
+ background-color: #cfd8dc;
+ }
+
+ &:disabled {
+ background-color: #eee;
+ color: #ccc;
+ cursor: auto;
+ }
+}
+
img {
+ display: block;
width: 100px;
height: auto;
}
\ No newline at end of file
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.ts b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.ts
index 53b01eef..06a16169 100644
--- a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.ts
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-detail/hero-detail.component.ts
@@ -1,6 +1,11 @@
-import { Component, Input } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
+import { Router, ActivatedRoute, Params } from '@angular/router';
+import { Location } from '@angular/common';
-import { Hero } from '../../shared/hero';
+import { Hero } from '../../shared/hero';
+import { HeroService } from '../../services/hero.service';
+
+import 'rxjs/add/operator/switchMap';
@Component({
selector: 'hero-detail',
@@ -8,6 +13,26 @@ import { Hero } from '../../shared/hero';
styleUrls: ['hero-detail.component.scss']
})
-export class HeroDetailComponent {
- @Input() hero: Hero;
+export class HeroDetailComponent implements OnInit {
+ hero: Hero;
+
+ constructor(private router: Router,
+ private heroService: HeroService,
+ private route: ActivatedRoute,
+ private location: Location) {
+ }
+
+ ngOnInit(): void {
+ this.route.params
+ .switchMap((params: Params) => this.heroService.getHero(+params['id']))
+ .subscribe(hero => this.hero = hero);
+ }
+
+ gotoEdit(): void {
+ this.router.navigate(['/edit', this.hero.id]);
+ }
+
+ goBack(): void {
+ this.location.back();
+ }
}
diff --git a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-edit/hero-edit.component.html b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-edit/hero-edit.component.html
index a171e8f1..bd8cb8a1 100644
--- a/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-edit/hero-edit.component.html
+++ b/homeworks/ihor.tkachuk_ihortkachuk/homework_10/src/app/components/hero-edit/hero-edit.component.html
@@ -1,16 +1,15 @@
-