Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GitBull
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
EIP
Labrador
GitBull
Commits
4544ba3e
Commit
4544ba3e
authored
Oct 12, 2023
by
CachoobiDoobi
Browse files
Options
Downloads
Patches
Plain Diff
made the course management page work
parent
69df26aa
No related branches found
No related tags found
1 merge request
!4
Resolve "Move functionality from frontend to backend"
Pipeline
#953280
failed
Oct 12, 2023
Stage: build
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/src/main/java/server/controller/GroupManagementController.java
+48
-31
48 additions, 31 deletions
...ain/java/server/controller/GroupManagementController.java
backend/src/main/resources/templates/modifyCourse.html
+47
-27
47 additions, 27 deletions
backend/src/main/resources/templates/modifyCourse.html
with
95 additions
and
58 deletions
backend/src/main/java/server/controller/GroupManagementController.java
+
48
−
31
View file @
4544ba3e
...
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Controller;
...
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Controller;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
reactor.util.annotation.Nullable
;
import
server.entity.Access
;
import
server.entity.Access
;
import
server.labraService.LabraConnectionService
;
import
server.labraService.LabraConnectionService
;
import
server.logging.LogWriter
;
import
server.logging.LogWriter
;
...
@@ -76,8 +77,8 @@ public class GroupManagementController {
...
@@ -76,8 +77,8 @@ public class GroupManagementController {
}
}
@GetMapping
(
"/"
)
@GetMapping
(
"/"
)
public
String
getModifyCoursePage
(
@RequestParam
(
"courseName"
)
String
courseName
,
public
String
getModifyCoursePage
(
@RequestParam
(
"courseName"
)
@Nullable
String
courseName
,
@RequestParam
(
"courseEdition"
)
String
courseEdition
,
Model
model
)
{
@RequestParam
(
"courseEdition"
)
@Nullable
String
courseEdition
,
Model
model
)
{
UserRequestDTO
userRequestDTO
=
UserRequestDTO
.
builder
().
build
();
UserRequestDTO
userRequestDTO
=
UserRequestDTO
.
builder
().
build
();
GroupRequestDTO
groupRequestDTO
=
GroupRequestDTO
.
builder
().
build
();
GroupRequestDTO
groupRequestDTO
=
GroupRequestDTO
.
builder
().
build
();
...
@@ -151,12 +152,13 @@ public class GroupManagementController {
...
@@ -151,12 +152,13 @@ public class GroupManagementController {
* exception occurs return HttpStatus from GitLab API
* exception occurs return HttpStatus from GitLab API
*/
*/
@PostMapping
(
"/addGroupMemberByEmail"
)
@PostMapping
(
"/addGroupMemberByEmail"
)
public
ResponseEntity
<
Member
>
addGroupMemberByEmail
(
@AuthenticatedPerson
Person
person
,
public
String
addGroupMemberByEmail
(
@AuthenticatedPerson
Person
person
,
@ModelAttribute
UserRequestDTO
userRequestDTO
,
Model
model
)
{
@ModelAttribute
UserRequestDTO
userRequestDTO
)
{
String
currentUsername
=
person
.
getUsername
();
String
currentUsername
=
person
.
getUsername
();
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
if
(
gitLabApi
==
null
)
if
(
gitLabApi
==
null
)
return
ResponseEntity
.
status
(
HttpStatus
.
UNAUTHORIZED
).
build
();
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();'
return
"error"
;
try
{
try
{
String
path
=
""
;
String
path
=
""
;
...
@@ -195,10 +197,12 @@ public class GroupManagementController {
...
@@ -195,10 +197,12 @@ public class GroupManagementController {
.
accountID
(
user
.
getUsername
()).
build
();
.
accountID
(
user
.
getUsername
()).
build
();
accessDBService
.
saveAccess
(
newAccess
);
accessDBService
.
saveAccess
(
newAccess
);
}
}
//TODO add error as attributes to page
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
member
);
return
"redirect:/api/group/?courseName="
+
userRequestDTO
.
getCourseName
()
+
"&courseEdition="
+
userRequestDTO
.
getCourseEdition
();
}
catch
(
GitLabApiException
e
)
{
}
catch
(
GitLabApiException
e
)
{
return
ResponseEntity
.
status
(
e
.
getHttpStatus
()).
build
();
// return ResponseEntity.status(e.getHttpStatus()).build();
return
"error"
;
}
}
}
}
...
@@ -212,11 +216,13 @@ public class GroupManagementController {
...
@@ -212,11 +216,13 @@ public class GroupManagementController {
* exception occurs return HttpStatus from GitLab API
* exception occurs return HttpStatus from GitLab API
*/
*/
@PostMapping
(
"/removeGroupMemberByEmail"
)
@PostMapping
(
"/removeGroupMemberByEmail"
)
public
ResponseEntity
<
User
>
removeGroupMemberByEmail
(
@RequestBody
UserRequestDTO
userRequestDTO
)
{
public
String
removeGroupMemberByEmail
(
@AuthenticatedPerson
Person
person
,
String
currentUsername
=
gitBullSecurity
.
getCurrentUsername
(
userRequestDTO
.
getSecret
());
@ModelAttribute
UserRequestDTO
userRequestDTO
)
{
String
currentUsername
=
person
.
getUsername
();
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
if
(
gitLabApi
==
null
)
if
(
gitLabApi
==
null
)
return
ResponseEntity
.
status
(
HttpStatus
.
UNAUTHORIZED
).
build
();
return
"error"
;
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
try
{
try
{
String
path
=
""
;
String
path
=
""
;
...
@@ -254,9 +260,12 @@ public class GroupManagementController {
...
@@ -254,9 +260,12 @@ public class GroupManagementController {
accessDBService
.
deleteAccess
(
accessToDelete
.
getAccessID
());
accessDBService
.
deleteAccess
(
accessToDelete
.
getAccessID
());
}
}
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
user
);
// return ResponseEntity.status(HttpStatus.OK).body(user);
return
"redirect:/api/group/?courseName="
+
userRequestDTO
.
getCourseName
()
+
"&courseEdition="
+
userRequestDTO
.
getCourseEdition
();
}
catch
(
GitLabApiException
e
)
{
}
catch
(
GitLabApiException
e
)
{
return
ResponseEntity
.
status
(
e
.
getHttpStatus
()).
build
();
return
"error"
;
// return ResponseEntity.status(e.getHttpStatus()).build();
}
}
}
}
...
@@ -271,12 +280,13 @@ public class GroupManagementController {
...
@@ -271,12 +280,13 @@ public class GroupManagementController {
* @return HttpStatus.CREATED and the member that has been added to the group if any
* @return HttpStatus.CREATED and the member that has been added to the group if any
* exception occurs return HttpStatus from GitLab API
* exception occurs return HttpStatus from GitLab API
*/
*/
@PutMapping
(
"/updateGroupMemberByEmail"
)
@PostMapping
(
"/updateGroupMemberByEmail"
)
public
ResponseEntity
<
Member
>
updateGroupMemberByEmail
(
@RequestBody
UserRequestDTO
userRequestDTO
)
{
public
String
updateGroupMemberByEmail
(
@AuthenticatedPerson
Person
person
,
String
currentUsername
=
gitBullSecurity
.
getCurrentUsername
(
userRequestDTO
.
getSecret
());
@ModelAttribute
UserRequestDTO
userRequestDTO
)
{
String
currentUsername
=
person
.
getUsername
();
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
if
(
gitLabApi
==
null
)
if
(
gitLabApi
==
null
)
return
ResponseEntity
.
status
(
HttpStatus
.
UNAUTHORIZED
).
build
()
;
return
"error"
;
try
{
try
{
String
path
=
""
;
String
path
=
""
;
...
@@ -323,9 +333,10 @@ public class GroupManagementController {
...
@@ -323,9 +333,10 @@ public class GroupManagementController {
accessDBService
.
saveAccess
(
accessToUpdate
);
accessDBService
.
saveAccess
(
accessToUpdate
);
}
}
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
member
);
return
"redirect:/api/group/?courseName="
+
userRequestDTO
.
getCourseName
()
+
"&courseEdition="
+
userRequestDTO
.
getCourseEdition
();
}
catch
(
GitLabApiException
e
)
{
}
catch
(
GitLabApiException
e
)
{
return
ResponseEntity
.
status
(
e
.
getHttpStatus
()).
build
()
;
return
"error"
;
}
}
}
}
...
@@ -337,11 +348,13 @@ public class GroupManagementController {
...
@@ -337,11 +348,13 @@ public class GroupManagementController {
* @return a Response containing the updated project info or an error message
* @return a Response containing the updated project info or an error message
*/
*/
@PostMapping
(
"/updateGroup"
)
@PostMapping
(
"/updateGroup"
)
public
ResponseEntity
<?>
updateGroup
(
@RequestBody
GroupRequestDTO
groupRequestDTO
)
{
public
String
updateGroup
(
@AuthenticatedPerson
Person
person
,
String
currentUsername
=
gitBullSecurity
.
getCurrentUsername
(
groupRequestDTO
.
getSecret
());
@ModelAttribute
GroupRequestDTO
groupRequestDTO
)
{
String
currentUsername
=
person
.
getUsername
();
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
if
(
gitLabApi
==
null
)
if
(
gitLabApi
==
null
)
return
ResponseEntity
.
status
(
HttpStatus
.
UNAUTHORIZED
).
build
();
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
return
"error"
;
try
{
try
{
GroupParams
groupParams
=
new
GroupParams
()
GroupParams
groupParams
=
new
GroupParams
()
...
@@ -353,9 +366,11 @@ public class GroupManagementController {
...
@@ -353,9 +366,11 @@ public class GroupManagementController {
.
withParentId
(
groupRequestDTO
.
getParentId
());
.
withParentId
(
groupRequestDTO
.
getParentId
());
Group
updatedGroup
=
groupAPIService
.
updateGroup
(
gitLabApi
,
groupRequestDTO
.
getPath
(),
Group
updatedGroup
=
groupAPIService
.
updateGroup
(
gitLabApi
,
groupRequestDTO
.
getPath
(),
groupParams
);
groupParams
);
return
ResponseEntity
.
ok
(
updatedGroup
);
// return ResponseEntity.ok(updatedGroup);
return
"redirect:/api/group/"
;
}
catch
(
GitLabApiException
e
)
{
}
catch
(
GitLabApiException
e
)
{
return
ResponseEntity
.
status
(
e
.
getHttpStatus
()).
body
(
e
.
getMessage
());
// return ResponseEntity.status(e.getHttpStatus()).body(e.getMessage());
return
"error"
;
}
}
}
}
...
@@ -368,13 +383,13 @@ public class GroupManagementController {
...
@@ -368,13 +383,13 @@ public class GroupManagementController {
* @return a Response containing the updated project info or an error message
* @return a Response containing the updated project info or an error message
*/
*/
@PostMapping
(
"/updateGroupAndSubgroups"
)
@PostMapping
(
"/updateGroupAndSubgroups"
)
public
ResponseEntity
<
List
<
String
>>
updateGroupAndSubgroups
(
public
String
updateGroupAndSubgroups
(
@AuthenticatedPerson
Person
person
,
@
RequestBody
GroupRequestDTO
groupRequestDTO
)
{
@
ModelAttribute
GroupRequestDTO
groupRequestDTO
)
{
String
currentUsername
=
gitBullSecurity
.
getCurrentUsername
(
groupRequestDTO
.
getSecret
()
);
String
currentUsername
=
person
.
getUsername
(
);
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
GitLabApi
gitLabApi
=
instanceMappingService
.
getInstance
(
currentUsername
);
if
(
gitLabApi
==
null
)
if
(
gitLabApi
==
null
)
return
ResponseEntity
.
status
(
HttpStatus
.
UNAUTHORIZED
).
build
();
//
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
return
"error"
;
try
{
try
{
Group
group
=
groupAPIService
.
getGroup
(
gitLabApi
,
groupRequestDTO
.
getPath
());
Group
group
=
groupAPIService
.
getGroup
(
gitLabApi
,
groupRequestDTO
.
getPath
());
...
@@ -409,9 +424,11 @@ public class GroupManagementController {
...
@@ -409,9 +424,11 @@ public class GroupManagementController {
}
}
return
ResponseEntity
.
ok
(
errorLog
);
// return ResponseEntity.ok(errorLog);
return
"redirect:/api/group/"
;
}
catch
(
GitLabApiException
e
)
{
}
catch
(
GitLabApiException
e
)
{
return
ResponseEntity
.
status
(
e
.
getHttpStatus
()).
body
(
List
.
of
(
e
.
getMessage
()));
// return ResponseEntity.status(e.getHttpStatus()).body(List.of(e.getMessage()));
return
"error"
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
backend/src/main/resources/templates/modifyCourse.html
+
47
−
27
View file @
4544ba3e
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
xmlns:th=
"http://www.thymeleaf.org"
xmlns:layout=
"http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate=
"~{layout}"
>
<html
lang=
"en"
xmlns:th=
"http://www.thymeleaf.org"
xmlns:layout=
"http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate=
"~{layout}"
>
<html
lang=
"en"
>
<html
lang=
"en"
>
<head>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
...
@@ -10,23 +11,32 @@
...
@@ -10,23 +11,32 @@
<div
class=
"main-section"
>
<div
class=
"main-section"
>
<div
class=
"content"
>
<div
class=
"content"
>
<h1>
Add User
</h1>
<h1>
Add User
</h1>
<form
th:action=
"@{/api/group/addGroupMemberByEmail}"
th:object=
"${user}"
method=
"post"
enctype=
"multipart/form-data"
>
<form
th:action=
"@{/api/group/addGroupMemberByEmail}"
th:object=
"${user}"
method=
"post"
enctype=
"multipart/form-data"
>
<div
th:if=
"${user != null}"
>
<div>
Course Name
</div>
<div>
Course Name
</div>
<input
type=
"text"
placeholder=
"${user.courseName}"
th:field=
"*{courseName}"
>
<input
type=
"text"
placeholder=
"${user.courseName}"
th:field=
"*{courseName}"
>
<div>
Course Edition
</div>
<div>
Course Edition
</div>
<input
type=
"text"
placeholder=
"${user.courseEdition}"
th:field=
"*{courseEdition}"
>
<input
type=
"text"
placeholder=
"${user.courseEdition}"
th:field=
"*{courseEdition}"
>
</div>
<div
th:unless=
"${user != null}"
>
<div>
Course Name
</div>
<input
type=
"text"
placeholder=
"Course name"
th:field=
"*{courseName}"
>
<div>
Course Edition
</div>
<input
type=
"text"
placeholder=
"Course edition"
th:field=
"*{courseEdition}"
>
</div>
<div>
Group Name
</div>
<div>
Group Name
</div>
<input
type=
"text"
placeholder=
"Group Name"
th:field=
"*{groupPath}"
>
<input
type=
"text"
placeholder=
"Group Name"
th:field=
"*{groupPath}"
>
<div>
Email
</div>
<div>
Email
</div>
<input
type=
"text"
placeholder=
"Email"
th:field=
"*{email}"
>
<input
type=
"text"
placeholder=
"Email"
th:field=
"*{email}"
>
<select
th:field=
"*{accessLevel}"
>
<select
th:field=
"*{accessLevel}"
>
<option
value=
"0"
>
No access
</option>
<option
value=
0
>
No access
</option>
<option
value=
"1"
>
Minimal Access
</option>
<option
value=
5
>
Minimal Access
</option>
<option
value=
"2"
>
Guest
</option>
<option
value=
10
>
Guest
</option>
<option
value=
"3"
>
Reporter
</option>
<option
value=
20
>
Reporter
</option>
<option
value=
"4"
selected
>
Developer
</option>
<option
value=
30
selected
>
Developer
</option>
<option
value=
"5"
>
Maintainer
</option>
<option
value=
40
>
Maintainer
</option>
<option
value=
"6"
>
Owner
</option>
<option
value=
50
>
Owner
</option>
</select>
</select>
<button
type=
"submit"
class=
"btn"
>
<button
type=
"submit"
class=
"btn"
>
Add User
Add User
...
@@ -34,23 +44,32 @@
...
@@ -34,23 +44,32 @@
</form>
</form>
<h1>
Update User
</h1>
<h1>
Update User
</h1>
<form
th:action=
"@{/api/group/updateGroupMemberByEmail}"
th:object=
"${user}"
method=
"post"
enctype=
"multipart/form-data"
>
<form
th:action=
"@{/api/group/updateGroupMemberByEmail}"
th:object=
"${user}"
method=
"post"
enctype=
"multipart/form-data"
>
<div
th:if=
"${user != null}"
>
<div>
Course Name
</div>
<div>
Course Name
</div>
<input
type=
"text"
placeholder=
"${user.courseName}"
th:field=
"*{courseName}"
>
<input
type=
"text"
placeholder=
"${user.courseName}"
th:field=
"*{courseName}"
>
<div>
Course Edition
</div>
<div>
Course Edition
</div>
<input
type=
"text"
placeholder=
"${user.courseEdition}"
th:field=
"*{courseEdition}"
>
<input
type=
"text"
placeholder=
"${user.courseEdition}"
th:field=
"*{courseEdition}"
>
</div>
<div
th:unless=
"${user != null}"
>
<div>
Course Name
</div>
<input
type=
"text"
placeholder=
"Course name"
th:field=
"*{courseName}"
>
<div>
Course Edition
</div>
<input
type=
"text"
placeholder=
"Course edition"
th:field=
"*{courseEdition}"
>
</div>
<div>
Group Name
</div>
<div>
Group Name
</div>
<input
type=
"text"
placeholder=
"Group Name"
th:field=
"*{groupPath}"
>
<input
type=
"text"
placeholder=
"Group Name"
th:field=
"*{groupPath}"
>
<div>
Email
</div>
<div>
Email
</div>
<input
type=
"text"
placeholder=
"Email"
th:field=
"*{email}"
>
<input
type=
"text"
placeholder=
"Email"
th:field=
"*{email}"
>
<select
th:field=
"*{accessLevel}"
>
<select
th:field=
"*{accessLevel}"
>
<option
value=
"0"
>
No access
</option>
<option
value=
0
>
No access
</option>
<option
value=
"1"
>
Minimal Access
</option>
<option
value=
5
>
Minimal Access
</option>
<option
value=
"2"
>
Guest
</option>
<option
value=
10
>
Guest
</option>
<option
value=
"3"
>
Reporter
</option>
<option
value=
20
>
Reporter
</option>
<option
value=
"4"
selected
>
Developer
</option>
<option
value=
30
selected
>
Developer
</option>
<option
value=
"5"
>
Maintainer
</option>
<option
value=
40
>
Maintainer
</option>
<option
value=
"6"
>
Owner
</option>
<option
value=
50
>
Owner
</option>
</select>
</select>
<button
type=
"submit"
class=
"btn"
>
<button
type=
"submit"
class=
"btn"
>
Update User
Update User
...
@@ -58,7 +77,8 @@
...
@@ -58,7 +77,8 @@
</form>
</form>
<h1>
Remove User
</h1>
<h1>
Remove User
</h1>
<form
th:action=
"@{/api/group/removeGroupMemberByEmail}"
th:object=
"${user}"
method=
"post"
enctype=
"multipart/form-data"
>
<form
th:action=
"@{/api/group/removeGroupMemberByEmail}"
th:object=
"${user}"
method=
"post"
enctype=
"multipart/form-data"
>
<div>
Course Name
</div>
<div>
Course Name
</div>
<input
type=
"text"
placeholder=
"${user.courseName}"
th:field=
"*{courseName}"
>
<input
type=
"text"
placeholder=
"${user.courseName}"
th:field=
"*{courseName}"
>
<div>
Course Edition
</div>
<div>
Course Edition
</div>
...
...
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