-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
231 lines (202 loc) · 7.17 KB
/
index.html
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dynamic Grid</title>
<link rel="stylesheet" href="DynamicGrid.css">
<script src="DynamicGrid/DynamicGrid.js"></script>
<script src="DynamicGrid/DynamicGridUI.js"></script>
<script src="DynamicGrid/TypePlugin.js"></script>
<script src="DynamicGrid/InherentTypePlugin.js"></script>
<script src="DynamicGrid/SJQLEngine.js"></script>
<script src="DynamicGrid/QueryParser.js"></script>
<script src="DynamicGrid/APIConnector.js"></script>
<script src="DynamicGrid/EventEmitter.js"></script>
<script src="DynamicGrid/KeyboardShortcuts.js"></script>
<script src="DynamicGrid/DynamicGridUtils.js"></script>
<script src="DynamicGrid/ContextMenu.js"></script>
<!-- <script src="/dist/DynamicGrid.js"></script>-->
<style>
/* General body styling */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f9f9f9;
color: #333;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
overflow: hidden;
}
/* Top and bottom sections styling */
.top, .bottom {
display: flex;
justify-content: center;
align-items: center;
width: 50vw;
transition: top 0.5s ease-in-out, opacity 0.5s ease-in-out, width 0.5s ease-in-out;
z-index: 100;
position: absolute;
}
.top {
top: 50%;
transform: translateY(-150%);
}
.top.active {
top: 0;
width: 90vw;
transform: translateY(0);
}
.bottom {
margin-top: 20px;
}
.bottom.active {
opacity: 0;
}
.bottom-er {
position: absolute;
bottom: 5vh;
left: 50%;
transform: translateX(-50%);
font-size: 16px;
color: #777;
z-index: 100;
transition: opacity 0.5s ease-in-out;
}
.bottom-er.active {
opacity: 0;
}
/* Styling for input fields */
input[type="file"], input[type="text"] {
padding: 10px;
margin: 10px 10px 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
width: 100%;
transition: border-color 0.3s, box-shadow 0.3s;
}
input[type="file"]:hover, input[type="text"]:hover {
border-color: #888;
}
input[type="file"]:focus, input[type="text"]:focus {
border-color: #007BFF;
outline: none;
box-shadow: 0 0 5px #007BFF;
}
/* Styling for the button */
button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007BFF;
color: white;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s, transform 0.2s;
width: 20%;
}
button:hover {
background-color: #0056b3;
}
button:active {
transform: scale(0.98);
}
</style>
</head>
<body>
<div class="top">
<input type="text" id="search" placeholder="Search... (e.g. isactive == true and id > 50)">
<button onclick="grid.render(document.getElementById('search').value)">Search</button>
</div>
<div class="bottom">
<input type="file" id="file" accept=".csv, .json" onchange="handleFile(this.files[0])">
or
<button onclick="fetchPresetData()" style="margin-left: 10px;">use preset</button>
</div>
<span class="bottom-er">
To use this grid, either use the preset data or upload a CSV or JSON file. You can use the grid by writing a query in the bar above using, or using right-click on the header and using the context menu. You can also consult the readme on github for more information.
<a href="https://grid.kronk.tech/testData/generated_100.json" target="_blank" class="bottom-er" style="bottom: 10vh;">Click here to view the preset data</a>
<a href="https://github.com/MattterSteege/DynamicGrid" target="_blank" class="bottom-er" style="bottom: 15vh;">Click here to view the readme/github repo</a>
</span>
<div id="gridContainer" style="width: 90vw; height: 90vh; position: fixed; top: calc(50% + 2vh); left: 50%; transform: translate(-50%, -50%); border-radius: 10px;"></div>
<script>
let grid = new DynamicGrid({
headers: {
id: {type: 'number', isUnique: true, isEditable: false},
guid: {type: 'string', isUnique: true, isEditable: false},
isActive: 'boolean',
balance: 'number',
age: 'number',
name: 'string',
gender: 'string',
email: 'string'
},
ui: {
containerId: '#gridContainer',
rowHeight: 30,
visibleRows: 20,
overscan: 5,
minColumnWidth: 5,
autoFitCellWidth: 'both',
allowFieldEditing: true,
},
engine: {
UseDataEnumeration: false,
UseDataIndexing: true,
StrictCase: false,
},
plugins: {
//'string': new customStringTypePlugin(),
},
APIConnector: {
connector: APIConnector,
options: {
timeoutDelay: -1,
},
endpoints: {
get: 'https://example.com/get',
put: 'https://example.com/put',
post: 'https://example.com/post',
delete:'https://example.com/delete',
}
},
});
function handleFile(file) {
const reader = new FileReader();
reader.onload = function (e) {
document.querySelector('.top').classList.add('active');
document.querySelector('.bottom').classList.add('active');
document.querySelector('.bottom-er').classList.add('active');
setTimeout(() => {
document.querySelector('.bottom').remove();
document.querySelector('.bottom-er').remove();
}, 3000);
//import data into the grid
grid.importData(e.target.result, { type: file.type.split("/")[1], delimiter: "," });
grid.render();
}
reader.readAsText(file);
}
function fetchPresetData() {
document.querySelector('.top').classList.add('active');
document.querySelector('.bottom').classList.add('active');
document.querySelector('.bottom-er').classList.add('active');
setTimeout(() => {
document.querySelector('.bottom').remove();
document.querySelector('.bottom-er').remove();
}, 3000);
fetch('https://grid.kronk.tech/testData/generated_100.json')
.then(response => response.text())
.then(data => {
grid.importData(data, { type: 'json' });
grid.render();
});
}
//fetchPresetData();
</script>
</body>
</html>