Bunch of MusicStore.Spa updates:
- Refactored grunt config into grunt folder with json file for each task using grunt-ide-support package - Using attribute routing - Add exclusions for non-K files to the project.json - Deleted unused Default.html file - Fixed paths in TemplateController to work in K - Fixed @model declarations in ng template views
This commit is contained in:
parent
6bbc74434d
commit
1d52705f8a
|
|
@ -16,7 +16,7 @@ namespace MusicStore.Apis
|
|||
_storeContext = storeContext;
|
||||
}
|
||||
|
||||
//[Route("api/albums")]
|
||||
[Route("api/albums")]
|
||||
public async Task<ActionResult> Paged(int page = 1, int pageSize = 50, string sortBy = null)
|
||||
{
|
||||
var albums = await _storeContext.Albums
|
||||
|
|
@ -28,7 +28,7 @@ namespace MusicStore.Apis
|
|||
return Json(albums);
|
||||
}
|
||||
|
||||
//[Route("api/albums/all")]
|
||||
[Route("api/albums/all")]
|
||||
public async Task<ActionResult> All()
|
||||
{
|
||||
var albums = await _storeContext.Albums
|
||||
|
|
@ -40,7 +40,7 @@ namespace MusicStore.Apis
|
|||
return Json(albums);
|
||||
}
|
||||
|
||||
//[Route("api/albums/mostPopular")]
|
||||
[Route("api/albums/mostPopular")]
|
||||
public async Task<ActionResult> MostPopular(int count = 6)
|
||||
{
|
||||
count = count > 0 && count < 20 ? count : 6;
|
||||
|
|
@ -52,7 +52,7 @@ namespace MusicStore.Apis
|
|||
return Json(albums);
|
||||
}
|
||||
|
||||
//[Route("api/albums/{albumId:int}")]
|
||||
[Route("api/albums/{albumId:int}")]
|
||||
public async Task<ActionResult> Details(int albumId)
|
||||
{
|
||||
// TODO: Remove this when EF supports related entity loading
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace MusicStore.Apis
|
|||
_storeContext = storeContext;
|
||||
}
|
||||
|
||||
//[Route("api/artists/lookup")]
|
||||
[Route("api/artists/lookup")]
|
||||
public async Task<ActionResult> Lookup()
|
||||
{
|
||||
var artists = await _storeContext.Artists
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace MusicStore.Apis
|
|||
_storeContext = storeContext;
|
||||
}
|
||||
|
||||
//[Route("api/genres/lookup")]
|
||||
[Route("api/genres/lookup")]
|
||||
public async Task<ActionResult> Lookup()
|
||||
{
|
||||
var genres = await _storeContext.Genres
|
||||
|
|
@ -24,7 +24,7 @@ namespace MusicStore.Apis
|
|||
return Json(genres);
|
||||
}
|
||||
|
||||
//[Route("api/genres/menu")]
|
||||
[Route("api/genres/menu")]
|
||||
public async Task<ActionResult> GenreMenuList(int count = 9)
|
||||
{
|
||||
count = count > 0 && count < 20 ? count : 9;
|
||||
|
|
@ -39,7 +39,7 @@ namespace MusicStore.Apis
|
|||
return Json(genres);
|
||||
}
|
||||
|
||||
//[Route("api/genres")]
|
||||
[Route("api/genres")]
|
||||
public async Task<ActionResult> GenreList()
|
||||
{
|
||||
var genres = await _storeContext.Genres
|
||||
|
|
@ -50,7 +50,7 @@ namespace MusicStore.Apis
|
|||
return Json(genres);
|
||||
}
|
||||
|
||||
//[Route("api/genres/{genreId:int}/albums")]
|
||||
[Route("api/genres/{genreId:int}/albums")]
|
||||
public async Task<ActionResult> GenreAlbums(int genreId)
|
||||
{
|
||||
var albums = await _storeContext.Albums
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
@model MvcMusicStore.Models.Album
|
||||
@model MusicStore.Models.Album
|
||||
|
||||
<div ng-controller="MusicStore.Admin.Catalog.AlbumDetailsController as viewModel">
|
||||
<h2>Album <small>Details</small></h2>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
@model MvcMusicStore.Models.Album
|
||||
@model MusicStore.Models.Album
|
||||
|
||||
<div ng-controller="MusicStore.Admin.Catalog.AlbumEditController as viewModel">
|
||||
<h2>Album <small>{{ viewModel.mode | titlecase }}</small></h2>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
@model MvcMusicStore.Models.Album
|
||||
@model MusicStore.Models.Album
|
||||
|
||||
<div ng-controller="MusicStore.Admin.Catalog.AlbumListController as viewModel">
|
||||
<h2>Albums</h2>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ namespace MusicStore.Controllers
|
|||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
//
|
||||
// GET: /Home/
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
|
|
|
|||
|
|
@ -5,16 +5,15 @@ namespace MusicStore.Controllers
|
|||
{
|
||||
public class TemplateController : Controller
|
||||
{
|
||||
private static readonly string _templateBasePath = "~/Client/ng-apps/";
|
||||
private static readonly string _templateBasePath = "/Client/ng-apps/";
|
||||
|
||||
// GET: Template
|
||||
//[Route("ng-apps/{*path}")]
|
||||
[Route("ng-apps/{*path}")]
|
||||
public ActionResult Index(string path)
|
||||
{
|
||||
if (!IsValidPath(path))
|
||||
{
|
||||
// TODO: Change this to NotFoundResult when it's available
|
||||
return new HttpStatusCodeResult(404);
|
||||
return new HttpNotFoundResult();
|
||||
}
|
||||
|
||||
return View(_templateBasePath + path);
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Welcome to ASP.NET vNext</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to ASP.NET vNext</h1>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,190 +1,25 @@
|
|||
/// <vs BeforeBuild='dev' Clean='clean' />
|
||||
/// <reference path="node_modules/grunt/lib/grunt.js" />
|
||||
|
||||
// node-debug (Resolve-Path ~\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt) task:target
|
||||
|
||||
module.exports = function (grunt) {
|
||||
/// <param name="grunt" type="grunt" />
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-contrib-less');
|
||||
grunt.loadNpmTasks('grunt-typescript');
|
||||
grunt.loadNpmTasks('grunt-tslint');
|
||||
grunt.loadNpmTasks('grunt-tsng');
|
||||
//grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
//grunt.loadNpmTasks('grunt-contrib-qunit');
|
||||
//grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
|
||||
grunt.initConfig({
|
||||
staticFilePattern: '**/*.{js,css,map,html,htm,ico,jpg,jpeg,png,gif,eot,svg,ttf,woff}',
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
uglify: {
|
||||
options: {
|
||||
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
|
||||
},
|
||||
release: {
|
||||
files: {
|
||||
'wwwroot/app.min.js': ['<%= typescript.dev.dest %>']
|
||||
}
|
||||
}
|
||||
},
|
||||
clean: {
|
||||
options: { force: true },
|
||||
bower: ['wwwroot/*', '!wwwroot/bin'],
|
||||
assets: ['wwwroot/*', '!wwwroot/bin'],
|
||||
tsng: ['client/**/*.ng.ts']
|
||||
},
|
||||
copy: {
|
||||
// This is to work around an issue with the dt-angular bower package https://github.com/dt-bower/dt-angular/issues/4
|
||||
fix: {
|
||||
files: {
|
||||
"bower_components/jquery/jquery.d.ts": ["bower_components/dt-jquery/jquery.d.ts"]
|
||||
}
|
||||
},
|
||||
bower: {
|
||||
files: [
|
||||
{ // JavaScript
|
||||
expand: true,
|
||||
flatten: true,
|
||||
cwd: "bower_components/",
|
||||
src: [
|
||||
"modernizr/modernizr.js",
|
||||
"jquery/dist/*.{js,map}",
|
||||
"jquery.validation/jquery.validate.js",
|
||||
"jquery.validation/additional-methods.js",
|
||||
"bootstrap/dist/**/*.js",
|
||||
"respond/dest/**/*.js",
|
||||
"angular/*.{js,.js.map}",
|
||||
"angular-route/*.{js,.js.map}",
|
||||
"angular-bootstrap/ui-bootstrap*"
|
||||
],
|
||||
dest: "wwwroot/js/",
|
||||
options: { force: true }
|
||||
},
|
||||
{ // CSS
|
||||
expand: true,
|
||||
flatten: true,
|
||||
cwd: "bower_components/",
|
||||
src: [
|
||||
"bootstrap/dist/**/*.css",
|
||||
],
|
||||
dest: "wwwroot/css/",
|
||||
options: { force: true }
|
||||
},
|
||||
{ // Fonts
|
||||
expand: true,
|
||||
flatten: true,
|
||||
cwd: "bower_components/",
|
||||
src: [
|
||||
"bootstrap/**/*.{woff,svg,eot,ttf}",
|
||||
],
|
||||
dest: "wwwroot/fonts/",
|
||||
options: { force: true }
|
||||
}
|
||||
]
|
||||
},
|
||||
assets: {
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: "Client/",
|
||||
src: [
|
||||
'<%= staticFilePattern %>'
|
||||
],
|
||||
dest: "wwwroot/",
|
||||
options: { force: true }
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
less: {
|
||||
dev: {
|
||||
options: {
|
||||
cleancss: false
|
||||
},
|
||||
files: {
|
||||
"wwwroot/css/site.css": "Client/**/*.less"
|
||||
}
|
||||
},
|
||||
release: {
|
||||
options: {
|
||||
cleancss: true
|
||||
},
|
||||
files: {
|
||||
"wwwroot/css/site.css": "Client/**/*.less"
|
||||
}
|
||||
}
|
||||
},
|
||||
tsng: {
|
||||
options: {
|
||||
extension: ".ng.ts"
|
||||
},
|
||||
dev: {
|
||||
files: [
|
||||
// TODO: Automate the generation of this config based on convention
|
||||
{
|
||||
src: ['Client/ng-apps/components/**/*.ts', 'Client/ng-apps/MusicStore.Store/**/*.ts', "!**/*.ng.ts"],
|
||||
dest: "Client/ng-apps" // This needs to be the same across all sets so shared components work
|
||||
},
|
||||
{
|
||||
src: ['Client/ng-apps/components/**/*.ts', 'Client/ng-apps/MusicStore.Admin/**/*.ts', "!**/*.ng.ts"],
|
||||
dest: "Client/ng-apps" // This needs to be the same across all sets so shared components work
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
staticFilePattern: "**/*.{js,css,map,html,htm,ico,jpg,jpeg,png,gif,eot,svg,ttf,woff}",
|
||||
tslint: {
|
||||
options: {
|
||||
configuration: grunt.file.readJSON("tslint.json")
|
||||
configuration: grunt.file.readJSON("grunt/tslint-rules.json")
|
||||
},
|
||||
files: {
|
||||
src: ['Client/**/*.ts', '!**/*.ng.ts']
|
||||
}
|
||||
},
|
||||
typescript: {
|
||||
options: {
|
||||
module: 'amd', // or commonjs
|
||||
target: 'es5', // or es3
|
||||
sourcemap: false
|
||||
},
|
||||
dev: {
|
||||
files: [
|
||||
// TODO: Automate the generation of this config based on convention
|
||||
{
|
||||
src: ['Client/ng-apps/components/**/*.ng.ts', 'Client/ng-apps/MusicStore.Store/**/*.ng.ts'],
|
||||
dest: 'wwwroot/js/MusicStore.Store.js'
|
||||
},
|
||||
{
|
||||
src: ['Client/ng-apps/components/**/*.ng.ts', 'Client/ng-apps/MusicStore.Admin/**/*.ng.ts'],
|
||||
dest: 'wwwroot/js/MusicStore.Admin.js'
|
||||
}
|
||||
]
|
||||
},
|
||||
release: {
|
||||
options: {
|
||||
sourcemap: true
|
||||
},
|
||||
files: '<%= typescript.dev.files %>'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
typescript: {
|
||||
files: ['Client/**/*.ts', "!**/*.ng.ts"],
|
||||
tasks: ['ts']
|
||||
},
|
||||
dev: {
|
||||
files: ['bower_components/<%= staticFilePattern %>', 'Client/<%= staticFilePattern %>'],
|
||||
tasks: ['dev']
|
||||
src: ["Client/**/*.ts", "!**/*.ng.ts"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//grunt.registerTask('test', ['jshint', 'qunit']);
|
||||
grunt.registerTask('ts', ['tslint', 'tsng', 'typescript:dev']);
|
||||
grunt.registerTask('dev', ['clean', 'copy', 'less:dev', 'ts']);
|
||||
grunt.registerTask('release', ['clean', 'copy', 'uglify', 'less:release', 'typescript:release']);
|
||||
grunt.registerTask('default', ['dev']);
|
||||
grunt.registerTask("ts", ["tslint", "tsng", "typescript:dev", "clean:tsng"]);
|
||||
grunt.registerTask("dev", ["clean", "copy", "less:dev", "ts"]);
|
||||
grunt.registerTask("release", ["clean", "copy", "uglify", "less:release", "typescript:release"]);
|
||||
grunt.registerTask("default", ["dev"]);
|
||||
|
||||
require("grunt-ide-support")(grunt);
|
||||
};
|
||||
|
|
@ -18,4 +18,9 @@
|
|||
<DevelopmentServerPort>5001</DevelopmentServerPort>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties Project_1json__JSONSchema="http://json.schemastore.org/project" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
|
|
@ -63,17 +63,7 @@ namespace MusicStore.Spa
|
|||
app.UseStaticFiles();
|
||||
|
||||
// Add MVC
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
// TODO: Move these back to attribute routes when they're available
|
||||
routes.MapRoute(null, "api/genres/menu", new { controller = "GenresApi", action = "GenreMenuList" });
|
||||
routes.MapRoute(null, "api/genres", new { controller = "GenresApi", action = "GenreList" });
|
||||
routes.MapRoute(null, "api/genres/{genreId}/albums", new { controller = "GenresApi", action = "GenreAlbums" });
|
||||
routes.MapRoute(null, "api/albums/mostPopular", new { controller = "AlbumsApi", action = "MostPopular" });
|
||||
routes.MapRoute(null, "api/albums/all", new { controller = "AlbumsApi", action = "All" });
|
||||
routes.MapRoute(null, "api/albums/{albumId}", new { controller = "AlbumsApi", action = "Details" });
|
||||
routes.MapRoute(null, "{controller}/{action}/{id?}", new { controller = "Home", action = "Index" });
|
||||
});
|
||||
app.UseMvc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"options": { "force": true },
|
||||
"bower": ["wwwroot/*", "!wwwroot/bin"],
|
||||
"assets": ["wwwroot/*", "!wwwroot/bin"],
|
||||
"tsng": ["client/**/*.ng.ts"]
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"fix": {
|
||||
"_": "This is to work around an issue with the dt-angular bower package https://github.com/dt-bower/dt-angular/issues/4",
|
||||
"files": {
|
||||
"bower_components/jquery/jquery.d.ts": [ "bower_components/dt-jquery/jquery.d.ts" ]
|
||||
}
|
||||
},
|
||||
"bower": {
|
||||
"files": [
|
||||
{
|
||||
"_": "JavaScript",
|
||||
"expand": true,
|
||||
"flatten": true,
|
||||
"cwd": "bower_components/",
|
||||
"src": [
|
||||
"modernizr/modernizr.js",
|
||||
"jquery/dist/*.{js,map}",
|
||||
"jquery.validation/jquery.validate.js",
|
||||
"jquery.validation/additional-methods.js",
|
||||
"bootstrap/dist/**/*.js",
|
||||
"respond/dest/**/*.js",
|
||||
"angular/*.{js,.js.map}",
|
||||
"angular-route/*.{js,.js.map}",
|
||||
"angular-bootstrap/ui-bootstrap*"
|
||||
],
|
||||
"dest": "wwwroot/js/",
|
||||
"options": { "force": true }
|
||||
},
|
||||
{
|
||||
"_": "CSS",
|
||||
"expand": true,
|
||||
"flatten": true,
|
||||
"cwd": "bower_components/",
|
||||
"src": [
|
||||
"bootstrap/dist/**/*.css"
|
||||
],
|
||||
"dest": "wwwroot/css/",
|
||||
"options": { "force": true }
|
||||
},
|
||||
{
|
||||
"_": "Fonts",
|
||||
"expand": true,
|
||||
"flatten": true,
|
||||
"cwd": "bower_components/",
|
||||
"src": [
|
||||
"bootstrap/**/*.{woff,svg,eot,ttf}"
|
||||
],
|
||||
"dest": "wwwroot/fonts/",
|
||||
"options": { "force": true }
|
||||
}
|
||||
]
|
||||
},
|
||||
"assets": {
|
||||
"files": [
|
||||
{
|
||||
"expand": true,
|
||||
"cwd": "Client/",
|
||||
"src": [
|
||||
"<%= staticFilePattern %>"
|
||||
],
|
||||
"dest": "wwwroot/",
|
||||
"options": { "force": true }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"dev": {
|
||||
"options": {
|
||||
"cleancss": false
|
||||
},
|
||||
"files": {
|
||||
"wwwroot/css/site.css": "Client/**/*.less"
|
||||
}
|
||||
},
|
||||
"release": {
|
||||
"options": {
|
||||
"cleancss": true
|
||||
},
|
||||
"files": {
|
||||
"wwwroot/css/site.css": "Client/**/*.less"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"options": {
|
||||
"extension": ".ng.ts"
|
||||
},
|
||||
"dev": {
|
||||
"files": [
|
||||
{
|
||||
"src": [ "Client/ng-apps/components/**/*.ts", "Client/ng-apps/MusicStore.Store/**/*.ts", "!**/*.ng.ts" ],
|
||||
"dest": "Client/ng-apps"
|
||||
},
|
||||
{
|
||||
"src": ["Client/ng-apps/components/**/*.ts", "Client/ng-apps/MusicStore.Admin/**/*.ts", "!**/*.ng.ts"],
|
||||
"dest": "Client/ng-apps"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"options": {
|
||||
"module": "amd",
|
||||
"target": "es5",
|
||||
"sourcemap": false
|
||||
},
|
||||
"dev": {
|
||||
"files": [
|
||||
{
|
||||
"src": ["Client/ng-apps/components/**/*.ng.ts", "Client/ng-apps/MusicStore.Store/**/*.ng.ts"],
|
||||
"dest": "wwwroot/js/MusicStore.Store.js"
|
||||
},
|
||||
{
|
||||
"src": ["Client/ng-apps/components/**/*.ng.ts", "Client/ng-apps/MusicStore.Admin/**/*.ng.ts"],
|
||||
"dest": "wwwroot/js/MusicStore.Admin.js"
|
||||
}
|
||||
]
|
||||
},
|
||||
"release": {
|
||||
"options": {
|
||||
"sourcemap": true
|
||||
},
|
||||
"files": "<%= typescript.dev.files %>"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"options": {
|
||||
"banner": "/*! <%= pkg.name %> <%= grunt.template.today('dd-mm-yyyy') %> */\n"
|
||||
},
|
||||
"release": {
|
||||
"files": {
|
||||
"wwwroot/app.min.js": ["<%= typescript.dev.dest %>"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"typescript": {
|
||||
"files": ["Client/**/*.ts", "!**/*.ng.ts"],
|
||||
"tasks": ["ts"]
|
||||
},
|
||||
"dev": {
|
||||
"files": ["bower_components/<%= staticFilePattern %>", "Client/<%= staticFilePattern %>"],
|
||||
"tasks": ["dev"]
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
"grunt-contrib-less": "~0.11.0",
|
||||
"grunt-typescript": "~0.3.6",
|
||||
"grunt-tslint": "~0.4.1",
|
||||
"grunt-tsng": "~0.1.3"
|
||||
"grunt-tsng": "~0.1.3",
|
||||
"grunt-ide-support": "~0.1.7"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"webroot": "wwwroot",
|
||||
"exclude": [ "wwwroot/**/*.*", "bower_components/**/*.*", "node_modules/**/*.*", "grunt/**/*.*" ],
|
||||
"pack-exclude": [ "bower.json", "package.json", "gruntfile.js", "bower_components/**/*.*", "node_modules/**/*.*", "grunt/**/*.*" ],
|
||||
"authors": [
|
||||
"Microsoft"
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue