Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SE577
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dmz39
SE577
Commits
e85aeb7b
Commit
e85aeb7b
authored
Mar 20, 2020
by
dmz39
Browse files
Options
Downloads
Patches
Plain Diff
Manage Orders page framework completed
parent
8887f604
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/edu/drexel/TrainDemo/controllers/users/AdminController.java
+24
-0
24 additions, 0 deletions
...u/drexel/TrainDemo/controllers/users/AdminController.java
src/main/resources/templates/admin/orders.html
+91
-0
91 additions, 0 deletions
src/main/resources/templates/admin/orders.html
with
115 additions
and
0 deletions
src/main/java/edu/drexel/TrainDemo/controllers/users/AdminController.java
+
24
−
0
View file @
e85aeb7b
...
...
@@ -2,8 +2,10 @@ package edu.drexel.TrainDemo.controllers.users;
import
edu.drexel.TrainDemo.Utils
;
import
edu.drexel.TrainDemo.configuration.LoggerConfiguration
;
import
edu.drexel.TrainDemo.models.sales.Order
;
import
edu.drexel.TrainDemo.models.users.Group
;
import
edu.drexel.TrainDemo.models.users.UserEntity
;
import
edu.drexel.TrainDemo.services.sales.OrderService
;
import
edu.drexel.TrainDemo.services.users.GroupService
;
import
edu.drexel.TrainDemo.services.users.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -15,7 +17,9 @@ import org.springframework.web.bind.annotation.*;
import
org.slf4j.Logger
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Controller
public
class
AdminController
{
...
...
@@ -26,6 +30,9 @@ public class AdminController {
@Autowired
GroupService
groupService
;
@Autowired
OrderService
orderService
;
@GetMapping
(
"/admin/dashboard"
)
String
adminDashboard
(
@AuthenticationPrincipal
OAuth2User
principal
)
{
UserEntity
currentUser
=
this
.
userService
.
getUser
(
principal
);
...
...
@@ -77,4 +84,21 @@ public class AdminController {
return
"admin/access_denied"
;
}
}
@GetMapping
(
"admin/orders"
)
String
manageOrders
(
@AuthenticationPrincipal
OAuth2User
principal
,
Model
model
)
{
UserEntity
currentUser
=
this
.
userService
.
getUser
(
principal
);
if
(
currentUser
!=
null
&&
this
.
userService
.
isAllowedAdminPanel
(
currentUser
))
{
List
<
Order
>
orders
=
this
.
orderService
.
getAllOrders
();
Map
<
Long
,
String
>
userMap
=
new
HashMap
<>();
for
(
UserEntity
user
:
this
.
userService
.
getUsers
())
{
userMap
.
put
(
user
.
getId
(),
user
.
getFirstName
()
+
" "
+
user
.
getLastName
());
}
model
.
addAttribute
(
"orders"
,
orders
);
model
.
addAttribute
(
"userMap"
,
userMap
);
return
"admin/orders"
;
}
else
{
return
"admin/access_denied"
;
}
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/templates/admin/orders.html
0 → 100644
+
91
−
0
View file @
e85aeb7b
<!doctype html>
<html
lang=
"en"
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<th:block
th:replace=
"base::header"
/>
<link
href=
"//cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css"
rel=
"stylesheet"
>
<script
src=
"//cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"
></script>
<script
type=
"text/javascript"
src=
"/js/admin.js"
></script>
</head>
<body>
<th:block
th:replace=
"base::navbar"
/>
<main
role=
"main"
>
<div
class=
"jumbotron"
>
<div
class=
"container"
>
<h1>
Admin Panel
</h1>
</div>
</div>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col"
>
<button
hidden
type=
"button"
class=
"btn btn-primary"
onclick=
"showModal('newGroupModal')"
>
New Group
</button>
</div>
</div>
<div
class=
"row"
>
<a
class=
"text"
>
Manage Orders:
</a><br>
</div>
<div
class=
"row"
>
<div
class=
"col"
>
<table
id=
"groupsTable"
class=
"table table-striped table-bordered table-sm"
cellspacing=
"0"
width=
"100%"
>
<thead>
<tr>
<th
class=
"th-sm"
>
Order ID
</th>
<th
class=
"th-sm"
>
Customer ID
</th>
<th
class=
"th-sm"
>
Customer Name
</th>
<th
class=
"th-sm"
>
Order Total
</th>
<th
class=
"th-sm"
>
Details
</th>
<th
class=
"th-sm"
>
Delete
</th>
</tr>
</thead>
<tbody>
<tr
th:each=
"order : ${orders}"
>
<td
th:text=
"${order.getId()}"
></td>
<td
th:text=
"${order.getUserId()}"
></td>
<td
th:text=
"${userMap.get(order.getUserId())}"
></td>
<td
th:text=
"${order.getPrice()}"
></td>
<td><button
class=
"btn btn-primary"
th:type=
"button"
>
Details
</button></td>
<td><button
class=
"btn btn-primary"
th:type=
"button"
>
×
</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div
class=
"modal fade"
tabindex=
"-1"
role=
"dialog"
aria-hidden=
"true"
id=
"newGroupModal"
>
<div
class=
"modal-dialog modal-dialog-centered"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"newGroupModalLongTitle"
>
New Group
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body"
>
<div
class=
"modal-body"
>
<p>
Please enter the information for the new group:
</p>
<form>
<div
class=
"form-group "
>
<label
for=
"gname"
>
Group Name:
</label>
<input
type=
"text"
class=
"form-control"
id=
"gname"
>
</div>
<div
class=
"form-group"
>
<label
for=
"gtype"
>
Group Type:
</label>
<select
type=
"name"
class=
"form-control"
id=
"gtype"
>
<option
value=
""
>
-- Type --
</option>
<option
value=
"ADMIN"
>
ADMIN
</option>
<option
value=
"EMPLOYEE"
>
EMPLOYEE
</option>
<option
value=
"CUSTOMER"
>
CUSTOMER
</option>
</select>
</div>
<div
class=
"form-group"
>
<button
onclick=
"addGroup()"
>
Save
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</main>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment