Search in sources :

Example 1 with Dashboard

use of org.hisp.dhis.webapi.webdomain.user.Dashboard in project dhis2-core by dhis2.

the class MeController method getDashboard.

@RequestMapping(value = "/dashboard")
@ResponseBody
public Dashboard getDashboard(HttpServletResponse response) throws Exception {
    User currentUser = currentUserService.getCurrentUser();
    if (currentUser == null) {
        throw new NotAuthenticatedException();
    }
    Dashboard dashboard = new Dashboard();
    dashboard.setUnreadMessageConversations(messageService.getUnreadMessageConversationCount());
    dashboard.setUnreadInterpretations(interpretationService.getNewInterpretationCount());
    return dashboard;
}
Also used : NotAuthenticatedException(org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException) Dashboard(org.hisp.dhis.webapi.webdomain.user.Dashboard)

Example 2 with Dashboard

use of org.hisp.dhis.webapi.webdomain.user.Dashboard in project dhis2-core by dhis2.

the class CurrentUserController method getDashboard.

@RequestMapping(value = "/dashboard", produces = { "application/json", "text/*" })
public void getDashboard(HttpServletResponse response) throws Exception {
    User currentUser = currentUserService.getCurrentUser();
    if (currentUser == null) {
        throw new NotAuthenticatedException();
    }
    Dashboard dashboard = new Dashboard();
    dashboard.setUnreadMessageConversations(messageService.getUnreadMessageConversationCount());
    dashboard.setUnreadInterpretations(interpretationService.getNewInterpretationCount());
    response.setContentType(MediaType.APPLICATION_JSON_VALUE);
    renderService.toJson(response.getOutputStream(), dashboard);
}
Also used : User(org.hisp.dhis.user.User) NotAuthenticatedException(org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException) Dashboard(org.hisp.dhis.webapi.webdomain.user.Dashboard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Dashboard

use of org.hisp.dhis.webapi.webdomain.user.Dashboard in project dhis2-core by dhis2.

the class CurrentUserController method getDashboards.

@RequestMapping(value = "/dashboards", produces = { "application/json", "text/*" })
public void getDashboards(HttpServletResponse response) throws NotAuthenticatedException, IOException {
    User user = currentUserService.getCurrentUser();
    if (user == null) {
        throw new NotAuthenticatedException();
    }
    List<org.hisp.dhis.dashboard.Dashboard> dashboards = Lists.newArrayList(manager.getAll(org.hisp.dhis.dashboard.Dashboard.class));
    for (org.hisp.dhis.dashboard.Dashboard dashboard : dashboards) {
        dashboard.setAccess(aclService.getAccess(dashboard, user));
        for (DashboardItem dashboardItem : dashboard.getItems()) {
            dashboardItem.setAccess(aclService.getAccess(dashboardItem, user));
        }
    }
    response.setContentType(MediaType.APPLICATION_JSON_VALUE);
    renderService.toJson(response.getOutputStream(), dashboards);
}
Also used : User(org.hisp.dhis.user.User) NotAuthenticatedException(org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException) Dashboard(org.hisp.dhis.webapi.webdomain.user.Dashboard) DashboardItem(org.hisp.dhis.dashboard.DashboardItem) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

NotAuthenticatedException (org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException)3 Dashboard (org.hisp.dhis.webapi.webdomain.user.Dashboard)3 User (org.hisp.dhis.user.User)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DashboardItem (org.hisp.dhis.dashboard.DashboardItem)1