From b9bcc262583d3407f0817213424a402ed24f73e0 Mon Sep 17 00:00:00 2001 From: "Maxence G. de Montauzan" Date: Sun, 1 Oct 2017 02:38:30 +0200 Subject: [PATCH] Remove unused hero part --- dashboard/src/app/app-routing.module.ts | 4 -- dashboard/src/app/app.module.ts | 6 -- dashboard/src/app/dashboard.component.ts | 2 - dashboard/src/app/hero-detail.component.css | 33 ---------- dashboard/src/app/hero-detail.component.html | 11 ---- dashboard/src/app/hero-detail.component.ts | 37 ----------- dashboard/src/app/hero.service.ts | 57 ----------------- dashboard/src/app/hero.ts | 4 -- dashboard/src/app/heroes.component.css | 61 ------------------ dashboard/src/app/heroes.component.html | 20 ------ dashboard/src/app/heroes.component.ts | 65 -------------------- dashboard/src/app/in-memory-data.service.ts | 19 ------ 12 files changed, 319 deletions(-) delete mode 100644 dashboard/src/app/hero-detail.component.css delete mode 100644 dashboard/src/app/hero-detail.component.html delete mode 100644 dashboard/src/app/hero-detail.component.ts delete mode 100644 dashboard/src/app/hero.service.ts delete mode 100644 dashboard/src/app/hero.ts delete mode 100644 dashboard/src/app/heroes.component.css delete mode 100644 dashboard/src/app/heroes.component.html delete mode 100644 dashboard/src/app/heroes.component.ts delete mode 100644 dashboard/src/app/in-memory-data.service.ts diff --git a/dashboard/src/app/app-routing.module.ts b/dashboard/src/app/app-routing.module.ts index 73e2f3f..ae61ab8 100644 --- a/dashboard/src/app/app-routing.module.ts +++ b/dashboard/src/app/app-routing.module.ts @@ -4,14 +4,10 @@ import { RouterModule, Routes } from '@angular/router'; import { DashboardComponent } from './dashboard.component'; import { AlbumComponent } from './album.component'; import { ArtistComponent } from './artist.component'; -import { HeroesComponent } from './heroes.component'; -import { HeroDetailComponent } from './hero-detail.component'; const routes: Routes = [ { path: '', redirectTo: '/dashboard', pathMatch: 'full' }, { path: 'dashboard', component: DashboardComponent }, - { path: 'detail/:id', component: HeroDetailComponent }, - { path: 'heroes', component: HeroesComponent }, { path: 'album/:name', component: AlbumComponent }, { path: 'artist/:name', component: ArtistComponent } ]; diff --git a/dashboard/src/app/app.module.ts b/dashboard/src/app/app.module.ts index fb87a3a..e84b0db 100644 --- a/dashboard/src/app/app.module.ts +++ b/dashboard/src/app/app.module.ts @@ -8,12 +8,9 @@ import { HttpModule } from '@angular/http'; // import { InMemoryDataService } from './in-memory-data.service'; import { AppComponent } from './app.component'; -import { HeroDetailComponent } from './hero-detail.component'; -import { HeroesComponent } from './heroes.component'; import { DashboardComponent } from './dashboard.component'; import { AlbumComponent } from './album.component'; import { ArtistComponent } from './artist.component'; -import { HeroService } from './hero.service'; import { ElsService } from './els.service'; @@ -32,8 +29,6 @@ import { SortPipe } from './sortby.pipe'; ], declarations: [ AppComponent, - HeroDetailComponent, - HeroesComponent, DashboardComponent, AlbumComponent, ArtistComponent, @@ -41,7 +36,6 @@ import { SortPipe } from './sortby.pipe'; SortPipe ], providers: [ - HeroService, ElsService ], bootstrap: [ AppComponent ] diff --git a/dashboard/src/app/dashboard.component.ts b/dashboard/src/app/dashboard.component.ts index be3cb44..8c7de06 100644 --- a/dashboard/src/app/dashboard.component.ts +++ b/dashboard/src/app/dashboard.component.ts @@ -1,7 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { Hero } from './hero'; -import { HeroService } from './hero.service'; import { ElsService } from './els.service'; import { Song } from './object/song'; import { Bucket } from './object/bucket'; diff --git a/dashboard/src/app/hero-detail.component.css b/dashboard/src/app/hero-detail.component.css deleted file mode 100644 index bf3f77a..0000000 --- a/dashboard/src/app/hero-detail.component.css +++ /dev/null @@ -1,33 +0,0 @@ -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; - 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: #ccc; - cursor: auto; -} diff --git a/dashboard/src/app/hero-detail.component.html b/dashboard/src/app/hero-detail.component.html deleted file mode 100644 index 119ec12..0000000 --- a/dashboard/src/app/hero-detail.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
-

