Skip to content

Commit

Permalink
Better filename for exported files (based on date)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvdo committed Mar 16, 2021
1 parent 03b3602 commit 3e49a91
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/yeti/SubPanelCourse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,25 @@ export default {
const features = this.features;
features[0].set('name', this.featuresTitle);
const filename = 'export' + Date.now() + extension;
const filename = this.setFilename(extension);
const content = format.writeFeatures(features, {
featureProjection: 'EPSG:3857',
});
utils.download(content, filename, mimetype + ';charset=utf-8');
},
setFilename(ext) {
let dateObj = new Date();
let month = ('0' + (dateObj.getMonth() + 1)).slice(-2);
let day = ('0' + dateObj.getDate()).slice(-2);
let year = dateObj.getFullYear();
let hours = ('0' + dateObj.getHours()).slice(-2);
let minutes = ('0' + dateObj.getMinutes()).slice(-2);
let seconds = ('0' + dateObj.getSeconds()).slice(-2);
return year + '-' + month + '-' + day + '_' + hours + '-' + minutes + '-' + seconds + ext;
},
},
};
</script>
Expand Down

0 comments on commit 3e49a91

Please sign in to comment.