Skip to content

Commit 28c4748

Browse files
committed
add notify in admin
1 parent 0ca7934 commit 28c4748

File tree

6 files changed

+50
-9
lines changed

6 files changed

+50
-9
lines changed

src/main/java/es/fiturjc/controller/AdminController.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ public String manageUsers(Model model, Pageable page) {
5757
}
5858

5959
@RequestMapping("/adminPage/manageUsers/delete/{id}")
60-
public String manageUsersDelete(@PathVariable long id) {
60+
public String manageUsersDelete(@PathVariable long id) throws InterruptedException {
6161
User user = usersRepository.findOne(id);
6262
usersRepository.delete(user);
63+
Thread.sleep(3000);
6364
return "redirect:/adminPage/manageUsers";
6465
}
6566

@@ -74,7 +75,7 @@ public String editSingleUser (Model model, @PathVariable long id) {
7475
}
7576

7677
@RequestMapping("/adminPage/editandsave/{id}")
77-
public String editAndSave (Model model, User user, @PathVariable long id, @RequestParam String passwordHash,@RequestParam String surname, @RequestParam int age) {
78+
public String editAndSave (Model model, User user, @PathVariable long id, @RequestParam String passwordHash,@RequestParam String surname, @RequestParam int age) throws InterruptedException {
7879

7980
user.setId(id);
8081
user.changePassword(passwordHash);
@@ -86,6 +87,7 @@ public String editAndSave (Model model, User user, @PathVariable long id, @Reque
8687
//Problems with the role while editing SOLVED
8788
usersRepository.saveAndFlush(user); // flush to the DB
8889

90+
Thread.sleep(3000);
8991
return "redirect:/adminPage/manageUsers";
9092
}
9193

@@ -105,9 +107,10 @@ public String manageGroups(Model model, Pageable page) {
105107
}
106108

107109
@RequestMapping("/adminPage/manageCourses/delete/{id}")
108-
public String manageGroupsDelete(@PathVariable long id) {
110+
public String manageGroupsDelete(@PathVariable long id) throws InterruptedException {
109111
Course course = courseRepository.findOne(id);
110112
courseRepository.delete(course);
113+
Thread.sleep(3000);
111114
return "redirect:/adminPage/manageCourses";
112115
}
113116

src/main/resources/static/css/alertify.default.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
}
88
.alertify {
99
background: #000000;
10+
color: white;
1011
border: 10px solid #333; /* browsers that don't support rgba */
1112
border: 10px solid rgb(254, 193, 8);
1213
border-radius: 8px;

src/main/resources/static/js/alertifyNotify.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,35 @@ function showDialogUnEnroll(element) {
7474

7575
function showDialogSoldOut(element) {
7676
alertify.alert("Full course Try another time.");
77-
}
77+
}
78+
79+
80+
function deleteUser(element) {
81+
var button = element;
82+
alertify.confirm("Delete user?", function(e){
83+
if(e){
84+
alertify.alert("Deleted: " + $(button).data('username'));
85+
document.location = "manageUsers/delete/" + $(button).data('iduser');
86+
}else{
87+
alertify.alert("Not deleted");
88+
}
89+
});
90+
}
91+
92+
93+
function saveUser(element) {
94+
alertify.alert("User save");
95+
}
96+
97+
function deleteCourse(element) {
98+
var button = element;
99+
alertify.confirm("Delete course?", function(e){
100+
if(e){
101+
alertify.alert("Deleted: " + $(button).data('coursename'));
102+
document.location = "manageCourses/delete/" + $(button).data('idcourse');
103+
}else{
104+
alertify.alert("Not deleted");
105+
}
106+
});
107+
}
108+

src/main/resources/templates/admin-controlCourses.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ <h4><u>{{name}} </u>: <h8>{{description}}</h8> </h4><br>
1515
<li type="circle"><a >Participants in Schedule {{idSchedule}}: {{listUsers.size}} </a></li>
1616
<li type="circle"><a>Users: {{listUsers}} </a> </li>
1717
{{/schedules}}
18-
<li type="circle"><a href="/adminPage/manageCourses/delete/{{id}}">Delete {{name}}<i class="fa fa-times" aria-hidden="true"></i></a></li>
18+
<li type="circle"><a class="btn btn-main btn-enter btn" data-coursename="{{name}}" data-idcourse="{{id}}" onclick="deleteCourse(this)">Delete {{name}}<i class="fa fa-times" aria-hidden="true"></i></a></li>
1919
</ul>
20-
20+
2121
{{/courses}}
2222
</ul>
2323
<br>

src/main/resources/templates/admin-controlUsers.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h2>{{Name}} {{Surname}}</h2>
3434
</div>
3535

3636
<div class="form-group">
37-
<label for="signup_password1">Password *</label> <input
37+
<label for="signup_password1">Password (Required)</label> <input
3838
id="signup_password1" class="form-control" name="passwordHash" required="required">
3939
<!--value="{{passwordHash}}">-->
4040
</div>
@@ -48,11 +48,11 @@ <h2>{{Name}} {{Surname}}</h2>
4848
<div class="col-12 col-md-auto btn-enter-div">
4949
<div class="row">
5050
<div class="col-md-1">
51-
<button type="submit" class="btn btn-primary">Save</button>
51+
<button type="submit" class="btn btn-primary" onclick="saveUser(this)">Save</button>
5252
</div>
5353
<div class="col-md-1">
5454
<a class="btn btn-main btn-enter btn"
55-
href="/adminPage/manageUsers/delete/{{id}}"> Delete</a>
55+
data-username="{{Name}}" data-iduser="{{id}}" onclick="deleteUser(this)"> Delete</a>
5656
</div>
5757
</div>
5858
</div>

src/main/resources/templates/admin.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<link rel="stylesheet"
2020
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
2121

22+
<link rel="stylesheet" href="/css/alertify.core.css">
23+
<link rel="stylesheet" href="/css/alertify.default.css">
24+
2225
</head>
2326

2427
<body>
@@ -74,6 +77,9 @@
7477
<script src="/vendor/bootstrap/js/bootstrap.min.js"></script>
7578
<script src="/vendor/bootstrap/js/light-bootstrap-dashboard.js"></script>
7679

80+
<script src="/js/alertify.min.js"></script>
81+
<script src="/js/alertifyNotify.js"></script>
82+
7783

7884
<!-- TOGGLE MENU, ERRORS WITH MANAGECOURSE FULL SIZE, NOT RESPONSIVE FOR THE MOMENT -->
7985

0 commit comments

Comments
 (0)