Skip to content

Commit

Permalink
SAK-43732 Add new UI dashboard tool (sakaiproject#8466)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Aug 26, 2020
1 parent 7a53cce commit 141cbf5
Show file tree
Hide file tree
Showing 165 changed files with 19,648 additions and 4,207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,15 @@ perm-annc.delete.any=Delete all announcements
perm-annc.delete.own=Delete own announcements
perm-annc.read.drafts=Read all draft announcements
perm-annc.all.groups=Access all group announcements

## Dashboard widget i18n
#title=Announcements
viewing=(viewing announcements from the last 10 days)
site=Site
search=Search
title=Title
site=Site
view=View
sort_by_title_tooltip=Sort by title
sort_by_site_tooltip=Sort by title
widget_title=Announcements
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package org.sakaiproject.announcement.api;

import java.util.List;
import java.util.Map;

import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.entity.api.Reference;
Expand Down Expand Up @@ -196,5 +197,6 @@ public AnnouncementChannelEdit addAnnouncementChannel(String ref) throws IdUsedE
* @exception NullPointerException
*/
public List getMessages(String channelReference, Filter filter, boolean order, boolean merged) throws IdUnusedException, PermissionException, NullPointerException;


public Map<String, List<AnnouncementMessage>> getAllAnnouncementsForCurrentUser();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
// import
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;

import lombok.Setter;
Expand All @@ -33,6 +35,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import org.sakaiproject.announcement.api.AnnouncementMessage;
import org.sakaiproject.authz.api.AuthzGroup;
import org.sakaiproject.authz.api.GroupNotDefinedException;
import org.sakaiproject.authz.api.Role;
Expand Down Expand Up @@ -290,7 +293,7 @@ public Message getMessage(MessageChannel channel, String id)
return (Message) super.getResource(channel, id);
}

public List getMessages(MessageChannel channel)
public List<AnnouncementMessage> getMessages(MessageChannel channel)
{
return super.getAllResources(channel);
}
Expand Down Expand Up @@ -599,4 +602,21 @@ protected boolean getPubView(String ref)
return false;
}
}

