-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.html
163 lines (142 loc) · 5.68 KB
/
view.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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap" rel="stylesheet">
<style>
nav {
padding: 20px;
display: flex;
justify-content: space-between;
box-shadow: 3px 10px 17px -15px rgba(0, 0, 0, 0.48);
}
a,
a:hover {
color: black;
text-decoration: none;
}
.search {
margin: 50px 0px;
display: flex;
justify-content: center;
}
.search select {
margin: 0px 15px;
}
.table {
text-align: center;
}
</style>
</head>
<body>
<nav>
<a href="Home"><span style="font-size: 2em;line-height: 3;font-weight: bold;">Dashboard</span></a>
<img src="static/AASTL.png" style="width: 100px; height: 100px;">
<a href="#"><img src="static/setting2.png" style="width: 80px;height: 80px;"></a>
</nav>
<div class="search">
<form class="form-inline">
<input class="form-control mr-sm-2" type="ID" placeholder="ID" aria-label="ID">
<input class="form-control mr-sm-2" type="name" placeholder="name" aria-label="name">
<select class="form-control" id="inputDuration">
<option selected>Membership Type</option>
<option>Semesterly</option>
<option>Monthly</option>
<option>Daily</option>
</select>
<select class="form-control" id="inputGender">
<option selected>Gender</option>
<option>Male</option>
<option>Female</option>
</select>
<select class="form-control" id="inputPeriod">
<option selected>Period</option>
<option>8:30 am</option>
<option>10:30 am</option>
<option>12:30 pm</option>
<option>3:30 pm</option>
<option>5:30 pm</option>
</select>
<select class="form-control" id="inputStatus">
<option selected>Status</option>
<option>Active</option>
<option>Not Active</option>
</select>
<button class="btn btn-success my-2 my-sm-0" type="button" onclick="update()">View</button>
</form>
</div>
<div class="table-responsive">
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Membership Type</th>
<th scope="col">Gender</th>
<th scope="col">Period</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
crossorigin="anonymous"></script>
<script>
var dict = [];
fetch('/members')
.then(function (response) {
return response.json();// convert it to a pure JavaScript object
})
.then(function (data) {
//Process Your data
for (let i = 0; i < data.length; i++) {
var last = Date.parse(data[i].enddate);
var today = Date.now();
var st = "Not Active";
if (last > today)
st = "Active";
dict.push({
ID: data[i].id,
Name: data[i].name,
Membership_type: data[i].membershiptype,
Gender: data[i].gender,
Period: data[i].period,
Status: st
})
}
})
.catch(function (err) {
console.log(err);
});
function update() {
var table = document.getElementById('tbody');
for (let i = 0; i < dict.length; i++) {
var record = dict[i];
tr = document.createElement('tr');
var Status_color;
if (record["Status"] == "Not Active")
Status_color = "rgb(180,0,0);";
else
Status_color = "rgb(0,100,0);"
tr.innerHTML =
"<th scope='row'>" + record['ID'] +
"</th><td>" + record['Name'] +
"</td><td>" + record['Membership_type'] +
"</td><td>" + record['Gender'] +
"</td><td>" + record['Period'] +
"</td><td> <p style='color:" + Status_color + " font-weight: bold;'>" + record['Status'] + "</p> </td>"
table.appendChild(tr);
}
}
</script>
</body>