Skip to content

Commit

Permalink
Merge pull request #57 from topcoder-platform/dev
Browse files Browse the repository at this point in the history
Promote to prod
  • Loading branch information
ajefts authored Mar 21, 2017
2 parents b4bf241 + 0964e5f commit b5ded24
Show file tree
Hide file tree
Showing 19 changed files with 897 additions and 117 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# support-admin-app
Customer support application <br>
Support application <br>

angular.js app using INSPINIA template
Internal application used to administer specific support tasks related to the Topcoder platform.
24 changes: 22 additions & 2 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ angular.module('supportAdminApp', [
'app.constants',
'appirio-tech-ng-api-services',
'appirio-tech-ng-auth',
'ui.footable',
'angular-clipboard',
'ng-file-model',
'ui.multiselect',
Expand Down Expand Up @@ -99,14 +98,20 @@ angular.module('supportAdminApp', [
url: '/tags',
templateUrl: 'app/tags/tags.html',
data: { pageTitle: 'Tags' },
controller: function ($scope, $state) {
controller: function ($scope, $state, TagService) {
$scope.$state = $state;
$scope.tagDomains = [{
value: 'skills',
name: 'Skills'
}, {
value: 'events',
name: 'Events'
}, {
value: 'technology',
name: 'Technology'
}, {
value: 'platform',
name: 'Platform'
}];

$scope.tagCategories = [{
Expand All @@ -128,6 +133,21 @@ angular.module('supportAdminApp', [
value: 'pending',
name: 'Pending'
}];

TagService.getTechnologyStatuses().then(function(techStatuses) {
_.forEach(techStatuses, function(status) {
status.value = _.lowerCase(status.description);
status.name = status.description;
});
$scope.techStatuses = techStatuses;
});
$scope.getTagStatuses = function(domainType) {
if (domainType === 'technology') {
return $scope.techStatuses;
} else {
return $scope.tagStatuses;
}
}
}
})
.state('index.tags.list', {
Expand Down
28 changes: 25 additions & 3 deletions src/app/billing_accounts/billingaccounts.edit.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var module = angular.module('supportAdminApp');
* Controller for edit billing account view
*/
module.controller('billingaccount.EditBillingAccountController', ['$scope', '$rootScope', '$log',
'BillingAccountService', 'Alert', '$state', '$stateParams',
function ($scope, $rootScope, $log, BillingAccountService, $alert, $state, $stateParams) {
'BillingAccountService', 'Alert', '$state', '$stateParams', 'ClientService',
function ($scope, $rootScope, $log, BillingAccountService, $alert, $state, $stateParams, ClientService) {
$scope.processing = false;

$scope.account = { };
Expand All @@ -18,9 +18,31 @@ module.controller('billingaccount.EditBillingAccountController', ['$scope', '$ro
$scope.account = data;
$scope.endDateOptions.minDate = new Date(data.startDate);
$scope.startDateOptions.maxDate = new Date(data.endDate);
if (data.clientId) {
ClientService.findClientById(data.clientId).then(function (data) {
$scope.account.client = data;
}).catch(function (error) {
$alert.error(error.error.message, $rootScope);
});
}
});
}

// search clients
$scope.getClients = function(name) {
$scope.loadingClients = true;
return ClientService.search({
name: name
}, {
page: 1,
limit: 10,
sort: 'name asc'
}).then(function (data) {
$scope.loadingClients = false;
return data.content;
})
};

// start date and end date options
$scope.endDateOptions = {
minDate: new Date()
Expand All @@ -40,7 +62,7 @@ module.controller('billingaccount.EditBillingAccountController', ['$scope', '$ro
$scope.processing = false;
$state.go('index.billingaccounts.list');
}).catch(function (error) {
$alert.error(error.error.message, $rootScope);
$alert.error(error.error, $rootScope);
$scope.processing = false;
});
};
Expand Down
11 changes: 11 additions & 0 deletions src/app/billing_accounts/billingaccounts.edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@
<input id="account-terms" type="textarea" class="form-control" ng-model="account.paymentTerms" name="paymentTerms">
</div>
</div>
<div class="row">
<div class="form-group col-md-6" ng-class="{'has-error': editAccountForm.client.$touched && editAccountForm.client.$invalid}">
<label for="account-description">Client</label>
<input type="text" ng-model="account.client"
uib-typeahead="client as client.name for client in getClients($viewValue)"
class="form-control" required="required">
</div>
<div class="form-group col-md-6">

</div>
</div>
<div class="row">
<div class="form-group col-md-12">
<button ui-sref="index.billingaccounts.list" type="button" class="btn btn-sm btn-warning m-l pull-right">
Expand Down
97 changes: 73 additions & 24 deletions src/app/billing_accounts/billingaccounts.list.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,102 @@
var module = angular.module('supportAdminApp');

module.controller('billingaccount.BillingAccountsListController', ['$scope', '$rootScope', '$log',
'BillingAccountService', 'Alert', '$timeout', 'billingaccounts.Constants',
function ($scope, $rootScope, $log, BillingAccountService, $alert, $timeout, constants) {

// footable
angular.element(document).ready(function () {
$('.footable').footable({
empty: constants.MSG_NO_RECORD_FOUND
});
});

$scope.$on('billingaccounts.TableDataUpdated', function(event) {
$timeout(function() {
$('.footable').trigger('footable_redraw');
});
});

'BillingAccountService', 'Alert', '$timeout', 'billingaccounts.Constants', 'ClientService',
function ($scope, $rootScope, $log, BillingAccountService, $alert, $timeout, constants, ClientService) {
// search
$scope.formSearch = {
isLoading: false,
criteria: { },
criteria: {
status: "1"
},
setLoading: function(loading) {
this.isLoading = loading;
}
};

// the current page number
$scope.pageNumber = 1;
// the total account count in DB
$scope.totalAccounts = 0;
// the sort criteria
$scope.sortCriteria = undefined;
// the sort order
$scope.sortOrder = 'asc';

// list data
$scope.accounts = [];

$scope.search = function () {
$scope.search = function (reset) {
if (reset) {
$scope.pageNumber = 1;
delete $scope.sortCriteria;
$scope.sortOrder = 'asc';
}
$scope.formSearch.setLoading(true);
BillingAccountService.search({
customer: $scope.formSearch.criteria.customer,
name: $scope.formSearch.criteria.name,
user: $scope.formSearch.criteria.user,
status: $scope.formSearch.criteria.status,
startDate: $scope.formSearch.criteria.startDate,
endDate: $scope.formSearch.criteria.endDate,
limit: 100000, // some very huge limit
}).then(function (data) {
endDate: $scope.formSearch.criteria.endDate},
{
page: $scope.pageNumber,
limit: 25,
sort: $scope.sortCriteria ? $scope.sortCriteria + ' ' + $scope.sortOrder : ''
}
).then(function (data) {
$scope.formSearch.setLoading(false);
$scope.accounts = data;
$scope.$broadcast('billingaccounts.TableDataUpdated');
$scope.accounts = data.content;
$scope.totalAccounts = data.metadata.totalCount;
}).catch(function (error) {
$scope.formSearch.setLoading(false);
$alert.error(error.error, $rootScope);
});
};

// sort by criteria
$scope.sort = function (criteria) {
if (criteria === $scope.sortCriteria) {
if ($scope.sortOrder === 'asc') {
$scope.sortOrder = 'desc';
} else {
$scope.sortOrder = 'asc';
}
} else {
$scope.sortOrder = 'asc';
}
$scope.sortCriteria = criteria;
$scope.search();
};

// change to a specific page
$scope.changePage = function (pageNumber) {
if (pageNumber === 0 || pageNumber > $scope.getLastPage()) {
return false;
}
$scope.pageNumber = pageNumber;
$scope.search();
};

// get the number array that shows the pagination bar
$scope.getPageArray = function() {
var res = [];
for (var i = $scope.pageNumber - 5; i <= $scope.pageNumber; i++) {
if (i > 0) {
res.push(i);
}
}
for (var i = $scope.pageNumber + 1; i <= $scope.getLastPage() && i <= $scope.pageNumber + 5; i++) {
res.push(i);
}
return res;
};

// move to the last page
$scope.getLastPage = function () {
return parseInt(($scope.totalAccounts + 24) / 25);
};

/**
* open datetimepicker
* @param {object} e event object
Expand Down
99 changes: 61 additions & 38 deletions src/app/billing_accounts/billingaccounts.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<form role="form" name="searchFrom" novalidate="novalidate">
<div class="row">
<div class="form-group col-md-4">
<label for="customer">Customer</label>
<input id="customer" type="text" class="form-control" ng-model="formSearch.criteria.customer" name="customer">
<label for="name">Name</label>
<input id="name" type="text" class="form-control" ng-model="formSearch.criteria.name" name="name">
</div>
<div class="form-group col-md-4">
<label for="user">User</label>
Expand All @@ -26,7 +26,7 @@
<div class="form-group col-md-4">
<label for="status">Status</label>
<select id="status" class="form-control" ng-model="formSearch.criteria.status">
<option value="" selected="selected"></option>
<option value="" selected="selected">Select status</option>
<option value="1">Active</option>
<option value="0">In Active</option>
</select>
Expand All @@ -52,7 +52,7 @@
</div>
<div class="row">
<div class="col col-md-12 col-lg-12">
<button class="btn btn-primary btn-sm pull-right" ng-click="search()">Filter</button>
<button class="btn btn-primary btn-sm pull-right" ng-click="search(true)">Filter</button>
</div>
</div>
</form>
Expand All @@ -65,46 +65,69 @@
<img src="assets/images/loading.gif" />
</div>
<div ng-show="!formSearch.isLoading">
<table class="footable table table-stripped toggle-arrow-tiny" data-page-size="50">
<table class="footable table table-stripped toggle-arrow-tiny">
<thead>
<tr>
<th>Account ID</th>
<th>Name</th>
<th>Status</th>
<th>Start Date</th>
<th colspan="2">End Date</th>
</tr>
<tr>
<th>Account ID
</th>
<th class="footable-sortable" ng-click="sort('name')" ng-class="{'footable-sorted': sortCriteria === 'name' && sortOrder === 'asc', 'footable-sorted-desc': sortCriteria === 'name' && sortOrder === 'desc'}">Name
<span class="footable-sort-indicator"></span>
</th>
<th class="footable-sortable" ng-click="sort('status')" ng-class="{'footable-sorted': sortCriteria === 'status' && sortOrder === 'asc', 'footable-sorted-desc': sortCriteria === 'status' && sortOrder === 'desc'}">Status
<span class="footable-sort-indicator"></span>
</th>
<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
<span class="footable-sort-indicator"></span>
</th>
<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
<span class="footable-sort-indicator"></span>
</th>
</tr>
</thead>
<tbody>
<tr class="animate-repeat" ng-repeat="row in accounts">
<td>
<a ui-sref="index.billingaccounts.view({accountId: row.id})">{{row.id}}</a>
</td>
<td>
{{row.name}}
</td>
<td>
{{row.status}}
</td>
<td>
{{row.startDate | date:'MMM dd, yyyy'}}
</td>
<td>
{{row.endDate | date:'MMM dd, yyyy'}}
</td>
<td>
<a ui-sref="index.billingaccounts.edit({accountId: row.id})">Edit Account</a> |
<a ui-sref="index.billingaccountresources.list({accountId: row.id})">View Resources</a>
</td>
</tr>
<tr class="animate-repeat" ng-repeat="row in accounts" ng-class-even="'footable-even'" ng-class-odd="'footable-odd'">
<td>
<a ui-sref="index.billingaccounts.view({accountId: row.id})">{{row.id}}</a>
</td>
<td>
{{row.name}}
</td>
<td>
{{row.status}}
</td>
<td>
{{row.startDate | date:'MMM dd, yyyy'}}
</td>
<td>
{{row.endDate | date:'MMM dd, yyyy'}}
</td>
<td>
<a ui-sref="index.billingaccounts.edit({accountId: row.id})">Edit Account</a> |
<a ui-sref="index.billingaccountresources.list({accountId: row.id})">View Resources</a>
</td>
</tr>
</tbody>

<tfoot>
<tr>
<td colspan="6">
<ul class="pagination pull-right"></ul>
</td>
</tr>
<tr>
<td colspan="6">
<ul class="pagination pull-right">
<li class="footable-page-arrow" ng-class="{'disabled': pageNumber === 1}"><a
ng-click="changePage(1)">«</a></li>
<li class="footable-page-arrow" ng-class="{'disabled': pageNumber === 1}">
<a ng-click="changePage(pageNumber - 1)"></a>
</li>
<li class="footable-page" ng-class="{'active' : item === pageNumber}" ng-repeat="item in getPageArray()">
<a ng-click="changePage(item)">{{item}}</a></li>
<li class="footable-page-arrow" ng-class="{'disabled': pageNumber === getLastPage()}">
<a ng-click="changePage(pageNumber + 1)"></a>
</li>
<li class="footable-page-arrow" ng-class="{'disabled': pageNumber === getLastPage()}">
<a ng-click="changePage(getLastPage())">»</a>
</li>
</ul>
</td>
</tr>
</tfoot>
</table>
</div>
Expand Down
Loading

0 comments on commit b5ded24

Please sign in to comment.