Skip to content

Commit d2f7ba6

Browse files
Merge pull request #249 from dataspread/reactIntegrate
React integrate
2 parents 3772f5f + 86b3a51 commit d2f7ba6

7 files changed

Lines changed: 581 additions & 174 deletions

File tree

dataspread-ui/src/App.js

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ class App extends Component {
2626
this.onNavFormOpen = this.onNavFormOpen.bind(this)
2727
this.updateHierFormOption = this.updateHierFormOption.bind(this)
2828
this.submitHierForm = this.submitHierForm.bind(this)
29-
//this.onBinFormOpen = this.onBinFormOpen.bind(this)
29+
this.onBinFormOpen = this.onBinFormOpen.bind(this)
3030

3131
this.submitNavForm = this.submitNavForm.bind(this);
32-
this.openBinForm = this.openBinForm.bind(this);
3332
this.scrollTo = this.scrollTo.bind(this);
3433
this.updateBreadcrumb = this.updateBreadcrumb.bind(this);
3534
this.computePath = this.computePath.bind(this);
@@ -78,11 +77,83 @@ class App extends Component {
7877
this.nav.submitHierForm(data);
7978
}
8079

81-
// onBinFormOpen(){
82-
// if (this.grid !== null) {
83-
// this.grid.openBinForm();
84-
// }
85-
// }
80+
onBinFormOpen() {
81+
if (this.nav.state.navOpen) {
82+
let queryData = {};
83+
queryData.bookId = this.state.bookId;
84+
queryData.sheetName = this.grid.state.sheetName;
85+
queryData.path = this.nav.computePath();
86+
fetch(this.grid.urlPrefix + '/api/' + 'redefineBoundaries', {
87+
method: "POST",
88+
body: JSON.stringify(queryData),
89+
headers: {
90+
'Content-Type': 'text/plain'
91+
}
92+
})
93+
.then(response => response.json())
94+
.then(data => {
95+
console.log(data)
96+
let array = [];
97+
for (let i = 0; i < data.data.bucketArray.length; i++) {
98+
array.push(false);
99+
}
100+
this.binForm.setState({
101+
binFormOpen: true,
102+
isNumeric: data.data.isNumeric,
103+
bucketArray: data.data.bucketArray,
104+
checkedArray: array,
105+
checkedCount: 0,
106+
checkedIndex: 0,
107+
dropdownIndex: 0,
108+
});
109+
110+
})
111+
}
112+
}
113+
114+
submitBinForm = () => {
115+
console.log(this.binForm)
116+
this.binForm.setState({
117+
binFormOpen: false,
118+
});
119+
120+
let queryData = {};
121+
queryData.bookId = this.state.bookId;
122+
queryData.sheetName = this.grid.state.sheetName;
123+
queryData.path = this.nav.computePath();
124+
if (this.binForm.state.isNumeric) {
125+
queryData.bucketArray = this.binForm.state.bucketArray;
126+
} else {
127+
let temp = [];
128+
let dataBucket = this.binForm.state.bucketArray;
129+
for (let i = 0; i < dataBucket.length; i++) {
130+
temp.push([dataBucket[i][0], dataBucket[i][dataBucket[i].length - 1]]);
131+
}
132+
queryData.bucketArray = temp;
133+
}
134+
console.log(queryData)
135+
fetch(this.grid.urlPrefix + '/api/' + 'updateBoundaries', {
136+
method: "POST",
137+
body: JSON.stringify(queryData),
138+
headers: {
139+
'Content-Type': 'text/plain'
140+
}
141+
})
142+
.then(response => response.json())
143+
.then(data => {
144+
console.log(data)
145+
console.log(this)
146+
if (this.nav.state.currLevel > 0) {
147+
this.nav.jumpToHistorialView(this.nav.computePath());
148+
} else {
149+
this.submitNavForm(this.grid.state.exploreCol + 1);
150+
// if (hieraOpen) {
151+
// getAggregateValue();
152+
//
153+
// }
154+
}
155+
});
156+
}
86157

87158
submitNavForm(attribute) {
88159
if (attribute) {
@@ -97,10 +168,13 @@ class App extends Component {
97168
urlPrefix: this.grid.urlPrefix
98169
});
99170
this.updateHierFormOption(this.navForm.state.options);
171+
this.toolBar.setState({
172+
navOpen: true,
173+
})
100174
this.nav.startNav(data);
101175
this.navBar.setState({
102176
breadcrumb_ls: [],
103-
attribute: 0,
177+
// attribute: 0,
104178
open: true,
105179
navHistoryPathIndex: {},
106180
navHistoryTable: {},
@@ -110,7 +184,7 @@ class App extends Component {
110184
exploreCol: attribute - 1,
111185
})
112186
console.log(this.grid)
113-
this.nav.brushNlink(this.grid.rowStartIndex,this.grid.rowStopIndex);
187+
this.nav.brushNlink(this.grid.rowStartIndex, this.grid.rowStopIndex);
114188
})
115189
}
116190
}
@@ -120,20 +194,13 @@ class App extends Component {
120194
}
121195

122196
jumpToHistorialView(path) {
123-
// console.log(path)
124197
this.nav.jumpToHistorialView(path);
125198
}
126199

127200
computePath() {
128201
return this.nav.computePath();
129202
}
130203

131-
openBinForm() {
132-
if (this.state.navOpen) {
133-
this.setState({binFormOpen: true});
134-
}
135-
}
136-
137204
scrollTo(lowerRange) {
138205
this.grid.grid.scrollToCell({columnIndex: 0, rowIndex: lowerRange});
139206
}
@@ -172,16 +239,18 @@ class App extends Component {
172239
<div>
173240
<Toolbar username={this.state.username} onSelectFile={this.onSelectFile}
174241
onNavFormOpen={this.onNavFormOpen} ref={ref => this.toolBar = ref}
175-
submitHierForm={this.submitHierForm}/>
242+
submitHierForm={this.submitHierForm} onBinFormOpen={this.onBinFormOpen}/>
176243
<Stylebar/>
177244
<HistoryBar ref={ref => this.navBar = ref} computePath={this.computePath}
178245
jumpToHistorialView={this.jumpToHistorialView}/>
179-
<Navigation bookId={this.state.bookId} scrollTo={this.scrollTo} ref={ref => this.nav = ref}
180-
updateBreadcrumb={this.updateBreadcrumb} updateHighlight={this.updateHighlight}/>
181246
<ExplorationForm grid={this.grid} submitNavForm={this.submitNavForm}
182247
ref={ref => this.navForm = ref}/>
248+
<Navigation bookId={this.state.bookId} scrollTo={this.scrollTo} ref={ref => this.nav = ref}
249+
updateBreadcrumb={this.updateBreadcrumb} updateHighlight={this.updateHighlight}/>
250+
<BinCustomizationForm ref={ref => this.binForm = ref} submitBinForm={this.submitBinForm}/>
183251
<DSGrid bookId={this.state.bookId} ref={ref => this.grid = ref} brushNlink={this.brushNlink}
184252
updateHierFormOption={this.updateHierFormOption}/>
253+
185254
</div>
186255
)
187256
}

0 commit comments

Comments
 (0)