Skip to content
Permalink
Browse files

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 d28a1d40f13b975507eaf24eae4e5522cb763e69
@@ -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: '<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 = {
@@ -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 */
@@ -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>
@@ -36,7 +36,7 @@ <h2> Suggested Search </h2>
</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>
@@ -46,78 +46,6 @@ <h2> Suggested Search </h2>
<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>
@@ -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>

0 comments on commit d28a1d4

Please sign in to comment.
You can’t perform that action at this time.