Skip to content

Commit

Permalink
SAK-50265 dashboard all widgets should display data for only pinned s…
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Jul 16, 2024
1 parent 0be3223 commit aa8e776
Show file tree
Hide file tree
Showing 162 changed files with 1,817 additions and 407,750 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ public interface CalendarEvent
*/
public String getSiteName();

/**
* Gets the event's site id
*
* @return The event's site id
*/
public String getSiteId();

/**
* <p>
* EventAccess enumerates different access modes for the event: site-wide or grouped.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public interface CalendarEventEdit
*/
public void setLocation(String location);

public void setSiteId(String siteId);

/**
* Set the event url (cover for PROP_CALENDAR_URL).
* @param location The event's eventUrl property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public CalendarEventVector getEvents(List references, TimeRange range)

public List<CalendarEvent> getFilteredEvents(Map<EventFilterKey, Object> options) {

if (options == null) { options = Collections.emptyMap(); }
if (options == null) options = Collections.emptyMap();

List<String> allRefs = new ArrayList<>();

Expand Down Expand Up @@ -2551,7 +2551,6 @@ public List getEvents(TimeRange range, Filter filter, Integer limit) throws Perm
Collections.sort(allowedEvents);

return allowedEvents;

} // getEvents

/**
Expand Down Expand Up @@ -2673,6 +2672,7 @@ public CalendarEvent addEvent(TimeRange range, String displayName, String descri
edit.setDescription(description);
edit.setType(type);
edit.setLocation(location);
edit.setSiteId(m_toolManager.getCurrentPlacement().getContext());
edit.setCreator();

// for site...
Expand Down Expand Up @@ -3634,6 +3634,8 @@ public class BaseCalendarEventEdit implements CalendarEventEdit, SessionBindingL
/** The message access. */
protected EventAccess m_access = EventAccess.SITE;

protected String siteId;

/**
* Construct.
*
Expand Down Expand Up @@ -4036,6 +4038,16 @@ public String getLocation()

} // getLocation

/**
* Access the siteId
*
* @return The event's siteId
*/
public String getSiteId()
{
return m_properties.getPropertyFormatted(ResourceProperties.PROP_CALENDAR_SITE_ID);
}

/**
* Access the event url (cover for PROP_CALENDAR_URL).
*
Expand Down Expand Up @@ -4179,7 +4191,18 @@ public void setLocation(String location)
{
m_properties.addProperty(ResourceProperties.PROP_CALENDAR_LOCATION, location);

} // setLocation
}

/**
* Set the siteId (cover for PROP_CALENDAR_SITE_ID).
*
* @param siteId
* The event's siteId property.
*/
public void setSiteId(String siteId)
{
m_properties.addProperty(ResourceProperties.PROP_CALENDAR_SITE_ID, siteId);
}

public void setEventUrl(String url)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,12 @@ public String getLocation()
.getPropertyFormatted(ResourceProperties.PROP_CALENDAR_LOCATION);
}

public String getSiteId()
{
return m_properties
.getPropertyFormatted(ResourceProperties.PROP_CALENDAR_SITE_ID);
}

public String getEventUrl()
{
return m_properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ public class PrototypeEvent implements CalendarEventEdit

private String location;

private String siteId;

private String eventUrl;

private String type;
Expand Down Expand Up @@ -249,6 +251,16 @@ public String getLocation()
return this.location;
}

/*
* (non-Javadoc)
*
* @see org.sakaiproject.calendar.api.CalendarEvent#getSiteId()
*/
public String getSiteId()
{
return this.siteId;
}

@Override
public String getEventUrl()
{
Expand Down Expand Up @@ -450,6 +462,16 @@ public void setLocation(String location)
this.location = location;
}

/*
* (non-Javadoc)
*
* @see org.sakaiproject.calendar.api.CalendarEventEdit#setSiteId(java.lang.String)
*/
public void setSiteId(String siteId)
{
this.siteId = siteId;
}

