Delete pre-processed *.ng.ts files from repo
This commit is contained in:
parent
1ca9e25e54
commit
ced2c3950f
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.Admin.Catalog {
|
|
||||||
angular.module("MusicStore.Admin.Catalog", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
module MusicStore.Admin.Catalog {
|
|
||||||
export interface IAlbumDeleteModalViewModel {
|
|
||||||
album: Models.IAlbum;
|
|
||||||
ok();
|
|
||||||
cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't register this controller with Angular's DI system because the $modal service
|
|
||||||
// will create and resolve its dependencies directly
|
|
||||||
|
|
||||||
//@NgController(skip=true)
|
|
||||||
export class AlbumDeleteModalController implements IAlbumDeleteModalViewModel {
|
|
||||||
private _modalInstance: ng.ui.bootstrap.IModalServiceInstance;
|
|
||||||
|
|
||||||
constructor($modalInstance: ng.ui.bootstrap.IModalServiceInstance, album: Models.IAlbum) {
|
|
||||||
this._modalInstance = $modalInstance;
|
|
||||||
this.album = album;
|
|
||||||
}
|
|
||||||
|
|
||||||
public album: Models.IAlbum;
|
|
||||||
|
|
||||||
public ok() {
|
|
||||||
this._modalInstance.close(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public cancel() {
|
|
||||||
this._modalInstance.dismiss("cancel");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.Admin.Catalog.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Admin.Catalog {
|
|
||||||
interface IAlbumDetailsRouteParams extends ng.route.IRouteParamsService {
|
|
||||||
albumId: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IAlbumDetailsViewModel {
|
|
||||||
album: Models.IAlbum;
|
|
||||||
deleteAlbum();
|
|
||||||
}
|
|
||||||
|
|
||||||
class AlbumDetailsController implements IAlbumDetailsViewModel {
|
|
||||||
private _modal: ng.ui.bootstrap.IModalService;
|
|
||||||
private _location: ng.ILocationService;
|
|
||||||
private _albumApi: AlbumApi.IAlbumApiService;
|
|
||||||
private _viewAlert: ViewAlert.IViewAlertService;
|
|
||||||
|
|
||||||
constructor($routeParams: IAlbumDetailsRouteParams,
|
|
||||||
$modal: ng.ui.bootstrap.IModalService,
|
|
||||||
$location: ng.ILocationService,
|
|
||||||
albumApi: AlbumApi.IAlbumApiService,
|
|
||||||
viewAlert: ViewAlert.IViewAlertService) {
|
|
||||||
|
|
||||||
this._modal = $modal;
|
|
||||||
this._location = $location;
|
|
||||||
this._albumApi = albumApi;
|
|
||||||
this._viewAlert = viewAlert;
|
|
||||||
|
|
||||||
albumApi.getAlbumDetails($routeParams.albumId).then(album => this.album = album);
|
|
||||||
}
|
|
||||||
|
|
||||||
public album: Models.IAlbum;
|
|
||||||
|
|
||||||
public deleteAlbum() {
|
|
||||||
var deleteModal = this._modal.open({
|
|
||||||
templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumDeleteModal.cshtml",
|
|
||||||
controller: "MusicStore.Admin.Catalog.AlbumDeleteModalController as viewModel",
|
|
||||||
resolve: {
|
|
||||||
album: () => this.album
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
deleteModal.result.then(shouldDelete => {
|
|
||||||
if (!shouldDelete) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._albumApi.deleteAlbum(this.album.AlbumId).then(result => {
|
|
||||||
// Navigate back to the list
|
|
||||||
this._viewAlert.alert = {
|
|
||||||
type: Models.AlertType.success,
|
|
||||||
message: result.data.Message
|
|
||||||
};
|
|
||||||
this._location.path("/albums").replace();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.Admin.Catalog")
|
|
||||||
.controller("MusicStore.Admin.Catalog.AlbumDetailsController", [
|
|
||||||
"$routeParams",
|
|
||||||
"$modal",
|
|
||||||
"$location",
|
|
||||||
"MusicStore.AlbumApi.IAlbumApiService",
|
|
||||||
"MusicStore.ViewAlert.IViewAlertService",
|
|
||||||
AlbumDetailsController
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,205 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.Admin.Catalog.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Admin.Catalog {
|
|
||||||
interface IAlbumDetailsRouteParams extends ng.route.IRouteParamsService {
|
|
||||||
mode: string;
|
|
||||||
albumId: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IAlbumDetailsViewModel {
|
|
||||||
mode: string; // edit or new
|
|
||||||
disabled: boolean;
|
|
||||||
album: Models.IAlbum;
|
|
||||||
alert: Models.IAlert;
|
|
||||||
artists: Array<Models.IArtist>;
|
|
||||||
genres: Array<Models.IGenreLookup>;
|
|
||||||
save();
|
|
||||||
clearAlert();
|
|
||||||
}
|
|
||||||
|
|
||||||
class AlbumEditController implements IAlbumDetailsViewModel {
|
|
||||||
private _albumApi: AlbumApi.IAlbumApiService;
|
|
||||||
private _artistApi: ArtistApi.IArtistApiService;
|
|
||||||
private _genreApi: GenreApi.IGenreApiService;
|
|
||||||
private _viewAlert: ViewAlert.IViewAlertService;
|
|
||||||
private _modal: ng.ui.bootstrap.IModalService;
|
|
||||||
private _location: ng.ILocationService;
|
|
||||||
private _timeout: ng.ITimeoutService;
|
|
||||||
private _log: ng.ILogService;
|
|
||||||
|
|
||||||
constructor($routeParams: IAlbumDetailsRouteParams,
|
|
||||||
albumApi: AlbumApi.IAlbumApiService,
|
|
||||||
artistApi: ArtistApi.IArtistApiService,
|
|
||||||
genreApi: GenreApi.IGenreApiService,
|
|
||||||
viewAlert: ViewAlert.IViewAlertService,
|
|
||||||
$modal: ng.ui.bootstrap.IModalService,
|
|
||||||
$location: ng.ILocationService,
|
|
||||||
$timeout: ng.ITimeoutService,
|
|
||||||
$q: ng.IQService,
|
|
||||||
$log: ng.ILogService) {
|
|
||||||
|
|
||||||
this._albumApi = albumApi;
|
|
||||||
this._artistApi = artistApi;
|
|
||||||
this._genreApi = genreApi;
|
|
||||||
this._viewAlert = viewAlert;
|
|
||||||
this._modal = $modal;
|
|
||||||
this._location = $location;
|
|
||||||
this._timeout = $timeout;
|
|
||||||
this._log = $log;
|
|
||||||
|
|
||||||
this.mode = $routeParams.mode;
|
|
||||||
|
|
||||||
this.alert = viewAlert.alert;
|
|
||||||
|
|
||||||
artistApi.getArtistsLookup().then(artists => this.artists = artists);
|
|
||||||
genreApi.getGenresLookup().then(genres => this.genres = genres);
|
|
||||||
|
|
||||||
if (this.mode.toLowerCase() === "edit") {
|
|
||||||
// TODO: Handle album load failure
|
|
||||||
albumApi.getAlbumDetails($routeParams.albumId).then(album => {
|
|
||||||
this.album = album;
|
|
||||||
|
|
||||||
// Pre-load the lookup arrays with the current values if not set yet
|
|
||||||
this.genres = this.genres || [album.Genre];
|
|
||||||
this.artists = this.artists || [album.Artist];
|
|
||||||
|
|
||||||
this.disabled = false;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.disabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public mode: string;
|
|
||||||
|
|
||||||
public disabled = true;
|
|
||||||
|
|
||||||
public album: Models.IAlbum;
|
|
||||||
|
|
||||||
public alert: Models.IAlert;
|
|
||||||
|
|
||||||
public artists: Array<Models.IArtist>;
|
|
||||||
|
|
||||||
public genres: Array<Models.IGenreLookup>;
|
|
||||||
|
|
||||||
public save() {
|
|
||||||
this.disabled = true;
|
|
||||||
|
|
||||||
var apiMethod = this.mode.toLowerCase() === "edit" ? this._albumApi.updateAlbum : this._albumApi.createAlbum;
|
|
||||||
apiMethod = apiMethod.bind(this._albumApi);
|
|
||||||
|
|
||||||
apiMethod(this.album).then(
|
|
||||||
// Success
|
|
||||||
response => {
|
|
||||||
var alert = {
|
|
||||||
type: Models.AlertType.success,
|
|
||||||
message: response.data.Message
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: Do we need to destroy this timeout on controller unload?
|
|
||||||
this._timeout(() => this.alert !== alert || this.clearAlert(), 3000);
|
|
||||||
|
|
||||||
if (this.mode.toLowerCase() === "new") {
|
|
||||||
this._log.info("Created album successfully!");
|
|
||||||
|
|
||||||
var albumId: number = response.data.Data;
|
|
||||||
|
|
||||||
this._viewAlert.alert = alert;
|
|
||||||
|
|
||||||
// Reload the view with the new album ID
|
|
||||||
this._location.path("/albums/" + albumId + "/edit").replace();
|
|
||||||
} else {
|
|
||||||
this.alert = alert;
|
|
||||||
this.disabled = false;
|
|
||||||
this._log.info("Updated album " + this.album.AlbumId + " successfully!");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Error
|
|
||||||
response => {
|
|
||||||
// TODO: Make this common logic, e.g. base controller class, injected helper service, etc.
|
|
||||||
if (response.status === 400) {
|
|
||||||
// We made a bad request
|
|
||||||
if (response.data && response.data.ModelErrors) {
|
|
||||||
// The server says the update failed validation
|
|
||||||
// TODO: Map errors back to client validators and/or summary
|
|
||||||
this.alert = {
|
|
||||||
type: Models.AlertType.danger,
|
|
||||||
message: response.data.Message,
|
|
||||||
modelErrors: response.data.ModelErrors
|
|
||||||
};
|
|
||||||
this.disabled = false;
|
|
||||||
} else {
|
|
||||||
// Some other bad request, just show the message
|
|
||||||
this.alert = {
|
|
||||||
type: Models.AlertType.danger,
|
|
||||||
message: response.data.Message
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else if (response.status === 404) {
|
|
||||||
// The album wasn't found, probably deleted. Leave the form disabled and show error message.
|
|
||||||
this.alert = {
|
|
||||||
type: Models.AlertType.danger,
|
|
||||||
message: response.data.Message
|
|
||||||
};
|
|
||||||
} else if (response.status === 401) {
|
|
||||||
// We need to authenticate again
|
|
||||||
// TODO: Should we just redirect to login page, show a message with a link, or something else
|
|
||||||
this.alert = {
|
|
||||||
type: Models.AlertType.danger,
|
|
||||||
message: "Your session has timed out. Please log in and try again."
|
|
||||||
};
|
|
||||||
} else if (!response.status) {
|
|
||||||
// Request timed out or no response from server or worse
|
|
||||||
this._log.error("Error updating album " + this.album.AlbumId);
|
|
||||||
this._log.error(response);
|
|
||||||
this.alert = { type: Models.AlertType.danger, message: "An unexpected error occurred. Please try again." };
|
|
||||||
this.disabled = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public deleteAlbum() {
|
|
||||||
var deleteModal = this._modal.open({
|
|
||||||
templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumDeleteModal.cshtml",
|
|
||||||
controller: "MusicStore.Admin.Catalog.AlbumDeleteModalController as viewModel",
|
|
||||||
resolve: {
|
|
||||||
album: () => this.album
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
deleteModal.result.then(shouldDelete => {
|
|
||||||
if (!shouldDelete) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._albumApi.deleteAlbum(this.album.AlbumId).then(result => {
|
|
||||||
// Navigate back to the list
|
|
||||||
this._viewAlert.alert = {
|
|
||||||
type: Models.AlertType.success,
|
|
||||||
message: result.data.Message
|
|
||||||
};
|
|
||||||
this._location.path("/albums").replace();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public clearAlert() {
|
|
||||||
this.alert = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.Admin.Catalog")
|
|
||||||
.controller("MusicStore.Admin.Catalog.AlbumEditController", [
|
|
||||||
"$routeParams",
|
|
||||||
"MusicStore.AlbumApi.IAlbumApiService",
|
|
||||||
"MusicStore.ArtistApi.IArtistApiService",
|
|
||||||
"MusicStore.GenreApi.IGenreApiService",
|
|
||||||
"MusicStore.ViewAlert.IViewAlertService",
|
|
||||||
"$modal",
|
|
||||||
"$location",
|
|
||||||
"$timeout",
|
|
||||||
"$q",
|
|
||||||
"$log",
|
|
||||||
AlbumEditController
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,135 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.Admin.Catalog.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Admin.Catalog {
|
|
||||||
interface IAlbumListViewModel {
|
|
||||||
albums: Array<Models.IAlbum>;
|
|
||||||
totalCount: number;
|
|
||||||
currentPage: number;
|
|
||||||
pageSize: number;
|
|
||||||
loadPage(page?: number);
|
|
||||||
deleteAlbum(album: Models.IAlbum);
|
|
||||||
clearAlert();
|
|
||||||
}
|
|
||||||
|
|
||||||
class AlbumListController implements IAlbumListViewModel {
|
|
||||||
private _albumApi: AlbumApi.IAlbumApiService;
|
|
||||||
private _modal: ng.ui.bootstrap.IModalService;
|
|
||||||
private _timeout: ng.ITimeoutService;
|
|
||||||
private _log: ng.ILogService;
|
|
||||||
|
|
||||||
constructor(albumApi: AlbumApi.IAlbumApiService,
|
|
||||||
viewAlert: ViewAlert.IViewAlertService,
|
|
||||||
$modal: ng.ui.bootstrap.IModalService,
|
|
||||||
$timeout: ng.ITimeoutService,
|
|
||||||
$log: ng.ILogService) {
|
|
||||||
|
|
||||||
this._albumApi = albumApi;
|
|
||||||
this._modal = $modal;
|
|
||||||
this._timeout = $timeout;
|
|
||||||
this._log = $log;
|
|
||||||
|
|
||||||
this.currentPage = 1;
|
|
||||||
this.pageSize = 50;
|
|
||||||
this.loadPage(1);
|
|
||||||
this.sortColumn = "Title";
|
|
||||||
|
|
||||||
this.showAlert(viewAlert.alert, 3000);
|
|
||||||
viewAlert.alert = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public alert: Models.IAlert;
|
|
||||||
|
|
||||||
public albums: Array<Models.IAlbum>;
|
|
||||||
|
|
||||||
public totalCount: number;
|
|
||||||
|
|
||||||
public currentPage: number;
|
|
||||||
|
|
||||||
public pageSize: number;
|
|
||||||
|
|
||||||
public sortColumn: string;
|
|
||||||
|
|
||||||
public sortDescending: boolean;
|
|
||||||
|
|
||||||
public loadPage(page?: number) {
|
|
||||||
page = page || this.currentPage;
|
|
||||||
var sortByExpression = this.getSortByExpression();
|
|
||||||
this._albumApi.getAlbums(page, this.pageSize, sortByExpression).then(result => {
|
|
||||||
this.albums = result.Data;
|
|
||||||
this.currentPage = result.Page;
|
|
||||||
this.totalCount = result.TotalCount;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public sortBy(column: string) {
|
|
||||||
if (this.sortColumn === column) {
|
|
||||||
// Just flip the direction
|
|
||||||
this.sortDescending = !this.sortDescending;
|
|
||||||
} else {
|
|
||||||
this.sortColumn = column;
|
|
||||||
this.sortDescending = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loadPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public deleteAlbum(album: Models.IAlbum) {
|
|
||||||
var deleteModal = this._modal.open({
|
|
||||||
templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumDeleteModal.cshtml",
|
|
||||||
controller: "MusicStore.Admin.Catalog.AlbumDeleteModalController as viewModel",
|
|
||||||
resolve: {
|
|
||||||
album: () => album
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
deleteModal.result.then(shouldDelete => {
|
|
||||||
if (!shouldDelete) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._albumApi.deleteAlbum(album.AlbumId).then(result => {
|
|
||||||
this.loadPage();
|
|
||||||
|
|
||||||
this.showAlert({
|
|
||||||
type: Models.AlertType.success,
|
|
||||||
message: result.data.Message
|
|
||||||
}, 3000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public clearAlert() {
|
|
||||||
this.alert = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private showAlert(alert: Models.IAlert, closeAfter?: number) {
|
|
||||||
if (!alert) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.alert = alert;
|
|
||||||
|
|
||||||
// TODO: Do we need to destroy this timeout on controller unload?
|
|
||||||
if (closeAfter) {
|
|
||||||
this._timeout(() => this.alert !== alert || this.clearAlert(), closeAfter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getSortByExpression() {
|
|
||||||
if (this.sortDescending) {
|
|
||||||
return this.sortColumn + " DESC";
|
|
||||||
}
|
|
||||||
return this.sortColumn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.Admin.Catalog")
|
|
||||||
.controller("MusicStore.Admin.Catalog.AlbumListController", [
|
|
||||||
"MusicStore.AlbumApi.IAlbumApiService",
|
|
||||||
"MusicStore.ViewAlert.IViewAlertService",
|
|
||||||
"$modal",
|
|
||||||
"$timeout",
|
|
||||||
"$log",
|
|
||||||
AlbumListController
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
/// <reference path="../references.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Admin {
|
|
||||||
angular.module("MusicStore.Admin", [
|
|
||||||
"ngRoute",
|
|
||||||
"ui.bootstrap",
|
|
||||||
"MusicStore.InlineData",
|
|
||||||
"MusicStore.GenreMenu",
|
|
||||||
"MusicStore.UrlResolver",
|
|
||||||
"MusicStore.UserDetails",
|
|
||||||
"MusicStore.LoginLink",
|
|
||||||
"MusicStore.Visited",
|
|
||||||
"MusicStore.TitleCase",
|
|
||||||
"MusicStore.Truncate",
|
|
||||||
"MusicStore.GenreApi",
|
|
||||||
"MusicStore.AlbumApi",
|
|
||||||
"MusicStore.ArtistApi",
|
|
||||||
"MusicStore.ViewAlert",
|
|
||||||
"MusicStore.Admin.Catalog",
|
|
||||||
]).config([
|
|
||||||
"$routeProvider",
|
|
||||||
"$logProvider",
|
|
||||||
configuration
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
var dependencies = [
|
|
||||||
"ngRoute",
|
|
||||||
"ui.bootstrap",
|
|
||||||
MusicStore.InlineData,
|
|
||||||
MusicStore.GenreMenu,
|
|
||||||
MusicStore.UrlResolver,
|
|
||||||
MusicStore.UserDetails,
|
|
||||||
MusicStore.LoginLink,
|
|
||||||
MusicStore.Visited,
|
|
||||||
MusicStore.TitleCase,
|
|
||||||
MusicStore.Truncate,
|
|
||||||
MusicStore.GenreApi,
|
|
||||||
MusicStore.AlbumApi,
|
|
||||||
MusicStore.ArtistApi,
|
|
||||||
MusicStore.ViewAlert,
|
|
||||||
MusicStore.Admin.Catalog
|
|
||||||
];
|
|
||||||
|
|
||||||
// Use this method to register work which needs to be performed on module loading.
|
|
||||||
// Note only providers can be injected as dependencies here.
|
|
||||||
function configuration($routeProvider: ng.route.IRouteProvider, $logProvider: ng.ILogProvider) {
|
|
||||||
// TODO: Enable debug logging based on server config
|
|
||||||
// TODO: Capture all logged errors and send back to server
|
|
||||||
$logProvider.debugEnabled(true);
|
|
||||||
|
|
||||||
// Configure routes
|
|
||||||
$routeProvider
|
|
||||||
.when("/albums/:albumId/details", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumDetails.cshtml" })
|
|
||||||
.when("/albums/:albumId/:mode", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumEdit.cshtml" })
|
|
||||||
.when("/albums/:mode", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumEdit.cshtml" })
|
|
||||||
.when("/albums", { templateUrl: "ng-apps/MusicStore.Admin/Catalog/AlbumList.cshtml" })
|
|
||||||
.otherwise({ redirectTo: "/albums" });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use this method to register work which should be performed when the injector is done loading all modules.
|
|
||||||
//function BUG:run() {
|
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.AlbumApi {
|
|
||||||
angular.module("MusicStore.AlbumApi", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.ArtistApi {
|
|
||||||
angular.module("MusicStore.ArtistApi", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.GenreApi {
|
|
||||||
angular.module("MusicStore.GenreApi", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.GenreMenu {
|
|
||||||
angular.module("MusicStore.GenreMenu", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.InlineData {
|
|
||||||
angular.module("MusicStore.InlineData", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.LoginLink {
|
|
||||||
angular.module("MusicStore.LoginLink", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.PreventSubmit {
|
|
||||||
angular.module("MusicStore.PreventSubmit", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.Store.Catalog {
|
|
||||||
angular.module("MusicStore.Store.Catalog", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.Store.Home {
|
|
||||||
angular.module("MusicStore.Store.Home", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.Store.Catalog.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Store.Catalog {
|
|
||||||
interface IAlbumDetailsViewModel {
|
|
||||||
album: Models.IAlbum;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IAlbumDetailsRouteParams extends ng.route.IRouteParamsService {
|
|
||||||
albumId: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AlbumDetailsController implements IAlbumDetailsViewModel {
|
|
||||||
public album: Models.IAlbum;
|
|
||||||
|
|
||||||
constructor($routeParams: IAlbumDetailsRouteParams, albumApi: AlbumApi.IAlbumApiService) {
|
|
||||||
var viewModel = this,
|
|
||||||
albumId = $routeParams.albumId;
|
|
||||||
|
|
||||||
albumApi.getAlbumDetails(albumId).then(album => {
|
|
||||||
viewModel.album = album;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.Store.Catalog")
|
|
||||||
.controller("MusicStore.Store.Catalog.AlbumDetailsController", [
|
|
||||||
"$routeParams",
|
|
||||||
"MusicStore.AlbumApi.IAlbumApiService",
|
|
||||||
AlbumDetailsController
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.Store.Catalog.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Store.Catalog {
|
|
||||||
interface IGenreDetailsViewModel {
|
|
||||||
albums: Array<Models.IAlbum>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IGenreDetailsRouteParams extends ng.route.IRouteParamsService {
|
|
||||||
genreId: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
class GenreDetailsController implements IGenreDetailsViewModel {
|
|
||||||
public albums: Array<Models.IAlbum>;
|
|
||||||
|
|
||||||
constructor($routeParams: IGenreDetailsRouteParams, genreApi: GenreApi.IGenreApiService) {
|
|
||||||
var viewModel = this;
|
|
||||||
|
|
||||||
genreApi.getGenreAlbums($routeParams.genreId).success(result => {
|
|
||||||
viewModel.albums = result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.Store.Catalog")
|
|
||||||
.controller("MusicStore.Store.Catalog.GenreDetailsController", [
|
|
||||||
"$routeParams",
|
|
||||||
"MusicStore.GenreApi.IGenreApiService",
|
|
||||||
GenreDetailsController
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.Store.Catalog.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Store.Catalog {
|
|
||||||
interface IGenreListViewModel {
|
|
||||||
genres: Array<Models.IGenre>;
|
|
||||||
}
|
|
||||||
|
|
||||||
class GenreListController implements IGenreListViewModel {
|
|
||||||
public genres: Array<Models.IGenre>;
|
|
||||||
|
|
||||||
constructor(genreApi: GenreApi.IGenreApiService) {
|
|
||||||
var viewModel = this;
|
|
||||||
|
|
||||||
genreApi.getGenresList().success(function (genres) {
|
|
||||||
viewModel.genres = genres;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.Store.Catalog")
|
|
||||||
.controller("MusicStore.Store.Catalog.GenreListController", [
|
|
||||||
"MusicStore.GenreApi.IGenreApiService",
|
|
||||||
GenreListController
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.Store.Home.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Store.Home {
|
|
||||||
interface IHomeViewModel {
|
|
||||||
albums: Array<Models.IAlbum>
|
|
||||||
}
|
|
||||||
|
|
||||||
class HomeController implements IHomeViewModel {
|
|
||||||
public albums: Array<Models.IAlbum>;
|
|
||||||
|
|
||||||
constructor(albumApi: AlbumApi.IAlbumApiService) {
|
|
||||||
var viewModel = this;
|
|
||||||
|
|
||||||
albumApi.getMostPopularAlbums().then(albums => {
|
|
||||||
viewModel.albums = albums;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.Store.Home")
|
|
||||||
.controller("MusicStore.Store.Home.HomeController", [
|
|
||||||
"MusicStore.AlbumApi.IAlbumApiService",
|
|
||||||
HomeController
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
/// <reference path="../references.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Store {
|
|
||||||
angular.module("MusicStore.Store", [
|
|
||||||
"ngRoute",
|
|
||||||
"MusicStore.InlineData",
|
|
||||||
"MusicStore.PreventSubmit",
|
|
||||||
"MusicStore.GenreMenu",
|
|
||||||
"MusicStore.UrlResolver",
|
|
||||||
"MusicStore.UserDetails",
|
|
||||||
"MusicStore.LoginLink",
|
|
||||||
"MusicStore.GenreApi",
|
|
||||||
"MusicStore.AlbumApi",
|
|
||||||
"MusicStore.Store.Home",
|
|
||||||
"MusicStore.Store.Catalog",
|
|
||||||
]).config([
|
|
||||||
"$routeProvider",
|
|
||||||
"$logProvider",
|
|
||||||
configuration
|
|
||||||
]).run([
|
|
||||||
"$log",
|
|
||||||
"MusicStore.UserDetails.IUserDetailsService",
|
|
||||||
run
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
var dependencies = [
|
|
||||||
"ngRoute",
|
|
||||||
MusicStore.InlineData,
|
|
||||||
MusicStore.PreventSubmit,
|
|
||||||
MusicStore.GenreMenu,
|
|
||||||
MusicStore.UrlResolver,
|
|
||||||
MusicStore.UserDetails,
|
|
||||||
MusicStore.LoginLink,
|
|
||||||
MusicStore.GenreApi,
|
|
||||||
MusicStore.AlbumApi,
|
|
||||||
MusicStore.Store.Home,
|
|
||||||
MusicStore.Store.Catalog
|
|
||||||
];
|
|
||||||
|
|
||||||
// Use this method to register work which needs to be performed on module loading.
|
|
||||||
// Note only providers can be injected as dependencies here.
|
|
||||||
function configuration($routeProvider: ng.route.IRouteProvider, $logProvider: ng.ILogProvider) {
|
|
||||||
// TODO: Enable debug logging based on server config
|
|
||||||
// TODO: Capture all logged errors and send back to server
|
|
||||||
$logProvider.debugEnabled(true);
|
|
||||||
|
|
||||||
$routeProvider
|
|
||||||
.when("/", { templateUrl: "ng-apps/MusicStore.Store/Home/Home.html" })
|
|
||||||
.when("/albums/genres", { templateUrl: "ng-apps/MusicStore.Store/Catalog/GenreList.html" })
|
|
||||||
.when("/albums/genres/:genreId", { templateUrl: "ng-apps/MusicStore.Store/Catalog/GenreDetails.html" })
|
|
||||||
.when("/albums/:albumId", { templateUrl: "ng-apps/MusicStore.Store/Catalog/AlbumDetails.html" })
|
|
||||||
.otherwise({ redirectTo: "/" });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use this method to register work which should be performed when the injector is done loading all modules.
|
|
||||||
function run($log: ng.ILogService, userDetails: UserDetails.IUserDetailsService) {
|
|
||||||
$log.log(userDetails.getUserDetails());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.TitleCase {
|
|
||||||
angular.module("MusicStore.TitleCase", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.Truncate {
|
|
||||||
angular.module("MusicStore.Truncate", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.UrlResolver {
|
|
||||||
angular.module("MusicStore.UrlResolver", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.UserDetails {
|
|
||||||
angular.module("MusicStore.UserDetails", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.ViewAlert {
|
|
||||||
angular.module("MusicStore.ViewAlert", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module MusicStore.Visited {
|
|
||||||
angular.module("MusicStore.Visited", []);
|
|
||||||
}
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.AlbumApi.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.AlbumApi {
|
|
||||||
export interface IAlbumApiService {
|
|
||||||
getAlbums(page?: number, pageSize?: number, sortBy?: string): ng.IPromise<Models.IPagedList<Models.IAlbum>>;
|
|
||||||
getAlbumDetails(albumId: number): ng.IPromise<Models.IAlbum>;
|
|
||||||
getMostPopularAlbums(count?: number): ng.IPromise<Array<Models.IAlbum>>;
|
|
||||||
createAlbum(album: Models.IAlbum, config?: ng.IRequestConfig): ng.IHttpPromise<Models.IApiResult>;
|
|
||||||
updateAlbum(album: Models.IAlbum, config?: ng.IRequestConfig): ng.IHttpPromise<Models.IApiResult>;
|
|
||||||
deleteAlbum(albumId: number, config?: ng.IRequestConfig): ng.IHttpPromise<Models.IApiResult>;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AlbumApiService implements IAlbumApiService {
|
|
||||||
private _inlineData: ng.ICacheObject;
|
|
||||||
private _q: ng.IQService;
|
|
||||||
private _http: ng.IHttpService;
|
|
||||||
private _urlResolver: UrlResolver.IUrlResolverService;
|
|
||||||
|
|
||||||
constructor($cacheFactory: ng.ICacheFactoryService,
|
|
||||||
$q: ng.IQService,
|
|
||||||
$http: ng.IHttpService,
|
|
||||||
urlResolver: UrlResolver.IUrlResolverService) {
|
|
||||||
this._inlineData = $cacheFactory.get("inlineData");
|
|
||||||
this._q = $q;
|
|
||||||
this._http = $http;
|
|
||||||
this._urlResolver = urlResolver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getAlbums(page?: number, pageSize?: number, sortBy?: string) {
|
|
||||||
var url = this._urlResolver.resolveUrl("~/api/albums"),
|
|
||||||
query: any = {},
|
|
||||||
querySeparator = "?",
|
|
||||||
inlineData;
|
|
||||||
|
|
||||||
if (page) {
|
|
||||||
query.page = page;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pageSize) {
|
|
||||||
query.pageSize = pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sortBy) {
|
|
||||||
query.sortBy = sortBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var key in query) {
|
|
||||||
if (query.hasOwnProperty(key)) {
|
|
||||||
url += querySeparator + key + "=" + encodeURIComponent(query[key]);
|
|
||||||
if (querySeparator === "?") {
|
|
||||||
querySeparator = "&";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inlineData = this._inlineData ? this._inlineData.get(url) : null;
|
|
||||||
|
|
||||||
if (inlineData) {
|
|
||||||
return this._q.when(inlineData);
|
|
||||||
} else {
|
|
||||||
return this._http.get(url).then(result => result.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getAlbumDetails(albumId: number) {
|
|
||||||
var url = this._urlResolver.resolveUrl("~/api/albums/" + albumId);
|
|
||||||
return this._http.get(url).then(result => result.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getMostPopularAlbums(count?: number) {
|
|
||||||
var url = this._urlResolver.resolveUrl("~/api/albums/mostPopular"),
|
|
||||||
inlineData = this._inlineData ? this._inlineData.get(url) : null;
|
|
||||||
|
|
||||||
if (inlineData) {
|
|
||||||
return this._q.when(inlineData);
|
|
||||||
} else {
|
|
||||||
if (count && count > 0) {
|
|
||||||
url += "?count=" + count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this._http.get(url).then(result => result.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public createAlbum(album: Models.IAlbum, config?: ng.IRequestConfig) {
|
|
||||||
var url = this._urlResolver.resolveUrl("api/albums");
|
|
||||||
return this._http.post(url, album, config || { timeout: 10000 });
|
|
||||||
}
|
|
||||||
|
|
||||||
public updateAlbum(album: Models.IAlbum, config?: ng.IRequestConfig) {
|
|
||||||
var url = this._urlResolver.resolveUrl("api/albums/" + album.AlbumId + "/update");
|
|
||||||
return this._http.put(url, album, config || { timeout: 10000 });
|
|
||||||
}
|
|
||||||
|
|
||||||
public deleteAlbum(albumId: number, config?: ng.IRequestConfig) {
|
|
||||||
var url = this._urlResolver.resolveUrl("api/albums/" + albumId);
|
|
||||||
return this._http.delete(url, config || { timeout: 10000 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.AlbumApi")
|
|
||||||
.service("MusicStore.AlbumApi.IAlbumApiService", [
|
|
||||||
"$cacheFactory",
|
|
||||||
"$q",
|
|
||||||
"$http",
|
|
||||||
"MusicStore.UrlResolver.IUrlResolverService",
|
|
||||||
AlbumApiService
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.ArtistApi.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.ArtistApi {
|
|
||||||
export interface IArtistApiService {
|
|
||||||
getArtistsLookup(): ng.IPromise<Array<Models.IArtist>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ArtistsApiService implements IArtistApiService {
|
|
||||||
private _inlineData: ng.ICacheObject;
|
|
||||||
private _q: ng.IQService;
|
|
||||||
private _http: ng.IHttpService;
|
|
||||||
private _urlResolver: UrlResolver.IUrlResolverService;
|
|
||||||
|
|
||||||
constructor($cacheFactory: ng.ICacheFactoryService,
|
|
||||||
$q: ng.IQService,
|
|
||||||
$http: ng.IHttpService,
|
|
||||||
urlResolver: UrlResolver.IUrlResolverService) {
|
|
||||||
this._inlineData = $cacheFactory.get("inlineData");
|
|
||||||
this._q = $q;
|
|
||||||
this._http = $http;
|
|
||||||
this._urlResolver = urlResolver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getArtistsLookup() {
|
|
||||||
var url = this._urlResolver.resolveUrl("~/api/artists/lookup"),
|
|
||||||
inlineData = this._inlineData ? this._inlineData.get(url) : null;
|
|
||||||
|
|
||||||
if (inlineData) {
|
|
||||||
return this._q.when(inlineData);
|
|
||||||
} else {
|
|
||||||
return this._http.get(url).then(result => result.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.ArtistApi")
|
|
||||||
.service("MusicStore.ArtistApi.IArtistApiService", [
|
|
||||||
"$cacheFactory",
|
|
||||||
"$q",
|
|
||||||
"$http",
|
|
||||||
"MusicStore.UrlResolver.IUrlResolverService",
|
|
||||||
ArtistsApiService
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.GenreApi.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.GenreApi {
|
|
||||||
export interface IGenreApiService {
|
|
||||||
getGenresLookup(): ng.IPromise<Array<Models.IGenreLookup>>;
|
|
||||||
getGenresMenu(): ng.IPromise<Array<Models.IGenre>>;
|
|
||||||
getGenresList(): ng.IHttpPromise<Array<Models.IGenre>>;
|
|
||||||
getGenreAlbums(genreId: number): ng.IHttpPromise<Array<Models.IAlbum>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
class GenreApiService implements IGenreApiService {
|
|
||||||
private _inlineData: ng.ICacheObject;
|
|
||||||
private _q: ng.IQService;
|
|
||||||
private _http: ng.IHttpService;
|
|
||||||
private _urlResolver: UrlResolver.IUrlResolverService;
|
|
||||||
|
|
||||||
constructor($cacheFactory: ng.ICacheFactoryService,
|
|
||||||
$q: ng.IQService,
|
|
||||||
$http: ng.IHttpService,
|
|
||||||
urlResolver: UrlResolver.IUrlResolverService) {
|
|
||||||
this._inlineData = $cacheFactory.get("inlineData");
|
|
||||||
this._q = $q;
|
|
||||||
this._http = $http;
|
|
||||||
this._urlResolver = urlResolver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getGenresLookup() {
|
|
||||||
var url = this._urlResolver.resolveUrl("~/api/genres/lookup"),
|
|
||||||
inlineData = this._inlineData ? this._inlineData.get(url) : null;
|
|
||||||
|
|
||||||
if (inlineData) {
|
|
||||||
return this._q.when(inlineData);
|
|
||||||
} else {
|
|
||||||
return this._http.get(url).then(result => result.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getGenresMenu() {
|
|
||||||
var url = this._urlResolver.resolveUrl("~/api/genres/menu"),
|
|
||||||
inlineData = this._inlineData ? this._inlineData.get(url) : null;
|
|
||||||
|
|
||||||
if (inlineData) {
|
|
||||||
return this._q.when(inlineData);
|
|
||||||
} else {
|
|
||||||
return this._http.get(url).then(result => result.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getGenresList() {
|
|
||||||
var url = this._urlResolver.resolveUrl("~/api/genres");
|
|
||||||
return this._http.get(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getGenreAlbums(genreId: number) {
|
|
||||||
var url = this._urlResolver.resolveUrl("~/api/genres/" + genreId + "/albums");
|
|
||||||
return this._http.get(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.GenreApi")
|
|
||||||
.service("MusicStore.GenreApi.IGenreApiService", [
|
|
||||||
"$cacheFactory",
|
|
||||||
"$q",
|
|
||||||
"$http",
|
|
||||||
"MusicStore.UrlResolver.IUrlResolverService",
|
|
||||||
GenreApiService
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.GenreMenu.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.GenreMenu {
|
|
||||||
interface IGenreMenuViewModel {
|
|
||||||
genres: Array<Models.IGenre>;
|
|
||||||
urlBase: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
class GenreMenuController implements IGenreMenuViewModel {
|
|
||||||
constructor(genreApi: GenreApi.IGenreApiService, urlResolver: UrlResolver.IUrlResolverService) {
|
|
||||||
var viewModel = this;
|
|
||||||
|
|
||||||
genreApi.getGenresMenu().then(genres => {
|
|
||||||
viewModel.genres = genres;
|
|
||||||
});
|
|
||||||
|
|
||||||
viewModel.urlBase = urlResolver.base;
|
|
||||||
}
|
|
||||||
|
|
||||||
public genres: Array<Models.IGenre>;
|
|
||||||
|
|
||||||
public urlBase: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.GenreMenu")
|
|
||||||
.controller("MusicStore.GenreMenu.GenreMenuController", [
|
|
||||||
"MusicStore.GenreApi.IGenreApiService",
|
|
||||||
"MusicStore.UrlResolver.IUrlResolverService",
|
|
||||||
GenreMenuController
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.GenreMenu.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.GenreMenu {
|
|
||||||
|
|
||||||
//@NgDirective('appGenreMenu')
|
|
||||||
class GenreMenuDirective implements ng.IDirective {
|
|
||||||
public replace = true;
|
|
||||||
public restrict = "A";
|
|
||||||
public templateUrl;
|
|
||||||
|
|
||||||
constructor(urlResolver: UrlResolver.IUrlResolverService) {
|
|
||||||
for (var m in this) {
|
|
||||||
if (this[m].bind) {
|
|
||||||
this[m] = this[m].bind(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.templateUrl = urlResolver.resolveUrl("~/ng-apps/components/GenreMenu/GenreMenu.html");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.GenreMenu")
|
|
||||||
.directive("appGenreMenu", [
|
|
||||||
"MusicStore.UrlResolver.IUrlResolverService",
|
|
||||||
function (a) {
|
|
||||||
return new GenreMenuDirective(a);
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.InlineData.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.InlineData {
|
|
||||||
interface InlineDataAttributes extends ng.IAttributes {
|
|
||||||
type: string;
|
|
||||||
for: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
//@NgDirective('appInlineData')
|
|
||||||
class InlineDataDirective implements ng.IDirective {
|
|
||||||
private _cache: ng.ICacheObject;
|
|
||||||
private _log: ng.ILogService;
|
|
||||||
|
|
||||||
constructor($cacheFactory: ng.ICacheFactoryService, $log: ng.ILogService) {
|
|
||||||
for (var m in this) {
|
|
||||||
if (this[m].bind) {
|
|
||||||
this[m] = this[m].bind(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._cache = $cacheFactory.get("inlineData") || $cacheFactory("inlineData");
|
|
||||||
this._log = $log;
|
|
||||||
}
|
|
||||||
|
|
||||||
public restrict = "A";
|
|
||||||
|
|
||||||
public link(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: InlineDataAttributes) {
|
|
||||||
var data = attrs.type === "application/json"
|
|
||||||
? angular.fromJson(element.text())
|
|
||||||
: element.text();
|
|
||||||
|
|
||||||
this._log.info("appInlineData: Inline data element found for " + attrs.for);
|
|
||||||
|
|
||||||
this._cache.put(attrs.for, data);
|
|
||||||
|
|
||||||
//element.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.InlineData")
|
|
||||||
.directive("appInlineData", [
|
|
||||||
"$cacheFactory",
|
|
||||||
"$log",
|
|
||||||
function (a,b) {
|
|
||||||
return new InlineDataDirective(a,b);
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.LoginLink.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.LoginLink {
|
|
||||||
interface LoginLinkAttributes extends ng.IAttributes {
|
|
||||||
href: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
//@NgDirective('appLoginLink')
|
|
||||||
class LoginLinkDirective implements ng.IDirective {
|
|
||||||
private _window: ng.IWindowService;
|
|
||||||
|
|
||||||
constructor(urlResolver: UrlResolver.IUrlResolverService, $window: ng.IWindowService) {
|
|
||||||
for (var m in this) {
|
|
||||||
if (this[m].bind) {
|
|
||||||
this[m] = this[m].bind(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._window = $window;
|
|
||||||
}
|
|
||||||
|
|
||||||
public restrict = "A";
|
|
||||||
|
|
||||||
public link(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: LoginLinkAttributes) {
|
|
||||||
if (!element.is("a[href]")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grab the original login URL
|
|
||||||
var loginUrl = attrs.href;
|
|
||||||
|
|
||||||
element.click(event => {
|
|
||||||
// Update the returnUrl querystring value to current path
|
|
||||||
var currentUrl = this._window.location.pathname + this._window.location.search + this._window.location.hash,
|
|
||||||
newUrl = loginUrl + "?returnUrl=" + encodeURIComponent(currentUrl);
|
|
||||||
|
|
||||||
element.prop("href", newUrl);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.LoginLink")
|
|
||||||
.directive("appLoginLink", [
|
|
||||||
"MusicStore.UrlResolver.IUrlResolverService",
|
|
||||||
"$window",
|
|
||||||
function (a,b) {
|
|
||||||
return new LoginLinkDirective(a,b);
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
module MusicStore.Models {
|
|
||||||
export interface IAlbum {
|
|
||||||
AlbumId: number;
|
|
||||||
GenreId: number;
|
|
||||||
ArtistId: number;
|
|
||||||
|
|
||||||
Title: string;
|
|
||||||
AlbumArtUrl: string;
|
|
||||||
Price: number;
|
|
||||||
|
|
||||||
Artist: IArtist;
|
|
||||||
Genre: IGenre;
|
|
||||||
|
|
||||||
DetailsUrl: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
module MusicStore.Models {
|
|
||||||
export interface IAlert {
|
|
||||||
type: AlertType;
|
|
||||||
message: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IModelErrorAlert extends IAlert {
|
|
||||||
modelErrors: Array<IModelError>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class AlertType {
|
|
||||||
constructor(public value: string) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public toString() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Values
|
|
||||||
static success = new AlertType("success");
|
|
||||||
static info = new AlertType("info");
|
|
||||||
static warning = new AlertType("warning");
|
|
||||||
static danger = new AlertType("danger");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
module MusicStore.Models {
|
|
||||||
export interface IApiResult {
|
|
||||||
Message?: string;
|
|
||||||
Data?: any;
|
|
||||||
ModelErrors?: Array<IModelError>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
module MusicStore.Models {
|
|
||||||
export interface IArtist {
|
|
||||||
ArtistId: number;
|
|
||||||
Name: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
module MusicStore.Models {
|
|
||||||
export interface IGenre {
|
|
||||||
GenreId: number;
|
|
||||||
Name: string;
|
|
||||||
Description: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
module MusicStore.Models {
|
|
||||||
export interface IGenreLookup {
|
|
||||||
GenreId: number;
|
|
||||||
Name: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
module MusicStore.Models {
|
|
||||||
export interface IModelError {
|
|
||||||
FieldName: string;
|
|
||||||
ErrorMessage: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
module MusicStore.Models {
|
|
||||||
export interface IPagedList<T> {
|
|
||||||
Data: Array<T>;
|
|
||||||
Page: number;
|
|
||||||
PageSize: number;
|
|
||||||
TotalCount: number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
module MusicStore.Models {
|
|
||||||
export interface IUserDetails {
|
|
||||||
isAuthenticated: boolean;
|
|
||||||
userName: string;
|
|
||||||
userId: string;
|
|
||||||
roles: Array<string>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.PreventSubmit.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.PreventSubmit {
|
|
||||||
interface IPreventSubmitAttributes extends ng.IAttributes {
|
|
||||||
name: string;
|
|
||||||
appPreventSubmit: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
//@NgDirective('appPreventSubmit')
|
|
||||||
class PreventSubmitDirective implements ng.IDirective {
|
|
||||||
constructor() {
|
|
||||||
for (var m in this) {
|
|
||||||
if (this[m].bind) {
|
|
||||||
this[m] = this[m].bind(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _preventSubmit: any;
|
|
||||||
|
|
||||||
public restrict = "A";
|
|
||||||
|
|
||||||
public link(scope: any, element: ng.IAugmentedJQuery, attrs: IPreventSubmitAttributes) {
|
|
||||||
// TODO: Just make this directive apply to all <form> tags and no-op if no action attr
|
|
||||||
|
|
||||||
element.submit(e => {
|
|
||||||
if (scope.$eval(attrs.appPreventSubmit)) {
|
|
||||||
e.preventDefault();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.PreventSubmit")
|
|
||||||
.directive("appPreventSubmit", [
|
|
||||||
function () {
|
|
||||||
return new PreventSubmitDirective();
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.TitleCase.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.TitleCase {
|
|
||||||
|
|
||||||
//@NgFilter('titlecase')
|
|
||||||
function titleCase(input: string) {
|
|
||||||
var out = "",
|
|
||||||
lastChar = "";
|
|
||||||
|
|
||||||
for (var i = 0; i < input.length; i++) {
|
|
||||||
out = out + (lastChar === " " || lastChar === ""
|
|
||||||
? input.charAt(i).toUpperCase()
|
|
||||||
: input.charAt(i));
|
|
||||||
|
|
||||||
lastChar = input.charAt(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.TitleCase")
|
|
||||||
.filter("titlecase", () => titleCase);
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.Truncate.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Truncate {
|
|
||||||
|
|
||||||
//@NgFilter
|
|
||||||
function truncate(input: string, length: number) {
|
|
||||||
if (!input) {
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input.length <= length) {
|
|
||||||
return input;
|
|
||||||
} else {
|
|
||||||
return input.substr(0, length).trim() + "…";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.Truncate")
|
|
||||||
.filter("truncate", () => truncate);
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.UrlResolver.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.UrlResolver {
|
|
||||||
export interface IUrlResolverService {
|
|
||||||
base: string;
|
|
||||||
resolveUrl(relativeUrl: string);
|
|
||||||
}
|
|
||||||
|
|
||||||
class UrlResolverService implements IUrlResolverService {
|
|
||||||
private _base: string;
|
|
||||||
|
|
||||||
constructor($rootElement: ng.IAugmentedJQuery) {
|
|
||||||
this._base = $rootElement.attr("data-url-base");
|
|
||||||
|
|
||||||
// Add trailing slash if not present
|
|
||||||
if (this._base === "" || this._base.substr(this._base.length - 1) !== "/") {
|
|
||||||
this._base = this._base + "/";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public get base() {
|
|
||||||
return this._base;
|
|
||||||
}
|
|
||||||
|
|
||||||
public resolveUrl(relativeUrl: string) {
|
|
||||||
var firstChar = relativeUrl.substr(0, 1);
|
|
||||||
|
|
||||||
if (firstChar === "~") {
|
|
||||||
relativeUrl = relativeUrl.substr(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
firstChar = relativeUrl.substr(0, 1);
|
|
||||||
|
|
||||||
if (firstChar === "/") {
|
|
||||||
relativeUrl = relativeUrl.substr(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this._base + relativeUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.UrlResolver")
|
|
||||||
.service("MusicStore.UrlResolver.IUrlResolverService", [
|
|
||||||
"$rootElement",
|
|
||||||
UrlResolverService
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.UserDetails.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.UserDetails {
|
|
||||||
export interface IUserDetailsService {
|
|
||||||
getUserDetails(): Models.IUserDetails;
|
|
||||||
getUserDetails(elementId: string): Models.IUserDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
class UserDetailsService implements IUserDetailsService {
|
|
||||||
private _document: ng.IDocumentService;
|
|
||||||
private _userDetails: Models.IUserDetails;
|
|
||||||
|
|
||||||
constructor($document: ng.IDocumentService) {
|
|
||||||
this._document = $document;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getUserDetails(elementId = "userDetails") {
|
|
||||||
if (!this._userDetails) {
|
|
||||||
//var el = this._document.querySelector("[data-json-id='" + elementId + "']");
|
|
||||||
var el = this._document.find("#" + elementId + "[type='application/json']");
|
|
||||||
|
|
||||||
if (el.length) {
|
|
||||||
this._userDetails = angular.fromJson(el.text());
|
|
||||||
} else {
|
|
||||||
this._userDetails = {
|
|
||||||
isAuthenticated: false,
|
|
||||||
userId: null,
|
|
||||||
userName: null,
|
|
||||||
roles: []
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this._userDetails;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.UserDetails")
|
|
||||||
.service("MusicStore.UserDetails.IUserDetailsService", [
|
|
||||||
"$document",
|
|
||||||
UserDetailsService
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.ViewAlert.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.ViewAlert {
|
|
||||||
export interface IViewAlertService {
|
|
||||||
alert: Models.IAlert;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ViewAlertService implements IViewAlertService {
|
|
||||||
public alert: Models.IAlert;
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.ViewAlert")
|
|
||||||
.service("MusicStore.ViewAlert.IViewAlertService", [
|
|
||||||
ViewAlertService
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
/// <reference path="..\..\MusicStore.Visited.ng.ts" />
|
|
||||||
|
|
||||||
module MusicStore.Visited {
|
|
||||||
interface IVisitedFormController extends ng.IFormController {
|
|
||||||
focus?: boolean;
|
|
||||||
visited?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
//@NgDirective('input')
|
|
||||||
//@NgDirective('select')
|
|
||||||
class VisitedDirective implements ng.IDirective {
|
|
||||||
private _window: ng.IWindowService;
|
|
||||||
|
|
||||||
constructor($window: ng.IWindowService) {
|
|
||||||
for (var m in this) {
|
|
||||||
if (this[m].bind) {
|
|
||||||
this[m] = this[m].bind(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._window = $window;
|
|
||||||
}
|
|
||||||
|
|
||||||
public restrict = "E";
|
|
||||||
|
|
||||||
public require = "?ngModel";
|
|
||||||
|
|
||||||
public link(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl: IVisitedFormController) {
|
|
||||||
if (!ctrl) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
element.on("focus", event => {
|
|
||||||
element.addClass("has-focus");
|
|
||||||
scope.$apply(() => ctrl.focus = true);
|
|
||||||
});
|
|
||||||
|
|
||||||
element.on("blur", event => {
|
|
||||||
element.removeClass("has-focus");
|
|
||||||
element.addClass("has-visited");
|
|
||||||
scope.$apply(() => {
|
|
||||||
ctrl.focus = false;
|
|
||||||
ctrl.visited = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
element.closest("form").on("submit", function () {
|
|
||||||
element.addClass("has-visited");
|
|
||||||
|
|
||||||
scope.$apply(() => {
|
|
||||||
ctrl.focus = false;
|
|
||||||
ctrl.visited = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("MusicStore.Visited")
|
|
||||||
.directive("input", [
|
|
||||||
"$window",
|
|
||||||
function (a) {
|
|
||||||
return new VisitedDirective(a);
|
|
||||||
}
|
|
||||||
])
|
|
||||||
.directive("select", [
|
|
||||||
"$window",
|
|
||||||
function (a) {
|
|
||||||
return new VisitedDirective(a);
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue