1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.mydashboard.modules.gru.web;
35
36 import fr.paris.lutece.plugins.mydashboard.modules.gru.business.Mail;
37 import fr.paris.lutece.plugins.mydashboard.modules.gru.service.IMailService;
38 import fr.paris.lutece.plugins.mydashboard.modules.gru.service.MokeMailService;
39 import fr.paris.lutece.plugins.mydashboard.service.MyDashboardComponent;
40 import fr.paris.lutece.portal.service.i18n.I18nService;
41 import fr.paris.lutece.portal.service.security.LuteceUser;
42 import fr.paris.lutece.portal.service.security.SecurityService;
43 import fr.paris.lutece.portal.service.template.AppTemplateService;
44 import fr.paris.lutece.portal.web.l10n.LocaleService;
45 import fr.paris.lutece.util.html.HtmlTemplate;
46
47 import java.util.HashMap;
48 import java.util.List;
49 import java.util.Locale;
50 import java.util.Map;
51
52 import javax.servlet.http.HttpServletRequest;
53
54
55
56
57
58 public class MyDashboardMailsComponent extends MyDashboardComponent
59 {
60 private static final String DASHBOARD_COMPONENT_ID = "mydashboard-gru.mailsComponent";
61 private static final String MESSAGE_DASHBOARD_COMPONENT_DESCRIPTION = "module.mydashboard.gru.component.mails.description";
62 private static final String TEMPLATE_DASHBOARD_COMPONENT = "skin/plugins/mydashboard/modules/gru/mails_component.html";
63 private static final String MARK_BILLS_LIST = "mails_list";
64
65
66
67 private static IMailService _billService = new MokeMailService();
68
69 @Override
70 public String getDashboardData( HttpServletRequest request )
71 {
72 LuteceUser user = SecurityService.getInstance().getRegisteredUser(request);
73 List<Mail> listMails = _billService.getMails( user );
74 Map<String, Object> model = new HashMap<String, Object>( );
75 model.put( MARK_BILLS_LIST, listMails );
76 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_DASHBOARD_COMPONENT,
77 LocaleService.getDefault( ), model );
78
79 return template.getHtml( );
80 }
81
82 @Override
83 public String getComponentId( )
84 {
85 return DASHBOARD_COMPONENT_ID;
86 }
87
88 @Override
89 public String getComponentDescription( Locale locale )
90 {
91 return I18nService.getLocalizedString( MESSAGE_DASHBOARD_COMPONENT_DESCRIPTION, locale );
92 }
93 }