-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
14,302 additions
and
10,324 deletions.
There are no files selected for viewing
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,7 +1,4 @@ | ||
<template> | ||
<h2>Server Clock</h2> | ||
<div> | ||
<button click.trigger="fetchTime()">Fetch time</button> | ||
${time} | ||
</div> | ||
<h1>Aurelia SSR demo</h1> | ||
<router-view></router-view> | ||
</template> |
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,13 +1,16 @@ | ||
export class AppViewModel { | ||
time = "n/a"; | ||
import { PLATFORM } from "aurelia-framework"; | ||
import { Router, RouterConfiguration } from "aurelia-router"; | ||
|
||
activate() { | ||
return this.fetchTime(); | ||
} | ||
export class AppViewModel { | ||
router: Router; | ||
|
||
fetchTime() { | ||
return fetch("/api/Time") | ||
.then<any>(response => response.json()) | ||
.then(obj => this.time = obj.time); | ||
configureRouter(config: RouterConfiguration, router: Router) { | ||
this.router = router; | ||
config.options.pushState = true; | ||
config.map([ | ||
{ route: '', name: 'home', moduleId: PLATFORM.moduleName('pages/home.html') }, | ||
{ route: 'all', name: 'master', moduleId: PLATFORM.moduleName('pages/master') }, | ||
{ route: 'item/:id', name: 'details', moduleId: PLATFORM.moduleName('pages/details') }, | ||
]); | ||
} | ||
} |
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 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,19 @@ | ||
<template> | ||
<h2>Details for ${item.firstName} ${item.lastName}</h2> | ||
<p>When you're done, <a route-href="route: master">go back to the list</a>!</p> | ||
<form with.bind="item"> | ||
<div> | ||
<label class="form-label">Id:</label> | ||
<!-- Wanted to use <input> but it breaks in JSDOM for now, confusion between fake and real Object --> | ||
<span textcontent.one-time="id"></span> | ||
</div> | ||
<div> | ||
<label>First name:</label> | ||
<span textcontent.one-time="firstName"></span> | ||
</div> | ||
<div> | ||
<label>Last name:</label> | ||
<span textcontent.one-time="lastName"></span> | ||
</div> | ||
</form> | ||
</template> |
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,9 @@ | ||
export class DetailsViewModel { | ||
item: any; | ||
|
||
activate({ id }: any) { | ||
return fetch("/api/duck/" + id) | ||
.then<any>(response => response.json()) | ||
.then(duck => this.item = duck); | ||
} | ||
} |
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,6 @@ | ||
<template> | ||
<h2>Home</h2> | ||
<p>This is the home page of this application.</p> | ||
<p>It's all static text so it's really boring.</p> | ||
<p>You should try another page, such as <a route-href="route: master">the master list</a>.</p> | ||
</template> |
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,18 @@ | ||
<template> | ||
<h2>Master List</h2> | ||
<p>Here's what the server has in store for us.</p> | ||
<p>You can click any line to see the details!</p> | ||
<p>Or <a route-href="route: home">go back to the boring home</a> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr repeat.for="duck of list" click.delegate="go(duck.id)"> | ||
<td>${duck.firstName}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</template> |
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,19 @@ | ||
import { autoinject } from 'aurelia-framework'; | ||
import { Router } from 'aurelia-router'; | ||
|
||
@autoinject | ||
export class MasterViewModel { | ||
list: any[]; | ||
|
||
constructor(private router: Router) { } | ||
|
||
activate() { | ||
return fetch("/api/duck") | ||
.then<any[]>(response => response.json()) | ||
.then(list => this.list = list); | ||
} | ||
|
||
go(id: number) { | ||
this.router.navigateToRoute("details", { id }); | ||
} | ||
} |
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,22 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace AureliaDemo.Controllers | ||
{ | ||
[Route("/api/duck")] | ||
public class DuckController { | ||
|
||
private static object[] data = new[] { | ||
new { Id = 1, FirstName = "Scrooge", LastName = "McDuck" }, | ||
new { Id = 2, FirstName = "Huey", LastName = "Duck" }, | ||
new { Id = 3, FirstName = "Dewey", LastName = "Duck" }, | ||
new { Id = 4, FirstName = "Louie", LastName = "Duck" }, | ||
new { Id = 5, FirstName = "Webbigail", LastName = "Vanderquack" }, | ||
}; | ||
|
||
[HttpGet] | ||
public object Index() => data; | ||
|
||
[HttpGet("{id}")] | ||
public object Index(int id) => data[id - 1]; | ||
} | ||
} |
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
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 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 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 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 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 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,81 @@ | ||
@import url('https://fonts.googleapis.com/css?family=Bungee'); | ||
|
||
html { | ||
font-family: "Segoe UI", Arial, sans-serif; | ||
} | ||
|
||
body { | ||
margin: 0 8px; | ||
} | ||
|
||
h1, h2 { | ||
font-family: "Bungee"; | ||
color: #6E4D9B; | ||
margin: 0; | ||
} | ||
|
||
h2, a { | ||
color: #E82887; | ||
} | ||
|
||
p { | ||
color: #444; | ||
margin: 0; | ||
} | ||
|
||
table { | ||
margin-top: 12px; | ||
width: 100%; | ||
border-spacing: 0; | ||
} | ||
|
||
th, td { | ||
color: #333; | ||
text-align: left; | ||
border-bottom: 1px solid #666; | ||
padding: 4px; | ||
} | ||
|
||
td { | ||
border-bottom-color: #ccc; | ||
} | ||
|
||
tbody tr:hover { | ||
background: #FFDEEE; | ||
cursor: pointer; | ||
} | ||
|
||
form { | ||
margin-top: 12px; | ||
} | ||
|
||
label { | ||
display: inline-block; | ||
width: 150px; | ||
font-weight: 600; | ||
} | ||
|
||
label + span { | ||
display: inline-block; | ||
width: 150px; | ||
border-bottom: solid 1px #ccc; | ||
} | ||
|
||
.server-side { | ||
margin: 0 -8px; | ||
padding: 8px; | ||
background: repeating-linear-gradient(45deg, #fff 0, #fff 15px, #FFDEEE 15px, #FFDEEE 30px); | ||
border-bottom: solid 1px #E82887; | ||
font-weight: bold; | ||
} | ||
|
||
.server-side button { | ||
margin-left: 16px; | ||
background: #6E4D9B; | ||
font-weight: bold; | ||
color: #fff; | ||
text-shadow: rgba(0, 0, 0, 0.25) -1px -1px; | ||
padding: 4px 16px; | ||
border: 1px solid #533281; | ||
border-radius: 4px; | ||
} |
Oops, something went wrong.