]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6834 use new API
authorStas Vilchik <vilchiks@gmail.com>
Fri, 18 Sep 2015 09:21:34 +0000 (11:21 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 18 Sep 2015 21:49:44 +0000 (23:49 +0200)
server/sonar-web/src/main/js/apps/computation/report.js
server/sonar-web/src/main/js/apps/computation/reports.js
server/sonar-web/src/main/js/apps/computation/router.js
server/sonar-web/src/main/js/apps/computation/templates/computation-list-item.hbs
server/sonar-web/src/main/js/apps/computation/templates/computation-search.hbs
server/sonar-web/src/test/json/computation-spec/history-big-1.json
server/sonar-web/src/test/json/computation-spec/history-big-2.json
server/sonar-web/src/test/json/computation-spec/history.json
server/sonar-web/src/test/json/computation-spec/queue.json
server/sonar-web/test/medium/computation.spec.js

index 9c1ca5258d071ec911a6f17a8b81bce869bfbb47..6296f0bcaa0ea6da8bd3f866feb569ad29adc6f0 100644 (file)
@@ -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;
   },
index b355aedf50ccaf79fe81a23184464aa4df433459..e284d27ee68e5117d5da7336359c11747a1d7815 100644 (file)
@@ -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;
+    }
+
+  });
 });
 
 
index 8ac31c7be904b90df55bce89fb4bfa52bdc0ee38..6ecfb2386170e32f3a3887a487cd53d085ec4959 100644 (file)
@@ -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' });
index 5a6ad8c3a243da5018768b4d2109fbd1471a5353..85465a1b5cb39cd5f1c82e5e2f35fb452366a63a 100644 (file)
@@ -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>
index 63bd417f1547c2ac99528c330603e97545b756bd..a41e880792d547e5e807d6c7c0cf3ab6704b19ab 100644 (file)
@@ -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>
index c7f53f33ea0f6a2ee1f8235fa5751bd9bdf63f31..d0cb80fa1a81be6b6dd2d00bb532501c2b9ccaaf 100644 (file)
@@ -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
     }
   ]
 }
index f0cd0fc3f8b057e923261bd041f7b670d742c2f9..08c000455b86b884bc3c3affb4ccedcef2d3432f 100644 (file)
@@ -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
     }
   ]
 }
index 1bb4198fcedd8f9f8b9ad6ee9f1634bdc62547eb..285e15a73018a5e330ba45e6e6b7eaae8e0091e1 100644 (file)
@@ -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
     }
   ]
 }
index 18dcfbcfbbac5810093091e9c18434760d7c84c9..a4dfb5b7646c1d39c01aa8bed573d39642f2d179 100644 (file)
@@ -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"
     }
   ]
 }
index 4884204fbf16787eebabd110f0c0bc5d012aa6a9..52b23a5391ddfca32c318a4265c3975a43cd39c3 100644 (file)
@@ -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);
     });