Mercurial > gemma
comparison client/src/components/importoverview/ImportOverview.vue @ 2799:e19fac818aab
import_overview: specifying single imports via URL should open the overview with all logentries of the according hour and open the details for the specified import
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 25 Mar 2019 16:16:58 +0100 |
parents | 718ec88fbeed |
children | fb7cc59f5e12 |
comparison
equal
deleted
inserted
replaced
2798:c9032a57996e | 2799:e19fac818aab |
---|---|
193 interval() { | 193 interval() { |
194 return [this.startDate, this.endDate]; | 194 return [this.startDate, this.endDate]; |
195 } | 195 } |
196 }, | 196 }, |
197 methods: { | 197 methods: { |
198 showSingleRessource(id) { | |
199 id = id * 1; | |
200 this.loadDetails(id) | |
201 .then(response => { | |
202 this.$store.commit("imports/setCurrentDetails", response.data); | |
203 const { enqueued } = response.data; | |
204 this.$store.commit("imports/setStartDate", startOfHour(enqueued)); | |
205 this.$store.commit("imports/setEndDate", endOfHour(enqueued)); | |
206 this.$store.commit("imports/showDetailsFor", id); | |
207 this.loadLogs(); | |
208 }) | |
209 .catch(error => { | |
210 this.loading = false; | |
211 this.$store.commit("imports/setCurrentDetails", {}); | |
212 const { status, data } = error.response; | |
213 displayError({ | |
214 title: this.$gettext("Backend Error"), | |
215 message: `${status}: ${data.message || data}` | |
216 }); | |
217 }); | |
218 }, | |
219 loadDetails(id) { | |
220 return new Promise((resolve, reject) => { | |
221 HTTP.get("/imports/" + id, { | |
222 headers: { "X-Gemma-Auth": localStorage.getItem("token") } | |
223 }) | |
224 .then(response => { | |
225 resolve(response); | |
226 }) | |
227 .catch(error => { | |
228 reject(error); | |
229 }); | |
230 }); | |
231 }, | |
198 determineInterval(pointInTime) { | 232 determineInterval(pointInTime) { |
199 let start, end; | 233 let start, end; |
200 switch (this.selectedInterval) { | 234 switch (this.selectedInterval) { |
201 case this.$options.LAST_HOUR: | 235 case this.$options.LAST_HOUR: |
202 start = startOfHour(pointInTime); | 236 start = startOfHour(pointInTime); |
249 to: format(this.endDate, "YYYY-MM-DDTHH:mm:ss.SSS"), | 283 to: format(this.endDate, "YYYY-MM-DDTHH:mm:ss.SSS"), |
250 query: this.searchQuery | 284 query: this.searchQuery |
251 }) | 285 }) |
252 .then(() => { | 286 .then(() => { |
253 if (this.show != -1) { | 287 if (this.show != -1) { |
254 HTTP.get("/imports/" + this.show, { | 288 this.loadDetails(this.show) |
255 headers: { "X-Gemma-Auth": localStorage.getItem("token") } | |
256 }) | |
257 .then(response => { | 289 .then(response => { |
258 this.$store.commit("imports/setCurrentDetails", response.data); | 290 this.$store.commit("imports/setCurrentDetails", response.data); |
259 this.loading = false; | 291 this.loading = false; |
260 }) | 292 }) |
261 .catch(error => { | 293 .catch(error => { |
346 } | 378 } |
347 }); | 379 }); |
348 } | 380 } |
349 }, | 381 }, |
350 watch: { | 382 watch: { |
383 $route() { | |
384 const { id } = this.$route.params; | |
385 if (id) this.showSingleRessource(id); | |
386 }, | |
351 selectedInterval() { | 387 selectedInterval() { |
352 const now = new Date(); | 388 const now = new Date(); |
353 switch (this.selectedInterval) { | 389 switch (this.selectedInterval) { |
354 case this.$options.LAST_HOUR: | 390 case this.$options.LAST_HOUR: |
355 this.$store.commit("imports/setStartDate", startOfHour(now)); | 391 this.$store.commit("imports/setStartDate", startOfHour(now)); |
394 filters() { | 430 filters() { |
395 this.loadLogs(); | 431 this.loadLogs(); |
396 } | 432 } |
397 }, | 433 }, |
398 mounted() { | 434 mounted() { |
399 this.$store.commit("application/searchQuery", ""); | 435 const { id } = this.$route.params; |
400 this.loadLogs(); | 436 if (!id) { |
437 this.$store.commit("application/searchQuery", ""); | |
438 this.loadLogs(); | |
439 } else { | |
440 this.showSingleRessource(id); | |
441 } | |
401 } | 442 } |
402 }; | 443 }; |
403 </script> | 444 </script> |
404 | 445 |
405 <style lang="scss" scoped> | 446 <style lang="scss" scoped> |
447 .overview { | |
448 max-height: 90vh; | |
449 } | |
406 .date { | 450 .date { |
407 font-stretch: condensed; | 451 font-stretch: condensed; |
408 } | 452 } |
409 .interval-select { | 453 .interval-select { |
410 padding: 0px; | 454 padding: 0px; |