~sil2100/+junk/apview

« back to all changes in this revision

Viewing changes to apview.js

  • Committer: Christopher Lee
  • Date: 2012-10-04 03:24:06 UTC
  • Revision ID: chris.lee@canonical.com-20121004032406-fj92287lt4j8v2q7
Better error reporting for timeouts and connection to VPN

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
$(document).ready(function() {
2
2
    var JSON_API_STR = "/api/json?jsonp=?";
 
3
    var DEFAULT_TIMEOUT = 40000; //aka 40 seconds
3
4
    var Artifact_Path = null;
4
5
 
5
6
    $('form#config').submit(function(event){
26
27
            dataType: 'json',
27
28
            crossDomain: true,
28
29
            url: get_build_list_url(),
 
30
            timeout: DEFAULT_TIMEOUT,
29
31
            success: function(data){
30
32
                build_menu(data);
31
33
            },
32
34
            error: function(request, textStatus, errorThrown) {
33
35
                console.log("ERROR: %s - %s", textStatus, errorThrown);
 
36
                alert("Unable to load build list. Are you connected to the VPN and logged in? Error: "+textStatus);
34
37
            },
35
38
            complete: function(request, textStatus) {
36
39
                menu_loading_status.hide();
60
63
                            set_active_menu_item($(this));
61
64
                            $("#detail_status").fadeIn();
62
65
                            var build_url =  $('a', $(this)).attr('href');
63
 
                            populate_test_details(build_url);
 
66
                            populate_list_of_build_details(build_url);
64
67
                        }
65
68
                        return false;
66
69
                    });
76
79
    }
77
80
 
78
81
    /* Control for the builds details */
79
 
    function populate_test_details(url) {
 
82
    function populate_list_of_build_details(url) {
80
83
        /* Actual actions */
81
84
        $('#details ul li').remove();
82
85
        $("#details .error_message").remove();
86
89
            dataType: 'json',
87
90
            crossDomain: true,
88
91
            url: get_testreport_url(),
 
92
            timeout: DEFAULT_TIMEOUT,
89
93
 
90
94
            success: function(data) {
91
95
                $("#detail_status").fadeOut();
97
101
                    var testreport_data = collate_testreport_data(data);
98
102
                    refresh_details_view(testreport_data);
99
103
                }
 
104
            },
 
105
            error: function(request, textStatus, errorThrown) {
 
106
                console.log("ERROR: %s - %s", textStatus, errorThrown);
 
107
                alert("Unable to retrieve the list of build details. Error: "+textStatus);
100
108
            }
101
109
        });
102
110
 
224
232
                            crossDomain: true,
225
233
                            url: get_test_details_url(test_result_url,
226
234
                                                      test_details),
 
235
                            timeout: DEFAULT_TIMEOUT,
227
236
                            success: function(data) {
228
237
                                loading_text.remove();
229
238
                                var detail_summary = extract_test_detail_summary(data);
231
240
                                var error_log = $('<pre>').appendTo(panel);
232
241
                                error_log.text(data['errorStackTrace']);
233
242
                                panel.addClass('data_present');
 
243
                            },
 
244
                            error: function(request, textStatus, errorThrown) {
 
245
                                console.log("ERROR: %s - %s", textStatus, errorThrown);
 
246
                                alert("Unable to load test log. Error: "+textStatus);
234
247
                            }
235
248
                        });
236
249
                    }
353
366
                    dataType: 'json',
354
367
                    crossDomain: true,
355
368
                    url: url+JSON_API_STR,
 
369
                    timeout: DEFAULT_TIMEOUT,
356
370
                    success: function(data){
357
371
                        var rel_path_parts = data['artifacts'][0]['relativePath'].split('/');
358
372
                        rel_path_parts.pop();
364
378
                    error: function(request, textStatus, errorThrown) {
365
379
                        Artifact_Path = null;
366
380
                        console.log("ERROR: %s - %s", textStatus, errorThrown);
 
381
                        alert("Unable to retrieve artifact. Error: "+textStatus);
367
382
                    },
368
383
                    complete: function(request, textStatus) {
369
384
                        // Mark as complete?