MusicStore.Spa changes:

- Upgraded to Angular 1.3 (Fixes #267)
- Fix XHR GET caching issue in IE with new NoCacheAttribute
- Slight fix in admin home page (album list) to ensure initial data fetch has the sort expression in the query
This commit is contained in:
DamianEdwards 2014-11-18 17:08:12 -08:00
parent 6a4f49a188
commit 22ad9b9572
7 changed files with 58 additions and 31 deletions

View File

@ -19,6 +19,7 @@ namespace MusicStore.Apis
}
[HttpGet]
[NoCache]
public async Task<ActionResult> Paged(int page = 1, int pageSize = 50, string sortBy = null)
{
await _storeContext.Genres.LoadAsync();
@ -36,6 +37,7 @@ namespace MusicStore.Apis
}
[HttpGet("all")]
[NoCache]
public async Task<ActionResult> All()
{
var albums = await _storeContext.Albums
@ -48,6 +50,7 @@ namespace MusicStore.Apis
}
[HttpGet("mostPopular")]
[NoCache]
public async Task<ActionResult> MostPopular(int count = 6)
{
count = count > 0 && count < 20 ? count : 6;
@ -61,6 +64,7 @@ namespace MusicStore.Apis
}
[HttpGet("{albumId:int}")]
[NoCache]
public async Task<ActionResult> Details(int albumId)
{
await _storeContext.Genres.LoadAsync();

View File

@ -0,0 +1,16 @@
using System;
using Microsoft.AspNet.Mvc;
namespace MusicStore.Spa.Infrastructure
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class NoCacheAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext context)
{
context.HttpContext.Response.Headers["Cache-Control"] = "private, max-age=0";
base.OnResultExecuting(context);
}
}
}

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<?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>
<DevelopmentServerPort>62635</DevelopmentServerPort>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
@ -11,4 +12,4 @@
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
</Project>

View File

@ -3,14 +3,14 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"bootstrap": "~3.1.0",
"jquery-validation": "~1.13.0",
"jquery": "~2.1.0",
"bootstrap": "~3.2.0",
"jquery-validation": "~1.13.1",
"jquery": "~2.1.1",
"modernizr": "~2.7.1",
"respond": "~1.4.2",
"angular": "~1.2.15",
"angular-route": "~1.2.15",
"angular-bootstrap": "~0.11.2"
"angular": "~1.3.3",
"angular-route": "~1.3.3",
"angular-bootstrap": "~0.12.0"
},
"devDependencies": {
"dt-angular": "~1.2.16",
@ -18,23 +18,26 @@
"dt-jquery": "~2.0.0"
},
"exportsOverride": {
"bootstrap": {
"js": "dist/js/*.*",
"css": "dist/css/*.*",
"fonts": "dist/fonts/*.*"
},
"/jquery/": {
"": "dist/*.*"
},
"/angular/": {
"": "*.{js,map}"
},
"modernizr": {
"": "modernizr.js"
},
"respond": {
"": "dest/*.*"
},
"dt-*": { }
}
"bootstrap": {
"js": "dist/js/*.*",
"css": "dist/css/*.*",
"fonts": "dist/fonts/*.*"
},
"/jquery/": {
"": "dist/*.*"
},
"/angular/": {
"": "*.{js,map}"
},
"modernizr": {
"": "modernizr.js"
},
"respond": {
"": "dest/*.*"
},
"dt-*": {}
},
"resolutions": {
"angular": "~1.3.3"
}
}

View File

@ -28,9 +28,10 @@
this.currentPage = 1;
this.pageSize = 50;
this.loadPage(1);
this.sortColumn = "Title";
this.loadPage(1);
this.showAlert(viewAlert.alert, 3000);
viewAlert.alert = null;
}

View File

@ -908,9 +908,10 @@ var MusicStore;
this.currentPage = 1;
this.pageSize = 50;
this.loadPage(1);
this.sortColumn = "Title";
this.loadPage(1);
this.showAlert(viewAlert.alert, 3000);
viewAlert.alert = null;
}

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<?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>
<DevelopmentServerPort>62634</DevelopmentServerPort>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
@ -11,4 +12,4 @@
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
</Project>