This repository has been archived by the owner on Oct 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #553 from blockchain/export-history
Export history fixes
- Loading branch information
Showing
10 changed files
with
95 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.left-nav(ui-view="left", ng-class="{toggled: menu.isCollapsed}") | ||
.top-view(ui-view="top") | ||
.main-container(ui-view="right", scroll-to-top, in-view-container, ng-click="hideMenu()") | ||
downloader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
angular | ||
.module('walletApp') | ||
.directive('downloadButton', downloadButton); | ||
|
||
function downloadButton ($window, $timeout) { | ||
const directive = { | ||
restrict: 'E', | ||
replace: true, | ||
scope: { | ||
filename: '@', | ||
content: '=' | ||
}, | ||
template: '<a href="{{dataRef}}" download="{{filename}}" target="_blank">{{::"DOWNLOAD"|translate}}</a>', | ||
link: link | ||
}; | ||
return directive; | ||
|
||
function link (scope, attr, elem) { | ||
scope.$watch('content', (content) => { | ||
let blob = new $window.Blob([content], {type: 'text/csv'}); | ||
scope.dataRef = $window.URL.createObjectURL(blob); | ||
}); | ||
scope.$on('download', (event) => { | ||
if (!scope.dataRef) return; | ||
$timeout(() => elem.$$element[0].click()); | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
describe "downloadButton", -> | ||
scope = undefined | ||
element = undefined | ||
isoScope = undefined | ||
$timeout = undefined | ||
|
||
beforeEach module("walletApp") | ||
|
||
beforeEach inject(($compile, $rootScope, $window, _$timeout_) -> | ||
$timeout = _$timeout_ | ||
|
||
spyOn($window, 'Blob').and.callFake((data) -> toString: -> "data[#{data.join()}]") | ||
spyOn($window.URL, 'createObjectURL').and.callFake((obj) -> "blob://#{obj}") | ||
|
||
scope = $rootScope.$new() | ||
scope.content = 'asdf' | ||
scope.$digest() | ||
|
||
element = $compile("<download-button content='content' filename='test.txt'></download-button>")(scope) | ||
isoScope = element.isolateScope() | ||
isoScope.$digest() | ||
) | ||
|
||
it "should create a data ref for content", -> | ||
expect(isoScope.dataRef).toEqual('blob://data[asdf]') | ||
|
||
it "should create a data ref when content is updated", -> | ||
isoScope.content = 'abc' | ||
isoScope.$digest() | ||
expect(isoScope.dataRef).toEqual('blob://data[abc]') | ||
|
||
it "should use the correct filename", -> | ||
expect(isoScope.filename).toEqual('test.txt') | ||
|
||
it "should click the anchor tag to trigger download", -> | ||
spyOn(element[0], 'click') | ||
scope.$broadcast("download") | ||
$timeout.flush() | ||
expect(element[0].click).toHaveBeenCalled() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters