Skip to content

Commit

Permalink
Upgraded to v1.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Feb 5, 2018
1 parent 628a470 commit fb53c28
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion chrome-ext-files/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Altair GraphQL Client",
"short_name": "Altair",
"description": "The only graphQL client you'll ever need.",
"version": "1.6.2",
"version": "1.6.3",
"icons": {
"16": "assets/img/altair_logo_128.png",
"48": "assets/img/altair_logo_128.png",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "altair",
"version": "1.6.2",
"version": "1.6.3",
"license": "MIT",
"author": "Samuel Imolorhe <[email protected]> (https://sirmuel.design/)",
"description": "The best graphQL client you will ever need",
Expand Down Expand Up @@ -67,6 +67,7 @@
"codemirror-graphql": "^0.6.12",
"cookie-parser": "^1.4.3",
"core-js": "^2.5.3",
"downloadjs": "^1.4.7",
"electron-compile": "^6.4.1",
"electron-is-dev": "^0.3.0",
"electron-log": "^2.2.11",
Expand Down
21 changes: 13 additions & 8 deletions src/app/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as toSnakeCase from 'to-snake-case';
import * as downloadJs from 'downloadjs';
const fileDialog = require('file-dialog');

/**
Expand All @@ -9,6 +10,7 @@ const fileDialog = require('file-dialog');
*/
export const downloadData = (data, fileName = 'data', opts = undefined) => {
let _opts = {
mimeType: 'text/plain',
dataUriAttr: 'text/plain;charset=utf-8',
fileType: 'txt'
};
Expand All @@ -18,14 +20,16 @@ export const downloadData = (data, fileName = 'data', opts = undefined) => {
}

const dataStr = `data:${_opts.dataUriAttr},${data}`;
const downloadLink = document.createElement('a');
const linkText = document.createTextNode('Download');
downloadLink.appendChild(linkText);
downloadLink.style.display = 'none';
downloadLink.setAttribute('href', dataStr);
downloadLink.setAttribute('download', `${toSnakeCase(fileName)}.${_opts.fileType}`);
document.body.appendChild(downloadLink);
downloadLink.click();
downloadJs(dataStr, `${toSnakeCase(fileName)}.${_opts.fileType}`, _opts.mimeType);
// const downloadLink = document.createElement('a');
// const linkText = document.createTextNode('Download');
// downloadLink.appendChild(linkText);
// downloadLink.style.display = 'none';
// downloadLink.setAttribute('target', '_blank');
// downloadLink.setAttribute('href', dataStr);
// downloadLink.setAttribute('download', `${toSnakeCase(fileName)}.${_opts.fileType}`);
// document.body.appendChild(downloadLink);
// downloadLink.click();
};

/**
Expand All @@ -35,6 +39,7 @@ export const downloadData = (data, fileName = 'data', opts = undefined) => {
*/
export const downloadJson = (obj, fileName = 'response', opts = undefined) => {
let _opts = {
mimeType: 'text/json',
dataUriAttr: 'text/json;charset=utf-8',
fileType: 'json'
};
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2985,6 +2985,10 @@ dotenv@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d"

downloadjs@^1.4.7:
version "1.4.7"
resolved "https://registry.yarnpkg.com/downloadjs/-/downloadjs-1.4.7.tgz#f69f96f940e0d0553dac291139865a3cd0101e3c"

dtrace-provider@~0.8:
version "0.8.5"
resolved "https://registry.yarnpkg.com/dtrace-provider/-/dtrace-provider-0.8.5.tgz#98ebba221afac46e1c39fd36858d8f9367524b92"
Expand Down

0 comments on commit fb53c28

Please sign in to comment.