11<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+ >
310 </task-list >
411
512 <v-navigation-drawer permament location =" right" width =" 400" ref =" drawer" >
5764 required
5865 ref =" exportTemplate"
5966 ></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+
6078 <v-btn-group rounded =" 1" density =" compact" >
6179 <v-btn color =" primary" density =" compact" v-if =" selectedExport.id" @click =" updateExport" >Save changes</v-btn >
6280 <v-btn color =" error" density =" compact" v-if =" selectedExport.id" @click =" confirmDeleteExport" >Delete</v-btn >
8199import { OBSERVABLE_TYPES } from " @/definitions/observableDefinitions.js" ;
82100import axios from " axios" ;
83101import TaskList from " @/components/TaskList.vue" ;
102+ import moment from " moment" ;
84103 </script >
85104
86105<script lang="ts">
@@ -97,16 +116,17 @@ export default {
97116 exports: [],
98117 exportTemplates: [],
99118 selectedExport: {},
100- timerListTemplates: null
119+ timerListTemplates: null ,
120+ frequencyUnit: " hours"
101121 };
102122 },
103123 mounted() {
104124 this .listTemplates ();
105125 },
106126 created() {
107- this .timerListTemplates = setInterval (this .listTemplates , 2000 );
127+ this .timerListTemplates = setInterval (this .listTemplates , 5000 );
108128 },
109- beforeDestroy () {
129+ unmounted () {
110130 clearInterval (this .timerListTemplates );
111131 },
112132 methods: {
@@ -119,6 +139,11 @@ export default {
119139 })
120140 .finally (() => {});
121141 },
142+ selectExport(task ) {
143+ this .selectedExport = task ;
144+ this .selectedExport .human_frequency = moment .duration (task .frequency ).asHours ();
145+ this .frequencyUnit = " hours" ;
146+ },
122147 updateExport() {
123148 let exportTask = {
124149 id: this .selectedExport .id ,
@@ -128,7 +153,8 @@ export default {
128153 ignore_tags: this .selectedExport .ignore_tags ,
129154 exclude_tags: this .selectedExport .exclude_tags ,
130155 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 )
132158 };
133159
134160 axios
@@ -152,7 +178,8 @@ export default {
152178 template_name: this .selectedExport .template_name ,
153179 exclude_tags: this .selectedExport .exclude_tags ,
154180 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 )
156183 };
157184 axios
158185 .post (` /api/v2/tasks/export/new ` , { export: exportTask })
@@ -192,9 +219,9 @@ export default {
192219 .then (response => {
193220 var fileURL = window .URL .createObjectURL (new Blob ([response .data ]));
194221 var fileLink = document .createElement (" a" );
195- var fileName = response . headers [ " content-disposition " ]. split ( " filename= " )[ 1 ] ;
222+ let fileName = ` ${ singleExport . name }_${ singleExport . last_run }.txt ` ;
196223 fileLink .href = fileURL ;
197- fileLink .setAttribute ( " download" , fileName ) ;
224+ fileLink .download = fileName ;
198225 document .body .appendChild (fileLink );
199226 fileLink .click ();
200227 })
0 commit comments