|
17 | 17 | import com.researchspace.model.dtos.NotificationStatus;
|
18 | 18 | import com.researchspace.model.field.ErrorList;
|
19 | 19 | import com.researchspace.model.views.ServiceOperationResult;
|
| 20 | +import com.researchspace.properties.IPropertyHolder; |
20 | 21 | import com.researchspace.service.CommunicationManager;
|
21 | 22 | import com.researchspace.service.IMessageAndNotificationTracker;
|
22 | 23 | import com.researchspace.service.RSpaceRequestManager;
|
|
35 | 36 | import org.springframework.web.bind.annotation.RequestMapping;
|
36 | 37 | import org.springframework.web.bind.annotation.RequestParam;
|
37 | 38 | import org.springframework.web.bind.annotation.ResponseBody;
|
| 39 | +import org.springframework.web.servlet.view.RedirectView; |
38 | 40 |
|
39 | 41 | /** Handles URL requests for the Dashboard page, including messaging and notifications. */
|
40 | 42 | @Controller
|
41 | 43 | @RequestMapping("/dashboard")
|
42 | 44 | public class DashboardController extends BaseController {
|
| 45 | + |
43 | 46 | @Autowired private SystemPropertyPermissionManager systemPropertyPermissionManager;
|
44 | 47 | private @Autowired RSpaceRequestManager reqStatusUpdateMgr;
|
45 | 48 | private @Autowired CommunicationManager commService;
|
46 | 49 | private @Autowired IMessageAndNotificationTracker tracker;
|
| 50 | + private @Autowired IPropertyHolder propertyHolder; |
47 | 51 |
|
48 | 52 | @GetMapping
|
49 | 53 | public String dashboard(Model model, Principal principal) {
|
@@ -157,6 +161,28 @@ public AjaxReturnObject<String> updateMessageStatus(
|
157 | 161 | return new AjaxReturnObject<>("Success", null);
|
158 | 162 | }
|
159 | 163 |
|
| 164 | + @GetMapping("/ajax/messageStatus") |
| 165 | + @ResponseBody |
| 166 | + public RedirectView updateMessageStatusGet( |
| 167 | + Principal principal, |
| 168 | + @RequestParam("messageOrRequestId") Long messageOrRequestId, |
| 169 | + @RequestParam("status") String status, |
| 170 | + @RequestParam(value = "optionalMessage", required = false) String optionalMessage) { |
| 171 | + CommunicationStatus statusEnum = CommunicationStatus.valueOf(status); |
| 172 | + String baseUrl = propertyHolder.getServerUrl(); |
| 173 | + switch (statusEnum) { |
| 174 | + case ACCEPTED: |
| 175 | + case COMPLETED: |
| 176 | + updateMessageStatus(principal, messageOrRequestId, status, optionalMessage); |
| 177 | + return new RedirectView(baseUrl + "/requestAccepted"); |
| 178 | + case REJECTED: |
| 179 | + updateMessageStatus(principal, messageOrRequestId, status, optionalMessage); |
| 180 | + return new RedirectView(baseUrl + "/requestDeclined"); |
| 181 | + default: |
| 182 | + return new RedirectView(baseUrl + "/error"); |
| 183 | + } |
| 184 | + } |
| 185 | + |
160 | 186 | /**
|
161 | 187 | * Handles a user responding to an original message.
|
162 | 188 | *
|
|
0 commit comments