aboutsummaryrefslogtreecommitdiff
path: root/src/main/webapp/pages/adminIndex.jsp
blob: ab7ecd1c5c8b26000f6adf4357713009b50cdb20 (plain) (blame)
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
<%@page import="models.User"%>
<%@page import="models.Monster"%>
<%@page import="java.util.ArrayList"%>
<%@page import="models.CONSTS"%>
<%@page import="java.rmi.Naming"%>
<%@page import="pokemon.IService"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Admin</title>
<style>
	table, th, td {
	  border: 1px solid black;
	  border-collapse: collapse;
	  padding:2px;
	}
	.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
  visibility: hidden;
  width: 300px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
  position: absolute;
  z-index: 1;
}
.tooltip:hover .tooltiptext {
  visibility: visible;
}
h1{
	display:inline
}
</style>
</head>
<body>
<%
boolean isAdmin=(Boolean)session.getAttribute("admin");
if(!isAdmin){
	response.sendRedirect("../index.jsp");
}
%>
<a href="logout.jsp">
	<button>Log out</button>
</a><br><br>
<a href="addNewPokemon.jsp">
	<button>DodajNovogPokemona</button>
</a>
<br>

<h1>Lista korisnika</h1><div class="tooltip" style="display:inline">(?)
  <span class="tooltiptext">Lista korisnika u bazi. Admin moze da izbrise korisnike koji nisu admin-i.
  </span>
</div>
<%
IService service=(IService)Naming.lookup(CONSTS.rmiUrl);
ArrayList<User>users=service.getAllUsers();
request.setAttribute("users", users);
ArrayList<Monster> monsters=service.getMonsters();
request.setAttribute("monsters", monsters);
%>
<table>
<tr>
<th>Id</th>
<th>Username</th>
<th>admin</th>
<th>pokemonId</th>
<th></th>
</tr>
<c:forEach items="${users}" var="item">
<tr>
	<td>
	<c:out value="${item.id}"/>
	</td>
	<td>
	<c:out value="${item.username}"/>
	</td>
	<td>
	<c:out value="${item.admin}"/>
	</td>
	<td>
	<c:if test="${item.monsterId!=-1}">
	<c:out value="${item.monsterId}"/>
	</c:if>
	</td>
	<td>
	<c:if test="${!item.admin}">
	<a href="deleteUser.jsp?userId=${item.id}">
	<button>Izbrisi</button>
	</a>
	</c:if>
	</td>
</tr> 
</c:forEach>

</table>
<br>




<br><br>
<h1>Registracija novog admina</h1><div class="tooltip">(?)
  <span class="tooltiptext">Korisnicko ime i sifra moraju da budu alfanumericki string i polja ne smeju biti prazna. Dobija poruku da li je registracija uspesna.
  </span>
</div>
<form method="post" action="registerAdmin.jsp">
	<input type="text" name="username" pattern="^[A-Za-z0-9]{1,}$" required> Korisnicko ime 
	<br>
	<input type="password" name="password" pattern="^[A-Za-z0-9]{1,}$" required>Sifra
	<br>
	<p style="color:red;">
	<%
		if(request.getParameter("id")!=null &&request.getParameter("id").equals("-1") )
			out.print("Username vec postoji");
	%>
	<%
		if(request.getParameter("id")!=null &&request.getParameter("id").equals("-3") )
			out.print("Username i password moraju biti alfanumericnog tipa");
	%>
	</p>
	<p style="color:green;">
	<%
		if(request.getParameter("id")!=null &&request.getParameter("id").equals("-2") )
			out.print("Uspesna registracija");
	%>
	</p>
	<button type="submit">Registruj admina</button>
</form>
<br>

<h1>
</h1>


<h1>Svi pokemoni</h1><div class="tooltip">(?)
  <span class="tooltiptext">Svi pokemoni registrovani u bazi. Ima mogucnost da ih obrise.
  </span>
</div>
<br>
<table>
<tr>
<th>Ime</th>
<th>Opis</th>
<th>Hp</th>
<th>Slika</th>
<th></th>
</tr>
<c:forEach items="${monsters}" var="item">
<tr>
	<td>
	<c:out value="${item.name}"/>
	</td>
	<td>
	<c:out value="${item.description}"/>
	</td>
	<td>
	<c:out value="${item.hp}"/>
	</td>
	<td>
	<img style="height: 50px" src="data:image/*;base64, ${item.base64Image }" />
	</td>
	<td>
	<a href="deletePokemon.jsp?monsterId=${item.id}">
	<button>Izbrisi</button>
</a>
	</td>
</tr> 
</c:forEach>

</table>
<br>





</body>
</html>