@Override
public void setEventUrl(String url)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4736,6 +4736,8 @@ public void doAdd(RunData runData, Context context) {
type = runData.getParameters().getString("eventType");
String location = "";
location = runData.getParameters().getString("location");

String siteId = ToolManager.getCurrentPlacement().getContext();

String calId = state.getPrimaryCalendarReference();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
public class MockCalendarEventEdit implements CalendarEventEdit {

private String location;
private String siteId;
private String description;
private TimeRange range;
private RecurrenceRule exclusionRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public interface ResourceProperties extends Serializable
/** Property for calendar event location (user settable). [String] */
static final String PROP_CALENDAR_LOCATION = "CHEF:calendar-location";

static final String PROP_CALENDAR_SITE_ID = "calendar-site-id";

static final String PROP_CALENDAR_URL = "CHEF:calendar-url";

/** Property for the channel to categories names inside a discussion channel (user settable). [String] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.sakaiproject.calendar.api.CalendarEvent;
import org.sakaiproject.content.api.ContentHostingService;
import org.sakaiproject.content.api.ContentResource;
import org.sakaiproject.entity.api.ResourceProperties;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.time.api.TimeRange;
import org.sakaiproject.util.CalendarUtil;
Expand Down Expand Up @@ -48,7 +49,7 @@ public class CalendarEventRestBean {
public CalendarEventRestBean(CalendarEvent ce, ContentHostingService chs) {

id = ce.getId();
siteId = ce.getLocation();
siteId = ce.getSiteId();
siteTitle = ce.getSiteName();
creator = ce.getCreator();
viewText = ce.getDescription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public class GradeRestBean {
private String url;
private String siteTitle;
private String siteRole;
private String siteId;

public GradeRestBean(Assignment assignment) {

id = assignment.getId();
name = assignment.getName();
siteId = assignment.getContext();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@
import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.entity.api.EntityManager;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.portal.api.PortalService;
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.site.api.Site;
import org.sakaiproject.site.api.ToolConfiguration;
import org.sakaiproject.user.api.UserNotDefinedException;

import org.springframework.http.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

Expand All @@ -43,37 +45,47 @@
@RestController
public class AnnouncementsController extends AbstractSakaiApiController {

@Resource
@Autowired
private AnnouncementService announcementService;

@Resource
@Autowired
private EntityManager entityManager;

@Resource(name = "org.sakaiproject.component.api.ServerConfigurationService")
@Autowired
private PortalService portalService;

@Autowired
@Qualifier("org.sakaiproject.component.api.ServerConfigurationService")
private ServerConfigurationService serverConfigurationService;

@Resource
@Autowired
private SiteService siteService;

@GetMapping(value = "/users/me/announcements", produces = MediaType.APPLICATION_JSON_VALUE)
public List<AnnouncementRestBean> getUserAnnouncements() throws UserNotDefinedException {

checkSakaiSession();

List<String> pinnedSites = portalService.getPinnedSites();

try {
return announcementService.getChannelMessages(null, null, true, null, true, true, null, 10)
.stream()
.map(am -> {

Optional<String> optionalUrl = entityManager.getUrl(am.getReference(), Entity.UrlType.PORTAL);
String siteId = entityManager.newReference(am.getReference()).getContext();

if (!pinnedSites.contains(siteId)) return null;

try {
return new AnnouncementRestBean(siteService.getSite(siteId), am, optionalUrl.get());
} catch (IdUnusedException idue) {
log.error("Invalid announcement message. No site for id {}", siteId, idue.toString());
}
return null;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
} catch (Exception ex) {
log.error("Error getting announcements: {}", ex.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import org.sakaiproject.api.app.messageforums.SynopticMsgcntrManager;
import org.sakaiproject.api.app.messageforums.SynopticMsgcntrItem;
import org.sakaiproject.portal.api.PortalService;
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.site.api.Site;
import org.sakaiproject.site.api.ToolConfiguration;
Expand All @@ -39,6 +40,9 @@
@RestController
public class ForumsController extends AbstractSakaiApiController {

@Autowired
private PortalService portalService;

@Autowired
private SynopticMsgcntrManager msgCenterManager;

Expand Down Expand Up @@ -79,8 +83,14 @@ public class ForumsController extends AbstractSakaiApiController {
@GetMapping(value = "/users/{userEid}/forums/summary", produces = MediaType.APPLICATION_JSON_VALUE)
public List<Map<String, Object>> getUserForums(@PathVariable String userEid) throws UserNotDefinedException {

List<String> pinnedSites = portalService.getPinnedSites();

return msgCenterManager.getWorkspaceSynopticMsgcntrItems(checkSakaiSession().getUserId())
.stream().filter(countFilter).map(handler).collect(Collectors.toList());
.stream()
.filter(i -> pinnedSites.contains(i.getSiteId()))
.filter(countFilter)
.map(handler)
.collect(Collectors.toList());
}

@GetMapping(value = "/sites/{siteId}/forums/summary", produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class GradesController extends AbstractSakaiApiController {
private SiteService siteService;

private final Function<String, List<GradeRestBean>> gradeDataSupplierForSite = (siteId) -> {

List<org.sakaiproject.grading.api.Assignment> assignments = gradingService.getViewableAssignmentsForCurrentUser(siteId);
List<Long> assignmentIds = assignments.stream().map(org.sakaiproject.grading.api.Assignment::getId).collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
all_pinned_sites=All Pinned Sites
viewing=(viewing announcements from the last 10 days)
site=Site
search=Search
title=Title
site=Site
Expand Down
2 changes: 1 addition & 1 deletion webcomponents/bundle/src/main/bundle/courselist.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
all_pinned_sites=All Pinned Sites
pinned_courses=Pinned Courses
pinned_projects=Pinned Projects
code_a_to_z=Code: A-Z
Expand All @@ -10,4 +11,3 @@ term_filter_label=Term filter
term_filter_none_option=Any term
title_a_to_z=Title: A-Z
title_z_to_a=Title: Z-A
view_pinned_sites=All Pinned Sites
3 changes: 0 additions & 3 deletions webcomponents/bundle/src/main/bundle/forums.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
syn_options=Options
syn_hide=Don't Show
sort_by_messages_tooltip=Sort by message number
syn_private_heading=New Messages
sort_by_forums_tooltip=Sort by number of forum posts
syn_discussion_heading=New in Discussions
sort_by_site_tooltip=Sort by site title
syn_site_heading=Site
syn_hide_tooltip=Hide this site from this forums/messages view
widget_title=Discussions
3 changes: 0 additions & 3 deletions webcomponents/bundle/src/main/bundle/forums_bg.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
syn_options=\u041e\u043f\u0446\u0438\u0438
syn_hide=\u041d\u0435 \u043f\u043e\u043a\u0430\u0437\u0432\u0430\u0439\u0442\u0435
sort_by_messages_tooltip=\u0421\u043e\u0440\u0442\u0438\u0440\u0430\u043d\u0435 \u043f\u043e \u043d\u043e\u043c\u0435\u0440 \u043d\u0430 \u0441\u044a\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u0442\u043e
syn_private_heading=\u041d\u043e\u0432\u0438 \u0441\u044a\u043e\u0431\u0449\u0435\u043d\u0438\u044f
sort_by_forums_tooltip=\u0421\u043e\u0440\u0442\u0438\u0440\u0430\u043d\u0435 \u043f\u043e \u0431\u0440\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u044a\u0432 \u0444\u043e\u0440\u0443\u043c\u0430
syn_discussion_heading=\u041d\u043e\u0432\u043e \u0432 \u0414\u0438\u0441\u043a\u0443\u0441\u0438\u0438
sort_by_site_tooltip=\u0421\u043e\u0440\u0442\u0438\u0440\u0430\u043d\u0435 \u043f\u043e \u0437\u0430\u0433\u043b\u0430\u0432\u0438\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442\u0430
syn_site_heading=\u0421\u0430\u0439\u0442
syn_hide_tooltip=\u0421\u043a\u0440\u0438\u0432\u0430\u043d\u0435 \u043d\u0430 \u0442\u043e\u0437\u0438 \u0441\u0430\u0439\u0442 \u043e\u0442 \u0442\u043e\u0437\u0438 \u0438\u0437\u0433\u043b\u0435\u0434 \u043d\u0430 \u0444\u043e\u0440\u0443\u043c\u0438/\u0441\u044a\u043e\u0431\u0449\u0435\u043d\u0438\u044f
widget_title=\u0414\u0438\u0441\u043a\u0443\u0441\u0438\u0438
3 changes: 0 additions & 3 deletions webcomponents/bundle/src/main/bundle/forums_ca.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
syn_options=Opcions
syn_hide=No ho mostris
sort_by_messages_tooltip=Ordena per nombre de missatges
syn_private_heading=Missatges nous
sort_by_forums_tooltip=Ordena per nombre de missatges al f\u00f2rum
syn_discussion_heading=Nous missatges al debat
sort_by_site_tooltip=Ordena per nom d\u2019espai
syn_site_heading=Espai
syn_hide_tooltip=Amaga aquest espai de la vista de f\u00f2rums/missatges
widget_title=Debat
3 changes: 0 additions & 3 deletions webcomponents/bundle/src/main/bundle/forums_eu.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
syn_options=Aukerak
syn_hide=Ez erakutsi
sort_by_messages_tooltip=Ordenatu mezuen zenbakiekin
syn_private_heading=Email berriak
sort_by_forums_tooltip=Ordenatu foroko sarreren zenbakiekin
syn_discussion_heading=Foroetan berriak
sort_by_site_tooltip=Ordenatu guneko tituluarekin
syn_site_heading=Gunea
syn_hide_tooltip=Ezkutatu gune hau foro/mezuen bistatik
widget_title=Foroak
3 changes: 0 additions & 3 deletions webcomponents/bundle/src/main/bundle/forums_ro_RO.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
syn_options=Optiuni
syn_hide=Nu afisa
sort_by_messages_tooltip=Sortati dupa numar mesaj
syn_private_heading=Mesaje noi
sort_by_forums_tooltip=Sortati dupa numarul de postari forum
syn_discussion_heading=Nou \u00een discu\u021bii
sort_by_site_tooltip=Sortati dupa titlul siteului
syn_site_heading=Site
syn_hide_tooltip=Ascunde acest site din vizualizarea acestui forum/mesaj
widget_title=Discutii
Loading

0 comments on commit aa8e776

Please sign in to comment.