diff options
Diffstat (limited to 'server')
10 files changed, 147 insertions, 107 deletions
diff --git a/server/sonar-web/src/main/js/apps/computation/report.js b/server/sonar-web/src/main/js/apps/computation/report.js index 9c1ca5258d0..6296f0bcaa0 100644 --- a/server/sonar-web/src/main/js/apps/computation/report.js +++ b/server/sonar-web/src/main/js/apps/computation/report.js @@ -1,5 +1,6 @@ import Backbone from 'backbone'; +<<<<<<< d3fd3a3175fac49d0c2874dc33e06497d4505de1 export default Backbone.Model.extend({ idAttribute: 'key', @@ -14,6 +15,27 @@ export default Backbone.Model.extend({ minutes: Math.floor(diff / (1000 * 60)) % 60, hours: Math.floor(diff / (1000 * 60 * 60)) % 24 }; +======= + return Backbone.Model.extend({ + getDuration: function () { + var duration = null; + if (this.has('startedAt')) { + var startedAtMoment = moment(this.get('startedAt')), + finishedAtMoment = moment(this.get('finishedAt') || new Date()), + diff = finishedAtMoment.diff(startedAtMoment); + duration = { + seconds: Math.floor(diff / 1000) % 60, + minutes: Math.floor(diff / (1000 * 60)) % 60, + hours: Math.floor(diff / (1000 * 60 * 60)) % 24 + }; + } + return duration; + }, + + isDanger: function () { + var dangerStatuses = ['CANCELLED', 'FAILED']; + return dangerStatuses.indexOf(this.get('status')) !== -1; +>>>>>>> SONAR-6834 use new API } return duration; }, diff --git a/server/sonar-web/src/main/js/apps/computation/reports.js b/server/sonar-web/src/main/js/apps/computation/reports.js index b355aedf50c..e284d27ee68 100644 --- a/server/sonar-web/src/main/js/apps/computation/reports.js +++ b/server/sonar-web/src/main/js/apps/computation/reports.js @@ -1,34 +1,35 @@ -import _ from 'underscore'; -import Backbone from 'backbone'; -import Report from './report'; - -export default Backbone.Collection.extend({ - model: Report, - url: '', - - parse: function (r) { - this.total = r.total || r.reports.length; - this.p = r.p || 1; - this.ps = r.ps; - return r.reports; - }, - - fetch: function (options) { - var opts = _.defaults(options || {}, { q: this.q }, { q: 'history', data: { ps: 250 } }); - opts.url = baseUrl + '/api/computation/' + opts.q; - this.q = opts.q; - return Backbone.Collection.prototype.fetch.call(this, opts); - }, - - fetchMore: function () { - var p = this.p + 1; - return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps } }); - }, - - hasMore: function () { - return this.total > this.p * this.ps; - } - +define([ + './report' +], function (Report) { + + return Backbone.Collection.extend({ + model: Report, + url: '', + + parse: function (r) { + this.total = (r.paging && r.paging.total) || r.tasks.length; + this.p = (r.paging && r.paging.pageIndex) || 1; + this.ps = r.paging && r.paging.pageSize; + return r.tasks; + }, + + fetch: function (options) { + var opts = _.defaults(options || {}, { q: this.q }, { q: 'activity', data: { ps: 250 } }); + opts.url = baseUrl + '/api/ce/' + opts.q; + this.q = opts.q; + return Backbone.Collection.prototype.fetch.call(this, opts); + }, + + fetchMore: function () { + var p = this.p + 1; + return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps } }); + }, + + hasMore: function () { + return this.total > this.p * this.ps; + } + + }); }); diff --git a/server/sonar-web/src/main/js/apps/computation/router.js b/server/sonar-web/src/main/js/apps/computation/router.js index 8ac31c7be90..6ecfb238617 100644 --- a/server/sonar-web/src/main/js/apps/computation/router.js +++ b/server/sonar-web/src/main/js/apps/computation/router.js @@ -17,9 +17,20 @@ export default Backbone.Router.extend({ this.current(); }, +<<<<<<< d3fd3a3175fac49d0c2874dc33e06497d4505de1 current: function () { this.options.reports.fetch({ q: 'queue' }); }, +======= + current: function () { + this.options.reports.fetch({ q: 'queue' }); + }, + + past: function () { + this.options.reports.fetch({ q: 'activity' }); + } + }); +>>>>>>> SONAR-6834 use new API past: function () { this.options.reports.fetch({ q: 'history' }); diff --git a/server/sonar-web/src/main/js/apps/computation/templates/computation-list-item.hbs b/server/sonar-web/src/main/js/apps/computation/templates/computation-list-item.hbs index 5a6ad8c3a24..85465a1b5cb 100644 --- a/server/sonar-web/src/main/js/apps/computation/templates/computation-list-item.hbs +++ b/server/sonar-web/src/main/js/apps/computation/templates/computation-list-item.hbs @@ -1,6 +1,6 @@ <div class="display-inline-block text-top width-30"> <i class="icon-qualifier-trk"></i> - <a href="{{dashboardUrl projectKey}}">{{projectName}}</a> + <a href="{{dashboardUrl componentKey}}">{{componentName}}</a> </div> <div class="display-inline-block text-top width-30"> @@ -28,5 +28,5 @@ {{/if}} <div class="pull-right"> - #{{key}} {{status}} + {{status}} </div> diff --git a/server/sonar-web/src/main/js/apps/computation/templates/computation-search.hbs b/server/sonar-web/src/main/js/apps/computation/templates/computation-search.hbs index 63bd417f154..a41e880792d 100644 --- a/server/sonar-web/src/main/js/apps/computation/templates/computation-search.hbs +++ b/server/sonar-web/src/main/js/apps/computation/templates/computation-search.hbs @@ -1,6 +1,6 @@ <div class="spacer-top"> <ul class="tabs"> <li><a class="js-queue {{#eq tab 'queue'}}selected{{/eq}}">{{t 'analysis_reports.current_activity'}}</a></li> - <li><a class="js-history {{#eq tab 'history'}}selected{{/eq}}">{{t 'analysis_reports.past_reports'}}</a></li> + <li><a class="js-history {{#eq tab 'activity'}}selected{{/eq}}">{{t 'analysis_reports.past_reports'}}</a></li> </ul> </div> diff --git a/server/sonar-web/src/test/json/computation-spec/history-big-1.json b/server/sonar-web/src/test/json/computation-spec/history-big-1.json index c7f53f33ea0..d0cb80fa1a8 100644 --- a/server/sonar-web/src/test/json/computation-spec/history-big-1.json +++ b/server/sonar-web/src/test/json/computation-spec/history-big-1.json @@ -1,27 +1,33 @@ { - "total": 3, - "p": 1, - "ps": 2, - "reports": [ + "paging": { + "pageIndex": 1, + "pageSize": 2, + "total": 3 + }, + "tasks": [ { - "submittedAt": "2015-05-07T14:25:20+0200", + "id": "AU_fwURCrnmp3Ks0AiQq", + "type": "REPORT", + "componentId": "AU_VQoJCzEjRSwxhFuns", + "componentKey": "com.sonarsource.rule-api:rule-api", + "componentName": "SonarSource :: Rule API", "status": "SUCCESS", - "finishedAt": "2015-05-07T14:25:26+0200", - "startedAt": "2015-05-07T14:25:20+0200", - "projectUuid": "id-sonarqube", - "projectName": "SonarQube", - "projectKey": "key-sonarqube", - "key": "2" + "submittedAt": "2015-09-18T11:20:43+0200", + "startedAt": "2015-09-18T11:20:37+0200", + "finishedAt": "2015-09-18T11:20:43+0200", + "executionTimeMs": 6030 }, { - "submittedAt": "2015-05-06T09:22:14+0200", + "id": "AU_fvdwNrnmp3Ks0AiLg", + "type": "REPORT", + "componentId": "AU_VQoJCzEjRSwxhFuns", + "componentKey": "com.sonarsource.rule-api:rule-api", + "componentName": "SonarSource :: Rule API", "status": "SUCCESS", - "finishedAt": "2015-05-06T09:22:18+0200", - "startedAt": "2015-05-06T09:22:14+0200", - "projectUuid": "id-sonarqube", - "projectName": "SonarQube", - "projectKey": "key-sonarqube", - "key": "1" + "submittedAt": "2015-09-18T11:16:56+0200", + "startedAt": "2015-09-18T11:16:47+0200", + "finishedAt": "2015-09-18T11:16:56+0200", + "executionTimeMs": 8671 } ] } diff --git a/server/sonar-web/src/test/json/computation-spec/history-big-2.json b/server/sonar-web/src/test/json/computation-spec/history-big-2.json index f0cd0fc3f8b..08c000455b8 100644 --- a/server/sonar-web/src/test/json/computation-spec/history-big-2.json +++ b/server/sonar-web/src/test/json/computation-spec/history-big-2.json @@ -1,17 +1,21 @@ { - "total": 3, - "p": 2, - "ps": 2, - "reports": [ + "paging": { + "pageIndex": 2, + "pageSize": 2, + "total": 3 + }, + "tasks": [ { - "submittedAt": "2015-05-13T15:44:15+0200", - "status": "FAILED", - "finishedAt": "2015-05-13T15:44:18+0200", - "startedAt": "2015-05-13T15:44:15+0200", - "projectUuid": "id-sonarqube", - "projectName": "SonarQube", - "projectKey": "key-sonarqube", - "key": "3" + "id": "AU_fvdwNrnmp5Ks0AiLg", + "type": "REPORT", + "componentId": "AU_VQoJCzEjRSwxhFuns", + "componentKey": "com.sonarsource.rule-api:rule-api", + "componentName": "SonarSource :: Rule API", + "status": "SUCCESS", + "submittedAt": "2015-09-18T11:16:56+0200", + "startedAt": "2015-09-18T11:16:47+0200", + "finishedAt": "2015-09-18T11:16:56+0200", + "executionTimeMs": 8671 } ] } diff --git a/server/sonar-web/src/test/json/computation-spec/history.json b/server/sonar-web/src/test/json/computation-spec/history.json index 1bb4198fced..285e15a7301 100644 --- a/server/sonar-web/src/test/json/computation-spec/history.json +++ b/server/sonar-web/src/test/json/computation-spec/history.json @@ -1,37 +1,33 @@ { - "total": 3, - "p": 1, - "ps": 10, - "reports": [ + "paging": { + "pageIndex": 1, + "pageSize": 2, + "total": 2 + }, + "tasks": [ { - "submittedAt": "2015-05-13T15:44:15+0200", - "status": "FAILED", - "finishedAt": "2015-05-13T15:44:18+0200", - "startedAt": "2015-05-13T15:44:15+0200", - "projectUuid": "id-sonarqube", - "projectName": "SonarQube", - "projectKey": "key-sonarqube", - "key": "3" - }, - { - "submittedAt": "2015-05-07T14:25:20+0200", + "id": "AU_fwURCrnmp3Ks0AiQq", + "type": "REPORT", + "componentId": "AU_VQoJCzEjRSwxhFuns", + "componentKey": "com.sonarsource.rule-api:rule-api", + "componentName": "SonarSource :: Rule API", "status": "SUCCESS", - "finishedAt": "2015-05-07T14:25:26+0200", - "startedAt": "2015-05-07T14:25:20+0200", - "projectUuid": "id-sonarqube", - "projectName": "SonarQube", - "projectKey": "key-sonarqube", - "key": "2" + "submittedAt": "2015-09-18T11:20:43+0200", + "startedAt": "2015-09-18T11:20:37+0200", + "finishedAt": "2015-09-18T11:20:43+0200", + "executionTimeMs": 6030 }, { - "submittedAt": "2015-05-06T09:22:14+0200", + "id": "AU_fvdwNrnmp3Ks0AiLg", + "type": "REPORT", + "componentId": "AU_VQoJCzEjRSwxhFuns", + "componentKey": "com.sonarsource.rule-api:rule-api", + "componentName": "SonarSource :: Rule API", "status": "SUCCESS", - "finishedAt": "2015-05-06T09:22:18+0200", - "startedAt": "2015-05-06T09:22:14+0200", - "projectUuid": "id-sonarqube", - "projectName": "SonarQube", - "projectKey": "key-sonarqube", - "key": "1" + "submittedAt": "2015-09-18T11:16:56+0200", + "startedAt": "2015-09-18T11:16:47+0200", + "finishedAt": "2015-09-18T11:16:56+0200", + "executionTimeMs": 8671 } ] } diff --git a/server/sonar-web/src/test/json/computation-spec/queue.json b/server/sonar-web/src/test/json/computation-spec/queue.json index 18dcfbcfbba..a4dfb5b7646 100644 --- a/server/sonar-web/src/test/json/computation-spec/queue.json +++ b/server/sonar-web/src/test/json/computation-spec/queue.json @@ -1,12 +1,13 @@ { - "reports": [ + "tasks": [ { - "submittedAt": "2015-05-13T15:44:15+0200", - "status": "WORKING", - "projectUuid": "id-sonarqube", - "projectName": "SonarQube", - "projectKey": "key-sonarqube", - "key": "4" + "id": "AU_fvdwNrnmp5Ks0AiLg", + "type": "REPORT", + "componentId": "AU_VQoJCzEjRSwxhFuns", + "componentKey": "com.sonarsource.rule-api:rule-api", + "componentName": "SonarSource :: Rule API", + "status": "PENDING", + "submittedAt": "2015-09-18T11:16:56+0200" } ] } diff --git a/server/sonar-web/test/medium/computation.spec.js b/server/sonar-web/test/medium/computation.spec.js index 4884204fbf1..52b23a5391d 100644 --- a/server/sonar-web/test/medium/computation.spec.js +++ b/server/sonar-web/test/medium/computation.spec.js @@ -6,18 +6,17 @@ define(function (require) { bdd.it('should show list', function () { return this.remote .open() - .mockFromFile('/api/computation/queue', 'computation-spec/queue.json') - .mockFromFile('/api/computation/history', 'computation-spec/history.json') + .mockFromFile('/api/ce/queue', 'computation-spec/queue.json') + .mockFromFile('/api/ce/activity', 'computation-spec/history.json') .startApp('computation', { urlRoot: '/test/medium/base.html' }) .checkElementCount('#computation-list li[data-id]', 1) - .checkElementInclude('#computation-list', 'SonarQube') + .checkElementInclude('#computation-list', 'SonarSource :: Rule API') .checkElementInclude('#computation-list-footer', '1') .checkElementExist('.js-queue.selected') .clickElement('.js-history') - .checkElementCount('#computation-list li[data-id]', 3) + .checkElementCount('#computation-list li[data-id]', 2) .checkElementInclude('#computation-list', 'Duration') .checkElementExist('.js-history.selected') - .checkElementExist('.panel-danger[data-id="3"]') .clickElement('.js-queue') .checkElementCount('#computation-list li[data-id]', 1); }); @@ -25,12 +24,12 @@ define(function (require) { bdd.it('should show more', function () { return this.remote .open('#past') - .mockFromFile('/api/computation/queue', 'computation-spec/queue.json') - .mockFromFile('/api/computation/history', 'computation-spec/history-big-1.json') + .mockFromFile('/api/ce/queue', 'computation-spec/queue.json') + .mockFromFile('/api/ce/activity', 'computation-spec/history-big-1.json') .startApp('computation', { urlRoot: '/test/medium/base.html' }) .checkElementCount('#computation-list li[data-id]', 2) .clearMocks() - .mockFromFile('/api/computation/history', 'computation-spec/history-big-2.json', { data: { p: 2 } }) + .mockFromFile('/api/ce/activity', 'computation-spec/history-big-2.json', { data: { p: 2 } }) .clickElement('#computation-fetch-more') .checkElementCount('#computation-list li[data-id]', 3); }); |