Repository navigation
Add AureliaSpa template #398
Changes from 1 commit
600aa17
f24fce8
28c778e
1563578
12120ef
b363ed7
fe5059c
790b719
e8b2ba8
5747fb8
48a8162
68bf670
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| <template> | ||
| <require from="../navmenu/navmenu.html"></require> | ||
| <require from="./app.css"></require> | ||
| <div class='container-fluid'> | ||
| <div class='row'> | ||
| <div class='col-sm-3'> | ||
| <div class="container-fluid"> | ||
| <div class="row"> | ||
| <div class="col-sm-3"> | ||
| <navmenu router.bind="router"></navmenu> | ||
| </div> | ||
| <div class='col-sm-9 body-content'> | ||
| <div class="col-sm-9 body-content"> | ||
| <router-view></router-view> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </template> | ||
| </template> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,17 @@ | ||
| import {Aurelia} from 'aurelia-framework'; | ||
| import {Router, RouterConfiguration} from 'aurelia-router'; | ||
| import { Aurelia } from 'aurelia-framework'; | ||
| import { Router, RouterConfiguration } from 'aurelia-router'; | ||
|
|
||
| export class App { | ||
| router: Router; | ||
| router: Router; | ||
|
|
||
| configureRouter(config: RouterConfiguration, router: Router) { | ||
| config.title = 'Aurelia'; | ||
| config.map([ | ||
| { route: ['', 'home'], name: 'home', settings:{class:'home'}, moduleId: '../home/home', nav: true, title: 'Home' }, | ||
| { route: 'counter', name: 'counter', settings:{class:'education'}, moduleId: '../counter/counter', nav: true, title: 'Counter' }, | ||
| { route: 'fetch-data', name: 'fetchdata', settings:{class:'th-list'}, moduleId: '../fetchdata/fetchdata', nav: true, title: 'Fetch data' } | ||
| ]); | ||
|
|
||
| this.router = router; | ||
| } | ||
| configureRouter(config: RouterConfiguration, router: Router) { | ||
| config.title = 'Aurelia'; | ||
| config.map([ | ||
| { route: ['', 'home'], name: 'home', settings: {icon: 'home'}, moduleId: '../home/home', nav: true, title: 'Home' }, | ||
| { route: 'counter', name: 'counter', settings: {icon: 'education'}, moduleId: '../counter/counter', nav: true, title: 'Counter' }, | ||
| { route: 'fetch-data', name: 'fetchdata', settings: {icon: 'th-list'}, moduleId: '../fetchdata/fetchdata', nav: true, title: 'Fetch data' } | ||
| ]); | ||
| this.router = router; | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 18 seems like unnecessary whitespace, then there's a missing trailing linebreak. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,7 @@ | ||
|
|
||
| export class Counter { | ||
| public currentCount = 0; | ||
|
|
||
| public incrementCounter() { | ||
| this.currentCount++; | ||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,16 @@ | ||
| /// <reference path="../../../../node_modules/aurelia-fetch-client/doc/whatwg-fetch.d.ts" /> | ||
| /// <reference path="../../../../node_modules/aurelia-fetch-client/doc/url.d.ts" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unfortunate that these are necessary. Has the underlying issue in Aurelia been reported? Is there any chance of getting a fix published? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These don't have anything to do with Aurelia as far as I know. They are standards that TypeScript is missing for some reason. However, I don't think that
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @EisenbergEffect I think @kmkatsma was saying they are needed because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as we know, there's nothing incorrect in our dts. It's just that we use the Fetch spec which relies on the there being dts for fetch and url. Those should be provided by TS because they are standards, but they aren't, so you have to include your own. If there's something we need to fix on our side, we're happy to do it though.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, OK, that makes sense! @kmkatsma In that case, the solution may be to reference
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, in general the change in type references for TS 2.0 was something I only realized this Saturday as I was cleaning up some things. Will look at. |
||
| import {HttpClient} from 'aurelia-fetch-client'; | ||
| import {inject} from 'aurelia-framework'; | ||
| import { HttpClient } from 'aurelia-fetch-client'; | ||
| import { inject } from 'aurelia-framework'; | ||
|
|
||
| @inject(HttpClient) | ||
| export class Fetchdata { | ||
| public forecasts: WeatherForecast[]; | ||
| http: HttpClient; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why store this as a member property? It doesn't seem to be used anywhere outside the constructor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I do find this entire class to be odd. I usually discourage making AJAX requests in a constructor function. Is this the way that other templates do it as well? Usually, a better practice is to have a service abstraction or "repository" type class that encapsulates the use of the http client and provides a simple method such as
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @EisenbergEffect It's the simplicity/extensibility tradeoff. In the Angular/Knockout/React templates we've followed this exact approach, as we're trying to make the templates accessible to newcompers and limit the concept count. People who get into using one of those frameworks won't struggle to create a service layer. In the ReactRedux template, we do the whole Redux thing which is a whole extra level of sophistication, but that's just fundamental to doing Redux. I think for this Aurelia template it's a reasonable choice of simplicity vs extensibility already, but we could change it if you think it's just flat out bad. |
||
|
|
||
|
|
||
| constructor(http: HttpClient) { | ||
| this.http = http; | ||
| this.http.fetch('/api/SampleData/WeatherForecasts') | ||
| //this.http = http; | ||
| http.fetch('/api/SampleData/WeatherForecasts') | ||
| .then(result => result.json()) | ||
| .then(data => { | ||
| this.forecasts = data; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,26 @@ | ||
| <template bindable="router"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent quotes in this file |
||
| <require from="./navmenu.css"></require> | ||
| <div class='main-nav'> | ||
| <div class='navbar navbar-inverse'> | ||
| <div class='navbar-header'> | ||
| <button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse'> | ||
| <span class='sr-only'>Toggle navigation</span> | ||
| <span class='icon-bar'></span> | ||
| <span class='icon-bar'></span> | ||
| <span class='icon-bar'></span> | ||
| <div class="main-nav"> | ||
| <div class="navbar navbar-inverse"> | ||
| <div class="navbar-header"> | ||
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
| <span class="sr-only">Toggle navigation</span> | ||
| <span class="icon-bar"></span> | ||
| <span class="icon-bar"></span> | ||
| <span class="icon-bar"></span> | ||
| </button> | ||
| <a class='navbar-brand' href="#/home">Aurelia</a> | ||
| <a class="navbar-brand" href="#/home">Aurelia</a> | ||
| </div> | ||
| <div class='clearfix'></div> | ||
| <div class='navbar-collapse collapse'> | ||
| <ul class='nav navbar-nav'> | ||
| <li class="${row.isActive ? 'link-active' : ''}" repeat.for = "row of router.navigation" > | ||
| <div class="clearfix"></div> | ||
| <div class="navbar-collapse collapse"> | ||
| <ul class="nav navbar-nav"> | ||
| <li repeat.for = "row of router.navigation" class="${ row.isActive ? 'link-active' : '' }" > | ||
| <a href.bind = "row.href"> | ||
| <span class='glyphicon glyphicon-${row.settings.class}'></span> ${row.title} | ||
| <span class="glyphicon glyphicon-${ row.settings.icon }"></span> ${ row.title } | ||
| </a> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </template> | ||
| </template> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,11 @@ | ||
| import {Aurelia} from 'aurelia-framework'; | ||
| import { Aurelia } from 'aurelia-framework'; | ||
| import 'bootstrap/dist/css/bootstrap.css'; | ||
| import 'bootstrap'; | ||
|
|
||
| // comment out if you don't want a Promise polyfill (remove also from webpack.config.js) | ||
| import * as Bluebird from 'bluebird'; | ||
| Bluebird.config({ warnings: false }); | ||
|
|
||
| export function configure(aurelia: Aurelia) { | ||
| aurelia.use | ||
| .standardConfiguration() | ||
| .developmentLogging(); | ||
|
|
||
| aurelia.start().then(() => aurelia.setRoot('app/components/app/app')); | ||
| } | ||
| aurelia.use.standardConfiguration(); | ||
| if (window.location.host.includes('localhost')) { | ||
| aurelia.use.developmentLogging(); | ||
| } | ||
| aurelia.start().then(() => aurelia.setRoot('app/components/app/app')); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,39 @@ | ||
| # Welcome to ASP.NET 5 | ||
| # Welcome to ASP.NET Core | ||
|
|
||
| We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s new. | ||
|
|
||
| You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016) | ||
| You've created a new ASP.NET Core project. [Learn what's new](https://go.microsoft.com/fwlink/?LinkId=518016) | ||
|
|
||
| ## This application consists of: | ||
|
|
||
| * Sample pages using ASP.NET MVC 6 | ||
| * [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries | ||
| * Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939) | ||
| * Sample pages using ASP.NET Core MVC | ||
| * [Gulp](https://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](https://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries | ||
| * Theming using [Bootstrap](https://go.microsoft.com/fwlink/?LinkID=398939) | ||
|
|
||
| ## How to | ||
|
|
||
| * [Add a Controller and View](http://go.microsoft.com/fwlink/?LinkID=398600) | ||
| * [Add an appsetting in config and access it in app.](http://go.microsoft.com/fwlink/?LinkID=699562) | ||
| * [Manage User Secrets using Secret Manager.](http://go.microsoft.com/fwlink/?LinkId=699315) | ||
| * [Use logging to log a message.](http://go.microsoft.com/fwlink/?LinkId=699316) | ||
| * [Add packages using NuGet.](http://go.microsoft.com/fwlink/?LinkId=699317) | ||
| * [Add client packages using Bower.](http://go.microsoft.com/fwlink/?LinkId=699318) | ||
| * [Target development, staging or production environment.](http://go.microsoft.com/fwlink/?LinkId=699319) | ||
| * [Add a Controller and View](https://go.microsoft.com/fwlink/?LinkID=398600) | ||
| * [Add an appsetting in config and access it in app.](https://go.microsoft.com/fwlink/?LinkID=699562) | ||
| * [Manage User Secrets using Secret Manager.](https://go.microsoft.com/fwlink/?LinkId=699315) | ||
| * [Use logging to log a message.](https://go.microsoft.com/fwlink/?LinkId=699316) | ||
| * [Add packages using NuGet.](https://go.microsoft.com/fwlink/?LinkId=699317) | ||
| * [Add client packages using Bower.](https://go.microsoft.com/fwlink/?LinkId=699318) | ||
| * [Target development, staging or production environment.](https://go.microsoft.com/fwlink/?LinkId=699319) | ||
|
|
||
| ## Overview | ||
|
|
||
| * [Conceptual overview of what is ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518008) | ||
| * [Fundamentals of ASP.NET 5 such as Startup and middleware.](http://go.microsoft.com/fwlink/?LinkId=699320) | ||
| * [Working with Data](http://go.microsoft.com/fwlink/?LinkId=398602) | ||
| * [Security](http://go.microsoft.com/fwlink/?LinkId=398603) | ||
| * [Client side development](http://go.microsoft.com/fwlink/?LinkID=699321) | ||
| * [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=699322) | ||
| * [Read more on the documentation site](http://go.microsoft.com/fwlink/?LinkID=699323) | ||
| * [Conceptual overview of what is ASP.NET Core](https://go.microsoft.com/fwlink/?LinkId=518008) | ||
| * [Fundamentals of ASP.NET Core such as Startup and middleware.](https://go.microsoft.com/fwlink/?LinkId=699320) | ||
| * [Working with Data](https://go.microsoft.com/fwlink/?LinkId=398602) | ||
| * [Security](https://go.microsoft.com/fwlink/?LinkId=398603) | ||
| * [Client side development](https://go.microsoft.com/fwlink/?LinkID=699321) | ||
| * [Develop on different platforms](https://go.microsoft.com/fwlink/?LinkID=699322) | ||
| * [Read more on the documentation site](https://go.microsoft.com/fwlink/?LinkID=699323) | ||
|
|
||
| ## Run & Deploy | ||
|
|
||
| * [Run your app](http://go.microsoft.com/fwlink/?LinkID=517851) | ||
| * [Run your app on .NET Core](http://go.microsoft.com/fwlink/?LinkID=517852) | ||
| * [Run commands in your project.json](http://go.microsoft.com/fwlink/?LinkID=517853) | ||
| * [Publish to Microsoft Azure Web Apps](http://go.microsoft.com/fwlink/?LinkID=398609) | ||
| * [Run your app](https://go.microsoft.com/fwlink/?LinkID=517851) | ||
| * [Run tools such as EF migrations and more](https://go.microsoft.com/fwlink/?LinkID=517853) | ||
| * [Publish to Microsoft Azure Web Apps](https://go.microsoft.com/fwlink/?LinkID=398609) | ||
|
|
||
| We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015) | ||
| We would love to hear your [feedback](https://go.microsoft.com/fwlink/?LinkId=518015) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF | |
| if (env.IsDevelopment()) | ||
| { | ||
| app.UseDeveloperExceptionPage(); | ||
| // Aurelia Webpack Plugin currently does not support HMR beyond CSS, leave HotModuleReplacement flag set to false | ||
| app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { | ||
| HotModuleReplacement = false | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure we'll get away with just setting this to Obviously the ideal solution would be if HMR could be made to work. I'd hope that's not impossible, since it's quite trivial to enable with Angular/Knockout/React, but I don't know if Aurelia does something that can't handle it. If it's not possible to make work, can you somehow stop the unrelated-seeming error message, and replace it with something like "Sorry, Hot Module Replacement is not supported with Aurelia"? |
||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |
| } | ||
|
|
||
| @section scripts { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason why the client should be doing 3 separate HTTP requests for these JS files? Couldn't the |
||
| <script type="text/javascript" src="~/dist/aurelia-bootstrap-bundle.js" asp-append-version="true"></script> | ||
| <script type="text/javascript" src="~/dist/aurelia-modules-bundle.js"asp-append-version="true"></script> | ||
| <script type="text/javascript" src="~/dist/app-bundle.js" asp-append-version="true"></script> | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,7 @@ | ||
| { | ||
| "name": "AureliaSpa", | ||
| "version": "0.0.0", | ||
| "aurelia": { | ||
| "build": { | ||
| "includeDependencies": "aurelia-*" | ||
| } | ||
| }, | ||
| "dependencies": { | ||
| "@types/bluebird": "^3.0.35", | ||
| "@types/node": "^6.0.45", | ||
| "aurelia-bootstrapper-webpack": "^1.0.0", | ||
| "aurelia-event-aggregator": "^1.0.0", | ||
| "aurelia-fetch-client": "^1.0.0", | ||
|
|
@@ -23,14 +16,12 @@ | |
| "aurelia-templating-binding": "^1.0.0", | ||
| "aurelia-templating-resources": "^1.0.0", | ||
| "aurelia-templating-router": "^1.0.0", | ||
| "bluebird": "^3.4.1", | ||
| "bootstrap": "^3.3.7", | ||
| "isomorphic-fetch": "^2.2.1", | ||
| "jquery": "^2.2.1", | ||
| "preboot": "^4.5.2" | ||
| "jquery": "^2.2.1" | ||
| }, | ||
| "devDependencies": { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure it's valid to regard these as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In production mode, I wouldn't think we'd have a dependency on webpack. I would just move everything to dependencies section (Angular2 template is set up this way), but the aurelia-webpack-plugin currently scans the package.json dependencies and also adds them to the bundle (I'm assuming in case there is missing import chain). So keeping dependencies section to a minimum is ideal. |
||
| "aspnet-prerendering": "^1.0.6", | ||
| "@types/node": "^6.0.45", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the |
||
| "aspnet-webpack": "^1.0.11", | ||
| "aurelia-webpack-plugin": "^1.1.0", | ||
| "copy-webpack-plugin": "^3.0.1", | ||
|
|
@@ -41,7 +32,6 @@ | |
| "html-loader": "^0.4.4", | ||
| "html-webpack-plugin": "^2.22.0", | ||
| "raw-loader": "^0.5.1", | ||
| "sourcemap-istanbul-instrumenter-loader": "^0.2.0", | ||
| "style-loader": "^0.13.1", | ||
| "to-string-loader": "^1.1.5", | ||
| "ts-loader": "^0.8.2", | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent quote style in this file. In TypeScript let's use single-quotes. In HTML templates, I don't know if Aurelia community has a standard, but can you find out what it is and use that?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer single quotes in JS/TS and double quotes in HTML.