Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Orders & front page stuff
Search on front page done. Adding a track to order is done.
  • Loading branch information
adl13006 committed Dec 7, 2015
1 parent 57708fb commit d28a1d4
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 119 deletions.
151 changes: 109 additions & 42 deletions 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");
Expand Down Expand Up @@ -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);
Expand All @@ -75,13 +75,24 @@ angular.module('routerApp').controller('userController', function ($q, $window,

// Dealing with Search
$scope.columns = [
{ field: 'TrackId', displayName: ' ', cellTemplate: '<center><button data-ng-click="addToCart(12)" class="btn btn-success btn-xs">Purchase</button></center></td>' },
{ 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: '<center><button data-ng-click="grid.appScope.addToCart({{row.entity.TrackId}})" class="btn btn-success btn-xs"> + </button></center></td>' },
{ 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 = {
Expand All @@ -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;
}
});
}

Expand Down Expand Up @@ -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
Expand All @@ -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'))
Expand Down Expand Up @@ -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
Expand All @@ -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 */
Expand Down
76 changes: 2 additions & 74 deletions TeamDBAwesome/TeamDBAwesome/pages/user-home.html
Expand Up @@ -17,7 +17,7 @@
</style>

<div ng-controller="userController">
<h2> Suggested Search </h2>
<center><h1>~~ Browse our Media ~~</h1></center>
<form name="myForm">
<table>
<td width="90%"><center><input type="text" ng-model="token" class="form-control" placeholder="Search our music database!" /></center></td>
Expand All @@ -36,7 +36,7 @@
</td>
<td width="10%">
<center>
<button type="button" class="btn btn-default" ng-click="search(token)">
<button type="button" class="btn btn-default" ng-click="search(token,data.singleSelect)">
&nbsp&nbsp<span class="glyphicon glyphicon-search"></span>&nbsp&nbsp
</button>
</center>
Expand All @@ -46,78 +46,6 @@
<div id="grid1" ui-grid="gridOptions" class="gridStyle"></div>

<br /><br />
<h2> Current Search </h2>

<div class="srch">
<input type="text" ng-model="token" class="form-control" placeholder="Search our music database!" />
<button type="button" class="btn btn-default" ng-click="search(token)">
&nbsp&nbsp<span class="glyphicon glyphicon-search"></span>&nbsp&nbsp
</button>
</div>
<accordion>
<!-- Albums -->
<accordion-group heading="Search by Album">
<table>
<td width="8%"><center> ????? </center></td>
<td width="30%"><center>Album Name</center></td>
<td width="30%"><center>Artist Name</center></td>
<tr ng-repeat="x in data.Album">
<td width="8%"><center><button data-ng-click="removeQuestion(x)" class="btn btn-success btn-xs">Purchase</button></center></td>
<td width="30%">{{x.Title}}</td>
<td width="30%">{{x.ArtistId}}</td>
</tr>
</table>
</accordion-group>
<!-- Artists-->
<accordion-group heading="Search by Artist">
<table>
<tr ng-repeat="x in names" ng-show="x.PAGE==3">
<td width="10%">
<label>
<ng-form name="checkForm"><input ng-hide="true" type="checkbox" ng-model=x.ACTIVE ng-true-value=1 ng-false-value=0 ng-checked="x.ACTIVE == 1" /></ng-form>
<h4>
<span class="label label-danger" data-ng-show="x.ACTIVE == 0">Disabled</span>
<span class="label label-success" data-ng-show="x.ACTIVE == 1">Activated</span>
</h4>
</label>
</td>
<td width="10%"><button data-ng-click="removeQuestion(x)" class="btn btn-warning btn-xs">Remove</button></td>
<td width="77%">{{x.STATEMENT}}</td>
</tr>
</table>
</accordion-group>
<!-- Tracks -->
<accordion-group heading="Search by Track">
<table>
<td width="8%"><center></center></td>
<td width="30%"><center>Track Name</center></td>
<td width="30%"><center>Album Name</center></td>
<td width="16%"><center>Media Type</center></td>
<td width="8%"><center>Genre</center></td>
<td width="5%">CLIP</td>
<td width="4%"><center>Price</center></td>
<tr ng-repeat="x in data.Track">
<td width="8%"><center><button data-ng-click="removeQuestion(x)" class="btn btn-success btn-xs">Purchase</button></center></td>
<td width="30%">{{x.TrackName}}</td>
<td width="30%">{{x.AlbumTitle}}</td>
<td width="16%">{{x.MediaType}}</td>
<td width="8%">{{x.Genre}}</td>
<td width="5%">CLIP</td>
<td width="4%">{{x.UnitPrice}}</td>
</tr>
</table>
</accordion-group>
<!-- Composer -->
<accordion-group heading="Search by Composer">

</accordion-group>
<!-- Genre -->
<accordion-group heading="Search by Genre">

</accordion-group>

</accordion>

<h2> Still need to display Orders </h2><br />

</div>
33 changes: 30 additions & 3 deletions TeamDBAwesome/TeamDBAwesome/pages/user-orders.html
Expand Up @@ -23,15 +23,42 @@
</tr>
</table>
</uib-tab>
<uib-tab heading="Add Tracks">Static content</uib-tab>
<uib-tab heading="Add Tracks">
<form name="myForm">
<table>
<td width="90%"><center><input type="text" ng-model="token" class="form-control" placeholder="Search our music database!" /></center></td>
<td width="20%">
<center>
<select name="singleSelect" ng-model="data.singleSelect">
<option value="">Please select Search</option>
<option value="Track">Search by Track</option>
<option value="Artist">Search by Artist</option>
<option value="Album">Search by Album</option>
<option value="Genre">Search by Genre</option>
<option value="Composer">Search by Composer</option>
<option value="Media">Search by Media</option>
</select><br>
</center>
</td>
<td width="10%">
<center>
<button type="button" class="btn btn-sm" ng-click="search(token,data.singleSelect)">
&nbsp&nbsp<span class="glyphicon glyphicon-search"></span>&nbsp&nbsp
</button>
</center>
</td>
</table>
</form>
<div id="grid1" ui-grid="orderOptions" class="gridStyle"></div>
</uib-tab>
</uib-tabset>
</div>
<div class="col-sm-3 middle">
<div class="col-sm-3 middle" style="overflow-y: scroll; height:450px;">
<table>
<tr><th colspan="2"><center>Current Order</center></th></tr>
<td width="90%"><center>Track Name</center></td>
<td width="10%"><center>Price</center></td>
<tr ng-repeat="x in data.Track">
<tr ng-repeat="x in currOrder">
<td width="90%">{{x.TrackName}}</td>
<td width="10%">{{x.UnitPrice}}</td>
</tr>
Expand Down

0 comments on commit d28a1d4

Please sign in to comment.