aboutsummaryrefslogtreecommitdiff
path: root/app/dashboard/static/js/linaro-boots-job-kernel-defconfig-0.0.5.js
blob: 2e6b6d5bea90680ad2376cced960e8bb97071163 (plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
var fileServer = $('#file-server').val();
var boardName = $('#board-name').val();
var jobName = $('#job-name').val();
var kernelName = $('#kernel-name').val();
var defconfigFull = $('#defconfig-full').val();

function populateBootPage(data) {
    'use strict';

    var localData = data.result,
        dataLen = localData.length,
        i = 0,
        allRows = '',
        col0,
        col1,
        col2,
        col3,
        col4,
        col5,
        rowHref,
        statusDisplay,
        createdOn,
        resultDescription,
        labName,
        arch,
        bootLog,
        bootLogHtml,
        fileServerUrl,
        fileServerResource,
        pathUrl = '',
        logPath = '',
        fileServerUri = null,
        uriPath = '';

    if (dataLen > 0) {
        for (i; i < dataLen; i = i + 1) {
            labName = localData[i].lab_name;
            createdOn = new Date(localData[i].created_on.$date);
            resultDescription = localData[i].boot_result_description;
            fileServerUrl = localData[i].file_server_url;
            fileServerResource = localData[i].file_server_resource;
            arch = localData[i].arch;
            bootLog = localData[i].boot_log;
            bootLogHtml = localData[i].boot_log_html;

            if (fileServerUrl !== null && fileServerUrl !== undefined) {
                fileServer = fileServerUrl;
            }

            if (fileServerResource !== null &&
                    fileServerResource !== undefined) {
                pathUrl = fileServerResource;
            } else {
                pathUrl = jobName + '/' + kernelName + '/' + arch + '-' +
                    defconfigFull + '/';
            }

            fileServerUri = new URI(fileServer);
            uriPath = fileServerUri.path() + '/' + pathUrl;

            switch (localData[i].status) {
                case 'PASS':
                    statusDisplay = '<span rel="tooltip" ' +
                        'data-toggle="tooltip"' +
                        'title="Boot completed"><span class="label ' +
                        'label-success"><i class="fa fa-check">' +
                        '</i></span></span>';
                    break;
                case 'FAIL':
                    statusDisplay = '<span rel="tooltip" ' +
                        'data-toggle="tooltip"' +
                        'title="Boot failed">' +
                        '<span class="label label-danger">' +
                        '<i class="fa fa-exclamation-triangle"></i>' +
                        '</span></span>';
                    break;
                case 'OFFLINE':
                    statusDisplay = '<span rel="tooltip" ' +
                        'data-toggle="tooltip"' +
                        'title="Board offline" ' +
                        '<span class="label label-info">' +
                        '<i class="fa fa-power-off"></i></span></span>';
                    break;
                default:
                    statusDisplay = '<span rel="tooltip" ' +
                        'data-toggle="tooltip"' +
                        'title="Unknown status"><span class="label ' +
                        'label-warning"><i class="fa fa-question"></i>' +
                        '</span></span>';
                    break;
            }

            col0 = '<td>' + labName + '</td>';
            if (resultDescription !== null) {
                if (resultDescription.length > 64) {
                    col1 = '<td>' +
                        '<span rel="tooltip" data-toggle="tooltip"' +
                        'title="' + resultDescription + '">' +
                        resultDescription.slice(0, 65) + '&hellip;' +
                        '</span></td>';
                } else {
                    col1 = '<td>' + resultDescription + '</td>';
                }
            } else {
                col1 = '<td>&nbsp;</td>';
            }

            col2 = '<td class="pull-center">';
            if (bootLog !== null || bootLogHtml !== null) {
                if (bootLog !== null) {
                    if (bootLog.search(labName) == -1) {
                        logPath = uriPath + '/' + labName + '/' + bootLog;
                    } else {
                        logPath = uriPath + '/' + bootLog;
                    }
                    col2 += '<span rel="tooltip" data-toggle="tooltip" ' +
                        'title="View raw text boot log"><a href="' +
                        fileServerUri.path(logPath).normalizePath().href() +
                        '">txt' +
                        '&nbsp;<i class="fa fa-external-link">' +
                        '</i></a></span>';
                }

                if (bootLogHtml !== null) {
                    if (bootLog !== null) {
                        col2 += '&nbsp;&mdash;&nbsp;';
                    }
                    if (bootLogHtml.search(labName) == -1) {
                        logPath = uriPath + '/' + labName + '/' + bootLogHtml;
                    } else {
                        logPath = uriPath + '/' + bootLogHtml;
                    }
                    col2 += '<span rel="tooltip" data-toggle="tooltip" ' +
                        'title="View HTML boot log"><a href="' +
                        fileServerUri.path(logPath).normalizePath().href() +
                        '">html&nbsp;<i class="fa fa-external-link">' +
                        '</i></a></span>';
                }
            } else {
                col2 += '&nbsp;';
            }
            col2 += '</td>';

            col3 = '<td class="pull-center">' +
                createdOn.getCustomISODate() + '</td>';
            col4 = '<td class="pull-center">' + statusDisplay + '</td>';

            rowHref = '/boot/' + boardName + '/job/' + jobName +
                '/kernel/' + kernelName + '/defconfig/' + defconfigFull +
                '/lab/' + labName + '/?_id=' + localData[i]._id.$oid;

            col5 = '<td><span rel="tooltip" data-toggle="tooltip"' +
                'title="Details for board&nbsp;' + boardName + 'with&nbsp;' +
                jobName + '&dash;' + kernelName + '&dash;' + defconfigFull +
                '&nbsp;&dash;&nbsp;(' + labName + ')' +
                '"><a href="' + rowHref + '">' +
                '<i class="fa fa-search"></i></a></span></td>';

            allRows += '<tr data-url="' + rowHref + '">' +
                col0 + col1 + col2 + col3 + col4 + col5 + '</tr>';
        }

        $('#boot-reports-loading-div').remove();
        $('#boot-reports-table-body').empty().append(allRows);
        $('#multiple-labs-table')
            .removeClass('hidden')
            .fadeIn('slow', 'linear');
    } else {
        $('#other-reports-table-div')
            .empty()
            .addClass('pull-center')
            .append('<strong>No data available.</strong>');
    }
}

function ajaxCallFailed() {
    'use strict';

    var staticContent = '<span rel="tooltip" data-toggle="tooltip" ' +
        'title="Not available"><i class="fa fa-ban"></i>' +
        '</span>';
    JSBase.replaceContentByClass('.loading-content', staticContent);

    $('#other-reports-table-div')
        .empty()
        .addClass('pull-center')
        .append('<strong>Error loading data.</strong>');
}

$(document).ready(function() {
    'use strict';

    $('#li-boot').addClass('active');

    $('#dd-tree').empty().append(
        '<span rel="tooltip" data-toggle="tooltip" ' +
        'title="Boot details for&nbsp;' + jobName + '">' +
        '<a href="/boot/all/job/' + jobName + '">' + jobName +
        '</a></span>' +
        '&nbsp;&mdash;&nbsp;' +
        '<span rel="tooltip" data-toggle="tooltip" ' +
        'title="Details for job&nbsp;' + jobName +
        '"><a href="/job/' + jobName +
        '"><i class="fa fa-sitemap"></i></a></span>'
    );
    $('#dd-git-describe').empty().append(
        '<span rel="tooltip" data-toggle="tooltip" ' +
        'title="Boot report details for&nbsp;' + jobName +
        '&nbsp;&dash;&nbsp;' +
        kernelName + '"><a href="/boot/all/job/' + jobName +
        '/kernel/' + kernelName + '">' + kernelName +
        '</a></span>' +
        '&nbsp;&mdash;&nbsp;' +
        '<span rel="tooltip" data-toggle="tooltip" ' +
        'title="Details for build&nbsp;' + jobName +
        '&nbsp;&dash;&nbsp;' +
        kernelName + '"><a href="/build/' + jobName +
        '/kernel/' + kernelName +
        '"><i class="fa fa-cube"></i></a></span>'

    );
    $('#dd-defconfig').empty().append(
        defconfigFull + '&nbsp;&mdash;&nbsp;' +
        '<span rel="tooltip" data-toggle="tooltip"' +
        'title="Details for build&nbsp;' + jobName +
        '&nbsp;&dash;&nbsp;' + kernelName +
        '&nbsp;&dash;&nbsp;' + defconfigFull +
        '"><a href="/build/' + jobName + '/kernel/' +
        kernelName + '/defconfig/' + defconfigFull +
        '"><i class="fa fa-cube"></i></a></span>'
    );

    var errorReason = 'Boot reports data call failed',
        ajaxData,
        ajaxDeferredCall = null;

    ajaxData = {
        'board': boardName,
        'job': jobName,
        'kernel': kernelName,
        'defconfig_full': defconfigFull,
        'field': [
            '_id', 'status', 'created_on', 'lab_name', 'file_server_url',
            'file_server_resource', 'boot_log', 'boot_log_html',
            'boot_result_description', 'arch'
        ]
    };
    ajaxDeferredCall = JSBase.createDeferredCall(
        '/_ajax/boot',
        'GET',
        ajaxData,
        null,
        ajaxCallFailed,
        errorReason
    );

    $.when(ajaxDeferredCall).done(populateBootPage);
});