forked from ExchangeBC/API-Management
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-list.js
50 lines (38 loc) · 1.36 KB
/
api-list.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(function(){
angular.module('ApiList', ['angularSpinner', 'ngResource', 'ngSanitize'])
.factory('ProgramListService', ['$resource', function($resource) {
return $resource('listing.json');
}])
.controller('ApiCtrl', ['$scope', 'usSpinnerService', '$q', 'ProgramListService',
function($scope, usSpinnerService, $q, ProgramListService) {
// Array of apis
$scope.apis = []
$scope.apisLoaded = false
$scope.predicate = 'title';
$scope.predicateTitle = 'Title A-Z'
// Array of alerts
$scope.alerts = []
$scope.startSpin = function(){
usSpinnerService.spin('spinner-1')
}
$scope.stopSpin = function(){
usSpinnerService.stop('spinner-1')
}
var apiListDeferred = $q.defer()
var apiPromise = apiListDeferred.promise
apiPromise.then(
function(){
usSpinnerService.stop('spinner-apis')
}
)
ProgramListService.get({}, function(data) {
$scope.apis = data.result.packages
apiListDeferred.resolve("# apis:"+data.result.packages.length)
$scope.apisLoaded = true
}, function(error) {
$scope.alerts.push({ type: 'warning', msg: 'There was an error accessing data from <strong>' + error.config.url + '</strong>.' })
apiListDeferred.resolve('error retrieving apis for ' + error.config.url)
$scope.apisLoaded = true
})
}])
})();