diff --git a/src/main/java/ru/ulstu/activity/controller/ActivityController.java b/src/main/java/ru/ulstu/activity/controller/ActivityController.java new file mode 100644 index 0000000..3aaf43e --- /dev/null +++ b/src/main/java/ru/ulstu/activity/controller/ActivityController.java @@ -0,0 +1,17 @@ +package ru.ulstu.activity.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import ru.ulstu.activity.service.ActivityService; + +@Controller() +@RequestMapping(value = "/activities") +public class ActivityController { + private ActivityService activityService; + + public ActivityController(ActivityService activityService) { + this.activityService = activityService; + } + + +} diff --git a/src/main/java/ru/ulstu/activity/model/Activity.java b/src/main/java/ru/ulstu/activity/model/Activity.java new file mode 100644 index 0000000..3c5e3e0 --- /dev/null +++ b/src/main/java/ru/ulstu/activity/model/Activity.java @@ -0,0 +1,81 @@ +package ru.ulstu.activity.model; + +import org.springframework.format.annotation.DateTimeFormat; +import ru.ulstu.core.model.BaseEntity; +import ru.ulstu.user.model.User; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Date; + +@Entity +@Table(name = "activity") +public class Activity extends BaseEntity { + + public enum ActivityState { + TOOK_IN_WORK("Взято в работу"), + COMPLETED("Выполнено"); + + private String statusName; + + ActivityState(String statusName) { + this.statusName = statusName; + } + + public String getStatusName() { + return this.statusName; + } + } + + @ManyToOne() + @JoinColumn(name = "user_id") + private User user; + + @Temporal(value = TemporalType.TIMESTAMP) + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date date; + + @Enumerated(value = EnumType.STRING) + @Column(name = "state") + private ActivityState activityState; + + public Activity(User user, ActivityState activityState) { + this.user = user; + this.date = new Date(); + this.activityState = activityState; + } + + public Activity() { + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public ActivityState getActivityState() { + return activityState; + } + + public void setActivityState(ActivityState activityState) { + this.activityState = activityState; + } +} diff --git a/src/main/java/ru/ulstu/activity/model/ActivityElement.java b/src/main/java/ru/ulstu/activity/model/ActivityElement.java new file mode 100644 index 0000000..17fecce --- /dev/null +++ b/src/main/java/ru/ulstu/activity/model/ActivityElement.java @@ -0,0 +1,38 @@ +package ru.ulstu.activity.model; + +public class ActivityElement { + private int startedCount = 0; + private int completedCount = 0; + + public ActivityElement() { + } + + public ActivityElement(int startedCount, int completedCount) { + this.startedCount = startedCount; + this.completedCount = completedCount; + } + + public int getStartedCount() { + return startedCount; + } + + public void setStartedCount(int startedCount) { + this.startedCount = startedCount; + } + + public int getCompletedCount() { + return completedCount; + } + + public void setCompletedCount(int completedCount) { + this.completedCount = completedCount; + } + + public void incrementStartedCount() { + this.startedCount++; + } + + public void incrementCompletedCount() { + this.completedCount++; + } +} diff --git a/src/main/java/ru/ulstu/activity/repository/ActivityRepository.java b/src/main/java/ru/ulstu/activity/repository/ActivityRepository.java new file mode 100644 index 0000000..993b339 --- /dev/null +++ b/src/main/java/ru/ulstu/activity/repository/ActivityRepository.java @@ -0,0 +1,19 @@ +package ru.ulstu.activity.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import ru.ulstu.activity.model.Activity; + +import java.util.Date; +import java.util.List; + +public interface ActivityRepository extends JpaRepository { + + @Query("SELECT a FROM Activity a WHERE (:userId IS NULL OR a.user.id = :userId) " + + "AND (CAST(:dateFrom AS date) IS NULL OR :dateFrom < a.date) " + + "AND (CAST(:dateTo AS date) IS NULL OR :dateTo > a.date)") + List getByUserAndDateInterval(@Param("userId") Integer userId, + @Param("dateFrom") Date dateFrom, + @Param("dateTo") Date dateTo); +} diff --git a/src/main/java/ru/ulstu/activity/service/ActivityService.java b/src/main/java/ru/ulstu/activity/service/ActivityService.java new file mode 100644 index 0000000..980d272 --- /dev/null +++ b/src/main/java/ru/ulstu/activity/service/ActivityService.java @@ -0,0 +1,56 @@ +package ru.ulstu.activity.service; + +import org.springframework.stereotype.Service; +import ru.ulstu.activity.model.Activity; +import ru.ulstu.activity.model.ActivityElement; +import ru.ulstu.activity.repository.ActivityRepository; +import ru.ulstu.user.model.User; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class ActivityService { + private ActivityRepository activityRepository; + + public ActivityService(ActivityRepository activityRepository) { + this.activityRepository = activityRepository; + } + + public void createActivity(List users, Activity.ActivityState state) { + List activities = new ArrayList<>(); + for (User user : users) { + activities.add(new Activity(user, state)); + } + activityRepository.save(activities); + } + + public Map getUsersActivity(Integer userId, Date dateFrom, Date dateTo) { + List activities = activityRepository.getByUserAndDateInterval(userId, dateFrom, dateTo); + Map dateActivities = new HashMap<>(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + for (Activity activity : activities) { + String dt = formatter.format(activity.getDate()); + ActivityElement element; + if (!dateActivities.containsKey(dt)) { + element = new ActivityElement(); + } else { + element = dateActivities.get(dt); + } + switch (activity.getActivityState()) { + case TOOK_IN_WORK: + element.incrementStartedCount(); + break; + case COMPLETED: + element.incrementCompletedCount(); + break; + } + dateActivities.put(dt, element); + } + return dateActivities; + } +} diff --git a/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java b/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java index 8b6bd9d..e878622 100644 --- a/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java +++ b/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java @@ -14,7 +14,7 @@ public class AuthFailureHandler implements AuthenticationFailureHandler { @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException ex) throws IOException { - if (ex.getClass() == UserBlockedException.class) { + if (ex.getCause() instanceof UserBlockedException) { response.sendRedirect("/users/block"); } } diff --git a/src/main/java/ru/ulstu/grant/model/Grant.java b/src/main/java/ru/ulstu/grant/model/Grant.java index 5b91453..a275b19 100644 --- a/src/main/java/ru/ulstu/grant/model/Grant.java +++ b/src/main/java/ru/ulstu/grant/model/Grant.java @@ -11,6 +11,7 @@ import ru.ulstu.file.model.FileData; import ru.ulstu.paper.model.Paper; import ru.ulstu.project.model.Project; import ru.ulstu.timeline.model.Event; +import ru.ulstu.activity.model.Activity; import ru.ulstu.user.model.User; import javax.persistence.CascadeType; @@ -173,6 +174,17 @@ public class Grant extends BaseEntity implements UserActivity, EventSource { return getAuthors(); } + public Activity.ActivityState getCommonActivityState() { + switch (this.status) { + case IN_WORK: + return Activity.ActivityState.TOOK_IN_WORK; + case COMPLETED: + return Activity.ActivityState.COMPLETED; + default: + return null; + } + } + public User getLeader() { return leader; } diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index 99387c7..1892629 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.Errors; +import ru.ulstu.activity.service.ActivityService; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.file.model.FileDataDto; @@ -26,6 +27,7 @@ import ru.ulstu.user.service.UserService; import java.io.IOException; import java.text.ParseException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; @@ -53,6 +55,7 @@ public class GrantService extends BaseService { private final GrantNotificationService grantNotificationService; private final KiasService kiasService; private final PingService pingService; + private final ActivityService activityService; public GrantService(GrantRepository grantRepository, FileService fileService, @@ -63,7 +66,8 @@ public class GrantService extends BaseService { EventService eventService, GrantNotificationService grantNotificationService, KiasService kiasService, - PingService pingService) { + PingService pingService, + ActivityService activityService) { this.grantRepository = grantRepository; this.kiasService = kiasService; this.baseRepository = grantRepository; @@ -75,6 +79,7 @@ public class GrantService extends BaseService { this.eventService = eventService; this.grantNotificationService = grantNotificationService; this.pingService = pingService; + this.activityService = activityService; } public GrantDto getExistGrantById(Integer id) { @@ -95,6 +100,7 @@ public class GrantService extends BaseService { Grant newGrant = copyFromDto(new Grant(), grantDto); newGrant = grantRepository.save(newGrant); eventService.createFromObject(newGrant, Collections.emptyList(), false, "гранта"); + activityService.createActivity(new ArrayList<>(newGrant.getAuthors()), newGrant.getCommonActivityState()); grantNotificationService.sendCreateNotification(newGrant); return newGrant; } @@ -137,6 +143,7 @@ public class GrantService extends BaseService { Grant grant = findById(grantDto.getId()); Set oldAuthors = new HashSet<>(grant.getAuthors()); User oldLeader = grant.getLeader(); + Grant.GrantStatus oldStatus = grant.getStatus(); for (FileDataDto file : grantDto.getFiles().stream() .filter(f -> f.isDeleted() && f.getId() != null) .collect(toList())) { @@ -158,6 +165,9 @@ public class GrantService extends BaseService { if (grant.getLeader() != oldLeader) { grantNotificationService.sendLeaderChangeNotification(grant, oldLeader); } + if (grant.getStatus() != oldStatus) { + activityService.createActivity(new ArrayList<>(grant.getAuthors()), grant.getCommonActivityState()); + } eventService.updateGrantDeadlines(grant); return grant.getId(); } diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java index 32a1e5e..ccf3289 100644 --- a/src/main/java/ru/ulstu/paper/model/Paper.java +++ b/src/main/java/ru/ulstu/paper/model/Paper.java @@ -11,6 +11,7 @@ import ru.ulstu.deadline.model.Deadline; import ru.ulstu.file.model.FileData; import ru.ulstu.grant.model.Grant; import ru.ulstu.timeline.model.Event; +import ru.ulstu.activity.model.Activity; import ru.ulstu.user.model.User; import javax.persistence.CascadeType; @@ -323,4 +324,15 @@ public class Paper extends BaseEntity implements UserActivity, EventSource { public int hashCode() { return Objects.hash(super.hashCode(), title, status, type, createDate, updateDate, deadlines, comment, url, locked, events, files, authors, latexText, conferences, grants); } + + public Activity.ActivityState getCommonActivityState() { + switch (this.status) { + case ON_PREPARATION: + return Activity.ActivityState.TOOK_IN_WORK; + case COMPLETED: + return Activity.ActivityState.COMPLETED; + default: + return null; + } + } } diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 3be9aee..18fb76f 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -3,6 +3,7 @@ package ru.ulstu.paper.service; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import ru.ulstu.activity.service.ActivityService; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.file.model.FileDataDto; @@ -22,6 +23,7 @@ import ru.ulstu.user.service.UserService; import java.io.IOException; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashSet; @@ -56,6 +58,7 @@ public class PaperService { private final EventService eventService; private final ReferenceRepository referenceRepository; private final PingService pingService; + private final ActivityService activityService; public PaperService(PaperRepository paperRepository, ReferenceRepository referenceRepository, @@ -64,7 +67,8 @@ public class PaperService { UserService userService, DeadlineService deadlineService, EventService eventService, - PingService pingService) { + PingService pingService, + ActivityService activityService) { this.paperRepository = paperRepository; this.referenceRepository = referenceRepository; this.fileService = fileService; @@ -73,6 +77,7 @@ public class PaperService { this.deadlineService = deadlineService; this.eventService = eventService; this.pingService = pingService; + this.activityService = activityService; } public List findAll() { @@ -201,6 +206,7 @@ public class PaperService { if (paper.getStatus() != oldStatus) { paperNotificationService.statusChangeNotification(paper, oldStatus); + activityService.createActivity(new ArrayList<>(paper.getAuthors()), paper.getCommonActivityState()); } return paper.getId(); @@ -241,7 +247,9 @@ public class PaperService { paper = paperRepository.save(paper); paperNotificationService.sendCreateNotification(paper); + eventService.createFromPaper(paper); + activityService.createActivity(new ArrayList<>(paper.getAuthors()), paper.getCommonActivityState()); return paper; } diff --git a/src/main/java/ru/ulstu/project/model/Project.java b/src/main/java/ru/ulstu/project/model/Project.java index 6c60052..224c91e 100644 --- a/src/main/java/ru/ulstu/project/model/Project.java +++ b/src/main/java/ru/ulstu/project/model/Project.java @@ -10,6 +10,7 @@ import ru.ulstu.deadline.model.Deadline; import ru.ulstu.file.model.FileData; import ru.ulstu.grant.model.Grant; import ru.ulstu.timeline.model.Event; +import ru.ulstu.activity.model.Activity; import ru.ulstu.user.model.User; import javax.persistence.CascadeType; @@ -106,6 +107,17 @@ public class Project extends BaseEntity implements UserActivity, EventSource { event.setProject(this); } + public Activity.ActivityState getCommonActivityState() { + switch (this.status) { + case IN_WORK: + return Activity.ActivityState.TOOK_IN_WORK; + case CLOSED: + return Activity.ActivityState.COMPLETED; + default: + return null; + } + } + public void setTitle(String title) { this.title = title; } diff --git a/src/main/java/ru/ulstu/project/service/ProjectService.java b/src/main/java/ru/ulstu/project/service/ProjectService.java index 699e241..92340c7 100644 --- a/src/main/java/ru/ulstu/project/service/ProjectService.java +++ b/src/main/java/ru/ulstu/project/service/ProjectService.java @@ -3,6 +3,7 @@ package ru.ulstu.project.service; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.thymeleaf.util.StringUtils; +import ru.ulstu.activity.service.ActivityService; import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.file.model.FileDataDto; import ru.ulstu.file.service.FileService; @@ -17,6 +18,7 @@ import ru.ulstu.user.model.User; import ru.ulstu.user.service.UserService; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -37,14 +39,15 @@ public class ProjectService { private final EventService eventService; private final UserService userService; private final PingService pingService; - + private final ActivityService activityService; public ProjectService(ProjectRepository projectRepository, DeadlineService deadlineService, GrantRepository grantRepository, FileService fileService, EventService eventService, UserService userService, - PingService pingService) { + PingService pingService, + ActivityService activityService) { this.projectRepository = projectRepository; this.deadlineService = deadlineService; this.grantRepository = grantRepository; @@ -52,6 +55,7 @@ public class ProjectService { this.eventService = eventService; this.userService = userService; this.pingService = pingService; + this.activityService = activityService; } public List findAll() { @@ -77,12 +81,17 @@ public class ProjectService { Project newProject = copyFromDto(new Project(), projectDto); newProject = projectRepository.save(newProject); eventService.createFromObject(newProject, Collections.emptyList(), false, "проекта"); + activityService.createActivity(new ArrayList<>(newProject.getExecutors()), newProject.getCommonActivityState()); + return newProject; } @Transactional public Project update(ProjectDto projectDto) throws IOException { Project project = projectRepository.findOne(projectDto.getId()); + if (project.getStatus() != projectDto.getStatus()) { + activityService.createActivity(new ArrayList<>(project.getExecutors()), project.getCommonActivityState()); + } projectRepository.save(copyFromDto(project, projectDto)); eventService.updateProjectDeadlines(project); for (FileDataDto file : projectDto.getFiles().stream() diff --git a/src/main/java/ru/ulstu/user/controller/UserController.java b/src/main/java/ru/ulstu/user/controller/UserController.java index d080d54..2fdec8e 100644 --- a/src/main/java/ru/ulstu/user/controller/UserController.java +++ b/src/main/java/ru/ulstu/user/controller/UserController.java @@ -2,6 +2,7 @@ package ru.ulstu.user.controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import ru.ulstu.activity.service.ActivityService; import ru.ulstu.configuration.Constants; import ru.ulstu.core.model.response.PageableItems; import ru.ulstu.core.model.response.Response; @@ -19,6 +21,7 @@ import ru.ulstu.odin.controller.OdinController; import ru.ulstu.odin.model.OdinMetadata; import ru.ulstu.odin.model.OdinVoid; import ru.ulstu.odin.service.OdinService; +import ru.ulstu.activity.model.ActivityElement; import ru.ulstu.user.model.User; import ru.ulstu.user.model.UserDto; import ru.ulstu.user.model.UserListDto; @@ -32,6 +35,8 @@ import ru.ulstu.user.service.UserSessionService; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.validation.Valid; + +import java.util.Date; import java.util.Map; import static ru.ulstu.user.controller.UserController.URL; @@ -55,16 +60,19 @@ public class UserController extends OdinController { private final UserSessionService userSessionService; private final OdinService odinRolesService; private final OdinService odinSessionsService; + private final ActivityService activityService; public UserController(UserService userService, UserSessionService userSessionService, OdinService odinRolesService, - OdinService odinSessionsService) { + OdinService odinSessionsService, + ActivityService activityService) { super(UserListDto.class, UserDto.class); this.userService = userService; this.userSessionService = userSessionService; this.odinRolesService = odinRolesService; this.odinSessionsService = odinSessionsService; + this.activityService = activityService; } @GetMapping(ROLES_URL) @@ -180,4 +188,11 @@ public class UserController extends OdinController { public void blockUser(@RequestParam("userId") Integer userId) { userService.blockUser(userId); } + + @GetMapping("/activities") + public Response> getActivitiesList(@RequestParam("userId") Integer userId, + @RequestParam("dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom, + @RequestParam("dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo) { + return new Response<>(activityService.getUsersActivity(userId, dateFrom, dateTo)); + } } diff --git a/src/main/java/ru/ulstu/user/controller/UserMvcController.java b/src/main/java/ru/ulstu/user/controller/UserMvcController.java index bf84176..49ef5e3 100644 --- a/src/main/java/ru/ulstu/user/controller/UserMvcController.java +++ b/src/main/java/ru/ulstu/user/controller/UserMvcController.java @@ -78,4 +78,8 @@ public class UserMvcController extends OdinController { @GetMapping("/block") public void getBlock() { } + + @GetMapping("/activities") + public void getActivities() { + } } diff --git a/src/main/java/ru/ulstu/user/service/UserService.java b/src/main/java/ru/ulstu/user/service/UserService.java index bbac124..0145182 100644 --- a/src/main/java/ru/ulstu/user/service/UserService.java +++ b/src/main/java/ru/ulstu/user/service/UserService.java @@ -42,6 +42,7 @@ import ru.ulstu.user.model.UserResetPasswordDto; import ru.ulstu.user.model.UserRole; import ru.ulstu.user.model.UserRoleConstants; import ru.ulstu.user.model.UserRoleDto; +import ru.ulstu.activity.repository.ActivityRepository; import ru.ulstu.user.repository.UserRepository; import ru.ulstu.user.repository.UserRoleRepository; import ru.ulstu.user.util.UserUtils; @@ -78,6 +79,7 @@ public class UserService implements UserDetailsService { private final TimetableService timetableService; private final ConferenceService conferenceService; private final UserSessionService userSessionService; + private final ActivityRepository activityRepository; private final PingService pingService; public UserService(UserRepository userRepository, @@ -88,7 +90,8 @@ public class UserService implements UserDetailsService { ApplicationProperties applicationProperties, @Lazy PingService pingService, @Lazy ConferenceService conferenceRepository, - @Lazy UserSessionService userSessionService) throws ParseException { + @Lazy UserSessionService userSessionService, + ActivityRepository activityRepository) throws ParseException { this.userRepository = userRepository; this.passwordEncoder = passwordEncoder; this.userRoleRepository = userRoleRepository; @@ -98,6 +101,7 @@ public class UserService implements UserDetailsService { this.conferenceService = conferenceRepository; this.timetableService = new TimetableService(); this.userSessionService = userSessionService; + this.activityRepository = activityRepository; this.pingService = pingService; } diff --git a/src/main/resources/db/changelog-20190603_000002-schema.xml b/src/main/resources/db/changelog-20190603_000002-schema.xml new file mode 100644 index 0000000..8ff0184 --- /dev/null +++ b/src/main/resources/db/changelog-20190603_000002-schema.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/src/main/resources/db/changelog-master.xml b/src/main/resources/db/changelog-master.xml index afcf8c9..4a5e1b2 100644 --- a/src/main/resources/db/changelog-master.xml +++ b/src/main/resources/db/changelog-master.xml @@ -54,4 +54,5 @@ + \ No newline at end of file diff --git a/src/main/resources/public/js/users.js b/src/main/resources/public/js/users.js index 0f8d1c0..b5aef4e 100644 --- a/src/main/resources/public/js/users.js +++ b/src/main/resources/public/js/users.js @@ -170,4 +170,39 @@ function drawChart() { showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING) } }) +} + +function drawActivitiesChart() { + userId = $('#author :selected').val() + dateFrom = $('#dateFrom').val() + dateTo = $('#dateTo').val() + + $.ajax({ + url:`/api/1.0/users/activities?userId=${userId}&dateFrom=${dateFrom}&dateTo=${dateTo}`, + contentType: "application/json; charset=utf-8", + method: "GET", + success: function(response) { + if (response.data.length == 0) { + return; + } + kk = response.data; + array = [['Активности', 'Количество начатых', 'Количество законченных']] + + Object.keys(response.data).forEach(function(key) { + console.table('Key : ' + key + ', Value : ' + response.data[key]) + array.push([key, response.data[key]['startedCount'], response.data[key]['completedCount']]) + }) + var data = google.visualization.arrayToDataTable(array); + var options = { + title: 'Активности', + is3D: true, + pieResidueSliceLabel: 'Остальное' + }; + var chart = new google.visualization.ColumnChart(document.getElementById('air')); + chart.draw(data, options); + }, + error: function(errorData) { + showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING) + } + }) } \ No newline at end of file diff --git a/src/main/resources/templates/users/activities.html b/src/main/resources/templates/users/activities.html new file mode 100644 index 0000000..33fc831 --- /dev/null +++ b/src/main/resources/templates/users/activities.html @@ -0,0 +1,46 @@ + + + + + + + + + + + +
+
+
+
+
+

Активность пользователей

+
+
+
+
+
Фильтр:
+ +
+ + +
+
+
+
+ +
+
+ +