import Backbone from 'backbone';
+<<<<<<< d3fd3a3175fac49d0c2874dc33e06497d4505de1
export default Backbone.Model.extend({
idAttribute: 'key',
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;
},
-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;
+ }
+
+ });
});
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' });
<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">
{{/if}}
<div class="pull-right">
- #{{key}} {{status}}
+ {{status}}
</div>
<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>
{
- "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
}
]
}
{
- "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
}
]
}
{
- "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
}
]
}
{
- "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"
}
]
}
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);
});
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);
});