{{hero.name}} details!

-
- {{hero.id}}
-
- - -
- - -
\ No newline at end of file diff --git a/dashboard/src/app/hero-detail.component.ts b/dashboard/src/app/hero-detail.component.ts deleted file mode 100644 index bb79cc0..0000000 --- a/dashboard/src/app/hero-detail.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import 'rxjs/add/operator/switchMap'; -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute, Params } from '@angular/router'; -import { Location } from '@angular/common'; - -import { HeroService } from './hero.service'; -import { Hero } from './hero'; - -@Component({ - selector: 'hero-detail', - templateUrl: './hero-detail.component.html' -}) - -export class HeroDetailComponent implements OnInit { - hero: Hero; - - constructor( - 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); - } - - save(): void { - this.heroService.update(this.hero) - .then(() => this.goBack()); - } - - goBack(): void { - this.location.back(); - } -} diff --git a/dashboard/src/app/hero.service.ts b/dashboard/src/app/hero.service.ts deleted file mode 100644 index 4c521e8..0000000 --- a/dashboard/src/app/hero.service.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Headers, Http } from '@angular/http'; - -import 'rxjs/add/operator/toPromise'; - -import { Hero } from './hero'; - -@Injectable() -export class HeroService { - private heroesUrl = 'api/heroes'; // URL to web api - private headers = new Headers({'Content-Type': 'application/json'}); - - constructor(private http: Http) { } - - getHeroes(): Promise { - return this.http.get(this.heroesUrl) - .toPromise() - .then(response => response.json().data as Hero[]) - .catch(this.handleError); - } - - update(hero: Hero): Promise { - const url = `${this.heroesUrl}/${hero.id}`; - return this.http.put(url, JSON.stringify(hero), {headers: this.headers}) - .toPromise() - .then(() => hero) - .catch(this.handleError); - } - - create(name: string): Promise { - return this.http.post(this.heroesUrl, JSON.stringify({name: name}), {headers: this.headers}) - .toPromise() - .then(res => res.json().data as Hero) - .catch(this.handleError); - } - - delete(id: number): Promise { - const url = `${this.heroesUrl}/${id}`; - return this.http.delete(url, {headers: this.headers}) - .toPromise() - .then(() => null) - .catch(this.handleError); - } - - getHero(id: number): Promise { - const url = `${this.heroesUrl}/${id}`; - return this.http.get(url) - .toPromise() - .then(response => response.json().data as Hero) - .catch(this.handleError); - } - - private handleError(error: any): Promise { - console.error('An error occurred', error); // for demo purposes only - return Promise.reject(error.message || error); - } -} diff --git a/dashboard/src/app/hero.ts b/dashboard/src/app/hero.ts deleted file mode 100644 index e3eac51..0000000 --- a/dashboard/src/app/hero.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class Hero { - id: number; - name: string; -} diff --git a/dashboard/src/app/heroes.component.css b/dashboard/src/app/heroes.component.css deleted file mode 100644 index f6cde89..0000000 --- a/dashboard/src/app/heroes.component.css +++ /dev/null @@ -1,61 +0,0 @@ -.selected { - background-color: #CFD8DC !important; - color: white; -} - -.heroes { - margin: 0 0 2em 0; - list-style-type: none; - padding: 0; - width: 15em; -} - -.heroes li { - cursor: pointer; - position: relative; - left: 0; - background-color: #EEE; - margin: .5em; - padding: .3em 0; - height: 1.6em; - border-radius: 4px; -} - -.heroes li.selected:hover { - background-color: #BBD8DC !important; - color: white; -} - -.heroes li:hover { - color: #607D8B; - background-color: #DDD; - left: .1em; -} - -.heroes .text { - position: relative; - top: -3px; -} - -.heroes .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; -} - -button.delete { - float:right; - margin-top: 2px; - margin-right: .8em; - background-color: gray !important; - color:white; -} \ No newline at end of file diff --git a/dashboard/src/app/heroes.component.html b/dashboard/src/app/heroes.component.html deleted file mode 100644 index 014c99e..0000000 --- a/dashboard/src/app/heroes.component.html +++ /dev/null @@ -1,20 +0,0 @@ -

My Heroes

-
    -
  • - {{hero.id}} {{hero.name}} - -
  • -
-
-

{{selectedHero.name | uppercase}} is my hero

- -
-
- - -
\ No newline at end of file diff --git a/dashboard/src/app/heroes.component.ts b/dashboard/src/app/heroes.component.ts deleted file mode 100644 index 94cdfa3..0000000 --- a/dashboard/src/app/heroes.component.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Component } from '@angular/core'; -import { OnInit } from '@angular/core'; -import { Router } from '@angular/router'; - -import { Hero } from './hero'; - -import { HeroService } from './hero.service'; - -@Component({ - selector: 'my-heroes', - templateUrl: './heroes.component.html', - styleUrls: [ './heroes.component.css' ] -}) - -export class HeroesComponent implements OnInit { - heroes: Hero[]; - selectedHero: Hero; - - constructor( - private heroService: HeroService, - private router: Router - ) { } - - ngOnInit(): void { - this.getHeroes(); - } - - onSelect(hero: Hero) { - this.selectedHero = hero; - } - - getHeroes(): void { - // this.heroService.getHeroes().then(heroes => this.heroes = heroes); - this.heroService.getHeroes().then(heroes => this.heroes = heroes); - } - - add(name: string): void { - name = name.trim(); - if (!name) { - return; - } - - this.heroService.create(name) - .then(hero => { - this.heroes.push(hero); - this.selectedHero = null; - }); - } - - delete(hero: Hero): void { - this.heroService - .delete(hero.id) - .then(() => { - this.heroes = this.heroes.filter(h => h !== hero); - if (this.selectedHero === hero) { this.selectedHero = null; } - }); - } - - gotoDetail(): void { - this.router.navigate(['/detail', this.selectedHero.id]); - } - -} - - diff --git a/dashboard/src/app/in-memory-data.service.ts b/dashboard/src/app/in-memory-data.service.ts deleted file mode 100644 index a70163d..0000000 --- a/dashboard/src/app/in-memory-data.service.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { InMemoryDbService } from 'angular-in-memory-web-api'; - -export class InMemoryDataService implements InMemoryDbService { - createDb() { - let heroes = [ - {id: 11, name: 'Mr. Nice'}, - {id: 12, name: 'Narco'}, - {id: 13, name: 'Bombasto'}, - {id: 14, name: 'Celeritas'}, - {id: 15, name: 'Magneta'}, - {id: 16, name: 'RubberMan'}, - {id: 17, name: 'Dynama'}, - {id: 18, name: 'Dr IQ'}, - {id: 19, name: 'Magma'}, - {id: 20, name: 'Tornado'} - ]; - return {heroes}; - } -}