-
Notifications
You must be signed in to change notification settings - Fork 31
/
index-0.js
101 lines (90 loc) · 2.25 KB
/
index-0.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import React from 'react';
import ReactDOM from 'react-dom';
import TerminusClient from "@terminusdb/terminusdb-client";
import './index.css';
class Content extends React.Component {
constructor(props) {
super(props);
this.state = {
status: "Connected",
};
}
render() {
if (false) {
return (<h2> {this.state.status} </h2>)
} else {
return (<h2> Not connected </h2>)
}
}
}
class Page extends React.Component {
constructor(props) {
super(props);
this.state = {
endpoint: "",
user: "",
team: "",
apiKey: "",
client: null,
schema: null,
entries: [],
};
this.handleLoginChange = this.handleLoginChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
async makeConnection(){
try{
// make connection here
}catch(err){
console.error(err.message)
}
}
handleLoginChange(event) {
const target = event.target;
const value = target.value;
const name = target.name;
this.setState({
[name]: value
});
}
handleSubmit(event) {
if (this.state.endpoint && this.state.user && this.state.team && this.state.apiKey) {
this.makeConnection();
} else {
alert('Missing one or more input.' )
}
event.preventDefault();
}
render() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<label>
End Point:
<input name="endpoint" type="text" value={this.state.endpoint} onChange={this.handleLoginChange} />
</label>
<label>
User:
<input name="user" type="text" value={this.state.user} onChange={this.handleLoginChange} />
</label>
<label>
Team:
<input name="team" type="text" value={this.state.team} onChange={this.handleLoginChange} />
</label>
<label>
Api Key:
<input name="apiKey" type="text" value={this.state.apiKey} onChange={this.handleLoginChange} />
</label>
<input type="submit" value="Submit"/>
</form>
<hr />
< Content />
</div>
);
}
}
// ========================================
ReactDOM.render(
<Page />,
document.getElementById('root')
);