1
1
<template >
2
- <task-list selectable-tasks task-type =" export" ref =" exportList" @taskSelected =" task => (this.selectedExport = task)" >
2
+ <task-list
3
+ selectable-tasks
4
+ downloadable-tasks
5
+ task-type =" export"
6
+ ref =" exportList"
7
+ @taskSelected =" task => selectExport(task)"
8
+ @taskDownload =" task => downloadExport(task)"
9
+ >
3
10
</task-list >
4
11
5
12
<v-navigation-drawer permament location =" right" width =" 400" ref =" drawer" >
57
64
required
58
65
ref =" exportTemplate"
59
66
></v-autocomplete >
67
+ <div class =" d-flex" >
68
+ <v-text-field
69
+ class =" w-50"
70
+ density =" compact"
71
+ label =" Run every"
72
+ v-model =" selectedExport.human_frequency"
73
+ ></v-text-field >
74
+ <!-- select hours, days, minutes, etc -->
75
+ <v-select density =" compact" v-model =" frequencyUnit" :items =" ['hours', 'days', 'minutes', 'seconds']" ></v-select >
76
+ </div >
77
+
60
78
<v-btn-group rounded =" 1" density =" compact" >
61
79
<v-btn color =" primary" density =" compact" v-if =" selectedExport.id" @click =" updateExport" >Save changes</v-btn >
62
80
<v-btn color =" error" density =" compact" v-if =" selectedExport.id" @click =" confirmDeleteExport" >Delete</v-btn >
81
99
import { OBSERVABLE_TYPES } from " @/definitions/observableDefinitions.js" ;
82
100
import axios from " axios" ;
83
101
import TaskList from " @/components/TaskList.vue" ;
102
+ import moment from " moment" ;
84
103
</script >
85
104
86
105
<script lang="ts">
@@ -97,16 +116,17 @@ export default {
97
116
exports: [],
98
117
exportTemplates: [],
99
118
selectedExport: {},
100
- timerListTemplates: null
119
+ timerListTemplates: null ,
120
+ frequencyUnit: " hours"
101
121
};
102
122
},
103
123
mounted() {
104
124
this .listTemplates ();
105
125
},
106
126
created() {
107
- this .timerListTemplates = setInterval (this .listTemplates , 2000 );
127
+ this .timerListTemplates = setInterval (this .listTemplates , 5000 );
108
128
},
109
- beforeDestroy () {
129
+ unmounted () {
110
130
clearInterval (this .timerListTemplates );
111
131
},
112
132
methods: {
@@ -119,6 +139,11 @@ export default {
119
139
})
120
140
.finally (() => {});
121
141
},
142
+ selectExport(task ) {
143
+ this .selectedExport = task ;
144
+ this .selectedExport .human_frequency = moment .duration (task .frequency ).asHours ();
145
+ this .frequencyUnit = " hours" ;
146
+ },
122
147
updateExport() {
123
148
let exportTask = {
124
149
id: this .selectedExport .id ,
@@ -128,7 +153,8 @@ export default {
128
153
ignore_tags: this .selectedExport .ignore_tags ,
129
154
exclude_tags: this .selectedExport .exclude_tags ,
130
155
acts_on: this .selectedExport .acts_on ,
131
- template_name: this .selectedExport .template_name
156
+ template_name: this .selectedExport .template_name ,
157
+ frequency: moment .duration (this .selectedExport .human_frequency , this .frequencyUnit )
132
158
};
133
159
134
160
axios
@@ -152,7 +178,8 @@ export default {
152
178
template_name: this .selectedExport .template_name ,
153
179
exclude_tags: this .selectedExport .exclude_tags ,
154
180
ignore_tags: this .selectedExport .ignore_tags ,
155
- include_tags: this .selectedExport .include_tags
181
+ include_tags: this .selectedExport .include_tags ,
182
+ frequency: moment .duration (this .selectedExport .human_frequency , this .frequencyUnit )
156
183
};
157
184
axios
158
185
.post (` /api/v2/tasks/export/new ` , { export: exportTask })
@@ -192,9 +219,9 @@ export default {
192
219
.then (response => {
193
220
var fileURL = window .URL .createObjectURL (new Blob ([response .data ]));
194
221
var fileLink = document .createElement (" a" );
195
- var fileName = response . headers [ " content-disposition " ]. split ( " filename= " )[ 1 ] ;
222
+ let fileName = ` ${ singleExport . name }_${ singleExport . last_run }.txt ` ;
196
223
fileLink .href = fileURL ;
197
- fileLink .setAttribute ( " download" , fileName ) ;
224
+ fileLink .download = fileName ;
198
225
document .body .appendChild (fileLink );
199
226
fileLink .click ();
200
227
})
0 commit comments