From d28a1d40f13b975507eaf24eae4e5522cb763e69 Mon Sep 17 00:00:00 2001 From: Antonia Lewis Date: Mon, 7 Dec 2015 16:29:30 -0500 Subject: [PATCH] Orders & front page stuff Search on front page done. Adding a track to order is done. --- .../TeamDBAwesome/js/userController.js | 151 +++++++++++++----- .../TeamDBAwesome/pages/user-home.html | 76 +-------- .../TeamDBAwesome/pages/user-orders.html | 33 +++- 3 files changed, 141 insertions(+), 119 deletions(-) diff --git a/TeamDBAwesome/TeamDBAwesome/js/userController.js b/TeamDBAwesome/TeamDBAwesome/js/userController.js index ba1171c..054cb09 100644 --- a/TeamDBAwesome/TeamDBAwesome/js/userController.js +++ b/TeamDBAwesome/TeamDBAwesome/js/userController.js @@ -1,5 +1,5 @@ // The user controller will deal with -angular.module('routerApp').controller('userController', function ($q, $window, $scope, $state, $stateParams, $location, $http, $cookies, urlService, $rootScope, HolderService,$uibModal) { +angular.module('routerApp').controller('userController', function ($q, $window, $scope, $state, $stateParams, $location, $http, $cookies, urlService, $rootScope, HolderService, $uibModal) { /* Retrieve Url */ var url = urlService.web; $location.hash("top"); @@ -49,10 +49,10 @@ angular.module('routerApp').controller('userController', function ($q, $window, pay.Type = data.type; pay.is_default = 0; pay.CustomerId = $cookies.get('userid'); - if ( data.token != undefined) pay.token = data.token; + if (data.token != undefined) pay.token = data.token; if (data.email != undefined) pay.email = data.email; - if ( data.num != undefined) pay.cardnum = data.num - if ( data.date != undefined) pay.expr_date = data.date; + if (data.num != undefined) pay.cardnum = data.num + if (data.date != undefined) pay.expr_date = data.date; if (data.default != undefined) pay.is_default = data.default; console.log("below is pay"); console.log(pay); @@ -75,13 +75,24 @@ angular.module('routerApp').controller('userController', function ($q, $window, // Dealing with Search $scope.columns = [ - { field: 'TrackId', displayName: ' ', cellTemplate: '
' }, - { field: 'TrackName', displayName: ' Track Name' }, - { field: 'AlbumTitle', displayName: ' Album Title ' }, - { field: 'MediaType', displayName: ' Media Type ' }, - { field: 'Genre', displayName: ' Genre ' }, - { field: 'Clip', displayName: ' Sound Clip ' }, - { field: 'UnitPrice', displayName: ' Unit Price ' } + { field: 'TrackName', displayName: ' Track Name', width: "20%" }, + { field: 'artist', displayName: ' Artist Name', width: "20%" }, + { field: 'AlbumTitle', displayName: ' Album ', width: "15%" }, + { field: 'MediaType', displayName: ' Media ', width: "10%" }, + { field: 'Genre', displayName: ' Genre ', width: "10%" }, + { field: 'Clip', displayName: ' Clip ', width: "10%" }, + { field: 'UnitPrice', displayName: ' Price ', width: "10%" } + ]; + + $scope.orderColumns = [ + { field: 'TrackId', displayName: ' ', width: "5%", cellTemplate: '
' }, + { field: 'TrackName', displayName: ' Track Name', width: "20%" }, + { field: 'artist', displayName: ' Artist Name', width: "20%" }, + { field: 'AlbumTitle', displayName: ' Album ', width: "15%" }, + { field: 'MediaType', displayName: ' Media ', width: "10%" }, + { field: 'Genre', displayName: ' Genre ', width: "10%" }, + { field: 'Clip', displayName: ' Clip ', width: "10%" }, + { field: 'UnitPrice', displayName: ' Price ', width: "10%" } ]; $scope.gridOptions = { @@ -91,18 +102,49 @@ angular.module('routerApp').controller('userController', function ($q, $window, onRegisterApi: function (gridApi) { $scope.gridApi = gridApi; var cellTemplate = 'ui-grid/selectionRowHeader'; - $scope.gridApi.core.addRowHeaderColumn({ name: 'rowHeaderCol', displayName: '', width: 30, cellTemplate: cellTemplate }); + } }; + $scope.orderOptions = { + data: null, + enableSorting: true, + columnDefs: $scope.orderColumns, + onRegisterApi: function (gridApi) { + $scope.gridApi = gridApi; + var cellTemplate = 'ui-grid/selectionRowHeader'; + + } + }; // Search Function - $scope.search = function (token) { + $scope.search = function (token, category) { console.log(token); + console.log(category); $http.get("http://localhost:50031/api/Search?search=" + token) .success(function (response) { $scope.data = angular.copy(response); - $scope.gridOptions.data = $scope.data.Track; + console.log(response); + if (category == "Track") { + $scope.gridOptions.data = $scope.data.Track; + $scope.orderOptions.data = $scope.data.Track; + } + else if (category == "Artist") { + $scope.gridOptions.data = $scope.data.Artist; + $scope.orderOptions.data = $scope.data.Artist; + } + else if (category == "Composer") { + $scope.gridOptions.data = $scope.data.Composer; + $scope.orderOptions.data = $scope.data.Composer; + } + else if (category == "Genre") { + $scope.gridOptions.data = $scope.data.Genre; + $scope.orderOptions.data = $scope.data.Genre; + } + else if (category == "Media") { + $scope.gridOptions.data = $scope.data.Media; + $scope.orderOptions.data = $scope.data.Media; + } }); } @@ -130,6 +172,23 @@ angular.module('routerApp').controller('userController', function ($q, $window, $scope.addToCart = function (trackid) { console.log(trackid); + var promise = $http({ + method: "get", + url: "http://localhost:50031/api/AddTrackOrder?trackId=" + trackid + "&orderId=" + $scope.currOrderID, + }). + success(function (response) { + console.log(response); + }); + + promise.then(function () { + console.log($scope.currOrderID); + $http.get("http://localhost:50031/api/GetOrderTracks?orderId=" + $scope.currOrderID) + .success(function (response) { + $scope.currOrder = angular.copy(response); + console.log($scope.currOrder); + }) + }); + } // Order Functions @@ -141,7 +200,7 @@ angular.module('routerApp').controller('userController', function ($q, $window, console.log($scope.playlists); }) }; - + // Get Custom Playlists $scope.getMyPlaylists = function () { $http.get("http://localhost:50031/api/GetCustomPlaylists?CustomerID=" + $cookies.get('userid')) @@ -177,13 +236,13 @@ angular.module('routerApp').controller('userController', function ($q, $window, animation: $scope.animationsEnabled, templateUrl: 'pages/user-modal.html', scope: $scope, - controller: 'userController', - resolve: { - items: function () { - return $scope.items; - } + controller: 'userController', + resolve: { + items: function () { + return $scope.items; } - }); + } + }); } // Open window for custom playlist @@ -203,34 +262,42 @@ angular.module('routerApp').controller('userController', function ($q, $window, }); } + // Get the current order for the customer + $scope.getMyOrder = function () { + var promise = $http({ + method: "get", + url: "http://localhost:50031/api/GetCustomerOrders?CustomerId=" + $cookies.get('userid'), + }). + success(function (response) { + if (response.length == 0) { + $http.get("http://localhost:50031/api/CreateOrder?CustomerID=" + $cookies.get('userid')) + .success(function (response) { + $scope.currOrderID = angular.copy(response); + }) + } + else { + $scope.currOrderID = angular.copy(response); + } + }); + + promise.then(function () { + console.log($scope.currOrderID); + $http.get("http://localhost:50031/api/GetOrderTracks?orderId=" + $scope.currOrderID) + .success(function (response) { + $scope.currOrder = angular.copy(response); + console.log($scope.currOrder); + }) + }); + }; + // Initialize Order Informations $scope.initOrders = function () { $scope.getPlaylists(); $scope.getMyPlaylists(); + $scope.getMyOrder(); } - $scope.myData = [ - { - "firstName": "Cox", - "lastName": "Carney", - "company": "Enormo", - "employed": true - }, - { - "firstName": "Lorraine", - "lastName": "Wise", - "company": "Comveyer", - "employed": false - }, - { - "firstName": "Nancy", - "lastName": "Waters", - "company": "Fuelton", - "employed": false - } - ]; - /* End Function Definitions */ /* Begin Logic */ diff --git a/TeamDBAwesome/TeamDBAwesome/pages/user-home.html b/TeamDBAwesome/TeamDBAwesome/pages/user-home.html index 6b603e3..5309af0 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/user-home.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/user-home.html @@ -17,7 +17,7 @@
-

Suggested Search

+

~~ Browse our Media ~~

@@ -36,7 +36,7 @@
-
@@ -46,78 +46,6 @@


-

Current Search

- -
- - -
- - - - - - - - - - - - -
?????
Album Name
Artist Name
{{x.Title}}{{x.ArtistId}}
-
- - - - - - - - -
- - {{x.STATEMENT}}
-
- - - - - - - - - - - - - - - - - - - -
Track Name
Album Name
Media Type
Genre
CLIP
Price
{{x.TrackName}}{{x.AlbumTitle}}{{x.MediaType}}{{x.Genre}}CLIP{{x.UnitPrice}}
-
- - - - - - - - - -
-

Still need to display Orders


diff --git a/TeamDBAwesome/TeamDBAwesome/pages/user-orders.html b/TeamDBAwesome/TeamDBAwesome/pages/user-orders.html index ab4f26b..ee32b7e 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/user-orders.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/user-orders.html @@ -23,15 +23,42 @@
- Static content + + + + + + +
+
+
+
+
+
+ +
+
+ +
+
-
+
- +
Current Order
Track Name
Price
{{x.TrackName}} {{x.UnitPrice}}