Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/master'
# Conflicts:
#	TeamDBAwesome/TeamDBAwesome/js/adminController.js
#	TeamDBAwesome/TeamDBAwesome/js/userController.js
  • Loading branch information
sec11008 committed Dec 11, 2015
2 parents 400cfa0 + 8a3c9b2 commit 0189f85
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 104 deletions.
52 changes: 19 additions & 33 deletions TeamDBAwesome/TeamDBAwesome/js/adminController.js
Expand Up @@ -27,25 +27,18 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt


// Return all invoices // Return all invoices
$scope.getAllInvoices = function () { $scope.getAllInvoices = function () {
/* $http.get("http://localhost:50031/api/GetAllInvoices") $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)
.success(function (response) { .success(function (response) {
$scope.currInvoices = angular.copy(response); $scope.currInvoices = angular.copy(response);
console.log($scope.currorders);
}) })
} }


// Open window for orders // Open window for orders
$scope.openOrder = function (orderid) { $scope.openOrder = function (orderid) {
console.log(orderid); //console.log(orderid);
$scope.catcats = orderid; $scope.catcats = orderid;
$scope.getCustomerInfo(orderid.customerId); $scope.getCustomerInfo(orderid.customerId);
//$scope.getOrderTracks(orderid.invoiceId); $scope.getInvoiceTracks(orderid.invoiceId);
var modalInstance = $uibModal.open({ var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled, animation: $scope.animationsEnabled,
templateUrl: 'pages/user-ordermodal.html', templateUrl: 'pages/user-ordermodal.html',
Expand All @@ -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 // Get information on the customer
$scope.getCustomerInfo = function(customerId){ $scope.getCustomerInfo = function(customerId){
$http.get("http://localhost:50031/api/GetCustomer?PersonID=" + customerId) $http.get("http://localhost:50031/api/GetCustomer?PersonID=" + customerId)
Expand Down Expand Up @@ -126,7 +127,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
sub.Milliseconds = parseInt(newTrack.milliseconds); sub.Milliseconds = parseInt(newTrack.milliseconds);
sub.Bytes = parseInt(newTrack.bytes); sub.Bytes = parseInt(newTrack.bytes);
sub.UnitPrice = parseFloat(newTrack.unitPrice); sub.UnitPrice = parseFloat(newTrack.unitPrice);
console.log(sub); //console.log(sub);


var promise = $http({ var promise = $http({
method: "post", method: "post",
Expand Down Expand Up @@ -156,7 +157,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
Name: null Name: null
} }
sub.Name = newArtist.artistName; sub.Name = newArtist.artistName;
console.log(sub);


var promise = $http({ var promise = $http({
method: "post", method: "post",
Expand Down Expand Up @@ -184,7 +184,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
} }
sub.Title = newAlbum.albumName; sub.Title = newAlbum.albumName;
sub.Artist = newAlbum.artistName; sub.Artist = newAlbum.artistName;
console.log(sub);


var promise = $http({ var promise = $http({
method: "post", method: "post",
Expand Down Expand Up @@ -213,7 +212,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$http.get("http://localhost:50031/api/AddGenre?GenreName=" + genreName) $http.get("http://localhost:50031/api/AddGenre?GenreName=" + genreName)
.success(function (response) { .success(function (response) {
$scope.messages = 'You created a genre!'; $scope.messages = 'You created a genre!';
console.log(response);
alert($scope.messages); alert($scope.messages);
}) })


Expand All @@ -223,7 +222,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$http.get("http://localhost:50031/api/AddMediaType?TypeName=" + mediaTypeName) $http.get("http://localhost:50031/api/AddMediaType?TypeName=" + mediaTypeName)
.success(function (response) { .success(function (response) {
$scope.messages = 'You created a media type!'; $scope.messages = 'You created a media type!';
console.log(response);
alert($scope.messages); alert($scope.messages);
}) })


Expand Down Expand Up @@ -269,12 +268,10 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt


$scope.getDemographics = function () { $scope.getDemographics = function () {
$scope.custInfoGridOptions.data = []; $scope.custInfoGridOptions.data = [];
console.log($scope.custInfoGridOptions.data);
$http.get("http://localhost:50031/api/GetDemographic") $http.get("http://localhost:50031/api/GetDemographic")
.success(function (response) { .success(function (response) {
$scope.custInfoGridOptions.data = angular.copy(response); $scope.custInfoGridOptions.data = angular.copy(response);
$scope.custInfoGridOptions.data.splice(0, 1); $scope.custInfoGridOptions.data.splice(0, 1);
console.log(response);
}) })
} }


Expand All @@ -301,7 +298,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
if (name != null) { if (name != null) {
$http.get("http://localhost:50031/api/AddPlaylist?playlistname=" + name) $http.get("http://localhost:50031/api/AddPlaylist?playlistname=" + name)
.success(function (response) { .success(function (response) {
console.log(response);
window.setTimeout($scope.getPlaylists(),1000); window.setTimeout($scope.getPlaylists(),1000);
}) })
} }
Expand All @@ -321,7 +317,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
.success(function (response) { .success(function (response) {
$scope.playlists = angular.copy(response); $scope.playlists = angular.copy(response);
$scope.playlistGridOptions.data = angular.copy(response); $scope.playlistGridOptions.data = angular.copy(response);
console.log(response);
}) })
} }


Expand All @@ -336,7 +331,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$scope.dropPlaylist = function (playlistID) { $scope.dropPlaylist = function (playlistID) {
$http.get("http://localhost:50031/api/DropPlaylist?PlaylistID="+ playlistID) $http.get("http://localhost:50031/api/DropPlaylist?PlaylistID="+ playlistID)
.success(function (response) { .success(function (response) {
console.log(response);
window.setTimeout($scope.getPlaylists(), 1000); window.setTimeout($scope.getPlaylists(), 1000);
}) })
} }
Expand All @@ -346,7 +340,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$http.get("http://localhost:50031/api/GetPlaylist?PlaylistID="+ playlistID) $http.get("http://localhost:50031/api/GetPlaylist?PlaylistID="+ playlistID)
.success(function (response) { .success(function (response) {
$scope.playlistTracks = angular.copy(response); $scope.playlistTracks = angular.copy(response);
console.log(response);
if ($scope.playlistTracks.length == 0) { if ($scope.playlistTracks.length == 0) {
$scope.emptyPlaylist = true; $scope.emptyPlaylist = true;
} }
Expand All @@ -359,10 +352,8 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
} }


$scope.addToPlaylist = function (trackID) { $scope.addToPlaylist = function (trackID) {
console.log(trackID);
$http.get("http://localhost:50031/api/AddTrackPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) $http.get("http://localhost:50031/api/AddTrackPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID)
.success(function (response) { .success(function (response) {
console.log(response);
window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist), 1000); window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist), 1000);


}) })
Expand All @@ -380,7 +371,6 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
{ {
$http.get("http://localhost:50031/api/RemoveTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) $http.get("http://localhost:50031/api/RemoveTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID)
.success(function (response) { .success(function (response) {
console.log(response);
window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist), 1000); window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist), 1000);
}) })
} }
Expand All @@ -401,13 +391,9 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
}; };


$scope.search = function (token, category) { $scope.search = function (token, category) {
console.log(token);
console.log(category);
console.log($scope.data);
$http.get("http://localhost:50031/api/Search?search=" + token) $http.get("http://localhost:50031/api/Search?search=" + token)
.success(function (response) { .success(function (response) {
$scope.data = angular.copy(response); $scope.data = angular.copy(response);
console.log(response);
if (category == "Track") { if (category == "Track") {
$scope.searchGridOptions.data = $scope.data.Track; $scope.searchGridOptions.data = $scope.data.Track;
} }
Expand Down Expand Up @@ -457,15 +443,15 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
.success(function (response) { .success(function (response) {
$scope.playlists = angular.copy(response); $scope.playlists = angular.copy(response);
$scope.playlistGridOptions.data = angular.copy(response); $scope.playlistGridOptions.data = angular.copy(response);
console.log(response); // console.log(response);
}) })
} }


$scope.getReports = function () { $scope.getReports = function () {
$scope.getInventory(); $scope.getInventory();
console.log("inventory"); // console.log("inventory");
$scope.getSales(); $scope.getSales();
console.log("sales"); // console.log("sales");




} }
Expand All @@ -474,15 +460,15 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$http.get("http://localhost:50031/api/GetAllTracks") $http.get("http://localhost:50031/api/GetAllTracks")
.success(function (response) { .success(function (response) {
$scope.inventoryGridOptions.data = angular.copy(response); $scope.inventoryGridOptions.data = angular.copy(response);
console.log(response); // console.log(response);
}) })
} }
$scope.getSales = function () { $scope.getSales = function () {
$scope.salesGridOptions.data = []; $scope.salesGridOptions.data = [];
$http.get("http://localhost:50031/api/GetAllInvoices") $http.get("http://localhost:50031/api/GetAllInvoices")
.success(function (response) { .success(function (response) {
$scope.salesGridOptions.data = angular.copy(response); $scope.salesGridOptions.data = angular.copy(response);
console.log(response); // console.log(response);
}) })
} }


Expand Down
11 changes: 2 additions & 9 deletions TeamDBAwesome/TeamDBAwesome/js/homeController.js
@@ -1,7 +1,6 @@
angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope, HolderService) { angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope, HolderService) {


/* BEGIN FUNCTIONS FUNCTIONS */ /* BEGIN FUNCTIONS FUNCTIONS */
console.log($cookies.get('userid'));
// Function to register new users. // Function to register new users.
$scope.createUser = function (newUser) { $scope.createUser = function (newUser) {
var sub = HolderService.getBlankCustomer(); var sub = HolderService.getBlankCustomer();
Expand All @@ -21,7 +20,6 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
sub.Company = newUser.company; sub.Company = newUser.company;
sub.SupportRepID = 0; sub.SupportRepID = 0;


console.log(sub);


var promise = $http({ var promise = $http({
method: "post", method: "post",
Expand All @@ -32,7 +30,7 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
data: sub data: sub
}). }).
success(function (data, status, headers, config) { success(function (data, status, headers, config) {
console.log(data);
$scope.messages = 'You are now registered and may now log in. '; $scope.messages = 'You are now registered and may now log in. ';
}). }).
error(function (error, status, headers, config) { error(function (error, status, headers, config) {
Expand All @@ -42,8 +40,7 @@ angular.module('routerApp').controller('homeController', function ($scope, $http


// Log in admins // Log in admins
$scope.toAdminPage = function (user) { $scope.toAdminPage = function (user) {
console.log(user);
console.log(!user.password);
if (!user.password) $scope.messages = "Please enter a password."; if (!user.password) $scope.messages = "Please enter a password.";
else { else {
$http.get("http://localhost:50031/api/GetEmployee?PersonID=" + user.username) $http.get("http://localhost:50031/api/GetEmployee?PersonID=" + user.username)
Expand All @@ -52,11 +49,9 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
$scope.messages = 'You have entered an incorrect Employee username'; $scope.messages = 'You have entered an incorrect Employee username';
} }
else { else {
console.log(response);
$cookies.put('userid', user.username); $cookies.put('userid', user.username);
$cookies.put('name', response.firstname); $cookies.put('name', response.firstname);
$cookies.put('isAdmin', response.isAdmin); $cookies.put('isAdmin', response.isAdmin);
console.log($cookies.get('userid'));
$state.go('admin-home'); $state.go('admin-home');
} }
}) })
Expand All @@ -74,8 +69,6 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
} }
else { else {
$cookies.put("userid", user.username); $cookies.put("userid", user.username);
console.log($cookies.get('userid'));
console.log(response);
$cookies.put('name', response.FName); $cookies.put('name', response.FName);
$state.go('user-home'); $state.go('user-home');
} }
Expand Down

0 comments on commit 0189f85

Please sign in to comment.