Skip to content

Commit b5ded24

Browse files
authored
Merge pull request #57 from topcoder-platform/dev
Promote to prod
2 parents b4bf241 + 0964e5f commit b5ded24

19 files changed

+897
-117
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# support-admin-app
2-
Customer support application <br>
2+
Support application <br>
33

4-
angular.js app using INSPINIA template
4+
Internal application used to administer specific support tasks related to the Topcoder platform.

src/app/app.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ angular.module('supportAdminApp', [
1515
'app.constants',
1616
'appirio-tech-ng-api-services',
1717
'appirio-tech-ng-auth',
18-
'ui.footable',
1918
'angular-clipboard',
2019
'ng-file-model',
2120
'ui.multiselect',
@@ -99,14 +98,20 @@ angular.module('supportAdminApp', [
9998
url: '/tags',
10099
templateUrl: 'app/tags/tags.html',
101100
data: { pageTitle: 'Tags' },
102-
controller: function ($scope, $state) {
101+
controller: function ($scope, $state, TagService) {
103102
$scope.$state = $state;
104103
$scope.tagDomains = [{
105104
value: 'skills',
106105
name: 'Skills'
107106
}, {
108107
value: 'events',
109108
name: 'Events'
109+
}, {
110+
value: 'technology',
111+
name: 'Technology'
112+
}, {
113+
value: 'platform',
114+
name: 'Platform'
110115
}];
111116

112117
$scope.tagCategories = [{
@@ -128,6 +133,21 @@ angular.module('supportAdminApp', [
128133
value: 'pending',
129134
name: 'Pending'
130135
}];
136+
137+
TagService.getTechnologyStatuses().then(function(techStatuses) {
138+
_.forEach(techStatuses, function(status) {
139+
status.value = _.lowerCase(status.description);
140+
status.name = status.description;
141+
});
142+
$scope.techStatuses = techStatuses;
143+
});
144+
$scope.getTagStatuses = function(domainType) {
145+
if (domainType === 'technology') {
146+
return $scope.techStatuses;
147+
} else {
148+
return $scope.tagStatuses;
149+
}
150+
}
131151
}
132152
})
133153
.state('index.tags.list', {

src/app/billing_accounts/billingaccounts.edit.controller.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ var module = angular.module('supportAdminApp');
66
* Controller for edit billing account view
77
*/
88
module.controller('billingaccount.EditBillingAccountController', ['$scope', '$rootScope', '$log',
9-
'BillingAccountService', 'Alert', '$state', '$stateParams',
10-
function ($scope, $rootScope, $log, BillingAccountService, $alert, $state, $stateParams) {
9+
'BillingAccountService', 'Alert', '$state', '$stateParams', 'ClientService',
10+
function ($scope, $rootScope, $log, BillingAccountService, $alert, $state, $stateParams, ClientService) {
1111
$scope.processing = false;
1212

1313
$scope.account = { };
@@ -18,9 +18,31 @@ module.controller('billingaccount.EditBillingAccountController', ['$scope', '$ro
1818
$scope.account = data;
1919
$scope.endDateOptions.minDate = new Date(data.startDate);
2020
$scope.startDateOptions.maxDate = new Date(data.endDate);
21+
if (data.clientId) {
22+
ClientService.findClientById(data.clientId).then(function (data) {
23+
$scope.account.client = data;
24+
}).catch(function (error) {
25+
$alert.error(error.error.message, $rootScope);
26+
});
27+
}
2128
});
2229
}
2330

31+
// search clients
32+
$scope.getClients = function(name) {
33+
$scope.loadingClients = true;
34+
return ClientService.search({
35+
name: name
36+
}, {
37+
page: 1,
38+
limit: 10,
39+
sort: 'name asc'
40+
}).then(function (data) {
41+
$scope.loadingClients = false;
42+
return data.content;
43+
})
44+
};
45+
2446
// start date and end date options
2547
$scope.endDateOptions = {
2648
minDate: new Date()
@@ -40,7 +62,7 @@ module.controller('billingaccount.EditBillingAccountController', ['$scope', '$ro
4062
$scope.processing = false;
4163
$state.go('index.billingaccounts.list');
4264
}).catch(function (error) {
43-
$alert.error(error.error.message, $rootScope);
65+
$alert.error(error.error, $rootScope);
4466
$scope.processing = false;
4567
});
4668
};

src/app/billing_accounts/billingaccounts.edit.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@
6767
<input id="account-terms" type="textarea" class="form-control" ng-model="account.paymentTerms" name="paymentTerms">
6868
</div>
6969
</div>
70+
<div class="row">
71+
<div class="form-group col-md-6" ng-class="{'has-error': editAccountForm.client.$touched && editAccountForm.client.$invalid}">
72+
<label for="account-description">Client</label>
73+
<input type="text" ng-model="account.client"
74+
uib-typeahead="client as client.name for client in getClients($viewValue)"
75+
class="form-control" required="required">
76+
</div>
77+
<div class="form-group col-md-6">
78+
79+
</div>
80+
</div>
7081
<div class="row">
7182
<div class="form-group col-md-12">
7283
<button ui-sref="index.billingaccounts.list" type="button" class="btn btn-sm btn-warning m-l pull-right">

src/app/billing_accounts/billingaccounts.list.controller.js

Lines changed: 73 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,102 @@
33
var module = angular.module('supportAdminApp');
44

55
module.controller('billingaccount.BillingAccountsListController', ['$scope', '$rootScope', '$log',
6-
'BillingAccountService', 'Alert', '$timeout', 'billingaccounts.Constants',
7-
function ($scope, $rootScope, $log, BillingAccountService, $alert, $timeout, constants) {
8-
9-
// footable
10-
angular.element(document).ready(function () {
11-
$('.footable').footable({
12-
empty: constants.MSG_NO_RECORD_FOUND
13-
});
14-
});
15-
16-
$scope.$on('billingaccounts.TableDataUpdated', function(event) {
17-
$timeout(function() {
18-
$('.footable').trigger('footable_redraw');
19-
});
20-
});
21-
6+
'BillingAccountService', 'Alert', '$timeout', 'billingaccounts.Constants', 'ClientService',
7+
function ($scope, $rootScope, $log, BillingAccountService, $alert, $timeout, constants, ClientService) {
228
// search
239
$scope.formSearch = {
2410
isLoading: false,
25-
criteria: { },
11+
criteria: {
12+
status: "1"
13+
},
2614
setLoading: function(loading) {
2715
this.isLoading = loading;
2816
}
2917
};
3018

19+
// the current page number
20+
$scope.pageNumber = 1;
21+
// the total account count in DB
22+
$scope.totalAccounts = 0;
23+
// the sort criteria
24+
$scope.sortCriteria = undefined;
25+
// the sort order
26+
$scope.sortOrder = 'asc';
27+
3128
// list data
3229
$scope.accounts = [];
3330

34-
$scope.search = function () {
31+
$scope.search = function (reset) {
32+
if (reset) {
33+
$scope.pageNumber = 1;
34+
delete $scope.sortCriteria;
35+
$scope.sortOrder = 'asc';
36+
}
3537
$scope.formSearch.setLoading(true);
3638
BillingAccountService.search({
37-
customer: $scope.formSearch.criteria.customer,
39+
name: $scope.formSearch.criteria.name,
3840
user: $scope.formSearch.criteria.user,
3941
status: $scope.formSearch.criteria.status,
4042
startDate: $scope.formSearch.criteria.startDate,
41-
endDate: $scope.formSearch.criteria.endDate,
42-
limit: 100000, // some very huge limit
43-
}).then(function (data) {
43+
endDate: $scope.formSearch.criteria.endDate},
44+
{
45+
page: $scope.pageNumber,
46+
limit: 25,
47+
sort: $scope.sortCriteria ? $scope.sortCriteria + ' ' + $scope.sortOrder : ''
48+
}
49+
).then(function (data) {
4450
$scope.formSearch.setLoading(false);
45-
$scope.accounts = data;
46-
$scope.$broadcast('billingaccounts.TableDataUpdated');
51+
$scope.accounts = data.content;
52+
$scope.totalAccounts = data.metadata.totalCount;
4753
}).catch(function (error) {
4854
$scope.formSearch.setLoading(false);
4955
$alert.error(error.error, $rootScope);
5056
});
5157
};
5258

59+
// sort by criteria
60+
$scope.sort = function (criteria) {
61+
if (criteria === $scope.sortCriteria) {
62+
if ($scope.sortOrder === 'asc') {
63+
$scope.sortOrder = 'desc';
64+
} else {
65+
$scope.sortOrder = 'asc';
66+
}
67+
} else {
68+
$scope.sortOrder = 'asc';
69+
}
70+
$scope.sortCriteria = criteria;
71+
$scope.search();
72+
};
73+
74+
// change to a specific page
75+
$scope.changePage = function (pageNumber) {
76+
if (pageNumber === 0 || pageNumber > $scope.getLastPage()) {
77+
return false;
78+
}
79+
$scope.pageNumber = pageNumber;
80+
$scope.search();
81+
};
82+
83+
// get the number array that shows the pagination bar
84+
$scope.getPageArray = function() {
85+
var res = [];
86+
for (var i = $scope.pageNumber - 5; i <= $scope.pageNumber; i++) {
87+
if (i > 0) {
88+
res.push(i);
89+
}
90+
}
91+
for (var i = $scope.pageNumber + 1; i <= $scope.getLastPage() && i <= $scope.pageNumber + 5; i++) {
92+
res.push(i);
93+
}
94+
return res;
95+
};
96+
97+
// move to the last page
98+
$scope.getLastPage = function () {
99+
return parseInt(($scope.totalAccounts + 24) / 25);
100+
};
101+
53102
/**
54103
* open datetimepicker
55104
* @param {object} e event object

src/app/billing_accounts/billingaccounts.list.html

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<form role="form" name="searchFrom" novalidate="novalidate">
1717
<div class="row">
1818
<div class="form-group col-md-4">
19-
<label for="customer">Customer</label>
20-
<input id="customer" type="text" class="form-control" ng-model="formSearch.criteria.customer" name="customer">
19+
<label for="name">Name</label>
20+
<input id="name" type="text" class="form-control" ng-model="formSearch.criteria.name" name="name">
2121
</div>
2222
<div class="form-group col-md-4">
2323
<label for="user">User</label>
@@ -26,7 +26,7 @@
2626
<div class="form-group col-md-4">
2727
<label for="status">Status</label>
2828
<select id="status" class="form-control" ng-model="formSearch.criteria.status">
29-
<option value="" selected="selected"></option>
29+
<option value="" selected="selected">Select status</option>
3030
<option value="1">Active</option>
3131
<option value="0">In Active</option>
3232
</select>
@@ -52,7 +52,7 @@
5252
</div>
5353
<div class="row">
5454
<div class="col col-md-12 col-lg-12">
55-
<button class="btn btn-primary btn-sm pull-right" ng-click="search()">Filter</button>
55+
<button class="btn btn-primary btn-sm pull-right" ng-click="search(true)">Filter</button>
5656
</div>
5757
</div>
5858
</form>
@@ -65,46 +65,69 @@
6565
<img src="assets/images/loading.gif" />
6666
</div>
6767
<div ng-show="!formSearch.isLoading">
68-
<table class="footable table table-stripped toggle-arrow-tiny" data-page-size="50">
68+
<table class="footable table table-stripped toggle-arrow-tiny">
6969
<thead>
70-
<tr>
71-
<th>Account ID</th>
72-
<th>Name</th>
73-
<th>Status</th>
74-
<th>Start Date</th>
75-
<th colspan="2">End Date</th>
76-
</tr>
70+
<tr>
71+
<th>Account ID
72+
</th>
73+
<th class="footable-sortable" ng-click="sort('name')" ng-class="{'footable-sorted': sortCriteria === 'name' && sortOrder === 'asc', 'footable-sorted-desc': sortCriteria === 'name' && sortOrder === 'desc'}">Name
74+
<span class="footable-sort-indicator"></span>
75+
</th>
76+
<th class="footable-sortable" ng-click="sort('status')" ng-class="{'footable-sorted': sortCriteria === 'status' && sortOrder === 'asc', 'footable-sorted-desc': sortCriteria === 'status' && sortOrder === 'desc'}">Status
77+
<span class="footable-sort-indicator"></span>
78+
</th>
79+
<th class="footable-sortable" ng-click="sort('startDate')" ng-class="{'footable-sorted': sortCriteria === 'startDate' && sortOrder === 'asc', 'footable-sorted-desc': sortCriteria === 'startDate' && sortOrder === 'desc'}">Start Date
80+
<span class="footable-sort-indicator"></span>
81+
</th>
82+
<th colspan="2" class="footable-sortable" ng-click="sort('endDate')" ng-class="{'footable-sorted': sortCriteria === 'endDate' && sortOrder === 'asc', 'footable-sorted-desc': sortCriteria === 'endDate' && sortOrder === 'desc'}">End Date
83+
<span class="footable-sort-indicator"></span>
84+
</th>
85+
</tr>
7786
</thead>
7887
<tbody>
79-
<tr class="animate-repeat" ng-repeat="row in accounts">
80-
<td>
81-
<a ui-sref="index.billingaccounts.view({accountId: row.id})">{{row.id}}</a>
82-
</td>
83-
<td>
84-
{{row.name}}
85-
</td>
86-
<td>
87-
{{row.status}}
88-
</td>
89-
<td>
90-
{{row.startDate | date:'MMM dd, yyyy'}}
91-
</td>
92-
<td>
93-
{{row.endDate | date:'MMM dd, yyyy'}}
94-
</td>
95-
<td>
96-
<a ui-sref="index.billingaccounts.edit({accountId: row.id})">Edit Account</a> |
97-
<a ui-sref="index.billingaccountresources.list({accountId: row.id})">View Resources</a>
98-
</td>
99-
</tr>
88+
<tr class="animate-repeat" ng-repeat="row in accounts" ng-class-even="'footable-even'" ng-class-odd="'footable-odd'">
89+
<td>
90+
<a ui-sref="index.billingaccounts.view({accountId: row.id})">{{row.id}}</a>
91+
</td>
92+
<td>
93+
{{row.name}}
94+
</td>
95+
<td>
96+
{{row.status}}
97+
</td>
98+
<td>
99+
{{row.startDate | date:'MMM dd, yyyy'}}
100+
</td>
101+
<td>
102+
{{row.endDate | date:'MMM dd, yyyy'}}
103+
</td>
104+
<td>
105+
<a ui-sref="index.billingaccounts.edit({accountId: row.id})">Edit Account</a> |
106+
<a ui-sref="index.billingaccountresources.list({accountId: row.id})">View Resources</a>
107+
</td>
108+
</tr>
100109
</tbody>
101110

102111
<tfoot>
103-
<tr>
104-
<td colspan="6">
105-
<ul class="pagination pull-right"></ul>
106-
</td>
107-
</tr>
112+
<tr>
113+
<td colspan="6">
114+
<ul class="pagination pull-right">
115+
<li class="footable-page-arrow" ng-class="{'disabled': pageNumber === 1}"><a
116+
ng-click="changePage(1)">«</a></li>
117+
<li class="footable-page-arrow" ng-class="{'disabled': pageNumber === 1}">
118+
<a ng-click="changePage(pageNumber - 1)"></a>
119+
</li>
120+
<li class="footable-page" ng-class="{'active' : item === pageNumber}" ng-repeat="item in getPageArray()">
121+
<a ng-click="changePage(item)">{{item}}</a></li>
122+
<li class="footable-page-arrow" ng-class="{'disabled': pageNumber === getLastPage()}">
123+
<a ng-click="changePage(pageNumber + 1)"></a>
124+
</li>
125+
<li class="footable-page-arrow" ng-class="{'disabled': pageNumber === getLastPage()}">
126+
<a ng-click="changePage(getLastPage())">»</a>
127+
</li>
128+
</ul>
129+
</td>
130+
</tr>
108131
</tfoot>
109132
</table>
110133
</div>

0 commit comments

Comments
 (0)