Skip to content

Commit

Permalink
feat(ScreenshotDialog): Download screenshot directly
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Jun 22, 2018
1 parent e2a9560 commit f8a2e2f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/components/core/Screenshots/ScreenshotDialog/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function generateImage() {

ctx.drawImage(img, 0, 0);

this.previewImageURL = this.canvas.toDataURL();
const imageType = `image/${this.fileType.substr(1)}`;
this.imageUrl = this.canvas.toDataURL();
});

img.src = this.screenshot.imgSrc;
Expand All @@ -61,9 +62,8 @@ function backgroundToFillStyle(bg) {
// ----------------------------------------------------------------------------

function save() {
const imageType = `image/${this.fileType.substr(1)}`;
this.$emit('save', this.screenshot.viewName, {
image: this.canvas.toDataURL(imageType),
image: this.imageUrl,
filename: this.filename + this.fileType,
});
}
Expand All @@ -77,7 +77,7 @@ export default {
screenshot: null,
filename: '',
visible: false,
previewImageURL: '',
imageUrl: '',
transparentBackground: false,
fileType: '',
fileTypes: FILE_TYPES,
Expand Down
12 changes: 10 additions & 2 deletions src/components/core/Screenshots/ScreenshotDialog/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<v-card flat tile>
<v-card-media
:class="$style.imagePreview"
:src="previewImageURL"
:src="imageUrl"
contain
height="250px"
/>
Expand Down Expand Up @@ -59,11 +59,19 @@
<span>Cancel</span>
</v-btn>
<v-btn
color="primary"
color="secondary"
@click.native="visible = false; save()"
>
<span>Save</span>
</v-btn>
<v-btn
color="primary"
:href="imageUrl"
:download="filename + fileType"
@click.native="visible = false"
>
<span>Download</span>
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>

0 comments on commit f8a2e2f

Please sign in to comment.