// GET: /Dashboard public ViewResult Dashboard() { DashboardViewModel dashboard = new DashboardViewModel(); //active projects dashboard.ActiveProjects = db.GetMyProjects(User).ToList().Where(p => p.IsActive); //active tasks dashboard.ActiveTasks = db.GetMyTasks(User).ToList().Where(t => t.IsActive); //active actions dashboard.ActiveActions = db.GetMyActions(User).ToList().Where(a => a.IsActive); //completed pomodoros dashboard.CompletedPomodoros = db.GetMyPomodoros(User).ToList().Where(p => p.Status == PomodoroStatus.Completed); //last active actions dashboard.LastActiveActions = new PomodoroContainerDateViewModel { HeaderTitle = "Last Active Actions", TableId = "last-active-actions", IconCssClass = "fa-play", ReportTypeDate = ReportTypeDate.LastPomodoro, RowsPerPage = 5, Type = PomodoroContainerType.Action, Items = db.GetMyPomodoros(User) .Where(pm => pm.Status == PomodoroStatus.Completed && pm.Start.HasValue) .Select(pm => pm.Action) .Distinct().ToList() .OrderByDescending(a => a.LastPomodoro.Start.Value) .Take(20) }; //last active tasks dashboard.LastActiveTasks = new PomodoroContainerDateViewModel { HeaderTitle = "Last Active Tasks", TableId = "last-active-tasks", IconCssClass = "fa-play-circle", ReportTypeDate = ReportTypeDate.LastPomodoro, RowsPerPage = 5, Type = PomodoroContainerType.Task, Items = db.GetMyPomodoros(User) .Where(pm => pm.Status == PomodoroStatus.Completed && pm.Start.HasValue) .Select(pm => pm.Action.Task) .Distinct().ToList() .OrderByDescending(t => t.LastPomodoro.Start.Value) .Take(20) }; //upcoming deadlines (actions) dashboard.UpcomingDeadlines = new PomodoroContainerDateViewModel { HeaderTitle = "Upcoming Deadlines", TableId = "upcoming-deadlines", IconCssClass = "fa-clock-o", ReportTypeDate = ReportTypeDate.NextDeadline, RowsPerPage = 5, Type = PomodoroContainerType.Action, Items = db.GetMyActions(User) .Where(a => a.Status == Status.Active && a.Deadline.HasValue) .ToList() .OrderBy(a => a.NextDeadline.Value) .Take(20) }; ////upcoming planified work (actions) //dashboard.UpcomingPlanifiedActions = new PomodoroContainerDateViewModel //{ // HeaderTitle = "Upcoming Planified Actions", // TableId = "upcoming-planified-actions", // IconCssClass = "fa-calendar", // ReportTypeDate = ReportTypeDate.NextPlanifiedPomodoro, // RowsPerPage = 5, // Items = db.GetMyPomodoros(User).ToList() // .Where(pm => pm.CalculatedStatus == PomodoroCalculatedStatus.Planified && pm.Start.HasValue) // .Select(pm => pm.Action) // .Distinct().ToList() // .OrderBy(a => a.NextPlanifiedPomodoro.Start.Value) // .Take(20) //}; //last active actions dashboard.LastCreatedActions = new PomodoroContainerDateViewModel { HeaderTitle = "Last Created Actions", TableId = "last-created-actions", IconCssClass = "fa-plus-circle", ReportTypeDate = ReportTypeDate.LastCreationDate, RowsPerPage = 5, Type = PomodoroContainerType.Action, Items = db.GetMyActions(User) .Where(a => a.CreationDate.HasValue) .ToList() .OrderByDescending(a => a.CreationDateLocal.Value) .Take(20) }; //work amount (line-chart) dashboard.WorkAmountChartViewModel = new MorrisLineChartViewModel { HeaderTitle = "Work Amount", Dates = db.GetMyPomodoros(User).ToList() .Where(p => p.Start.HasValue && p.CalculatedStatus == LoggableItemCalculatedStatus.Completed) .Select(p => p.StartLocal.Value).AsEnumerable(), Interval = DateInterval.Monthly, Label = "Work units", HtmlElementId = "work-amount" }; dashboard.WorkDivisionViewModel = new MorrisDonutChartViewModel { HeaderTitle = "Work Division", Items = db.GetMyProjects(User) .AsEnumerable() .OrderByDescending(p => p.CompletedPomodorosCount), HtmlElementId = "work-division" }; dashboard.MyWorkspace = db.GetMyWorkspace(User); //dashboard.WorkDivisionViewModels = new List<MorrisDonutChartViewModel> { // //work project division (donut chart) // new MorrisDonutChartViewModel // { // HeaderTitle = "Projects", // Items = db.GetMyProjects(User), // HtmlElementId = "project-chart" // }, // //work task division (donut chart) // new MorrisDonutChartViewModel // { // HeaderTitle = "Tasks", // Items = db.GetMyTasks(User), // HtmlElementId = "task-chart", // UseFullPathItemName = true // } //}; return(View(dashboard)); }