Mercurial > gemma
comparison client/src/components/importoverview/ImportOverview.vue @ 4793:d6d73ca5496a
client: import_overview: improve implementation of exporting logs
* adjust using of end point
* delete the generation of csv in front end
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Fri, 25 Oct 2019 15:09:10 +0200 |
parents | 1fd771b08ced |
children | b23414a3b333 |
comparison
equal
deleted
inserted
replaced
4792:9412bc2545e8 | 4793:d6d73ca5496a |
---|---|
254 timeout: 0, | 254 timeout: 0, |
255 buttons: [{ text: "Ok", action: null, bold: true }] | 255 buttons: [{ text: "Ok", action: null, bold: true }] |
256 } | 256 } |
257 }); | 257 }); |
258 HTTP.get( | 258 HTTP.get( |
259 `/imports?from=${encodeURIComponent( | 259 `/imports/export?from=${encodeURIComponent( |
260 format(startOfDay(new Date(from)), "YYYY-MM-DDTHH:mm:ssZ") | 260 format(startOfDay(new Date(from)), "YYYY-MM-DDTHH:mm:ssZ") |
261 )}&to=${encodeURIComponent( | 261 )}&to=${encodeURIComponent( |
262 format(endOfDay(new Date(to)), "YYYY-MM-DDTHH:mm:ssZ") | 262 format(endOfDay(new Date(to)), "YYYY-MM-DDTHH:mm:ssZ") |
263 )}&query=`, | 263 )}&query=`, |
264 { | 264 { |
265 headers: { "X-Gemma-Auth": localStorage.getItem("token") } | 265 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
266 } | 266 } |
267 ) | 267 ) |
268 .then(response => { | 268 .then(response => { |
269 const { imports } = response.data; | 269 const imports = response.data; |
270 app.$snotify.clear(); | 270 app.$snotify.clear(); |
271 if (!imports) return; | 271 if (!imports) return; |
272 const csvLink = | 272 const csvLink = |
273 "data:text/csv;charset=utf-8," + | 273 "data:text/csv;charset=utf-8," + encodeURIComponent(imports); |
274 encodeURIComponent( | |
275 "id,kind,enqueued,user,country,signer,state,changed,warnings\n" + | |
276 imports | |
277 .map(el => { | |
278 return `${el.id},${el.kind},${el.enqueued},\ | |
279 ${el.user || " "},${this.userCountries[el.user] || " "},${el.signer || " "},\ | |
280 ${el.state || " "},${el.changed || " "},${el.warnings || " "}`; | |
281 }) | |
282 .join("\n") | |
283 ); | |
284 let element = document.createElement("a"); | 274 let element = document.createElement("a"); |
285 element.setAttribute("download", "log.csv"); | 275 element.setAttribute("download", "log.csv"); |
286 element.setAttribute("href", csvLink); | 276 element.setAttribute("href", csvLink); |
287 document.querySelector("body").appendChild(element); | 277 document.querySelector("body").appendChild(element); |
288 element.click(); | 278 element.click(); |