This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#12 Adapted first version of Angulars own Tour of Heroes sample, REST…
…ful way
- Loading branch information
Showing
32 changed files
with
849 additions
and
245 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { ResourceRouterModule } from 'angular-resource-router'; | ||
import { DashboardComponent } from './dashboard/dashboard.component'; | ||
import { HeroesComponent } from './heroes/heroes.component'; | ||
import { HeroDetailComponent } from './hero-detail/hero-detail.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
ResourceRouterModule.forTypes([ | ||
{ | ||
type: 'application/x.dashboard', | ||
component: DashboardComponent | ||
}, | ||
{ | ||
type: 'application/x.heroes', | ||
component: HeroesComponent | ||
}, | ||
{ | ||
type: 'application/x.hero', | ||
component: HeroDetailComponent | ||
} | ||
]) | ||
], | ||
exports: [ | ||
ResourceRouterModule | ||
], | ||
}) | ||
export class AppRoutingModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* AppComponent's private CSS styles */ | ||
h1 { | ||
font-size: 1.2em; | ||
color: #999; | ||
margin-bottom: 0; | ||
} | ||
|
||
h2 { | ||
font-size: 2em; | ||
margin-top: 0; | ||
padding-top: 0; | ||
} | ||
|
||
nav a { | ||
padding: 5px 10px; | ||
text-decoration: none; | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,11 @@ | ||
<p>See <a href="http://docs.resourcerouterexample.apiary.io/#">API definition</a></p> | ||
|
||
<ng-container [resourceContext]="resource"> | ||
<div> | ||
<a [resourceLink]="resource.url + '/a'" [target]="resource">+A</a> | ||
<a [resourceLink]="resource.url + '/..'" [target]="resource">-A</a> | ||
</div> | ||
|
||
<h1>ROOT</h1> | ||
<h2>{{resource.url}}</h2> | ||
<p>{{resource.loading ? 'Loading...' : 'Loaded!'}}</p> | ||
<resource-view [data]="resource.data"></resource-view> | ||
<h1>{{title}}</h1> | ||
<ng-container *resourceData="let data of apiLocation" [resourceContext]="data"> | ||
<nav> | ||
<!-- TODO --> | ||
<a [resourceLink]="'/api/dashboard'">Dashboard</a> | ||
<a [resourceLink]="'/api/heroes'">Heroes</a> | ||
</nav> | ||
|
||
<resource-view [data]="data"></resource-view> | ||
</ng-container> | ||
|
||
<!--<h1>*resourceData</h1>--> | ||
<!--<p>apiLocation.url={{apiLocation.url}}</p>--> | ||
<!--<div *resourceData="let data of apiLocation; let loading = loading" [resourceContext]="data">--> | ||
<!--<h2>{{data.url}}</h2>--> | ||
<!--<p>{{loading ? 'Loading...' : 'Loaded!'}}</p>--> | ||
<!--<resource-view [data]="data"></resource-view>--> | ||
|
||
<!--<h2>Menu like</h2>--> | ||
<!--<resource-outlet [src]="data.url + '/246'"></resource-outlet>--> | ||
<!--</div>--> | ||
<app-messages></app-messages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,15 @@ | ||
import { Component, OnDestroy, OnInit } from '@angular/core'; | ||
import { ApiLocation, bindUrl, ResourceData } from '../lib/src'; | ||
import { Subscription } from 'rxjs/Subscription'; | ||
|
||
// TODO asi by to chtelo prejmenovat ResourceData, protoze to nepopisuje, co trida dela - drzi location a aktualni data, | ||
// TODO tedy takovy container - pak se da prejmenovat i ViewData.target | ||
import { Component } from '@angular/core'; | ||
import { ApiLocation } from '../lib/src'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
providers: [ResourceData] | ||
styleUrls: ['./app.component.css'] | ||
}) | ||
export class AppComponent implements OnInit, OnDestroy { | ||
|
||
private urlSubscription = Subscription.EMPTY; | ||
export class AppComponent { | ||
|
||
constructor(public apiLocation: ApiLocation, | ||
public resource: ResourceData) { | ||
} | ||
|
||
ngOnInit() { | ||
this.urlSubscription = bindUrl(this.apiLocation, this.resource); | ||
} | ||
title = 'Tour of Heroes'; | ||
|
||
ngOnDestroy() { | ||
this.urlSubscription.unsubscribe(); | ||
constructor(public apiLocation: ApiLocation) { | ||
} | ||
} |
Oops, something went wrong.