JOE
2018-10-29 3890d37d2bcc8f3f8a6b5987db9fa0772824c9d6
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
{{>layout/header-temp}}
<body>
<div class="content">
    <h2>Module List&nbsp;</h2>
    {{#modules}}
    <h3 data-path="{{path}}" data-id="{{id}}">
        {{name}} : <span id="{{id}}" class="test-result"></span>
    </h3>
    {{/modules}}
</div>
<script>
    $(function(){
        function getStatus(code) {
            switch (code){
                case 401:
                    code = '401 - UNAUTHORIZED.';
                    break;
                case 403:
                    code = '403 - Access Denied.';
                    break;
                case 406:
                    code = '403 - Access Denied.';
                    break;
                default:
                    code = '200 - SUCCESS.';
                    break;
            }
            return code;
        }
 
        $.each($('h3'), function () {
            const id = $(this).attr('data-id');
            const path = $(this).attr('data-path');
                $.ajax({
                    method: "GET",
                    url: "{{context}}"+path,
                    data: {
                        //for component api - /geo-location-circle
                        zlevel: 8,
                        locids: "1,2",
                        bound: "1,2,3,4",
                        //for members api
                        memberId: "5b6974345389967bdf999a45"
                    }
                })
                .done(function( data ) {
                    if(-1 < path.search(/\/accounts|\/modules|\/roles|\/segments|\/customer-data/)){
                        if((typeof data.resultCode == 'undefined') && -1 < String(data).indexOf('ERROR 403')){
                            var tempData = {};
                            tempData.resultCode = 403;
                            data = tempData;
                        }
                    }
 
                    var resultMessage = getStatus(data.resultCode);
 
                    if(200 < data.resultCode){
                        $('#'+id).addClass('error');
                    }
 
                    $('#'+id).text(resultMessage);
                })
                .fail(function(e) {
                    $('#'+id).addClass('error');
                    $('#'+id).text(e.status + " - " + e.message);
                });
        });
 
 
 
    });
</script>
{{>layout/footer}}