Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
246 changes: 246 additions & 0 deletions templates/AureliaSpa/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
/Properties/launchSettings.json

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
bin/
Bin/
obj/
Obj/

# Visual Studio 2015 cache/options directory
.vs/
/wwwroot/dist/**
/ClientApp/dist/**

# Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
!/wwwroot/dist/_placeholder.txt
!/ClientApp/dist/_placeholder.txt


# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Microsoft Azure Build Output
csx/
*.build.csdef

# Microsoft Azure Emulator
ecf/
rcf/

# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config

# Windows Store app package directory
AppPackages/
BundleArtifacts/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
orleans.codegen.cs

# Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
/node_modules/**
!/node_modules/_placeholder.txt

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions

# Paket dependency manager
.paket/paket.exe

# FAKE - F# Make
.fake/
18 changes: 18 additions & 0 deletions templates/AureliaSpa/Aurelia.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>33d8dad9-74f9-471d-8bad-55f828faa736</ProjectGuid>
<RootNamespace>Angular2</RootNamespace>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this

<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
6 changes: 6 additions & 0 deletions templates/AureliaSpa/ClientApp/app/components/app/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@media (max-width: 767px) {
/* On small screens, the nav menu spans the full width of the screen. Leave a space for it. */
.body-content {
padding-top: 50px;
}
}
14 changes: 14 additions & 0 deletions templates/AureliaSpa/ClientApp/app/components/app/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
Copy link
Member

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?

Copy link

@EisenbergEffect EisenbergEffect Oct 24, 2016

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.

<require from="../navmenu/navmenu.html"></require>
<require from="./app.css"></require>
<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'>
<router-view></router-view>
</div>
</div>
</div>
</template>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing trailing linebreak which is present in most files. Could you add one here and to any other TS/JS/HTML/CSS file where it's missing?

19 changes: 19 additions & 0 deletions templates/AureliaSpa/ClientApp/app/components/app/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Aurelia} from 'aurelia-framework';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some few formatting issues in this file:

  • missing spaces around { ImportedModule }
  • The config.map object looks pretty strange. Not sure if you were trying to line things up with tabs or something, but it's not lined up now. Also some of the key-value pairs have spaces after the colon and others don't. Could you lay this code out more conventionally?
import {Router, RouterConfiguration} from 'aurelia-router';

export class App {
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' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of the term class here is a bit odd. I'd naturally think that refers to a class in the code, but it looks like you're using that to mean "CSS class we should set on the icon element". Could you rename this to something more descriptive, such as icon or icon-className?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer icon.

{ 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;
}
}


Copy link
Member

Choose a reason for hiding this comment

The 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
@@ -0,0 +1,9 @@
<template>
<h2>Counter</h2>

<p>This is a simple example of an Aurelia component.</p>

<p>Current count: <strong>${currentCount}</strong></p>

<button click.delegate="incrementCounter()">Increment</button>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary blank lines on line 1 and 7

export class Counter {
public currentCount = 0;

public incrementCounter() {
this.currentCount++;

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent quotes and ${ spacing } in this file

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from the server.</p>

<p if.bind="!forecasts"><em>Loading...</em></p>

<table class='table' if.bind="forecasts">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
<tr repeat.for="forecast of forecasts">
<td>${forecast.dateFormatted }</td>
<td>${ forecast.temperatureC }</td>
<td>${ forecast.temperatureF }</td>
<td>${ forecast.summary }</td>
</tr>
</tbody>
</table>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference path="../../../../node_modules/aurelia-fetch-client/doc/whatwg-fetch.d.ts" />
/// <reference path="../../../../node_modules/aurelia-fetch-client/doc/url.d.ts" />
Copy link
Member

Choose a reason for hiding this comment

The 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?

Choose a reason for hiding this comment

The 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 reference comments should be needed either way.

Copy link
Member

@SteveSandersonMS SteveSandersonMS Oct 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EisenbergEffect I think @kmkatsma was saying they are needed because aurelia-fetch-client currently contains an incorrect .d.ts file. Not sure though.

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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 whatwg-fetch from types in tsconfig.json, just like we do in the Knockout and ReactRedux templates. Then you should be able to remove these /// <reference> lines and have it still build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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';

@inject(HttpClient)
export class Fetchdata {
public forecasts: WeatherForecast[];
http: HttpClient;
Copy link
Member

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The 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 getForecast() to get the data. Internally, the method can cache that data if it wants to but it would always return a promise for consistency.

Copy link
Member

Choose a reason for hiding this comment

The 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')
.then(result => result.json())
.then(data => {
this.forecasts = data;
});
}
}

interface WeatherForecast {
dateFormatted: string;
temperatureC: number;
temperatureF: number;
summary: string;
}
Loading