-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
110 lines (87 loc) · 2.78 KB
/
index.html
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<html ng-app>
<head>
<script src="https://code.angularjs.org/angular-1.0.1.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous">
<script>
var myApp = angular.module('myApp',[]);
function MyCtrl($scope, $http, $q, $timeout) {
$scope.response = [];
$scope.brands = ['shoptime', 'americanas', 'submarino'];
$scope.update = function(data){
var promises = [];
$scope.brands.forEach(function(brand){
var deferred = $q.defer();
var url = 'https://api.'+ brand +'.com.br/v1/oascache/info';
promises.push($http.get(url, {params: {brand : brand}}, function (error, msg, body) {
if (error) {
deferred.reject();
}
deferred.resolve();
}));
});
$q.all(promises).then(function (resp) {
$scope.response = [];
var arr = [];
resp.forEach(function(obj){
var brand = obj.config.params.brand;
var body = obj.data;
var oas = body.oas[brand];
var oassitepage = body.oassitepage[brand];
var ftpupload = body.ftpupload[brand];
arr.push({ 'oas' : oas, 'oassitepage': oassitepage, 'ftpupload': ftpupload, 'brand' : brand });
});
$scope.response = arr;
});
$timeout($scope.update, 5000);
};
$scope.update();
};
</script>
<style type="text/css">
.americanas th { background: #e60014; color: #fff}
.submarino th { background: #00adef}
.shoptime th { background: #ff9c5a}
</style>
</head>
<body ng-controller="MyCtrl">
<div ng-repeat="data in response">
<table class="table">
<thead>
<tr class="{{data.brand}}">
<th>{{data.brand}}</th>
<th>complete</th>
<th>dequeued</th>
<th>queued</th>
<th>failed</th>
</tr>
</thead>
<tbody>
<tr>
<td>oas</td>
<td>{{data.oas.complete}}</td>
<td>{{data.oas.dequeued}}</td>
<td>{{data.oas.queued}}</td>
<td>{{data.oas.failed}}</td>
</tr>
<tr>
<td>oas-sitepage</td>
<td>{{data.oassitepage.complete}}</td>
<td>{{data.oassitepage.dequeued}}</td>
<td>{{data.oassitepage.queued}}</td>
<td>{{data.oassitepage.failed}}</td>
</tr>
<tr>
<td>ftp-upload</td>
<td>{{data.ftpupload.complete}}</td>
<td>{{data.ftpupload.dequeued}}</td>
<td>{{data.ftpupload.queued}}</td>
<td>{{data.ftpupload.failed}}</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>