Skip to content

Commit

Permalink
Working JSON view export
Browse files Browse the repository at this point in the history
  • Loading branch information
pkerpedjiev committed Jan 22, 2017
1 parent 5fa6ec2 commit 0586cfd
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions app/scripts/HiGlassComponent.jsx
Expand Up @@ -1048,9 +1048,21 @@ export class HiGlassComponent extends React.Component {
return;
}

getViewsAsString() {
console.log('views:', this.state.views);
let newJson = JSON.parse(JSON.stringify(this.props.viewConfig));
newJson.views = dictItems(this.state.views).map(k => {
k[1].uid = k[0];
return k[1];
});


let data = JSON.stringify(newJson);
return data;
}

handleExportViewAsJSON() {
let wholeJSON = dictValues(this.state.views);
let data = JSON.stringify(wholeJSON,null,2);
let data = this.getViewsAsString();

var a = document.createElement("a");
var file = new Blob([data], {type: 'text/json'});
Expand All @@ -1060,11 +1072,7 @@ export class HiGlassComponent extends React.Component {
}

handleExportViewsAsLink() {
let wholeJSON = dictValues(this.state.views);
let newJson = JSON.parse(JSON.stringify(this.props.viewConfig));
newJson.views = this.state.views;

let data = JSON.stringify(newJson);
let data = this.getViewsAsString();

this.setState({
exportLinkModalOpen: true,
Expand Down Expand Up @@ -1215,6 +1223,7 @@ export class HiGlassComponent extends React.Component {
processViewConfig(viewConfig) {
let views = viewConfig.views;
let viewsByUid = {};

views.forEach(v => {
this.fillInMinWidths(v.tracks);
viewsByUid[v.uid] = v;
Expand Down

0 comments on commit 0586cfd

Please sign in to comment.