Skip to content

Commit b4bf241

Browse files
authored
Merge pull request #51 from appirio-tech/dev
Initial client and billing management
2 parents bc8c01f + d53ca52 commit b4bf241

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1706
-1962
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"moment": "~2.11.2",
3333
"moment-timezone": "~0.5.0",
3434
"ng-file-model": "https://github.com/mistralworks/ng-file-model.git#fd1889b28e279944012919574bbcaaf45c1540d6",
35-
"angular-bootstrap-multiselect": "*",
35+
"angular-bootstrap-multiselect": "*",
3636
"bootstrap-ui-datetime-picker": "^2.4.0"
3737
},
3838
"overrides": {

src/app/app.js

+72
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,78 @@ angular.module('supportAdminApp', [
189189
data: { pageTitle: 'Projects List' },
190190
controller: 'ProjectListCtrl',
191191
controllerAs: 'vm'
192+
})
193+
.state('index.clients', {
194+
abstract: true,
195+
url: '/clients',
196+
templateUrl: 'app/clients/clients.html',
197+
data: { pageTitle: 'Clients' },
198+
controller: 'billingaccount.ClientsController'
199+
})
200+
.state('index.clients.list', {
201+
url: '/list',
202+
templateUrl: 'app/clients/clients.list.html',
203+
controller: 'billingaccount.ClientsListController'
204+
})
205+
.state('index.clients.new', {
206+
url: '/new',
207+
templateUrl: 'app/clients/clients.new.html',
208+
controller: 'billingaccount.NewClientController',
209+
data: { pageTitle: 'New Client' }
210+
})
211+
.state('index.clients.edit', {
212+
url: '/edit/:clientId',
213+
templateUrl: 'app/clients/clients.edit.html',
214+
controller: 'billingaccount.EditClientController',
215+
data: { pageTitle: 'Edit Client' }
216+
})
217+
.state('index.billingaccounts', {
218+
abstract: true,
219+
url: '/billingaccounts',
220+
templateUrl: 'app/billing_accounts/billingaccounts.html',
221+
data: { pageTitle: 'Billing Accounts' },
222+
controller: 'billingaccount.BillingAccountsController'
223+
})
224+
.state('index.billingaccounts.list', {
225+
url: '/list',
226+
templateUrl: 'app/billing_accounts/billingaccounts.list.html',
227+
controller: 'billingaccount.BillingAccountsListController'
228+
})
229+
.state('index.billingaccounts.new', {
230+
url: '/new',
231+
templateUrl: 'app/billing_accounts/billingaccounts.new.html',
232+
controller: 'billingaccount.NewBillingAccountController',
233+
data: { pageTitle: 'New Billing Account' }
234+
})
235+
.state('index.billingaccounts.edit', {
236+
url: '/edit/:accountId',
237+
templateUrl: 'app/billing_accounts/billingaccounts.edit.html',
238+
controller: 'billingaccount.EditBillingAccountController',
239+
data: { pageTitle: 'Edit Billing Account' }
240+
})
241+
.state('index.billingaccounts.view', {
242+
url: '/view/:accountId',
243+
templateUrl: 'app/billing_accounts/billingaccounts.view.html',
244+
controller: 'billingaccount.ViewBillingAccountController',
245+
data: { pageTitle: 'Details - Billing Account' }
246+
})
247+
.state('index.billingaccountresources', {
248+
abstract: true,
249+
url: '/billingaccountresources',
250+
templateUrl: 'app/billing_account_resources/billingaccountresources.html',
251+
data: { pageTitle: 'Billing Account Resources' },
252+
controller: 'billingaccount.BillingAccountResourcesController'
253+
})
254+
.state('index.billingaccountresources.list', {
255+
url: '/list/:accountId',
256+
templateUrl: 'app/billing_account_resources/billingaccountresources.list.html',
257+
controller: 'billingaccount.BillingAccountResourcesListController'
258+
})
259+
.state('index.billingaccountresources.new', {
260+
url: '/:accountId/new',
261+
templateUrl: 'app/billing_account_resources/billingaccountresources.new.html',
262+
controller: 'billingaccount.NewBillingAccountResourceController',
263+
data: { pageTitle: 'New Billing Account Resource' }
192264
});
193265

194266
$urlRouterProvider.otherwise('/login');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
var module = angular.module('supportAdminApp');
4+
5+
/**
6+
* The parent controller for the billing account resources states
7+
*/
8+
module.controller('billingaccount.BillingAccountResourcesController', ['$scope', 'AuthService', '$state',
9+
function ($scope, $authService, $state) {
10+
$scope.$state = $state;
11+
12+
/**
13+
* Validate the user authentication
14+
*/
15+
$scope.authorized = function() {
16+
return $authService.isLoggedIn();
17+
};
18+
}
19+
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="row wrapper border-bottom white-bg page-heading">
2+
<div class="col-lg-10">
3+
<h2>{{$state.current.data.pageTitle}}</h2>
4+
</div>
5+
<div class="col-md-10 col-lg-12" ng-include src="'components/alert/alert.html'"></div>
6+
</div>
7+
<div ui-view=""></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
'use strict';
2+
3+
var module = angular.module('supportAdminApp');
4+
5+
module.controller('billingaccount.BillingAccountResourcesListController', ['$scope', '$rootScope', '$log',
6+
'billingaccountresources.Constants', 'BillingAccountResourceService', 'Alert', '$timeout', '$stateParams', '$state', 'UserService',
7+
function ($scope, $rootScope, $log, constants, BillingAccountResourceService, $alert, $timeout, $stateParams, $state, UserService) {
8+
9+
$scope.billingAccountId = $stateParams.accountId;
10+
11+
// footable
12+
angular.element(document).ready(function () {
13+
$('.footable').footable({
14+
empty: constants.MSG_NO_RECORD_FOUND
15+
});
16+
});
17+
18+
$scope.$on('billingaccountresources.TableDataUpdated', function(event) {
19+
$timeout(function() {
20+
$('.footable').trigger('footable_redraw');
21+
});
22+
});
23+
24+
// search
25+
$scope.formSearch = {
26+
isLoading: false,
27+
setLoading: function(loading) {
28+
this.isLoading = loading;
29+
}
30+
};
31+
32+
// list data
33+
$scope.resources = [];
34+
35+
/**
36+
* Search billing account resources
37+
* Current implementation will return list of all resources
38+
*/
39+
$scope.search = function (accountId) {
40+
$alert.clear();
41+
$scope.formSearch.setLoading(true);
42+
BillingAccountResourceService.findAll(accountId).then(function (data) {
43+
$scope.resources = data;
44+
$scope.formSearch.setLoading(false);
45+
$scope.$broadcast('billingaccountresources.TableDataUpdated');
46+
}).catch(function (error) {
47+
$alert.error(error.error, $rootScope);
48+
$scope.formSearch.setLoading(false);
49+
});
50+
};
51+
52+
/**
53+
* Delete the resource
54+
* @param {String} userId the id of resource
55+
*/
56+
$scope.deleteResource = function (user) {
57+
UserService.find({
58+
filter: 'handle=' + user.name
59+
}).then(function (data) {
60+
if (data && data.length) {
61+
BillingAccountResourceService.removeBillingAccountResource($scope.billingAccountId, data[0].id).then(function () {
62+
$state.reload();
63+
}).catch(function (error) {
64+
$alert.error(error.error, $rootScope);
65+
});
66+
}
67+
});
68+
69+
};
70+
71+
if ($stateParams.accountId) {
72+
// load the resources on controller init
73+
$scope.search($stateParams.accountId);
74+
}
75+
}
76+
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<div class="wrapper wrapper-content animated fadeInRight" ng-show="authorized()">
2+
<!-- add client button row -->
3+
<div class="row">
4+
<div class="col col-md-12 col-lg-12">
5+
<a class="btn btn-primary pull-right m-b" ui-sref="index.billingaccounts.list" style="margin-left: 20px">
6+
<strong>Back</strong>
7+
</a>
8+
<a class="btn btn-info pull-right m-b" ui-sref="index.billingaccountresources.new({accountId: billingAccountId})">
9+
<strong><i class="fa fa-plus"></i> Add Resource</strong>
10+
</a>
11+
</div>
12+
</div>
13+
<div class="row">
14+
<div class="col-lg-12">
15+
<div class="ibox float-e-margins">
16+
17+
<div class="ibox-content">
18+
<div class="text-center" ng-show="formSearch.isLoading">
19+
<img src="assets/images/loading.gif" />
20+
</div>
21+
<div ng-show="!formSearch.isLoading">
22+
<table class="footable table table-stripped toggle-arrow-tiny" data-page-size="50">
23+
<thead>
24+
<tr>
25+
<th>Name</th>
26+
<th colspan="2">Status</th>
27+
</tr>
28+
</thead>
29+
30+
<tbody>
31+
<tr class="animate-repeat" ng-repeat="user in resources">
32+
<td>{{user.name}}</td>
33+
<td>{{user.status}}</td>
34+
<td>
35+
<a href="javascript:;" ng-click="deleteResource(user)">Delete</a>
36+
</td>
37+
</tr>
38+
</tbody>
39+
40+
<tfoot>
41+
<tr>
42+
<td colspan="4">
43+
<ul class="pagination pull-right"></ul>
44+
</td>
45+
</tr>
46+
</tfoot>
47+
</table>
48+
</div>
49+
</div>
50+
</div>
51+
</div>
52+
</div>
53+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
var module = angular.module('supportAdminApp');
4+
5+
module.controller('billingaccount.NewBillingAccountResourceController', ['$scope', '$rootScope', '$log',
6+
'BillingAccountResourceService', 'Alert', '$state', '$stateParams',
7+
function ($scope, $rootScope, $log, BillingAccountResourceService, $alert, $state, $stateParams) {
8+
$scope.processing = false;
9+
$scope.billingAccountId = $stateParams.accountId;
10+
$scope.newResource = { status: 'active' };
11+
12+
/**
13+
* Submit the resource to the API
14+
*/
15+
$scope.submitResource = function () {
16+
$scope.processing = true;
17+
BillingAccountResourceService.createBillingAccountResource($scope.billingAccountId, $scope.newResource).then(function () {
18+
$scope.processing = false;
19+
$state.go('index.billingaccountresources.list', { accountId: $scope.billingAccountId });
20+
}).catch(function (error) {
21+
$alert.error(error.error, $rootScope);
22+
$scope.processing = false;
23+
});
24+
};
25+
}
26+
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<div class="wrapper wrapper-content animated fadeInRight" ng-show="authorized()">
2+
<div class="row">
3+
<div class="col-lg-12">
4+
<div class="ibox float-e-margins">
5+
<div class="ibox-content">
6+
<form role="form" name="addResourceForm" data-toggle="validator" novalidate>
7+
<div class="row">
8+
<div class="form-group col-md-6" ng-class="{'has-error': addResourceForm.name.$touched && addResourceForm.name.$invalid}">
9+
<label for="resource-name">TC Handle</label>
10+
<input id="resource-name" type="text" data-find-user class="form-control" ng-model="newResource.name" name="name" required="required" placeholder="Handle">
11+
</div>
12+
<div class="form-group col-md-6" ng-class="{'has-error': addResourceForm.status.$touched && addResourceForm.status.$invalid}">
13+
<label for="resource-status">Status</label>
14+
<select id="resource-status" class="form-control" ng-model="newResource.status">
15+
<option value="active">Active</option>
16+
<option value="inactive">In Active</option>
17+
</select>
18+
</div>
19+
</div>
20+
21+
<div class="row">
22+
<div class="form-group col-md-12" ng-class="{'has-error': addResourceForm.userId.$touched && addResourceForm.userId.$invalid}">
23+
<label for="resource-user-id">User ID</label>
24+
<input id="resource-user-id" type="text" class="form-control" ng-model="newResource.userId" name="userId" required="required" placeholder="User ID" disabled="disabled">
25+
</div>
26+
</div>
27+
<div class="row ">
28+
<div class="form-group col-md-12">
29+
<button ui-sref="index.billingaccountresources.list({accountId: billingAccountId})" type="button" class="btn btn-sm btn-warning m-l pull-right">
30+
<strong>Cancel</strong>
31+
</button>
32+
<button ng-click="submitResource()" type="submit" class="btn btn-sm btn-success pull-right" ng-disabled="addResourceForm.$invalid || processing">
33+
<strong>Save Changes</strong>
34+
</button>
35+
</div>
36+
</div>
37+
</form>
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
</div>

0 commit comments

Comments
 (0)