diff options
author | Milo Casagrande <milo.casagrande@linaro.org> | 2014-12-04 16:19:08 +0100 |
---|---|---|
committer | Milo Casagrande <milo.casagrande@linaro.org> | 2014-12-04 16:19:08 +0100 |
commit | 8242008c712ea515ba5506e21ac0c13aca79aeca (patch) | |
tree | f32a8313d2e9aadf50a460e22b62b1483733fea4 | |
parent | c80fb50d4c373e6aab9f18d1dec1fa7a4f810dfa (diff) |
Refactor using new base lib.
Change-Id: Ie39e717723a2d886d694319aaa4b1ce4c5c39b0b
-rw-r--r-- | app/dashboard/static/js/linaro-builds-all-1.0.9.js | 73 |
1 files changed, 24 insertions, 49 deletions
diff --git a/app/dashboard/static/js/linaro-builds-all-1.0.9.js b/app/dashboard/static/js/linaro-builds-all-1.0.9.js index b3ebfbd..dab32aa 100644 --- a/app/dashboard/static/js/linaro-builds-all-1.0.9.js +++ b/app/dashboard/static/js/linaro-builds-all-1.0.9.js @@ -99,7 +99,7 @@ function createBuildsTable(data) { 'type': 'date', 'className': 'pull-center', 'render': function(data) { - var created = new Date(data['$date']); + var created = new Date(data.$date); return created.getCustomISODate(); } }, @@ -167,7 +167,7 @@ function createBuildsTable(data) { '/kernel/' + tableData.kernel + '/defconfig/' + tableData.defconfig_full; if (tableData._id !== null) { - location += '?_id=' + tableData._id['$oid']; + location += '?_id=' + tableData._id.$oid; } window.location = location; @@ -192,55 +192,30 @@ $(document).ready(function() { 'use strict'; $('#li-build').addClass('active'); - - $('body').tooltip({ - 'selector': '[rel=tooltip]', - 'placement': 'auto' - }); - $('#table-div').hide(); - var ajaxCall = null, + var ajaxDeferredCall = null, + ajaxData = null, errorReason = ''; - errorReason = 'Defconfig data call failed.'; - ajaxCall = $.ajax({ - 'url': '/_ajax/defconf', - 'traditional': true, - 'cache': true, - 'dataType': 'json', - 'data': { - 'sort': 'created_on', - 'sort_order': -1, - 'date_range': $('#date-range').val(), - 'field': [ - '_id', 'job', 'kernel', 'status', - 'arch', 'created_on', 'git_branch', 'defconfig_full' - ] - }, - 'timeout': 6000, - 'beforeSend': function(jqXHR) { - setXhrHeader(jqXHR); - }, - 'error': function() { - failedAjaxCall(); - }, - 'statusCode': { - 403: function() { - setErrorAlert('build-403-error', 403, errorReason); - }, - 404: function() { - setErrorAlert('build-404-error', 404, errorReason); - }, - 408: function() { - errorReason = 'Defconfig data call failed: timeout.'; - setErrorAlert('build-408-error', 408, errorReason); - }, - 500: function() { - setErrorAlert('build-500-error', 500, errorReason); - } - } - }); - - $.when(ajaxCall).then(createBuildsTable, failedAjaxCall); + errorReason = 'Defconfig data call failed'; + ajaxData = { + 'sort': 'created_on', + 'sort_order': -1, + 'date_range': $('#date-range').val(), + 'field': [ + '_id', 'job', 'kernel', 'status', + 'arch', 'created_on', 'git_branch', 'defconfig_full' + ] + }; + ajaxDeferredCall = JSBase.createDeferredCall( + '/_ajax/defconf', + 'GET', + ajaxData, + null, + failedAjaxCall, + errorReason + ); + + $.when(ajaxDeferredCall).done(createBuildsTable); }); |