From 8a3c9b275548ed7f4c2e0c47658e1153d5da904b Mon Sep 17 00:00:00 2001 From: Antonia Lewis Date: Thu, 10 Dec 2015 22:35:05 -0500 Subject: [PATCH] Cleaned up comments. Added cool stuff to orders. --- .../TeamDBAwesome/js/adminController.js | 62 ++++++++--------- .../TeamDBAwesome/js/homeController.js | 11 +-- .../TeamDBAwesome/js/userController.js | 67 +++++-------------- .../TeamDBAwesome/pages/admin-home.html | 16 +++-- .../TeamDBAwesome/pages/user-ordermodal.html | 21 +++++- .../TeamDBAwesome/pages/user-orders.html | 8 +-- 6 files changed, 81 insertions(+), 104 deletions(-) diff --git a/TeamDBAwesome/TeamDBAwesome/js/adminController.js b/TeamDBAwesome/TeamDBAwesome/js/adminController.js index 5ea074f..7b295d9 100644 --- a/TeamDBAwesome/TeamDBAwesome/js/adminController.js +++ b/TeamDBAwesome/TeamDBAwesome/js/adminController.js @@ -27,25 +27,18 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt // Return all invoices $scope.getAllInvoices = function () { - /* $http.get("http://localhost:50031/api/GetAllInvoices") - .success(function (response) { - $scope.currInvoices = angular.copy(response); - })*/ - - //Currently not working - $http.get("http://localhost:50031/api/GetCustomerInvoice?custId=" + 1) + $http.get("http://localhost:50031/api/GetAllInvoices") .success(function (response) { $scope.currInvoices = angular.copy(response); - console.log($scope.currorders); }) } // Open window for orders $scope.openOrder = function (orderid) { - console.log(orderid); + //console.log(orderid); $scope.catcats = orderid; $scope.getCustomerInfo(orderid.customerId); - //$scope.getOrderTracks(orderid.invoiceId); + $scope.getInvoiceTracks(orderid.invoiceId); var modalInstance = $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'pages/user-ordermodal.html', @@ -59,6 +52,14 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt }); } + // Get tracks associated with invoice + $scope.getInvoiceTracks = function(id){ + $http.get("http://localhost:50031/api/InvoiceTrackData?invoiceId=" + id) + .success(function (response) { + $scope.currInvoiceTracks = angular.copy(response); + }) + } + // Get information on the customer $scope.getCustomerInfo = function(customerId){ $http.get("http://localhost:50031/api/GetCustomer?PersonID=" + customerId) @@ -126,7 +127,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt sub.Milliseconds = parseInt(newTrack.milliseconds); sub.Bytes = parseInt(newTrack.bytes); sub.UnitPrice = parseFloat(newTrack.unitPrice); - console.log(sub); + //console.log(sub); var promise = $http({ method: "post", @@ -156,7 +157,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt Name: null } sub.Name = newArtist.artistName; - console.log(sub); var promise = $http({ method: "post", @@ -184,7 +184,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt } sub.Title = newAlbum.albumName; sub.Artist = newAlbum.artistName; - console.log(sub); var promise = $http({ method: "post", @@ -213,7 +212,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt $http.get("http://localhost:50031/api/AddGenre?GenreName=" + genreName) .success(function (response) { $scope.messages = 'You created a genre!'; - console.log(response); + alert($scope.messages); }) @@ -223,7 +222,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt $http.get("http://localhost:50031/api/AddMediaType?TypeName=" + mediaTypeName) .success(function (response) { $scope.messages = 'You created a media type!'; - console.log(response); + alert($scope.messages); }) @@ -269,12 +268,10 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt $scope.getDemographics = function () { $scope.custInfoGridOptions.data = []; - console.log($scope.custInfoGridOptions.data); $http.get("http://localhost:50031/api/GetDemographic") .success(function (response) { $scope.custInfoGridOptions.data = angular.copy(response); $scope.custInfoGridOptions.data.splice(0, 1); - console.log(response); }) } @@ -301,7 +298,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt if (name != null) { $http.get("http://localhost:50031/api/AddPlaylist?playlistname=" + name) .success(function (response) { - console.log(response); }) } window.setTimeout($scope.getPlaylists(),1000); @@ -321,7 +317,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt .success(function (response) { $scope.playlists = angular.copy(response); $scope.playlistGridOptions.data = angular.copy(response); - console.log(response); + //console.log(response); }) } @@ -337,7 +333,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt $scope.dropPlaylist = function (playlistID) { $http.get("http://localhost:50031/api/DropPlaylist?PlaylistID="+ playlistID) .success(function (response) { - console.log(response); + // console.log(response); }) } @@ -346,16 +342,16 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt $http.get("http://localhost:50031/api/GetPlaylist?PlaylistID="+ playlistID) .success(function (response) { $scope.playlistTracks = angular.copy(response); - console.log(response); + // console.log(response); }) } $scope.addToPlaylist = function (trackID) { - console.log(trackID); + //console.log(trackID); $http.get("http://localhost:50031/api/AddTrackPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) .success(function (response) { - console.log(response); + // console.log(response); }) window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist),1000); } @@ -371,7 +367,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt { $http.get("http://localhost:50031/api/RemoveTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) .success(function (response) { - console.log(response); + // console.log(response); }) } @@ -391,13 +387,13 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt }; $scope.search = function (token, category) { - console.log(token); - console.log(category); - console.log($scope.data); + // console.log(token); + // console.log(category); + // console.log($scope.data); $http.get("http://localhost:50031/api/Search?search=" + token) .success(function (response) { $scope.data = angular.copy(response); - console.log(response); + // console.log(response); if (category == "Track") { $scope.searchGridOptions.data = $scope.data.Track; } @@ -446,15 +442,15 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt .success(function (response) { $scope.playlists = angular.copy(response); $scope.playlistGridOptions.data = angular.copy(response); - console.log(response); + // console.log(response); }) } $scope.getReports = function () { $scope.getInventory(); - console.log("inventory"); + // console.log("inventory"); $scope.getSales(); - console.log("sales"); + // console.log("sales"); } @@ -463,7 +459,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt $http.get("http://localhost:50031/api/GetAllTracks") .success(function (response) { $scope.inventoryGridOptions.data = angular.copy(response); - console.log(response); + // console.log(response); }) } $scope.getSales = function () { @@ -471,7 +467,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt $http.get("http://localhost:50031/api/GetAllInvoices") .success(function (response) { $scope.salesGridOptions.data = angular.copy(response); - console.log(response); + // console.log(response); }) } diff --git a/TeamDBAwesome/TeamDBAwesome/js/homeController.js b/TeamDBAwesome/TeamDBAwesome/js/homeController.js index 29ad7cb..3e37120 100644 --- a/TeamDBAwesome/TeamDBAwesome/js/homeController.js +++ b/TeamDBAwesome/TeamDBAwesome/js/homeController.js @@ -1,7 +1,6 @@ angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope, HolderService) { /* BEGIN FUNCTIONS FUNCTIONS */ - console.log($cookies.get('userid')); // Function to register new users. $scope.createUser = function (newUser) { var sub = HolderService.getBlankCustomer(); @@ -21,7 +20,6 @@ angular.module('routerApp').controller('homeController', function ($scope, $http sub.Company = newUser.company; sub.SupportRepID = 0; - console.log(sub); var promise = $http({ method: "post", @@ -32,7 +30,7 @@ angular.module('routerApp').controller('homeController', function ($scope, $http data: sub }). success(function (data, status, headers, config) { - console.log(data); + $scope.messages = 'You are now registered and may now log in. '; }). error(function (error, status, headers, config) { @@ -42,8 +40,7 @@ angular.module('routerApp').controller('homeController', function ($scope, $http // Log in admins $scope.toAdminPage = function (user) { - console.log(user); - console.log(!user.password); + if (!user.password) $scope.messages = "Please enter a password."; else { $http.get("http://localhost:50031/api/GetEmployee?PersonID=" + user.username) @@ -52,11 +49,9 @@ angular.module('routerApp').controller('homeController', function ($scope, $http $scope.messages = 'You have entered an incorrect Employee username'; } else { - console.log(response); $cookies.put('userid', user.username); $cookies.put('name', response.firstname); $cookies.put('isAdmin', response.isAdmin); - console.log($cookies.get('userid')); $state.go('admin-home'); } }) @@ -74,8 +69,6 @@ angular.module('routerApp').controller('homeController', function ($scope, $http } else { $cookies.put("userid", user.username); - console.log($cookies.get('userid')); - console.log(response); $cookies.put('name', response.FName); $state.go('user-home'); } diff --git a/TeamDBAwesome/TeamDBAwesome/js/userController.js b/TeamDBAwesome/TeamDBAwesome/js/userController.js index dd1a2fc..eda9bd1 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, $sce) { /* Begin Function Definitions */ @@ -14,12 +14,10 @@ angular.module('routerApp').controller('userController', function ($q, $window, // Retrieve Data $scope.getUserInfo = function () { var customerid = $cookies.get('userid'); - console.log(customerid); $scope.user = {}; $http.get("http://localhost:50031/api/GetCustomer?PersonID=" + customerid) .success(function (response) { $scope.user = angular.copy(response); - console.log(response); }) } // Update User Information @@ -43,7 +41,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, // Add Payment $scope.addPayment = function (data) { var pay = HolderService.getBlankPayment(); - console.log(data); pay.Type = data.type; pay.is_default = 0; pay.CustomerId = $cookies.get('userid'); @@ -52,8 +49,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, 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); var promise = $http({ method: "post", url: "http://localhost:50031/api/AddPayment", @@ -68,7 +63,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, error(function (error, status, headers, config) { $scope.messages = 'There was a network error. Try again later.'; }); - console.log(pay); } // Dealing with Search @@ -78,7 +72,7 @@ angular.module('routerApp').controller('userController', function ($q, $window, { field: 'AlbumTitle', displayName: ' Album ', width: "15%" }, { field: 'MediaType', displayName: ' Media ', width: "10%" }, { field: 'Genre', displayName: ' Genre ', width: "10%" }, - { field: 'Clip', displayName: ' Clip ', width: "10%", cellTemplate: '
' }, + { field: 'Clip', displayName: ' Clip ', width: "10%", cellTemplate: '
' }, { field: 'UnitPrice', displayName: ' Price ', width: "10%" } ]; @@ -117,8 +111,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, // Search Function $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); @@ -152,7 +144,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, var param = id + " " + pass; var promise = $http.post(url + "/authenticateUser", param) .success(function (data, status) { - console.log(data); if (data.STATUS == 555) { $scope.authenticated = false; resolve('We did it'); @@ -169,21 +160,17 @@ angular.module('routerApp').controller('userController', function ($q, $window, } $scope.addToCart = function (trackid) { - console.log(trackid + "the track id"); 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); }) }); @@ -191,15 +178,12 @@ angular.module('routerApp').controller('userController', function ($q, $window, // functions for adding playlists to cart $scope.addPLToCart = function (plid) { - console.log("cats"); - console.log(plid); + var promise = $http.get("http://localhost:50031/api/GetPlaylist?PlaylistID=" + plid) .success(function (response) { $scope.currplaylist = angular.copy(response); - console.log($scope.currplaylist); }); promise.then(function () { - console.log($scope.currplaylist); var end = $scope.currplaylist.length; for (var i = 0; i < end; i++) { $scope.addToCart($scope.currplaylist[i].TrackId); @@ -208,15 +192,12 @@ angular.module('routerApp').controller('userController', function ($q, $window, } $scope.addMPLToCart = function (plid) { - console.log("cats"); - console.log(plid); + var promise = $http.get("http://localhost:50031/api/GetPlaylist?PlaylistID=" + plid) .success(function (response) { $scope.currplaylist = angular.copy(response); - console.log($scope.currplaylist); }); promise.then(function () { - console.log($scope.currplaylist); var end = $scope.currplaylist.length; for (var i = 0; i < end; i++) { $scope.addToCart($scope.currplaylist[i].TrackId); @@ -230,7 +211,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, $http.get("http://localhost:50031/api/GetPlaylistList") .success(function (response) { $scope.playlists = angular.copy(response); - console.log($scope.playlists); }) }; @@ -239,7 +219,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, $http.get("http://localhost:50031/api/GetCustomPlaylists?CustomerID=" + $cookies.get('userid')) .success(function (response) { $scope.myPlaylists = angular.copy(response); - console.log($scope.myPlaylists); }) }; @@ -248,23 +227,24 @@ angular.module('routerApp').controller('userController', function ($q, $window, $http.get("http://localhost:50031/api/GetPlaylist?PlaylistID=" + id) .success(function (response) { $scope.currplaylist = angular.copy(response); - console.log($scope.currplaylist); }) }; //Play Audio Clip $scope.play = function () { - var audio = document.getElementById("audio1"); + audio = document.getElementById("audio1"); audio.play(); }; + $scope.trustSrcurl = function (data) { + return $sce.trustAsResourceUrl(data); + } + // Get CustomPlaylist Tracks $scope.getMyPlaylistTracks = function (id) { - console.log("Custom Playlist tracks"); $http.get("http://localhost:50031/api/GetCustomPlaylist?PlaylistID=" + id) .success(function (response) { $scope.currplaylist = angular.copy(response); - console.log($scope.currplaylist); }) }; @@ -304,9 +284,8 @@ angular.module('routerApp').controller('userController', function ($q, $window, // Open window for orders $scope.openOrder = function (orderid) { - console.log(orderid); $scope.catcats = orderid; - $scope.getOrderTracks(orderid.invoiceId); + $scope.getInvoiceTracks(orderid.invoiceId); var modalInstance = $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'pages/user-ordermodal.html', @@ -320,13 +299,19 @@ angular.module('routerApp').controller('userController', function ($q, $window, }); } + // Get tracks associated with invoice + $scope.getInvoiceTracks = function (id) { + $http.get("http://localhost:50031/api/InvoiceTrackData?invoiceId=" + id) + .success(function (response) { + $scope.currInvoiceTracks = angular.copy(response); + }) + } + // Get order tracks for an order number $scope.getOrderTracks = function (orderid) { $http.get("http://localhost:50031/api/GetOrderTracks?orderId=" + orderid) .success(function (response) { - console.log(response); $scope.currordertracks = angular.copy(response); - console.log($scope.currordertracks); }) }; @@ -350,11 +335,9 @@ angular.module('routerApp').controller('userController', function ($q, $window, }); 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); }) }); }; @@ -364,14 +347,12 @@ angular.module('routerApp').controller('userController', function ($q, $window, $http.get("http://localhost:50031/api/GetPayment?CustomerID=" + $cookies.get('userid')) .success(function (response) { $scope.currpayments = angular.copy(response); - console.log($scope.currpayments); }) }; // From shopping cart to invoice $scope.buy = function (payid) { - console.log(payid); $http.get("http://localhost:50031/api/GenerateInvoice?custId=" + $cookies.get('userid') + "&payId=" + payid + "&orderId=" + $scope.currOrderID) .success(function (response) { $http.get("http://localhost:50031/api/CreateOrder?CustomerID=" + $cookies.get('userid')) @@ -399,7 +380,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, $http.get("http://localhost:50031/api/GetCustomerInvoice?custId=" + $cookies.get('userid')) .success(function (response) { $scope.currorders = angular.copy(response); - console.log($scope.currorders); }) } @@ -460,7 +440,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, .success(function (response) { $scope.playlists = angular.copy(response); $scope.playlistGridOptions.data = angular.copy(response); - console.log(response); }) } @@ -475,26 +454,21 @@ angular.module('routerApp').controller('userController', function ($q, $window, $scope.dropCustomPlaylist = function (playlistID) { $http.get("http://localhost:50031/api/DropCustomPlaylist?PlaylistID=" + playlistID) .success(function (response) { - console.log(response); }) } $scope.getCustomPlaylistTracks = function (playlistID) { $scope.playlistTracks = []; - console.log(playlistID); $http.get("http://localhost:50031/api/GetCustomPlaylist?PlaylistID=" + playlistID) .success(function (response) { $scope.playlistTracks = angular.copy(response); - console.log(response); }) } $scope.addToCustomPlaylist = function (trackID) { - console.log(trackID); $http.get("http://localhost:50031/api/AddTrackCustomPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) .success(function (response) { - console.log(response); }) window.setTimeout($scope.getCustomPlaylistTracks($scope.currentPlaylist), 1000); } @@ -509,7 +483,6 @@ angular.module('routerApp').controller('userController', function ($q, $window, $scope.dropCustomTrack = function (trackID) { $http.get("http://localhost:50031/api/RemoveCustomTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) .success(function (response) { - console.log(response); }) } @@ -529,13 +502,9 @@ angular.module('routerApp').controller('userController', function ($q, $window, }; $scope.trackSearch = function (token, category) { - console.log(token); - console.log(category); - console.log($scope.data); $http.get("http://localhost:50031/api/Search?search=" + token) .success(function (response) { $scope.data = angular.copy(response); - console.log(response); if (category == "Track") { $scope.trackSearchGridOptions.data = $scope.data.Track; } diff --git a/TeamDBAwesome/TeamDBAwesome/pages/admin-home.html b/TeamDBAwesome/TeamDBAwesome/pages/admin-home.html index c234829..f83cfc9 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/admin-home.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/admin-home.html @@ -5,11 +5,13 @@

