Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SkuciSe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tim 2 - 2022
SkuciSe
Commits
0797f0d8
Commit
0797f0d8
authored
Sep 04, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dodat flash attributes na delete i accept
parent
6bfa9e9d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
+6
-10
SkuciSe/src/main/resources/templates/lista-korisnika.html
+8
-0
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
View file @
0797f0d8
...
@@ -11,6 +11,7 @@ import org.springframework.ui.Model;
...
@@ -11,6 +11,7 @@ import org.springframework.ui.Model;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -41,21 +42,16 @@ public class AdminController
...
@@ -41,21 +42,16 @@ public class AdminController
}
}
@PostMapping
(
"/delete-user/{id}"
)
@PostMapping
(
"/delete-user/{id}"
)
public
String
deleteUser
(
@PathVariable
(
"id"
)
Integer
id
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
Model
model
){
public
String
deleteUser
(
@PathVariable
(
"id"
)
Integer
id
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
Model
model
,
RedirectAttributes
redirectAttributes
){
kRepo
.
deleteUser
(
id
);
kRepo
.
deleteUser
(
id
);
List
<
String
>
list
=
new
ArrayList
<
String
>();
redirectAttributes
.
addFlashAttribute
(
"deleted"
,
true
);
for
(
Korisnik
k:
kRepo
.
findAll
())
{
return
"redirect:/lista-korisnika"
;
list
.
add
(
kRepo
.
findCity
(
k
.
getGradId
()));
}
model
.
addAttribute
(
"korisnici"
,
kRepo
.
findAll
());
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"gradovi"
,
list
);
return
"lista-korisnika-delete"
;
}
}
@PostMapping
(
"/accept-user/{id}"
)
@PostMapping
(
"/accept-user/{id}"
)
public
String
acceptUser
(
@PathVariable
(
"id"
)
Integer
id
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
Model
model
){
public
String
acceptUser
(
@PathVariable
(
"id"
)
Integer
id
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
Model
model
,
RedirectAttributes
redirectAttributes
){
kRepo
.
enableKorisnik
(
id
);
kRepo
.
enableKorisnik
(
id
);
redirectAttributes
.
addFlashAttribute
(
"accepted"
,
true
);
return
"redirect:/lista-korisnika"
;
return
"redirect:/lista-korisnika"
;
}
}
}
}
SkuciSe/src/main/resources/templates/lista-korisnika.html
View file @
0797f0d8
...
@@ -80,6 +80,14 @@
...
@@ -80,6 +80,14 @@
<div
class=
"container d-flex align-items-center justify-content-center flex flex-column h-50"
>
<div
class=
"container d-flex align-items-center justify-content-center flex flex-column h-50"
>
<h1>
Spisak korisnika
</h1>
<h1>
Spisak korisnika
</h1>
<div
class=
"alert alert-info"
th:object=
"${deleted}"
th:if=
"${deleted == true}"
>
<strong>
Uspesno!
</strong>
Uspesno ste obrisali korisnika!
<button
type=
"button"
class=
"btn-close"
data-dismiss=
"alert"
></button>
</div>
<div
class=
"alert alert-info"
th:object=
"${accepted}"
th:if=
"${accepted == true}"
>
<strong>
Uspesno!
</strong>
Uspesno ste prihvatili korisnika!
<button
type=
"button"
class=
"btn-close"
data-dismiss=
"alert"
></button>
</div>
<div
class=
"row w-100 h-50"
style=
"margin-top:50px;"
>
<div
class=
"row w-100 h-50"
style=
"margin-top:50px;"
>
<div>
<div>
<div
class=
"row h-50"
>
<div
class=
"row h-50"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment