Skip to content

Commit b969b7e

Browse files
authored
Merge pull request #18 from angular-dashboard-framework/feature/17_easyredmine_burdown_widget
Feature/17 easyredmine burdown widget
2 parents c7683f8 + 9df941c commit b969b7e

10 files changed

+465
-432
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- EasyRedmine widget: `Burn-down/up`
810

911
## [v0.2.0] - 2020-12-16
1012
### Added

dist/adf-widget-redmine.js

+259-243
Large diffs are not rendered by default.

dist/adf-widget-redmine.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ gulp.task('easyRedmineTemplate', function(){
5454
});
5555

5656
gulp.task('sample', ['redmineTemplate', 'easyRedmineTemplate'], function(){
57-
var files = gulp.src(['src/main/**/*.js', 'src/main/**/*.css', 'src/main/**/*.less', '.tmp/dist/*.js'])
58-
.pipe($.if('*.js', $.angularFilesort()));
57+
var files = gulp.src(['src/main/**/*.js', 'src/main/**/*.css', 'src/main/**/*.less', '.tmp/dist/*.js']);
5958

6059
gulp.src('sample/index.html')
6160
.pipe(wiredep({

karma.conf.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ module.exports = function(config) {
1818
'components/angular/angular.js',
1919
'components/angular-mocks/angular-mocks.js',
2020
'src/main/redmine.js',
21-
'src/main/service.js',
21+
'src/main/services/apiService.js',
22+
'src/main/services/redmineService.js',
23+
'src/main/services/easyRedmineService.js',
2224
'src/main/**/*.js',
2325
'src/test/**/*Spec.js'
2426
],

src/main/redmine.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@ angular.module('adf.widget.easyredmine', ['adf.provider', 'chart.js', 'ui.bootst
142142
// Create widgets
143143
createMyIssuesWidget(dashboardProvider, 'easyredmine-my-issues', 'My Issues', category, true);
144144
createCustomQueriesWidget(dashboardProvider, 'easyredmine-custom-queries', 'Custom Queries', category, true);
145-
//createChartWidget(dashboardProvider, 'easyredmine-chart', 'Chart', category, true);
145+
createChartWidget(dashboardProvider, 'easyredmine-chart', 'Chart', category, true);
146146
});

src/main/service.js

-184
This file was deleted.

src/main/services/apiService.js

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
'use strict';
2+
3+
function ApiService($http, apiEndpoint, apiEndpointRedirect, $q) {
4+
this.http = $http;
5+
this.apiEndpoint = apiEndpoint;
6+
this.apiEndpointRedirect = apiEndpointRedirect;
7+
this.q = $q;
8+
}
9+
10+
ApiService.prototype.request = function (param) {
11+
return this.http.get(this.apiEndpoint + param).then(function (response) {
12+
return response.data;
13+
});
14+
};
15+
16+
ApiService.prototype.getProjects = function(){
17+
return this.request('projects.json').then(function (data) {
18+
return data.projects;
19+
});
20+
};
21+
22+
ApiService.prototype.getVersions = function (project) {
23+
return this.request('projects/' + project + '/versions.json').then(function (data) {
24+
return data.versions;
25+
});
26+
};
27+
28+
ApiService.prototype.getIssues = function (config) {
29+
var params = this.generateGeneralIssuesParameters(config);
30+
var limit = config.limit ? config.limit : Number.MAX_SAFE_INTEGER;
31+
return this.getIssuesWithParamsAndLimit(params, limit);
32+
};
33+
34+
ApiService.prototype.getIssuesForChart = function(config) {
35+
var allIssues = [];
36+
var limit = config.limit ? config.limit : Number.MAX_SAFE_INTEGER;
37+
var params1 = this.generateParametersForIssuesOpenOnEnd(config);
38+
var params2 = this.generateParametersForIssuesClosedBetweenStartAndEnd(config);
39+
var params3 = this.generateParametersForIssuesOpen(config);
40+
return this.q.all([this.getIssuesWithParamsAndLimit(params1, limit), this.getIssuesWithParamsAndLimit(params2, limit),
41+
this.getIssuesWithParamsAndLimit(params3, limit)]).then(function (responses) {
42+
angular.forEach(responses, function (issues) {
43+
angular.forEach(issues, function (issue) {
44+
allIssues.push(issue);
45+
});
46+
});
47+
return allIssues;
48+
});
49+
};
50+
51+
ApiService.prototype.getIssuesWithParamsAndLimit = function (params, limit) {
52+
var allIssues = [];
53+
return this.collectPageIssues(params, 0).then(function (issues) {
54+
angular.forEach(issues.issues, function (issue) {
55+
allIssues.push(issue);
56+
});
57+
var requests = [];
58+
for (var i = 100; i < issues.total_count && i < limit; i = i + 100) {
59+
requests.push(this.collectPageIssues(params, i));
60+
}
61+
if (params.length > 0) {
62+
return this.q.all(requests).then(function (responses) {
63+
angular.forEach(responses, function (response) {
64+
angular.forEach(response.issues, function (issue) {
65+
allIssues.push(issue);
66+
});
67+
});
68+
return allIssues;
69+
});
70+
} else {
71+
return allIssues;
72+
}
73+
}.bind(this));
74+
};
75+
76+
77+
ApiService.prototype.collectPageIssues = function (params, offset) {
78+
return this.request('issues.json' + params + '&offset=' + offset).then(function (issues) {
79+
return issues;
80+
});
81+
};
82+
83+
ApiService.prototype.generateParametersForIssuesOpenOnEnd = function (data) {
84+
var params = this.generateGeneralIssuesParameters(data);
85+
params += '&status_id=*';
86+
var toDate = new Date(data.timespan.toDateTime);
87+
params += '&created_on=<=' + this.dateToYMD(toDate);
88+
params += '&closed_on=>=' + this.dateToYMD(toDate);
89+
return params;
90+
};
91+
92+
ApiService.prototype.generateParametersForIssuesOpen = function (data) {
93+
var params = this.generateGeneralIssuesParameters(data);
94+
params += '&status_id=open';
95+
var toDate = new Date(data.timespan.toDateTime);
96+
params += '&created_on=<=' + this.dateToYMD(toDate);
97+
return params;
98+
};
99+
100+
ApiService.prototype.generateParametersForIssuesClosedBetweenStartAndEnd = function (data) {
101+
var params = this.generateGeneralIssuesParameters(data);
102+
params += '&status_id=*';
103+
var fromDate = new Date(data.timespan.fromDateTime);
104+
var toDate = new Date(data.timespan.toDateTime);
105+
params += '&closed_on=><' + this.dateToYMD(fromDate) + '|' + this.dateToYMD(toDate);
106+
return params;
107+
};
108+
109+
ApiService.prototype.generateGeneralIssuesParameters = function (data) {
110+
var params = '?limit=100&sort=created_on';
111+
if (data.project && data.project !== 'All') {
112+
params += '&project_id=' + angular.fromJson(data.project).id;
113+
}
114+
if (data.filterWithAssigned && data.assigned_to_id) {
115+
params += '&assigned_to_id=' + data.assigned_to_id;
116+
}
117+
if (data.showClosed) {
118+
params += '&status_id=*';
119+
}
120+
if (data.filterWithVersion && data.version) {
121+
params += '&fixed_version_id=' + angular.fromJson(data.version).id;
122+
}
123+
if (data.filterWithTracker && data.tracker) {
124+
params += '&tracker_id=' + angular.fromJson(data.tracker).id;
125+
}
126+
return params;
127+
};
128+
129+
ApiService.prototype.dateToYMD = function (date) {
130+
var d = date.getDate();
131+
var m = date.getMonth() + 1;
132+
var y = date.getFullYear();
133+
return '' + y + '-' + (m <= 9 ? '0' + m : m) + '-' + (d <= 9 ? '0' + d : d);
134+
};
135+
136+
ApiService.prototype.getCustomQueries = function () {
137+
return this.request('queries.json?limit=100');
138+
};
139+
140+
ApiService.prototype.getIssuesByQueryId = function (queryId, projectId) {
141+
return this.request('issues.json?query_id=' + queryId + '&project_id=' + projectId).then(function (data) {
142+
return data.issues;
143+
});
144+
};
145+
146+
ApiService.prototype.getRedmineEndpoint = function () {
147+
return this.apiEndpoint;
148+
};
149+
150+
ApiService.prototype.getRedmineRedirectEndpoint = function () {
151+
return this.apiEndpointRedirect;
152+
};
153+
154+
ApiService.prototype.getTrackers = function () {
155+
return this.request('trackers.json').then(function (data) {
156+
return data.trackers;
157+
});
158+
};
159+
160+
ApiService.prototype.getMyIssues = function () {
161+
return this.request('issues.json?assigned_to_id=me').then(function (data) {
162+
return data;
163+
});
164+
};

0 commit comments

Comments
 (0)