- - - - - - -

Current Orders


Click an order to see details
Invoice Number
{{x.invoiceId}}
+
+ + + + + + +

Current Orders


Click an order to see details
Invoice Number
{{x.invoiceId}}
+
\ No newline at end of file diff --git a/TeamDBAwesome/TeamDBAwesome/pages/user-ordermodal.html b/TeamDBAwesome/TeamDBAwesome/pages/user-ordermodal.html index 01790ef..b9802ec 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/user-ordermodal.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/user-ordermodal.html @@ -1,7 +1,7 @@ 
-

Invoice ID {{catcats.invoiceId}}

+

Invoice ID {{catcats.invoiceId}}

@@ -12,9 +12,26 @@ -

Email Address

{{catcats.payment.email}}

Card number

{{catcats.payment.cardnum}}

Expiration Date

{{catcats.payment.expr_date}}

Invoice Total

{{catcats.total}}
+

Invoice Tracks

+ + + + + + + + + + + + + +
Track NameQuantityPrice
{{x.TrackName}} {{x.qty}} {{x.UnitPrice}}

Invoice Total

{{catcats.total}}

+ + +
\ No newline at end of file diff --git a/TeamDBAwesome/TeamDBAwesome/pages/user-orders.html b/TeamDBAwesome/TeamDBAwesome/pages/user-orders.html index 2812e17..3a66258 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/user-orders.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/user-orders.html @@ -60,16 +60,16 @@
Price
- {{x.TrackName}} + {{x.TrackName}}> {{x.AlbumTitle}} {{x.MediaType}} {{x.Genre}} -