diff --git a/web/satellite/src/components/accessGrants/steps/ResultStep.vue b/web/satellite/src/components/accessGrants/steps/ResultStep.vue index 79084e195..971ae1094 100644 --- a/web/satellite/src/components/accessGrants/steps/ResultStep.vue +++ b/web/satellite/src/components/accessGrants/steps/ResultStep.vue @@ -25,6 +25,13 @@ height="30px" :on-press="onCopyGrantClick" /> + .key + */ + public onDownloadGrantClick(): void { + // this code is based on this Stackoverflow response: https://stackoverflow.com/a/33542499 + // It works for downloading a file in IE 10+, Firefox, and Chrome without any additional libraries + const blob = new Blob([this.access], {type: 'text/plain'}); + const ts = new Date(); + const filename = 'access-grant-' + ts.toJSON() + '.key'; + + if (window.navigator.msSaveBlob) { + window.navigator.msSaveBlob(blob, filename); + } else { + const elem = window.document.createElement('a'); + elem.href = window.URL.createObjectURL(blob); + elem.download = filename; + document.body.appendChild(elem); + elem.click(); + document.body.removeChild(elem); + } + + this.$notify.success('Token was downloaded successfully'); + } + /** * Holds on back button click logic. * Redirects to previous step. @@ -275,7 +307,7 @@ export default class ResultStep extends Vue { } &__button { - min-width: 66px; + min-width: 85px; min-height: 30px; margin-left: 10px; }