Skip to content

Commit

Permalink
SAK-46842 make number of dashboard home MOTDs configurable (sakaiproj…
Browse files Browse the repository at this point in the history
  • Loading branch information
ottenhoff authored Mar 18, 2022
1 parent 4575c38 commit 683a351
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5757,6 +5757,10 @@ rubrics.integration.token-secret=12345678900909091234
# DEFAULT: announcements,calendar,forums,grades"
#dashboard.course.widgets=announcements,calendar

# Configure the number of MOTDs to display in the home dashboard
# DEFAULT: 1
#dashboard.home.motd.display=3

# Set the key rotation period - SAK-45491
# For positive numbers this is the number of days before rotation happens
# For negative numbers it is the number of minutes before rotation happens (for testing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class DashboardController extends AbstractSakaiApiController {
private List<String> homeWidgets = new ArrayList<>();

private List<String> defaultHomeLayout = new ArrayList<>();
private int maxNumberMotd = 1;

/** This will be the map of the default widget layouts, one entry for each template */
private Map<String, List<String>> defaultWidgetLayouts = new HashMap<>();
Expand Down Expand Up @@ -134,6 +135,8 @@ public void init() {
courseWidgetLayout3 = new String[] { "calendar", "announcements", "grades", "forums" };
}
defaultWidgetLayouts.put("3", Arrays.asList(courseWidgetLayout3));

maxNumberMotd = serverConfigurationService.getInt("dashboard.home.motd.display", 1);
}

@GetMapping(value = "/users/{userId}/dashboard", produces = MediaType.APPLICATION_JSON_VALUE)
Expand All @@ -157,13 +160,15 @@ public DashboardRestBean getUserDashboard(@PathVariable String userId) throws Us
try {
List<AnnouncementMessage> motdMessages = announcementService.getMessages(
announcementService.getSummarizableReference(null, announcementService.MOTD_TOOL_ID),
new ViewableFilter(null, null, 1, announcementService),
new ViewableFilter(null, null, maxNumberMotd, announcementService),
false,
false);

if (motdMessages.size() > 0) {
bean.setMotd(motdMessages.get(motdMessages.size() - 1).getBody());
StringBuffer sb = new StringBuffer();
for (AnnouncementMessage motdMessage : motdMessages) {
sb.append(motdMessage.getBody());
}
bean.setMotd(sb.toString());
} catch (IdUnusedException idue) {
log.debug("No MOTD set.");
} catch (Exception e) {
Expand Down

0 comments on commit 683a351

Please sign in to comment.