Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit a2f4a20

Browse files
authored
Fix report export urls (#127)
1 parent 2efba36 commit a2f4a20

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

app/analysis/controller.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,31 @@ const AnalysisController = Controller.extend(ReportFilterControllerMixin, {
2121

2222
exportLinks: config.APP.REPORTEXPORTS,
2323

24-
getTarget(url) {
24+
getTarget(url, params) {
2525
let queryString = toQueryString(
26-
cleanParams(
27-
this.getProperties(
26+
cleanParams({
27+
...params,
28+
...this.getProperties(
2829
...this.get('queryParams').filter(
2930
key => !['page', 'page_size'].includes(key)
3031
),
3132
'jwt'
3233
)
33-
)
34+
})
3435
)
3536

36-
return `${url}&${queryString}`
37+
return `${url}?${queryString}`
3738
},
3839

3940
actions: {
40-
download(url) {
41+
download(url, params) {
4142
/* istanbul ignore else */
4243
if (testing) {
4344
return
4445
}
4546

4647
/* istanbul ignore next */
47-
window.location.href = this.getTarget(url)
48+
window.location.href = this.getTarget(url, params)
4849
}
4950
}
5051
})

app/analysis/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
<p>
6868
{{#each exportLinks as |link index|}}
69-
<button {{action 'download' link.url}}
69+
<button {{action 'download' link.url link.params}}
7070
type="button"
7171
disabled={{gt model.length 4000}}
7272
class="btn btn-default"

config/environment.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,29 @@ module.exports = function(environment) {
2020
REPORTEXPORTS: [
2121
{
2222
label: 'CSV',
23-
url: '/api/v1/reports/export?file_type=csv'
23+
url: '/api/v1/reports/export',
24+
params: {
25+
file_type: 'csv'
26+
}
2427
},
2528
{
2629
label: 'ODS',
27-
url: '/api/v1/reports/export?file_type=ods'
30+
url: '/api/v1/reports/export',
31+
params: {
32+
file_type: 'ods'
33+
}
2834
},
2935
{
3036
label: 'XLSX',
31-
url: '/api/v1/reports/export?file_type=xlsx'
37+
url: '/api/v1/reports/export',
38+
params: {
39+
file_type: 'xlsx'
40+
}
3241
},
3342
{
3443
label: 'Work report',
35-
url: '/api/v1/work-reports'
44+
url: '/api/v1/work-reports',
45+
params: {}
3646
}
3747
]
3848
},

tests/unit/analysis/controller-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ describe('Unit | Controller | analysis', function() {
1616
controller.set('page_size', 100)
1717
controller.set('customer', 1)
1818

19-
let target = controller.getTarget('test')
19+
let target = controller.getTarget('test', { foo: 'bar' })
2020

21+
expect(target).to.contain('foo=bar')
2122
expect(target).to.contain('jwt=foobar')
2223
expect(target).to.contain('user=1')
2324
expect(target).to.contain('customer=1')

0 commit comments

Comments
 (0)