public Map<String, List<AnnouncementMessage>> getAllAnnouncementsForCurrentUser() {

Map<String, List<AnnouncementMessage>> allAnnouncements = new HashMap<>();

// First grab all the current user's sites
m_siteService.getUserSites().forEach(site -> {

String channelRef = channelReference(site.getId(), "main");
try {
allAnnouncements.put(site.getId(), (List<AnnouncementMessage>) getMessages(channelRef, null, true, true));
} catch (Exception e) {
}
});

return allAnnouncements;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public final class AssignmentConstants {
/**
* Calendar event field for assignment due dates
*/
public static final String NEW_ASSIGNMENT_DUEDATE_CALENDAR_ASSIGNMENT_ID = "new_assignment_duedate_calendar_assignment_id";
public static final String NEW_ASSIGNMENT_DUE_DATE_SCHEDULED = "new_assignment_due_date_scheduled";
public static final String NEW_ASSIGNMENT_OPEN_DATE_ANNOUNCED = "new_assignment_open_date_announced";
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,8 @@ public interface AssignmentService extends EntityProducer {
/**
* Creates and adds a new Assignment to the service.
*
* @param context -
* Describes the portlet context - generated with DefaultId.getChannel().
* @return AssignmentEdit The new Assignment object.
* @param context The site id for this assignment
* @return Assignment The new Assignment object, ready for editing.
* @throws IdInvalidException if the id contains prohibited characers.
* @throws IdUsedException if the id is already used in the service.
* @throws PermissionException if current User does not have permission to do this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
import org.sakaiproject.site.api.ToolConfiguration;
import org.sakaiproject.taggable.api.TaggingManager;
import org.sakaiproject.taggable.api.TaggingProvider;
import org.sakaiproject.tasks.api.Priorities;
import org.sakaiproject.tasks.api.Task;
import org.sakaiproject.tasks.api.TaskService;
import org.sakaiproject.time.api.TimeService;
import org.sakaiproject.time.api.UserTimeService;
import org.sakaiproject.tool.api.SessionManager;
Expand Down Expand Up @@ -234,6 +237,7 @@ public class AssignmentServiceImpl implements AssignmentService, EntityTransferr
@Setter private ServerConfigurationService serverConfigurationService;
@Setter private SiteService siteService;
@Setter private TaggingManager taggingManager;
@Setter private TaskService taskService;
@Setter private TimeService timeService;
@Setter private ToolManager toolManager;
@Setter private UserDirectoryService userDirectoryService;
Expand Down Expand Up @@ -1025,6 +1029,8 @@ public void softDeleteAssignment(Assignment assignment) throws PermissionExcepti
throw new PermissionException(sessionManager.getCurrentSessionUserId(), SECURE_REMOVE_ASSIGNMENT, null);
}

taskService.removeTaskByReference(reference);

assignmentDueReminderService.removeScheduledReminder(assignment.getId());
assignmentRepository.softDeleteAssignment(assignment.getId());

Expand Down Expand Up @@ -1254,6 +1260,16 @@ public void updateAssignment(Assignment assignment) throws PermissionException {
assignment.setModifier(sessionManager.getCurrentSessionUserId());
assignmentRepository.merge(assignment);

Task task = new Task();
task.setSiteId(assignment.getContext());
task.setReference(reference);
task.setSystem(true);
task.setDescription(assignment.getTitle());
task.setDue(assignment.getDueDate());
taskService.createTask(task, allowAddSubmissionUsers(reference)
.stream().map(User::getId).collect(Collectors.toSet()),
Priorities.HIGH);

eventTrackingService.post(eventTrackingService.newEvent(AssignmentConstants.EVENT_UPDATE_ASSIGNMENT, reference, true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.sakaiproject.service.gradebook.shared.GradebookService;
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.springframework.orm.hibernate.AdditionalHibernateMappings;
import org.sakaiproject.tasks.api.TaskService;
import org.sakaiproject.taggable.api.TaggingManager;
import org.sakaiproject.time.api.TimeService;
import org.sakaiproject.time.api.UserTimeService;
Expand Down Expand Up @@ -321,4 +322,9 @@ public SearchIndexBuilder searchIndexBuilder() {
public TransactionTemplate transactionTemplate() {
return mock(TransactionTemplate.class);
}

@Bean(name = "org.sakaiproject.tasks.api.TaskService")
public TaskService taskService() {
return mock(TaskService.class);
}
}
1 change: 1 addition & 0 deletions assignment/impl/src/webapp/WEB-INF/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<property name="serverConfigurationService" ref="org.sakaiproject.component.api.ServerConfigurationService"/>
<property name="siteService" ref="org.sakaiproject.site.api.SiteService"/>
<property name="taggingManager" ref="org.sakaiproject.taggable.api.TaggingManager"/>
<property name="taskService" ref="org.sakaiproject.tasks.api.TaskService"/>
<property name="toolManager" ref="org.sakaiproject.tool.api.ToolManager"/>
<property name="userDirectoryService" ref="org.sakaiproject.user.api.UserDirectoryService"/>
<property name="userTimeService" ref="org.sakaiproject.time.api.UserTimeService"/>
Expand Down
4 changes: 4 additions & 0 deletions assignment/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<groupId>org.sakaiproject.calendar</groupId>
<artifactId>sakai-calendar-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.calendar</groupId>
<artifactId>sakai-calendar-util</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.edu-services.gradebook</groupId>
<artifactId>gradebook-service-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import static org.sakaiproject.assignment.api.model.Assignment.GradeType.UNGRADED_GRADE_TYPE;
import static org.sakaiproject.assignment.api.model.Assignment.GradeType.values;

import org.sakaiproject.util.CalendarUtil;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -8688,7 +8690,7 @@ private void addAssignmentIdToCalendar(Assignment assignment, Calendar c, Calend
if (c != null && e != null && assignment != null) {
CalendarEventEdit edit = c.getEditEvent(e.getId(), org.sakaiproject.calendar.api.CalendarService.EVENT_ADD_CALENDAR);

edit.setField(AssignmentConstants.NEW_ASSIGNMENT_DUEDATE_CALENDAR_ASSIGNMENT_ID, assignment.getId());
edit.setField(CalendarUtil.NEW_ASSIGNMENT_DUEDATE_CALENDAR_ASSIGNMENT_ID, assignment.getId());
edit.setField(AssignmentConstants.NEW_ASSIGNMENT_OPEN_DATE_ANNOUNCED, assignmentService.getUsersLocalDateTimeString(assignment.getOpenDate()));

c.commitEvent(edit);
Expand Down
4 changes: 4 additions & 0 deletions calendar/calendar-bundles/resources/calendar.properties
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,7 @@ perm-calendar.read=View events
perm-calendar.all.groups=Access/create group events
perm-calendar.options=Change calendar options
perm-calendar.view.audience=View event audience

## Dashboard widget
widget_title=Calendar
events_for=Events for
5 changes: 5 additions & 0 deletions dashboard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Sakai Dashboard Tool

Displays a set of widgets containing information about your Sakai sites. The home dashboard widgets
work in an aggregating way, showing you information from across all your sites. The site dashboard
shows you just the information for that site.
42 changes: 42 additions & 0 deletions dashboard/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.sakaiproject</groupId>
<artifactId>master</artifactId>
<version>21-SNAPSHOT</version>
<relativePath>../master/pom.xml</relativePath>
</parent>

<groupId>org.sakaiproject.dashboard</groupId>
<artifactId>sakai-dashboard-base</artifactId>
<version>21-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>tool</module>
</modules>

<name>sakai-dashboard-base</name>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>

</project>
75 changes: 75 additions & 0 deletions dashboard/tool/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sakaiproject.dashboard</groupId>
<artifactId>sakai-dashboard-base</artifactId>
<version>21-SNAPSHOT</version>
</parent>

<artifactId>sakai-dashboard-tool</artifactId>
<packaging>war</packaging>

<name>sakai-dashboard-tool</name>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
</properties>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-component-manager</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-util</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.portal</groupId>
<artifactId>sakai-portal-util</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<scope>compile</scope>
</dependency>
<!-- thymeleaf template engine -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit 141cbf5

Please sign in to comment.