-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainWindow.html
251 lines (204 loc) · 7.1 KB
/
mainWindow.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!DOCTYPE html>
<html>
<head>
<title>Student Information System</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="">
<script src="node_modules/pouchdb/dist/pouchdb.min.js"></script>
</head>
<body>
<style>
header{
background-color: cadetblue;
text-align: center;
color: white;
padding-top: 12px;
margin: 0 auto;
min-height: 60px;
border: groove;
}
p{
text-align: center;
padding: 3px;
font-size: 19px;
}
form{
padding: 5px;
}
table, th, td
{
margin:10px 0;
border:solid 1px #333;
padding:2px 4px;
font:15px Verdana;
}
th {
font-weight:bold;
}
</style>
<header>
<h3>Student Information System</h3>
</header>
<section>
<p style="color: blue">Student information system for add, view, delete and update student. </p>
</section>
<div class="container">
<!-- <div class="row">
<div class="col-md-12">
<table style="width: 712px">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Course</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<tr>
<td>Himanshu</td>
<td>Pandey</td>
<td>himanshu@gmail.com</td>
<td>MCA</td>
<td>Shyam Park</td>
</tr>
</tbody>
</table>
</div> -->
<table class="table" id="studnet_table">
<tr>
<th>Address</th>
<th>City</th>
<th>Course</th>
<th>Email</th>
<th>First Name</th>
<th>Last Name</th>
<th>Password</th>
<th>Zip</th>
</tr>
</table>
</div>
<div id="showData"></div>
</div>
<script>
const electron = require('electron');
const {ipcRenderer} = electron;
//Add Student
ipcRenderer.on('item:addStudent', function(e,item){
console.log(item["FirstName"])
// Insert in database
var addStudentInfo = {
_id: new Date().toISOString(),
title: item,
completed: false
};
db.put(addStudentInfo, function callback(err, result) {
if (!err) {
console.log('Successfully posted a Student!');
}
});
// Show the current list of todos by reading them from the database
// db.allDocs({include_docs: true, descending: true}).then(function(doc) {
// redrawTodosUI(doc.rows);
// }).catch(function (err) {
// console.log(err);
// });
var student_info = '';
for (var i = 0; i < item.length; i++) {
console.log(item["Address"]);
student_info += '<tr>';
student_info += '<td>'+item["Address"]+'</td>';
student_info += '<td>'+item["City"]+'</td>';
student_info += '<td>'+item["Course"]+'</td>';
student_info += '<td>'+item["Email"]+'</td>';
student_info += '<td>'+item["FirstName"]+'</td>'
student_info += '<td>'+item["LastName"]+'</td>'
student_info += '<td>'+item["Password"]+'</td>'
student_info += '<td>'+item["Zip"]+'</td>'
student_info += '</tr';
}
console.log(student_info);
document.getElementById("studnet_table").appendChild(student_info);
var col = [];
//Push table header in col array
for (var i = 0; i < item.length; i++) {
for (var key in item[i]) {
if (col.indexOf(key) === -1) {
col.push(key);
}
}
}
var table = document.createElement("table");
var tr = table.insertRow(-1);
for (var i = 0; i < col.length; i++) {
var th = document.createElement("th");
th.innerHTML = col[i];
tr.appendChild(th);
}
// ADD JSON DATA TO THE TABLE AS ROWS.
for (var i = 0; i < item.length; i++) {
tr = table.insertRow(-1);
for (var j = 0; j < col.length; j++) {
var tabCell = tr.insertCell(-1);
tabCell.innerHTML = item[i][col[j]];
}
}
// FINALLY ADD THE NEWLY CREATED TABLE WITH JSON DATA TO A CONTAINER.
var divContainer = document.getElementById("showData");
divContainer.innerHTML = "";
divContainer.appendChild(table);
// var newDiv = document.createElement('div');
// var newDivText = document.createTextNode(item["FirstName"]);
// newDiv.appendChild(newDivText);
// var form = document.querySelector('form .container');
// var h2 = document.querySelector('form h1');
// form.insertBefore(newDiv, h2);
// var newDivText = document.createTextNode(item["LastName"]);
// newDiv.appendChild(newDivText);
// form.insertBefore(newDiv, h2);
// var newDiv = document.createElement('div');
// var newDivText = document.createTextNode(item["Email"]);
// newDiv.appendChild(newDivText);
// var form = document.querySelector('form .container');
// var h2 = document.querySelector('form h1');
// form.insertBefore(newDiv, h2);
// var newDiv = document.createElement('div');
// var newDivText = document.createTextNode(item["Password"]);
// newDiv.appendChild(newDivText);
// var form = document.querySelector('form .container');
// var h2 = document.querySelector('form h1');
// form.insertBefore(newDiv, h2);
// var newDiv = document.createElement('div');
// var newDivText = document.createTextNode(item["Address"]);
// newDiv.appendChild(newDivText);
// var form = document.querySelector('form .container');
// var h2 = document.querySelector('form h1');
// form.insertBefore(newDiv, h2);
// var newDiv = document.createElement('div');
// var newDivText = document.createTextNode(item["City"]);
// newDiv.appendChild(newDivText);
// var form = document.querySelector('form .container');
// var h2 = document.querySelector('form h1');
// form.insertBefore(newDiv, h2);
// var newDiv = document.createElement('div');
// var newDivText = document.createTextNode(item["Course"]);
// newDiv.appendChild(newDivText);
// var form = document.querySelector('form .container');
// var h2 = document.querySelector('form h1');
// form.insertBefore(newDiv, h2);
// var newDiv = document.createElement('div');
// var newDivText = document.createTextNode(item["Zip"]);
// newDiv.appendChild(newDivText);
// var form = document.querySelector('form .container');
// var h2 = document.querySelector('form h1');
// form.insertBefore(newDiv, h2);
});
//Delete Student
ipcRenderer.on('item: DeleteStudent', function(){
newDiv.innerHTML = '';
});
</script>
<script src="db.js"></script>
</body>
</html>