Revision 49691
Added by Antonis Lempesis over 6 years ago
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/helpadmin/HelpAdminWidget.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.client.helpadmin; |
|
2 |
|
|
3 |
import com.google.gwt.core.client.GWT; |
|
4 |
import com.google.gwt.dom.client.Document; |
|
5 |
import com.google.gwt.event.dom.client.ClickEvent; |
|
6 |
import com.google.gwt.event.dom.client.ClickHandler; |
|
7 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
|
8 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
9 |
import com.google.gwt.user.client.ui.HTML; |
|
10 |
import com.google.gwt.user.client.ui.Widget; |
|
11 |
import eu.dnetlib.gwt.client.help.AdminWidget; |
|
12 |
import eu.dnetlib.gwt.client.help.HelpService; |
|
13 |
import eu.dnetlib.gwt.client.help.HelpServiceAsync; |
|
14 |
import eu.dnetlib.gwt.shared.Help; |
|
15 |
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget; |
|
16 |
import org.gwtbootstrap3.client.ui.Button; |
|
17 |
import org.gwtbootstrap3.client.ui.constants.IconPosition; |
|
18 |
|
|
19 |
import java.util.List; |
|
20 |
|
|
21 |
/** |
|
22 |
* Created by stefania on 3/9/16. |
|
23 |
*/ |
|
24 |
public class HelpAdminWidget implements RepositoryManagerWidget { |
|
25 |
|
|
26 |
private static HelpAdminWidget instance = null; |
|
27 |
|
|
28 |
private String parentToken = ""; |
|
29 |
private String restToken = ""; |
|
30 |
|
|
31 |
private FlowPanel helpAdminPanel = new FlowPanel(); |
|
32 |
|
|
33 |
private FlowPanel myRepositoriesListPanel = new FlowPanel(); |
|
34 |
private FlowPanel myRepositoriesListInnerPanel = new FlowPanel(); |
|
35 |
private FlowPanel myRepositoriesListBox = new FlowPanel(); |
|
36 |
private FlowPanel myRepositoriesListBoxContent = new FlowPanel(); |
|
37 |
|
|
38 |
private FlowPanel actionButtonsPanel = new FlowPanel(); |
|
39 |
|
|
40 |
private FlowPanel sidePanel = new FlowPanel(); |
|
41 |
private FlowPanel previewPanel = new FlowPanel(); |
|
42 |
private FlowPanel previewPanelContent = new FlowPanel(); |
|
43 |
private FlowPanel helpPanel = new FlowPanel(); |
|
44 |
|
|
45 |
private AdminWidget helpTextsAdminWidget = new AdminWidget(previewPanelContent, false); |
|
46 |
|
|
47 |
private static HelpServiceAsync helpService = GWT.create(HelpService.class); |
|
48 |
|
|
49 |
private HelpAdminWidget() { |
|
50 |
|
|
51 |
helpAdminPanel.addStyleName("row"); |
|
52 |
|
|
53 |
myRepositoriesListPanel.addStyleName("col-lg-9"); |
|
54 |
myRepositoriesListPanel.add(myRepositoriesListInnerPanel); |
|
55 |
|
|
56 |
myRepositoriesListInnerPanel.addStyleName("wrapper wrapper-content animated fadeInUp"); |
|
57 |
myRepositoriesListInnerPanel.add(myRepositoriesListBox); |
|
58 |
|
|
59 |
myRepositoriesListBox.addStyleName("ibox"); |
|
60 |
myRepositoriesListBox.add(myRepositoriesListBoxContent); |
|
61 |
|
|
62 |
myRepositoriesListBoxContent.addStyleName("ibox-content"); |
|
63 |
|
|
64 |
sidePanel.addStyleName("col-lg-3"); |
|
65 |
sidePanel.add(previewPanel); |
|
66 |
|
|
67 |
previewPanel.addStyleName("previewPanel"); |
|
68 |
previewPanel.add(new HTML("<div class=\"previewTitle\">PREVIEW</div>")); |
|
69 |
previewPanel.add(previewPanelContent); |
|
70 |
|
|
71 |
actionButtonsPanel.addStyleName("helpAdminActionButtons"); |
|
72 |
|
|
73 |
Button preview = new Button(); |
|
74 |
Button submit = new Button(); |
|
75 |
|
|
76 |
preview.setText("Preview"); |
|
77 |
preview.addStyleName("btn-grey-light"); |
|
78 |
preview.removeStyleName("btn-default"); |
|
79 |
preview.setIconPosition(IconPosition.RIGHT); |
|
80 |
preview.addClickHandler(new ClickHandler() { |
|
81 |
@Override |
|
82 |
public void onClick(ClickEvent event) { |
|
83 |
helpTextsAdminWidget.previewHelpText(); |
|
84 |
} |
|
85 |
}); |
|
86 |
|
|
87 |
submit.setText("Submit Changes"); |
|
88 |
submit.addStyleName("btn-grey-light"); |
|
89 |
submit.removeStyleName("btn-default"); |
|
90 |
submit.setIconPosition(IconPosition.RIGHT); |
|
91 |
submit.addClickHandler(new ClickHandler() { |
|
92 |
@Override |
|
93 |
public void onClick(ClickEvent event) { |
|
94 |
helpTextsAdminWidget.saveHelpText(); |
|
95 |
} |
|
96 |
}); |
|
97 |
|
|
98 |
actionButtonsPanel.add(preview); |
|
99 |
actionButtonsPanel.add(submit); |
|
100 |
|
|
101 |
helpAdminPanel.add(myRepositoriesListPanel); |
|
102 |
helpAdminPanel.add(sidePanel); |
|
103 |
|
|
104 |
AdminWidget.HelpTextUpdatedListener helpTextUpdatedListener = new AdminWidget.HelpTextUpdatedListener() { |
|
105 |
|
|
106 |
@Override |
|
107 |
public void helpTextUpdated(Help updatedHelp) { |
|
108 |
if(updatedHelp!=null && updatedHelp.getId().equals(parentToken)) |
|
109 |
reloadHelp(); |
|
110 |
} |
|
111 |
}; |
|
112 |
helpTextsAdminWidget.setHelpTextUpdatedListener(helpTextUpdatedListener); |
|
113 |
} |
|
114 |
|
|
115 |
public static final HelpAdminWidget getInstance() { |
|
116 |
|
|
117 |
if(instance==null) |
|
118 |
instance = new HelpAdminWidget(); |
|
119 |
|
|
120 |
return instance; |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void clear() { |
|
125 |
myRepositoriesListBoxContent.clear(); |
|
126 |
helpAdminPanel.remove(helpPanel); |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public void reload() { |
|
131 |
|
|
132 |
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent"); |
|
133 |
|
|
134 |
reloadHelp(); |
|
135 |
|
|
136 |
helpTextsAdminWidget.setToken(""); |
|
137 |
helpTextsAdminWidget.setEditorUIColor("#d4dee7"); |
|
138 |
helpTextsAdminWidget.clear(); |
|
139 |
helpTextsAdminWidget.reload(); |
|
140 |
|
|
141 |
FlowPanel rowPanel = new FlowPanel(); |
|
142 |
rowPanel.addStyleName("row"); |
|
143 |
myRepositoriesListBoxContent.add(rowPanel); |
|
144 |
|
|
145 |
FlowPanel colPanel = new FlowPanel(); |
|
146 |
colPanel.addStyleName("col-lg-12"); |
|
147 |
rowPanel.add(colPanel); |
|
148 |
|
|
149 |
HTML title = new HTML("<h1>Monitor Help Texts</h1>"); |
|
150 |
title.addStyleName("m-b-md"); |
|
151 |
colPanel.add(title); |
|
152 |
|
|
153 |
helpTextsAdminWidget.addStyleName("col-lg-12"); |
|
154 |
colPanel.add(helpTextsAdminWidget.asWidget()); |
|
155 |
|
|
156 |
colPanel.add(actionButtonsPanel); |
|
157 |
|
|
158 |
helpService.getAll(new AsyncCallback<List<Help>>() { |
|
159 |
|
|
160 |
@Override |
|
161 |
public void onFailure(Throwable caught) { |
|
162 |
|
|
163 |
} |
|
164 |
|
|
165 |
@Override |
|
166 |
public void onSuccess(List<Help> helpTexts) { |
|
167 |
helpTextsAdminWidget.setHelpTexts(helpTexts); |
|
168 |
} |
|
169 |
}); |
|
170 |
} |
|
171 |
|
|
172 |
@Override |
|
173 |
public void setToken(String parentToken, String rest) { |
|
174 |
this.parentToken = parentToken; |
|
175 |
this.restToken = rest; |
|
176 |
} |
|
177 |
|
|
178 |
@Override |
|
179 |
public void afterAdditionToRootPanel() { |
|
180 |
helpTextsAdminWidget.afterAdditionToRootPanel(); |
|
181 |
} |
|
182 |
|
|
183 |
@Override |
|
184 |
public Widget asWidget() { |
|
185 |
return helpAdminPanel; |
|
186 |
} |
|
187 |
|
|
188 |
private void reloadHelp() { |
|
189 |
|
|
190 |
helpService.getHelpById(parentToken, new AsyncCallback<Help>() { |
|
191 |
|
|
192 |
@Override |
|
193 |
public void onFailure(Throwable caught) { |
|
194 |
} |
|
195 |
|
|
196 |
@Override |
|
197 |
public void onSuccess(Help help) { |
|
198 |
|
|
199 |
if (help != null && help.getText()!=null && !help.getText().trim().isEmpty()) { |
|
200 |
|
|
201 |
HTML html = new HTML(); |
|
202 |
html.setHTML(help.getText()); |
|
203 |
|
|
204 |
helpPanel.clear(); |
|
205 |
helpPanel.add(html); |
|
206 |
sidePanel.add(helpPanel); |
|
207 |
} |
|
208 |
} |
|
209 |
}); |
|
210 |
} |
|
211 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/helpadmin/HelpAdminController.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.client.helpadmin; |
|
2 |
|
|
3 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
4 |
import com.google.gwt.user.client.ui.HTML; |
|
5 |
import com.google.gwt.user.client.ui.RootPanel; |
|
6 |
import eu.dnetlib.repo.manager.client.RepositoryManager; |
|
7 |
import eu.dnetlib.repo.manager.client.TokenController; |
|
8 |
|
|
9 |
/** |
|
10 |
* Created by stefania on 3/9/16. |
|
11 |
*/ |
|
12 |
public class HelpAdminController extends TokenController { |
|
13 |
|
|
14 |
private HelpAdminWidget helpAdminWidget = HelpAdminWidget.getInstance(); |
|
15 |
|
|
16 |
private static HelpAdminController instance = null; |
|
17 |
|
|
18 |
public static HelpAdminController getInstance() { |
|
19 |
if (instance == null) |
|
20 |
instance = new HelpAdminController(); |
|
21 |
|
|
22 |
return instance; |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public void showWidget(FlowPanel contentPanel, String parent, String rest) { |
|
27 |
redrawWidget(contentPanel, helpAdminWidget, parent, rest); |
|
28 |
} |
|
29 |
|
|
30 |
// @Override |
|
31 |
// public void drawHeader(String rest) { |
|
32 |
// |
|
33 |
// RootPanel.get("pageHeader").addStyleName("row wrapper border-bottom white-bg page-heading"); |
|
34 |
// RepositoryManager.pageHeader.clear(); |
|
35 |
// RepositoryManager.pageHeader.add(new HTML("<div class=\"col-sm-9\"><h2>Help Texts Admin</h2><ol class=\"breadcrumb\">" + |
|
36 |
// "<li><a href=\"#dashboard\">Home</a></li><li class=\"active\"><strong>Help Texts Admin</strong></li></ol></div>")); |
|
37 |
// } |
|
38 |
|
|
39 |
@Override |
|
40 |
public String[] getMenuPath(String parent, String rest) { |
|
41 |
return new String[] {"helpAdmin"}; |
|
42 |
} |
|
43 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/services/UserServiceImpl.java | ||
---|---|---|
4 | 4 |
import eu.dnetlib.gwt.server.service.SpringGwtRemoteServiceServlet; |
5 | 5 |
import eu.dnetlib.repo.manager.client.services.UserService; |
6 | 6 |
import eu.dnetlib.repo.manager.server.utils.EmailUtils; |
7 |
import eu.dnetlib.repo.manager.shared.Tuple; |
|
7 | 8 |
import eu.dnetlib.repo.manager.shared.UserAccessException; |
8 | 9 |
import eu.dnetlib.users.UserApi; |
9 | 10 |
import org.apache.log4j.Logger; |
... | ... | |
13 | 14 |
import javax.servlet.ServletConfig; |
14 | 15 |
import javax.servlet.ServletException; |
15 | 16 |
import java.util.ArrayList; |
17 |
import java.util.Arrays; |
|
16 | 18 |
import java.util.List; |
17 | 19 |
import java.util.regex.Pattern; |
18 | 20 |
|
... | ... | |
40 | 42 |
} |
41 | 43 |
|
42 | 44 |
@Override |
43 |
public UserProfile login(String email_username, String password) throws UserAccessException {
|
|
45 |
public Tuple<UserProfile, String> login(String email_username, String password) throws UserAccessException {
|
|
44 | 46 |
LOGGER.info("Checking credentials for user " + email_username); |
45 | 47 |
try { |
46 | 48 |
|
... | ... | |
64 | 66 |
throw new UserAccessException("login.InvalidPassword", UserAccessException.ErrorCode.INVALID_PASSWORD); |
65 | 67 |
} |
66 | 68 |
|
67 |
return this.userAPI.getUser(email); |
|
69 |
UserProfile userProfile = this.userAPI.getUser(email); |
|
70 |
String role = ""; |
|
68 | 71 |
|
72 |
String[] adminEmails = new String[] {"stefania.martziou@gmail.com" , "antleb@di.uoa.gr", "ant.lebesis@gmail.com", "natalia@di.uoa.gr", "pedroprincipe@sdum.uminho.pt", "dpierrakos@gmail.com", "jochen.schirrwagen@uni-bielefeld.de", "aenne.loehden@uni-bielefeld.de"}; |
|
73 |
if(Arrays.asList(adminEmails).contains(userProfile.getEmail())) |
|
74 |
role = "admin"; |
|
75 |
|
|
76 |
return new Tuple<>(userProfile, role); |
|
77 |
|
|
69 | 78 |
} catch (Exception e) { |
70 | 79 |
LOGGER.error("An error occurred while checking credentials for user " + email_username, e); |
71 | 80 |
emailUtils.reportException(e); |
... | ... | |
81 | 90 |
} |
82 | 91 |
|
83 | 92 |
@Override |
84 |
public UserProfile getUserByEmail(String email) throws UserAccessException {
|
|
93 |
public Tuple<UserProfile, String> getUserByEmail(String email) throws UserAccessException {
|
|
85 | 94 |
LOGGER.info("Getting user with email " + email); |
86 | 95 |
try { |
87 | 96 |
|
88 |
return this.userAPI.getUser(email); |
|
97 |
UserProfile userProfile = this.userAPI.getUser(email); |
|
98 |
String role = ""; |
|
89 | 99 |
|
100 |
String[] adminEmails = new String[] {"stefania.martziou@gmail.com" , "antleb@di.uoa.gr", "ant.lebesis@gmail.com", "natalia@di.uoa.gr", "pedroprincipe@sdum.uminho.pt", "dpierrakos@gmail.com", "jochen.schirrwagen@uni-bielefeld.de", "aenne.loehden@uni-bielefeld.de"}; |
|
101 |
if(Arrays.asList(adminEmails).contains(userProfile.getEmail())) |
|
102 |
role = "admin"; |
|
103 |
|
|
104 |
return new Tuple<>(userProfile, role); |
|
105 |
|
|
90 | 106 |
} catch (Exception e) { |
91 | 107 |
LOGGER.error("An error occurred while getting user with email " + email, e); |
92 | 108 |
emailUtils.reportException(e); |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/services/RepositoryServiceImpl.java | ||
---|---|---|
5 | 5 |
import eu.dnetlib.domain.data.Repository; |
6 | 6 |
import eu.dnetlib.domain.data.RepositoryInterface; |
7 | 7 |
import eu.dnetlib.domain.enabling.Vocabulary; |
8 |
import eu.dnetlib.domain.functionality.UserProfile; |
|
8 | 9 |
import eu.dnetlib.gwt.server.service.SpringGwtRemoteServiceServlet; |
9 | 10 |
import eu.dnetlib.repo.manager.client.services.RepositoryService; |
10 | 11 |
import eu.dnetlib.repo.manager.server.utils.EmailUtils; |
... | ... | |
550 | 551 |
} |
551 | 552 |
|
552 | 553 |
@Override |
553 |
public void enableMetricsForRepository(Repository repository) throws RepositoryServiceException { |
|
554 |
public void enableMetricsForRepository(Repository repository, UserProfile requestor) throws RepositoryServiceException {
|
|
554 | 555 |
|
555 | 556 |
String URL = analyticsURL + "siteName=" + repository.getOfficialName() + "&url=" + repository.getWebsiteUrl(); |
556 | 557 |
|
... | ... | |
560 | 561 |
// |
561 | 562 |
// String siteId = (String) map.get("value"); |
562 | 563 |
|
563 |
String siteId = "49"; |
|
564 |
String siteId = new Random(new Date().getTime()).nextInt(200) + ""; |
|
565 |
String authenticationToken = new Random(new Date().getTime()).nextInt(1000000000) + ""; |
|
566 |
|
|
564 | 567 |
PiwikInfo piwikInfo = new PiwikInfo(); |
565 | 568 |
piwikInfo.setRepositoryId(repository.getId()); |
569 |
piwikInfo.setRepositoryName(repository.getOfficialName()); |
|
570 |
piwikInfo.setCountry(repository.getCountryName()); |
|
566 | 571 |
piwikInfo.setSiteId(siteId); |
572 |
piwikInfo.setAuthenticationToken(authenticationToken); |
|
573 |
piwikInfo.setRequestorEmail(requestor.getEmail()); |
|
574 |
piwikInfo.setRequestorName(requestor.getFirstname() + " " + requestor.getLastname()); |
|
575 |
piwikInfo.setApproved(false); |
|
567 | 576 |
|
568 | 577 |
this.piwikDAO.savePiwikInfo(piwikInfo); |
569 | 578 |
|
579 |
//TODO send this in an email as well to the usage stats admin list |
|
580 |
|
|
570 | 581 |
// } catch (IOException e) { |
571 | 582 |
// LOGGER.error("Error while creating piwik site", e); |
572 | 583 |
// emailUtils.reportException(e); |
... | ... | |
587 | 598 |
} |
588 | 599 |
} |
589 | 600 |
|
601 |
@Override |
|
602 |
public List<PiwikInfo> getPiwikSitesForRepositories() throws RepositoryServiceException { |
|
603 |
try { |
|
604 |
|
|
605 |
List<PiwikInfo> piwikInfos = new ArrayList<>(); |
|
606 |
piwikInfos = this.piwikDAO.getPiwikSitesForRepos(); |
|
607 |
|
|
608 |
return piwikInfos; |
|
609 |
|
|
610 |
} catch (EmptyResultDataAccessException e) { |
|
611 |
LOGGER.error("Error while getting list of piwik sites: ", e); |
|
612 |
emailUtils.reportException(e); |
|
613 |
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
614 |
} |
|
615 |
} |
|
616 |
|
|
617 |
@Override |
|
618 |
public void approvePiwikSite(String repositoryId) throws RepositoryServiceException { |
|
619 |
try { |
|
620 |
|
|
621 |
this.piwikDAO.approvePiwikSite(repositoryId); |
|
622 |
|
|
623 |
} catch (EmptyResultDataAccessException e) { |
|
624 |
LOGGER.error("Error while approving piwik site: ", e); |
|
625 |
emailUtils.reportException(e); |
|
626 |
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
627 |
} |
|
628 |
} |
|
629 |
|
|
590 | 630 |
private String getCountryCode(String countryName) { |
591 | 631 |
Vocabulary countries = this.getVocabulary("dnet:countries"); |
592 | 632 |
|
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/services/PiwikDAO.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.repo.manager.server.services; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.repo.manager.shared.PiwikInfo; |
4 |
import eu.dnetlib.utils.md5.MD5; |
|
4 | 5 |
import org.springframework.beans.factory.annotation.Autowired; |
5 | 6 |
import org.springframework.beans.factory.annotation.Qualifier; |
6 | 7 |
import org.springframework.jdbc.core.JdbcTemplate; |
... | ... | |
8 | 9 |
import org.springframework.stereotype.Component; |
9 | 10 |
|
10 | 11 |
import javax.sql.DataSource; |
12 |
import java.security.NoSuchAlgorithmException; |
|
11 | 13 |
import java.sql.ResultSet; |
12 | 14 |
import java.sql.SQLException; |
13 | 15 |
import java.sql.Types; |
16 |
import java.util.List; |
|
14 | 17 |
|
15 | 18 |
/** |
16 | 19 |
* Created by stefania on 12/19/16. |
... | ... | |
22 | 25 |
@Qualifier("repomanager.dataSource") |
23 | 26 |
private DataSource dataSource; |
24 | 27 |
|
25 |
private final static String GET_PIWIK_SITE = "select repositoryid, siteid, creationdate from piwik_site where repositoryid = ?;"; |
|
26 |
private final static String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate) values (?, ?, now())"; |
|
28 |
private final static String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, approved, approvaldate, comment, repositoryname, country from piwik_site where repositoryid = ?;"; |
|
27 | 29 |
|
30 |
private final static String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, approved, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)"; |
|
31 |
|
|
32 |
private final static String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, approved, approvaldate, comment, repositoryname, country from piwik_site order by repositoryname"; |
|
33 |
|
|
34 |
private final static String APPROVE_PIWIK_SITE = "update piwik_site set approved=true, approvaldate=now() where repositoryid = ?;"; |
|
35 |
|
|
28 | 36 |
private RowMapper<PiwikInfo> piwikRowMapper = new RowMapper<PiwikInfo>() { |
29 | 37 |
@Override |
30 | 38 |
public PiwikInfo mapRow(ResultSet rs, int i) throws SQLException { |
31 |
return new PiwikInfo(rs.getString("repositoryid"), rs.getString("siteid"), rs.getTimestamp("creationdate")); |
|
39 |
return new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"), |
|
40 |
rs.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"), |
|
41 |
rs.getBoolean("approved"), rs.getTimestamp("approvaldate"), rs.getString("comment")); |
|
32 | 42 |
} |
33 | 43 |
}; |
34 | 44 |
|
... | ... | |
38 | 48 |
|
39 | 49 |
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) { |
40 | 50 |
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); |
41 |
jdbcTemplate.update(INSERT_PIWIK_INFO, new String[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId()}, new int[]{Types.VARCHAR, Types.VARCHAR}); |
|
51 |
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(), |
|
52 |
piwikInfo.getRequestorEmail(), piwikInfo.isApproved(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()}, |
|
53 |
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR}); |
|
42 | 54 |
return piwikInfo; |
43 | 55 |
} |
56 |
|
|
57 |
public List<PiwikInfo> getPiwikSitesForRepos() { |
|
58 |
return new JdbcTemplate(dataSource).query(GET_PIWIK_SITES, piwikRowMapper); |
|
59 |
} |
|
60 |
|
|
61 |
public void approvePiwikSite(String repositoryId) { |
|
62 |
new JdbcTemplate(dataSource).update(APPROVE_PIWIK_SITE, new Object[] {repositoryId}, new int[] {Types.VARCHAR}); |
|
63 |
} |
|
64 |
|
|
65 |
private String getOpenaireId(String repositoryid) { |
|
66 |
try { |
|
67 |
if (repositoryid != null && repositoryid.contains("::")) |
|
68 |
return repositoryid.split("::")[0] + "::" + MD5.encrypt2Hex(repositoryid.split("::")[1]); |
|
69 |
else |
|
70 |
return null; |
|
71 |
} catch (NoSuchAlgorithmException e) { |
|
72 |
e.printStackTrace(); |
|
73 |
} |
|
74 |
return null; |
|
75 |
} |
|
44 | 76 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/shared/PiwikInfo.java | ||
---|---|---|
10 | 10 |
public class PiwikInfo implements IsSerializable { |
11 | 11 |
|
12 | 12 |
private String repositoryId; |
13 |
private String openaireId; |
|
14 |
private String repositoryName; |
|
15 |
private String country; |
|
13 | 16 |
private String siteId; |
17 |
private String authenticationToken; |
|
14 | 18 |
private Date creationDate; |
19 |
private String requestorName; |
|
20 |
private String requestorEmail; |
|
21 |
private boolean approved; |
|
22 |
private Date approvalDate; |
|
23 |
private String comment; |
|
15 | 24 |
|
16 | 25 |
public PiwikInfo() { |
17 | 26 |
|
18 | 27 |
} |
19 | 28 |
|
20 |
public PiwikInfo(String repositoryId, String siteId, Date creationDate) { |
|
29 |
public PiwikInfo(String repositoryId, String openaireId, String repositoryName, String country, String siteId, |
|
30 |
String authenticationToken, Date creationDate, String requestorName, String requestorEmail, |
|
31 |
boolean approved, Date approvalDate, String comment) { |
|
21 | 32 |
this.repositoryId = repositoryId; |
33 |
this.openaireId = openaireId; |
|
34 |
this.repositoryName = repositoryName; |
|
35 |
this.country = country; |
|
22 | 36 |
this.siteId = siteId; |
37 |
this.authenticationToken = authenticationToken; |
|
23 | 38 |
this.creationDate = creationDate; |
39 |
this.requestorName = requestorName; |
|
40 |
this.requestorEmail = requestorEmail; |
|
41 |
this.approved = approved; |
|
42 |
this.approvalDate = approvalDate; |
|
43 |
this.comment = comment; |
|
24 | 44 |
} |
25 | 45 |
|
26 | 46 |
public String getRepositoryId() { |
... | ... | |
31 | 51 |
this.repositoryId = repositoryId; |
32 | 52 |
} |
33 | 53 |
|
54 |
public String getOpenaireId() { |
|
55 |
return openaireId; |
|
56 |
} |
|
57 |
|
|
58 |
public void setOpenaireId(String openaireId) { |
|
59 |
this.openaireId = openaireId; |
|
60 |
} |
|
61 |
|
|
62 |
public String getRepositoryName() { |
|
63 |
return repositoryName; |
|
64 |
} |
|
65 |
|
|
66 |
public void setRepositoryName(String repositoryName) { |
|
67 |
this.repositoryName = repositoryName; |
|
68 |
} |
|
69 |
|
|
70 |
public String getCountry() { |
|
71 |
return country; |
|
72 |
} |
|
73 |
|
|
74 |
public void setCountry(String country) { |
|
75 |
this.country = country; |
|
76 |
} |
|
77 |
|
|
34 | 78 |
public String getSiteId() { |
35 | 79 |
return siteId; |
36 | 80 |
} |
... | ... | |
39 | 83 |
this.siteId = siteId; |
40 | 84 |
} |
41 | 85 |
|
86 |
public String getAuthenticationToken() { |
|
87 |
return authenticationToken; |
|
88 |
} |
|
89 |
|
|
90 |
public void setAuthenticationToken(String authenticationToken) { |
|
91 |
this.authenticationToken = authenticationToken; |
|
92 |
} |
|
93 |
|
|
42 | 94 |
public Date getCreationDate() { |
43 | 95 |
return creationDate; |
44 | 96 |
} |
... | ... | |
46 | 98 |
public void setCreationDate(Date creationDate) { |
47 | 99 |
this.creationDate = creationDate; |
48 | 100 |
} |
101 |
|
|
102 |
public String getRequestorName() { |
|
103 |
return requestorName; |
|
104 |
} |
|
105 |
|
|
106 |
public void setRequestorName(String requestorName) { |
|
107 |
this.requestorName = requestorName; |
|
108 |
} |
|
109 |
|
|
110 |
public String getRequestorEmail() { |
|
111 |
return requestorEmail; |
|
112 |
} |
|
113 |
|
|
114 |
public void setRequestorEmail(String requestorEmail) { |
|
115 |
this.requestorEmail = requestorEmail; |
|
116 |
} |
|
117 |
|
|
118 |
public boolean isApproved() { |
|
119 |
return approved; |
|
120 |
} |
|
121 |
|
|
122 |
public void setApproved(boolean approved) { |
|
123 |
this.approved = approved; |
|
124 |
} |
|
125 |
|
|
126 |
public Date getApprovalDate() { |
|
127 |
return approvalDate; |
|
128 |
} |
|
129 |
|
|
130 |
public void setApprovalDate(Date approvalDate) { |
|
131 |
this.approvalDate = approvalDate; |
|
132 |
} |
|
133 |
|
|
134 |
public String getComment() { |
|
135 |
return comment; |
|
136 |
} |
|
137 |
|
|
138 |
public void setComment(String comment) { |
|
139 |
this.comment = comment; |
|
140 |
} |
|
49 | 141 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/services/UserService.java | ||
---|---|---|
3 | 3 |
import com.google.gwt.user.client.rpc.RemoteService; |
4 | 4 |
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; |
5 | 5 |
import eu.dnetlib.domain.functionality.UserProfile; |
6 |
import eu.dnetlib.repo.manager.shared.Tuple; |
|
6 | 7 |
import eu.dnetlib.repo.manager.shared.UserAccessException; |
7 | 8 |
|
8 | 9 |
/** |
... | ... | |
11 | 12 |
@RemoteServiceRelativePath("springGwtServices/userService") |
12 | 13 |
public interface UserService extends RemoteService { |
13 | 14 |
|
14 |
UserProfile login(String email, String password) throws UserAccessException;
|
|
15 |
Tuple<UserProfile, String> login(String email, String password) throws UserAccessException;
|
|
15 | 16 |
|
16 | 17 |
void register(UserProfile userProfile) throws UserAccessException; |
17 | 18 |
|
... | ... | |
19 | 20 |
|
20 | 21 |
void updateUser(UserProfile userProfile) throws UserAccessException; |
21 | 22 |
|
22 |
UserProfile getUserByEmail(String email) throws UserAccessException;
|
|
23 |
Tuple<UserProfile, String> getUserByEmail(String email) throws UserAccessException;
|
|
23 | 24 |
|
24 | 25 |
void prepareResetPassword(String email) throws UserAccessException; |
25 | 26 |
|
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/services/RepositoryService.java | ||
---|---|---|
4 | 4 |
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; |
5 | 5 |
import eu.dnetlib.domain.data.Repository; |
6 | 6 |
import eu.dnetlib.domain.data.RepositoryInterface; |
7 |
import eu.dnetlib.domain.functionality.UserProfile; |
|
7 | 8 |
import eu.dnetlib.repo.manager.shared.*; |
8 | 9 |
|
9 | 10 |
import java.util.List; |
... | ... | |
55 | 56 |
|
56 | 57 |
PiwikInfo getPiwikSiteForRepository(String repoId) throws RepositoryServiceException; |
57 | 58 |
|
58 |
void enableMetricsForRepository(Repository repository) throws RepositoryServiceException; |
|
59 |
void enableMetricsForRepository(Repository repository, UserProfile requestor) throws RepositoryServiceException;
|
|
59 | 60 |
|
60 | 61 |
String getPiwikScriptForRepository(String repoId) throws RepositoryServiceException; |
62 |
|
|
63 |
List<PiwikInfo> getPiwikSitesForRepositories() throws RepositoryServiceException; |
|
64 |
|
|
65 |
void approvePiwikSite(String repositoryId) throws RepositoryServiceException; |
|
61 | 66 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/LoginPage.java | ||
---|---|---|
17 | 17 |
import eu.dnetlib.gwt.client.MyFormGroup; |
18 | 18 |
import eu.dnetlib.repo.manager.client.services.UserService; |
19 | 19 |
import eu.dnetlib.repo.manager.client.services.UserServiceAsync; |
20 |
import eu.dnetlib.repo.manager.shared.Tuple; |
|
20 | 21 |
import eu.dnetlib.repo.manager.shared.UserAccessException; |
21 | 22 |
import org.gwtbootstrap3.client.ui.Alert; |
22 | 23 |
import org.gwtbootstrap3.client.ui.Anchor; |
... | ... | |
92 | 93 |
|
93 | 94 |
} else { |
94 | 95 |
|
95 |
userService.login(email.getValue(), password.getValue(), new AsyncCallback<UserProfile>() {
|
|
96 |
userService.login(email.getValue(), password.getValue(), new AsyncCallback<Tuple<UserProfile, String>>() {
|
|
96 | 97 |
|
97 | 98 |
@Override |
98 | 99 |
public void onFailure(Throwable throwable) { |
... | ... | |
111 | 112 |
} |
112 | 113 |
|
113 | 114 |
@Override |
114 |
public void onSuccess(UserProfile userProfile) {
|
|
115 |
public void onSuccess(Tuple<UserProfile, String> result) {
|
|
115 | 116 |
|
116 |
RepositoryManager.currentUser = userProfile; |
|
117 |
RepositoryManager.currentUser = result.getFirst(); |
|
118 |
RepositoryManager.currentUserRole = result.getSecond(); |
|
119 |
|
|
117 | 120 |
Date expireDate = new Date(); |
118 | 121 |
CalendarUtil.addDaysToDate(expireDate, 1); |
119 |
Cookies.setCookie("currentUser", Crypto.encrypt(userProfile.getEmail()), expireDate);
|
|
122 |
Cookies.setCookie("currentUser", Crypto.encrypt(result.getFirst().getEmail()), expireDate);
|
|
120 | 123 |
|
121 | 124 |
if (loginListener != null) |
122 |
loginListener.loginSucceeded(userProfile);
|
|
125 |
loginListener.loginSucceeded(result.getFirst());
|
|
123 | 126 |
} |
124 | 127 |
}); |
125 | 128 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/admin/helptexts/HelpTextsAdminController.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.client.admin.helptexts; |
|
2 |
|
|
3 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
4 |
import eu.dnetlib.repo.manager.client.TokenController; |
|
5 |
|
|
6 |
/** |
|
7 |
* Created by stefania on 3/9/16. |
|
8 |
*/ |
|
9 |
public class HelpTextsAdminController extends TokenController { |
|
10 |
|
|
11 |
private HelpTextsAdminWidget helpTextsAdminWidget = new HelpTextsAdminWidget(); |
|
12 |
|
|
13 |
private static HelpTextsAdminController instance = null; |
|
14 |
|
|
15 |
public static HelpTextsAdminController getInstance() { |
|
16 |
if (instance == null) |
|
17 |
instance = new HelpTextsAdminController(); |
|
18 |
|
|
19 |
return instance; |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public void showWidget(FlowPanel contentPanel, String parent, String rest) { |
|
24 |
redrawWidget(contentPanel, helpTextsAdminWidget, parent, rest); |
|
25 |
} |
|
26 |
|
|
27 |
// @Override |
|
28 |
// public void drawHeader(String rest) { |
|
29 |
// |
|
30 |
// RootPanel.get("pageHeader").addStyleName("row wrapper border-bottom white-bg page-heading"); |
|
31 |
// RepositoryManager.pageHeader.clear(); |
|
32 |
// RepositoryManager.pageHeader.add(new HTML("<div class=\"col-sm-9\"><h2>Help Texts Admin</h2><ol class=\"breadcrumb\">" + |
|
33 |
// "<li><a href=\"#dashboard\">Home</a></li><li class=\"active\"><strong>Help Texts Admin</strong></li></ol></div>")); |
|
34 |
// } |
|
35 |
|
|
36 |
@Override |
|
37 |
public String[] getMenuPath(String parent, String rest) { |
|
38 |
return new String[] {"helpAdmin"}; |
|
39 |
} |
|
40 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/admin/helptexts/HelpTextsAdminWidget.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.client.admin.helptexts; |
|
2 |
|
|
3 |
import com.google.gwt.core.client.GWT; |
|
4 |
import com.google.gwt.dom.client.Document; |
|
5 |
import com.google.gwt.event.dom.client.ClickEvent; |
|
6 |
import com.google.gwt.event.dom.client.ClickHandler; |
|
7 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
|
8 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
9 |
import com.google.gwt.user.client.ui.HTML; |
|
10 |
import com.google.gwt.user.client.ui.Widget; |
|
11 |
import eu.dnetlib.gwt.client.help.AdminWidget; |
|
12 |
import eu.dnetlib.gwt.client.help.HelpService; |
|
13 |
import eu.dnetlib.gwt.client.help.HelpServiceAsync; |
|
14 |
import eu.dnetlib.gwt.shared.Help; |
|
15 |
import eu.dnetlib.repo.manager.client.AbstractRepositoryManagerWidget; |
|
16 |
import eu.dnetlib.repo.manager.client.HelpCallback; |
|
17 |
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget; |
|
18 |
import org.gwtbootstrap3.client.ui.Alert; |
|
19 |
import org.gwtbootstrap3.client.ui.Button; |
|
20 |
import org.gwtbootstrap3.client.ui.constants.AlertType; |
|
21 |
import org.gwtbootstrap3.client.ui.constants.IconPosition; |
|
22 |
|
|
23 |
import java.util.List; |
|
24 |
|
|
25 |
/** |
|
26 |
* Created by stefania on 3/9/16. |
|
27 |
*/ |
|
28 |
public class HelpTextsAdminWidget extends AbstractRepositoryManagerWidget implements RepositoryManagerWidget { |
|
29 |
|
|
30 |
// private static HelpTextsAdminWidget instance = null; |
|
31 |
// |
|
32 |
// private String parentToken = ""; |
|
33 |
// private String restToken = ""; |
|
34 |
// |
|
35 |
// private FlowPanel helpAdminPanel = new FlowPanel(); |
|
36 |
// |
|
37 |
// private FlowPanel myRepositoriesListPanel = new FlowPanel(); |
|
38 |
// private FlowPanel myRepositoriesListInnerPanel = new FlowPanel(); |
|
39 |
// private FlowPanel myRepositoriesListBox = new FlowPanel(); |
|
40 |
// private FlowPanel myRepositoriesListBoxContent = new FlowPanel(); |
|
41 |
// |
|
42 |
// private FlowPanel actionButtonsPanel = new FlowPanel(); |
|
43 |
// |
|
44 |
// private FlowPanel sidePanel = new FlowPanel(); |
|
45 |
// private FlowPanel previewPanel = new FlowPanel(); |
|
46 |
// private FlowPanel previewPanelContent = new FlowPanel(); |
|
47 |
// private FlowPanel helpPanel = new FlowPanel(); |
|
48 |
|
|
49 |
private String parentToken = ""; |
|
50 |
private String restToken = ""; |
|
51 |
|
|
52 |
private FlowPanel helpTextsAdminBoxContent = new FlowPanel(); |
|
53 |
|
|
54 |
private FlowPanel actionButtonsPanel = new FlowPanel(); |
|
55 |
|
|
56 |
private Alert errorAlert = new Alert(); |
|
57 |
|
|
58 |
// private FlowPanel helpPanel = new FlowPanel(); |
|
59 |
private FlowPanel helpText = new FlowPanel(); |
|
60 |
private FlowPanel preview = new FlowPanel(); |
|
61 |
|
|
62 |
private AdminWidget helpTextsAdminWidget = new AdminWidget(preview, false); |
|
63 |
|
|
64 |
private static HelpServiceAsync helpService = GWT.create(HelpService.class); |
|
65 |
|
|
66 |
public HelpTextsAdminWidget() { |
|
67 |
|
|
68 |
super(); |
|
69 |
|
|
70 |
HTML title = new HTML("<h1 class=\"uk-article-title\">Help Texts Admin</h1>"); |
|
71 |
title.addStyleName("uk-margin-medium-bottom"); |
|
72 |
contentPanel.add(title); |
|
73 |
|
|
74 |
errorAlert.setType(AlertType.DANGER); |
|
75 |
errorAlert.setDismissable(false); |
|
76 |
errorAlert.setVisible(false); |
|
77 |
helpTextsAdminBoxContent.add(errorAlert); |
|
78 |
|
|
79 |
contentPanel.add(helpTextsAdminBoxContent); |
|
80 |
gridPanel.add(helpPanel); |
|
81 |
|
|
82 |
// helpAdminPanel.addStyleName("row"); |
|
83 |
// |
|
84 |
// myRepositoriesListPanel.addStyleName("col-lg-9"); |
|
85 |
// myRepositoriesListPanel.add(myRepositoriesListInnerPanel); |
|
86 |
// |
|
87 |
// myRepositoriesListInnerPanel.addStyleName("wrapper wrapper-content animated fadeInUp"); |
|
88 |
// myRepositoriesListInnerPanel.add(myRepositoriesListBox); |
|
89 |
// |
|
90 |
// myRepositoriesListBox.addStyleName("ibox"); |
|
91 |
// myRepositoriesListBox.add(myRepositoriesListBoxContent); |
|
92 |
// |
|
93 |
// myRepositoriesListBoxContent.addStyleName("ibox-content"); |
|
94 |
// |
|
95 |
// sidePanel.addStyleName("col-lg-3"); |
|
96 |
// sidePanel.add(previewPanel); |
|
97 |
|
|
98 |
HTML tt = new HTML(); |
|
99 |
|
|
100 |
tt.setHTML("<div class=\"previewTitle\">PREVIEW</div>"); |
|
101 |
preview.addStyleName("previewPanel"); |
|
102 |
// preview.add(new HTML("<div class=\"previewTitle\">PREVIEW</div>")); |
|
103 |
|
|
104 |
preview.clear(); |
|
105 |
preview.add(tt); |
|
106 |
helpPanel.add(preview); |
|
107 |
|
|
108 |
actionButtonsPanel.addStyleName("helpAdminActionButtons"); |
|
109 |
|
|
110 |
Button preview = new Button(); |
|
111 |
Button submit = new Button(); |
|
112 |
|
|
113 |
preview.setText("Preview"); |
|
114 |
// preview.addStyleName("btn-grey-light"); |
|
115 |
// preview.removeStyleName("btn-default"); |
|
116 |
preview.setIconPosition(IconPosition.RIGHT); |
|
117 |
preview.addClickHandler(new ClickHandler() { |
|
118 |
@Override |
|
119 |
public void onClick(ClickEvent event) { |
|
120 |
helpTextsAdminWidget.previewHelpText(); |
|
121 |
} |
|
122 |
}); |
|
123 |
|
|
124 |
submit.setText("Submit Changes"); |
|
125 |
preview.addStyleName("uk-button-primary"); |
|
126 |
// submit.addStyleName("btn-grey-light"); |
|
127 |
// submit.removeStyleName("btn-default"); |
|
128 |
submit.setIconPosition(IconPosition.RIGHT); |
|
129 |
submit.addClickHandler(new ClickHandler() { |
|
130 |
@Override |
|
131 |
public void onClick(ClickEvent event) { |
|
132 |
helpTextsAdminWidget.saveHelpText(); |
|
133 |
} |
|
134 |
}); |
|
135 |
|
|
136 |
actionButtonsPanel.add(preview); |
|
137 |
actionButtonsPanel.add(submit); |
|
138 |
|
|
139 |
// helpAdminPanel.add(myRepositoriesListPanel); |
|
140 |
// helpAdminPanel.add(sidePanel); |
|
141 |
|
|
142 |
AdminWidget.HelpTextUpdatedListener helpTextUpdatedListener = new AdminWidget.HelpTextUpdatedListener() { |
|
143 |
|
|
144 |
@Override |
|
145 |
public void helpTextUpdated(Help updatedHelp) { |
|
146 |
if(updatedHelp!=null && updatedHelp.getId().equals(parentToken)) |
|
147 |
helpService.getHelpById(parentToken, new HelpCallback(helpText, helpPanel)); |
|
148 |
} |
|
149 |
}; |
|
150 |
helpTextsAdminWidget.setHelpTextUpdatedListener(helpTextUpdatedListener); |
|
151 |
} |
|
152 |
|
|
153 |
@Override |
|
154 |
public void clear() { |
|
155 |
|
|
156 |
helpTextsAdminBoxContent.clear(); |
|
157 |
errorAlert.setVisible(false); |
|
158 |
helpPanel.remove(helpText); |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public void reload() { |
|
163 |
|
|
164 |
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent"); |
|
165 |
helpTextsAdminBoxContent.add(errorAlert); |
|
166 |
|
|
167 |
helpService.getHelpById(parentToken, new HelpCallback(helpText, helpPanel)); |
|
168 |
|
|
169 |
helpTextsAdminWidget.setToken(""); |
|
170 |
helpTextsAdminWidget.setEditorUIColor("#d4dee7"); |
|
171 |
helpTextsAdminWidget.clear(); |
|
172 |
helpTextsAdminWidget.reload(); |
|
173 |
|
|
174 |
// FlowPanel rowPanel = new FlowPanel(); |
|
175 |
// rowPanel.addStyleName("row"); |
|
176 |
// myRepositoriesListBoxContent.add(rowPanel); |
|
177 |
// |
|
178 |
// FlowPanel colPanel = new FlowPanel(); |
|
179 |
// colPanel.addStyleName("col-lg-12"); |
|
180 |
// rowPanel.add(colPanel); |
|
181 |
// |
|
182 |
// HTML title = new HTML("<h1>Monitor Help Texts</h1>"); |
|
183 |
// title.addStyleName("m-b-md"); |
|
184 |
// colPanel.add(title); |
|
185 |
// |
|
186 |
// helpTextsAdminWidget.addStyleName("col-lg-12"); |
|
187 |
helpTextsAdminBoxContent.add(helpTextsAdminWidget.asWidget()); |
|
188 |
|
|
189 |
helpTextsAdminBoxContent.add(actionButtonsPanel); |
|
190 |
|
|
191 |
helpService.getAll(new AsyncCallback<List<Help>>() { |
|
192 |
|
|
193 |
@Override |
|
194 |
public void onFailure(Throwable caught) { |
|
195 |
|
|
196 |
} |
|
197 |
|
|
198 |
@Override |
|
199 |
public void onSuccess(List<Help> helpTexts) { |
|
200 |
helpTextsAdminWidget.setHelpTexts(helpTexts); |
|
201 |
} |
|
202 |
}); |
|
203 |
} |
|
204 |
|
|
205 |
@Override |
|
206 |
public void setToken(String parentToken, String rest) { |
|
207 |
this.parentToken = parentToken; |
|
208 |
this.restToken = rest; |
|
209 |
} |
|
210 |
|
|
211 |
@Override |
|
212 |
public void afterAdditionToRootPanel() { |
|
213 |
helpTextsAdminWidget.afterAdditionToRootPanel(); |
|
214 |
} |
|
215 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/admin/metrics/MetricsAdminWidget.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.client.admin.metrics; |
|
2 |
|
|
3 |
import com.google.gwt.core.client.GWT; |
|
4 |
import com.google.gwt.dom.client.Document; |
|
5 |
import com.google.gwt.event.dom.client.ClickEvent; |
|
6 |
import com.google.gwt.event.dom.client.ClickHandler; |
|
7 |
import com.google.gwt.i18n.client.DateTimeFormat; |
|
8 |
import com.google.gwt.query.client.Function; |
|
9 |
import com.google.gwt.user.client.Event; |
|
10 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
|
11 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
12 |
import com.google.gwt.user.client.ui.HTML; |
|
13 |
import eu.dnetlib.gwt.client.help.HelpService; |
|
14 |
import eu.dnetlib.gwt.client.help.HelpServiceAsync; |
|
15 |
import eu.dnetlib.repo.manager.client.AbstractRepositoryManagerWidget; |
|
16 |
import eu.dnetlib.repo.manager.client.HelpCallback; |
|
17 |
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget; |
|
18 |
import eu.dnetlib.repo.manager.client.services.RepositoryService; |
|
19 |
import eu.dnetlib.repo.manager.client.services.RepositoryServiceAsync; |
|
20 |
import eu.dnetlib.repo.manager.shared.PiwikInfo; |
|
21 |
import org.gwtbootstrap3.client.ui.Alert; |
|
22 |
import org.gwtbootstrap3.client.ui.Button; |
|
23 |
import org.gwtbootstrap3.client.ui.Modal; |
|
24 |
import org.gwtbootstrap3.client.ui.ModalBody; |
|
25 |
import org.gwtbootstrap3.client.ui.constants.AlertType; |
|
26 |
import org.gwtbootstrap3.client.ui.constants.ButtonType; |
|
27 |
import org.gwtbootstrap3.client.ui.constants.ModalBackdrop; |
|
28 |
|
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import static com.google.gwt.query.client.GQuery.$; |
|
33 |
|
|
34 |
/** |
|
35 |
* Created by stefania on 10/18/17. |
|
36 |
*/ |
|
37 |
public class MetricsAdminWidget extends AbstractRepositoryManagerWidget implements RepositoryManagerWidget { |
|
38 |
|
|
39 |
private String parentToken = ""; |
|
40 |
private String restToken = ""; |
|
41 |
|
|
42 |
private FlowPanel metricsAdminBoxContent = new FlowPanel(); |
|
43 |
|
|
44 |
private Alert errorAlert = new Alert(); |
|
45 |
|
|
46 |
private static HelpServiceAsync helpService = GWT.create(HelpService.class); |
|
47 |
private static RepositoryServiceAsync repositoryService = GWT.create(RepositoryService.class); |
|
48 |
|
|
49 |
private DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd"); |
|
50 |
|
|
51 |
public MetricsAdminWidget() { |
|
52 |
|
|
53 |
super(); |
|
54 |
|
|
55 |
HTML title = new HTML("<h1 class=\"uk-article-title\">Metrics Admin</h1>"); |
|
56 |
title.addStyleName("uk-margin-medium-bottom"); |
|
57 |
contentPanel.add(title); |
|
58 |
|
|
59 |
errorAlert.setType(AlertType.DANGER); |
|
60 |
errorAlert.setDismissable(false); |
|
61 |
errorAlert.setVisible(false); |
|
62 |
metricsAdminBoxContent.add(errorAlert); |
|
63 |
|
|
64 |
contentPanel.add(metricsAdminBoxContent); |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public void clear() { |
|
69 |
|
|
70 |
metricsAdminBoxContent.clear(); |
|
71 |
errorAlert.setVisible(false); |
|
72 |
gridPanel.remove(helpPanel); |
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
76 |
public void reload() { |
|
77 |
|
|
78 |
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent"); |
|
79 |
metricsAdminBoxContent.add(errorAlert); |
|
80 |
|
|
81 |
helpService.getHelpById(parentToken, new HelpCallback(helpPanel, gridPanel)); |
|
82 |
|
|
83 |
final HTML loadingWheel = new HTML("<div class=\"loader-big\" style=\"text-align: center; padding-top: 170px; " + |
|
84 |
"color: rgb(47, 64, 80); font-weight: bold;\">Retrieving piwik sites info...</div>" + |
|
85 |
"<div class=\"whiteFilm\"></div>"); |
|
86 |
metricsAdminBoxContent.addStyleName("loading-big"); |
|
87 |
metricsAdminBoxContent.add(loadingWheel); |
|
88 |
|
|
89 |
repositoryService.getPiwikSitesForRepositories(new AsyncCallback<List<PiwikInfo>>() { |
|
90 |
|
|
91 |
@Override |
|
92 |
public void onFailure(Throwable caught) { |
|
93 |
|
|
94 |
metricsAdminBoxContent.removeStyleName("loading-big"); |
|
95 |
metricsAdminBoxContent.remove(loadingWheel); |
|
96 |
|
|
97 |
errorAlert.setText("System error retrieving piwik sites info."); |
|
98 |
errorAlert.setVisible(true); |
|
99 |
} |
|
100 |
|
|
101 |
@Override |
|
102 |
public void onSuccess(List<PiwikInfo> results) { |
|
103 |
|
|
104 |
metricsAdminBoxContent.removeStyleName("loading-big"); |
|
105 |
metricsAdminBoxContent.remove(loadingWheel); |
|
106 |
|
|
107 |
if(results!=null) { |
|
108 |
createPiwikSitesInfoList(results, metricsAdminBoxContent); |
|
109 |
} else { |
|
110 |
errorAlert.setText("System error retrieving piwik sites info."); |
|
111 |
errorAlert.setVisible(true); |
|
112 |
} |
|
113 |
} |
|
114 |
}); |
|
115 |
} |
|
116 |
|
|
117 |
@Override |
|
118 |
public void setToken(String parentToken, String rest) { |
|
119 |
this.parentToken = parentToken; |
|
120 |
this.restToken = rest; |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void afterAdditionToRootPanel() { |
|
125 |
|
|
126 |
} |
|
127 |
|
|
128 |
private void addWidgetHandlers() { |
|
129 |
|
|
130 |
$(".approve").click(new Function() { |
|
131 |
|
|
132 |
public boolean f(Event e) { |
|
133 |
|
|
134 |
errorAlert.setVisible(false); |
|
135 |
|
|
136 |
String[] idParts = $(e).get(0).getId().split("#"); |
|
137 |
List<String> repositoryIds = new ArrayList<String>(); |
|
138 |
repositoryIds.add(idParts[0]); |
|
139 |
|
|
140 |
approvePiwikSites(repositoryIds); |
|
141 |
|
|
142 |
return true; |
|
143 |
} |
|
144 |
}); |
|
145 |
} |
|
146 |
|
|
147 |
private void createPiwikSitesInfoList(List<PiwikInfo> results, FlowPanel piwikInfosPanel) { |
|
148 |
|
|
149 |
if(results.isEmpty()) { |
|
150 |
piwikInfosPanel.add(new HTML("There are no piwik sites available yet.")); |
|
151 |
} else { |
|
152 |
|
|
153 |
// HTML datasourceTitle = new HTML(); |
|
154 |
// datasourceTitle.setHTML("<h4 class=\"uk-h4 uk-text-primary uk-scrollspy-inview uk-animation-slide-top-medium\"" + |
|
155 |
// "uk-scrollspy-class=\"\"><span>" + piwikInfo + "</span></h4>"); |
|
156 |
// piwikInfosPanel.add(datasourceTitle); |
|
157 |
|
|
158 |
FlowPanel colPanel = new FlowPanel(); |
|
159 |
colPanel.addStyleName("uk-width-1-1@m uk-first-column uk-margin-medium-bottom"); |
|
160 |
piwikInfosPanel.add(colPanel); |
|
161 |
|
|
162 |
FlowPanel divPanel = new FlowPanel(); |
|
163 |
divPanel.addStyleName("uk-overflow-auto uk-scrollspy-inview uk-animation-slide-top-medium"); |
|
164 |
colPanel.add(divPanel); |
|
165 |
|
|
166 |
String content = "<table class=\"uk-table uk-table-striped uk-table-middle\" style=\"font-size: 12px\">" + |
|
167 |
"<thead><tr><th class=\"uk-text-nowrap\">Repository</th><th class=\"uk-text-nowrap\">Piwik site</th>" + |
|
168 |
"<th class=\"uk-text-nowrap\">Requested on</th><th class=\"uk-text-nowrap\">Requestor</th>" + |
|
169 |
"<th class=\"uk-text-nowrap\">Approved</th>" + |
|
170 |
"<th class=\"uk-text-nowrap\">Actions</th></tr></thead>"; |
|
171 |
|
|
172 |
content += "<tbody>"; |
|
173 |
|
|
174 |
for(PiwikInfo piwikInfo : results) { |
|
175 |
|
|
176 |
content += "<tr class=\"el-item\">" + |
|
177 |
""; |
|
178 |
|
|
179 |
// REPOSITORY |
|
180 |
content += "<td class=\"uk-table-shrink\">"; |
|
181 |
if(piwikInfo.getRepositoryName()!=null && !piwikInfo.getRepositoryName().trim().equals("")) |
|
182 |
content += "<div class=\"el-title\">" + piwikInfo.getRepositoryName() + "</div>"; |
|
183 |
else |
|
184 |
content += "--"; |
|
185 |
if(piwikInfo.getCountry()!=null && !piwikInfo.getCountry().trim().equals("")) |
|
186 |
content += "<div class=\"el-title\">" + piwikInfo.getCountry() + "</div>"; |
|
187 |
else |
|
188 |
content += "--"; |
|
189 |
if(piwikInfo.getRepositoryId()!=null && !piwikInfo.getRepositoryId().trim().equals("")) |
|
190 |
content += "<div class=\"el-title\">(ID: " + piwikInfo.getRepositoryId() + ")</div>"; |
|
191 |
else |
|
192 |
content += "--"; |
|
193 |
|
|
194 |
content += "</td>"; |
|
195 |
|
|
196 |
// PIWIK SITE |
|
197 |
content += "<td class=\"uk-table-shrink\">"; |
|
198 |
if(piwikInfo.getSiteId()!=null && !piwikInfo.getSiteId().trim().equals("")) |
|
199 |
content += "<div class=\"el-title\">ID: " + piwikInfo.getSiteId() + "</div>"; |
|
200 |
else |
|
201 |
content += "--"; |
|
202 |
if(piwikInfo.getAuthenticationToken()!=null && !piwikInfo.getAuthenticationToken().trim().equals("")) |
|
203 |
content += "<div class=\"el-title\">Authentication token: " + piwikInfo.getAuthenticationToken() + "</div>"; |
|
204 |
else |
|
205 |
content += "--"; |
|
206 |
content += "</td>"; |
|
207 |
|
|
208 |
// REQUEST DATE |
|
209 |
if(piwikInfo.getCreationDate()!=null) |
|
210 |
content += "<td class=\"uk-text-nowrap uk-table-shrink\"><div class=\"el-title\">" + dtf.format(piwikInfo.getCreationDate()) + "</div></td>"; |
|
211 |
else |
|
212 |
content += "<td class=\"uk-text-nowrap uk-table-shrink\"><div class=\"el-title\">--</div></td>"; |
|
213 |
|
|
214 |
// REQUESTOR |
|
215 |
content += "<td class=\"uk-text-nowrap uk-table-shrink\">"; |
|
216 |
if(piwikInfo.getRequestorName()!=null && !piwikInfo.getRequestorName().trim().equals("")) |
|
217 |
content += "<div class=\"el-title\">" + piwikInfo.getRequestorName() + "</div>"; |
|
218 |
else |
|
219 |
content += "--"; |
|
220 |
if(piwikInfo.getRequestorEmail()!=null && !piwikInfo.getRequestorEmail().trim().equals("")) |
|
221 |
content += "<div class=\"el-title\">" + piwikInfo.getRequestorEmail() + "</div>"; |
|
222 |
else |
|
223 |
content += "--"; |
|
224 |
content += "</td>"; |
|
225 |
|
|
226 |
// APPROVED |
|
227 |
if(piwikInfo.isApproved()) { |
|
228 |
content += "<td class=\"uk-text-nowrap uk-table-shrink\">"; |
|
229 |
content += "<div class=\"el-title\">YES</div>" ; |
|
230 |
if(piwikInfo.getApprovalDate()!=null) |
|
231 |
content += "<div class=\"el-title\">on " + dtf.format(piwikInfo.getApprovalDate()) + "</div>" ; |
|
232 |
content += "</td>"; |
|
233 |
} else |
|
234 |
content += "<td class=\"uk-text-nowrap uk-table-shrink\"><div class=\"el-title\">NO</div></td>"; |
|
235 |
|
|
236 |
content += "<td class=\"uk-text-nowrap uk-table-shrink\">"; |
|
237 |
|
|
238 |
// ACTIONS |
|
239 |
if(!piwikInfo.isApproved()) |
|
240 |
content += "<a href=\"javascript:;\" id=\"" + piwikInfo.getRepositoryId() + "#approve\" " + |
|
241 |
"class=\"uk-button uk-button-primary approve\">Approve</button>"; |
|
242 |
content += "</td>" + |
|
243 |
"</tr>"; |
|
244 |
} |
|
245 |
|
|
246 |
content += "</tbody></table>"; |
|
247 |
|
|
248 |
HTML reposListHTML = new HTML(); |
|
249 |
reposListHTML.setHTML(content); |
|
250 |
|
|
251 |
divPanel.add(reposListHTML); |
|
252 |
} |
|
253 |
|
|
254 |
addWidgetHandlers(); |
|
255 |
} |
|
256 |
|
|
257 |
private void approvePiwikSites(final List<String> repositoryIds) { |
|
258 |
|
|
259 |
final Modal approvePiwikSitesConfirmationPopup = new Modal(); |
|
260 |
approvePiwikSitesConfirmationPopup.setDataBackdrop(ModalBackdrop.STATIC); |
|
261 |
|
|
262 |
FlowPanel modalContent = new FlowPanel(); |
|
263 |
|
|
264 |
HTML description = new HTML("<h2 class=\"uk-modal-title\">Approval Confirmation</h2>\n" + |
|
265 |
"<p>Are you sure you want to approve the selected piwik site(s)?</p>"); |
|
266 |
modalContent.add(description); |
|
267 |
|
|
268 |
FlowPanel actionButtons = new FlowPanel(); |
|
269 |
actionButtons.addStyleName("uk-text-right"); |
|
270 |
modalContent.add(actionButtons); |
|
271 |
|
|
272 |
Button no = new Button("Cancel"); |
|
273 |
no.setType(ButtonType.DEFAULT); |
|
274 |
no.addClickHandler(new ClickHandler() { |
|
275 |
@Override |
|
276 |
public void onClick(ClickEvent event) { |
|
277 |
approvePiwikSitesConfirmationPopup.hide(); |
|
278 |
approvePiwikSitesConfirmationPopup.removeFromParent(); |
|
279 |
} |
|
280 |
}); |
|
281 |
actionButtons.add(no); |
|
282 |
|
|
283 |
Button yes = new Button("Yes, approve"); |
|
284 |
yes.setType(ButtonType.PRIMARY); |
|
285 |
yes.addClickHandler(new ClickHandler() { |
|
286 |
@Override |
|
287 |
public void onClick(ClickEvent event) { |
|
288 |
|
|
289 |
approvePiwikSitesConfirmationPopup.hide(); |
|
290 |
approvePiwikSitesConfirmationPopup.removeFromParent(); |
|
291 |
|
|
292 |
final HTML loadingWheel = new HTML("<div class=\"loader-big\"></div><div class=\"whiteFilm\"></div>"); |
|
293 |
metricsAdminBoxContent.addStyleName("loading-big"); |
|
294 |
metricsAdminBoxContent.add(loadingWheel); |
|
295 |
|
|
296 |
repositoryService.approvePiwikSite(repositoryIds.get(0), new AsyncCallback<Void>() { |
|
297 |
|
|
298 |
@Override |
|
299 |
public void onFailure(Throwable caught) { |
|
300 |
|
|
301 |
metricsAdminBoxContent.removeStyleName("loading-big"); |
|
302 |
metricsAdminBoxContent.remove(loadingWheel); |
|
303 |
|
|
304 |
errorAlert.setText("System error approving the specified piwik site(s)"); |
|
305 |
errorAlert.setVisible(true); |
|
306 |
} |
|
307 |
|
|
308 |
@Override |
|
309 |
public void onSuccess(Void result) { |
|
310 |
|
|
311 |
metricsAdminBoxContent.removeStyleName("loading-big"); |
|
312 |
metricsAdminBoxContent.remove(loadingWheel); |
|
313 |
|
|
314 |
clear(); |
|
315 |
reload(); |
|
316 |
} |
|
317 |
}); |
|
318 |
} |
|
319 |
}); |
|
320 |
actionButtons.add(yes); |
|
321 |
|
|
322 |
ModalBody modalBody = new ModalBody(); |
|
323 |
modalBody.add(modalContent); |
|
324 |
approvePiwikSitesConfirmationPopup.add(modalBody); |
|
325 |
approvePiwikSitesConfirmationPopup.getElement().getChild(0).getChild(0).getChild(0).removeFromParent(); |
|
326 |
|
|
327 |
approvePiwikSitesConfirmationPopup.show(); |
|
328 |
} |
|
329 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/admin/metrics/MetricsAdminController.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.client.admin.metrics; |
|
2 |
|
|
3 |
import com.google.gwt.user.client.ui.FlowPanel; |
|
4 |
import eu.dnetlib.repo.manager.client.TokenController; |
|
5 |
|
|
6 |
/** |
|
7 |
* Created by stefania on 10/18/17. |
|
8 |
*/ |
|
9 |
public class MetricsAdminController extends TokenController { |
|
10 |
|
|
11 |
private MetricsAdminWidget metricsAdminWidget = new MetricsAdminWidget(); |
|
12 |
|
|
13 |
private static MetricsAdminController instance = null; |
|
14 |
|
|
15 |
public static MetricsAdminController getInstance() { |
|
16 |
if (instance == null) |
|
17 |
instance = new MetricsAdminController(); |
|
18 |
|
|
19 |
return instance; |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public void showWidget(FlowPanel contentPanel, String parent, String rest) { |
|
24 |
redrawWidget(contentPanel, metricsAdminWidget, parent, rest); |
|
25 |
} |
|
26 |
|
|
27 |
// @Override |
|
28 |
// public void drawHeader(String rest) { |
|
29 |
// |
|
30 |
// RootPanel.get("pageHeader").addStyleName("row wrapper border-bottom white-bg page-heading"); |
|
31 |
// RepositoryManager.pageHeader.clear(); |
|
32 |
// RepositoryManager.pageHeader.add(new HTML("<div class=\"col-sm-9\"><h2>Help Texts Admin</h2><ol class=\"breadcrumb\">" + |
|
33 |
// "<li><a href=\"#dashboard\">Home</a></li><li class=\"active\"><strong>Help Texts Admin</strong></li></ol></div>")); |
|
34 |
// } |
|
35 |
|
|
36 |
@Override |
|
37 |
public String[] getMenuPath(String parent, String rest) { |
|
38 |
return new String[] {"metrics"}; |
|
39 |
} |
|
40 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/admin/AdminController.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.client.admin; |
|
2 |
|
|
3 |
import eu.dnetlib.repo.manager.client.TokenController; |
|
4 |
import eu.dnetlib.repo.manager.client.admin.helptexts.HelpTextsAdminController; |
|
5 |
import eu.dnetlib.repo.manager.client.admin.metrics.MetricsAdminController; |
|
6 |
|
|
7 |
/** |
|
8 |
* Created by stefania on 10/18/17. |
|
9 |
*/ |
|
10 |
public class AdminController extends TokenController { |
|
11 |
|
|
12 |
private static AdminController instance = null; |
|
13 |
|
|
14 |
public static AdminController getInstance() { |
|
15 |
if (instance == null) |
|
16 |
instance = new AdminController(); |
|
17 |
|
|
18 |
return instance; |
|
19 |
} |
|
20 |
|
|
21 |
private AdminController() { |
|
22 |
this.subControllers.put("helpTexts", HelpTextsAdminController.getInstance()); |
|
23 |
this.subControllers.put("metrics", MetricsAdminController.getInstance()); |
|
24 |
} |
|
25 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/RepositoryManager.java | ||
---|---|---|
17 | 17 |
import eu.dnetlib.domain.functionality.UserProfile; |
18 | 18 |
import eu.dnetlib.repo.manager.client.services.UserService; |
19 | 19 |
import eu.dnetlib.repo.manager.client.services.UserServiceAsync; |
20 |
import eu.dnetlib.repo.manager.shared.Tuple; |
|
20 | 21 |
import eu.dnetlib.repo.manager.shared.UserAccessException; |
21 | 22 |
|
22 | 23 |
import java.util.logging.Level; |
... | ... | |
28 | 29 |
public class RepositoryManager implements EntryPoint { |
29 | 30 |
|
30 | 31 |
public static UserProfile currentUser = null; |
32 |
public static String currentUserRole = null; |
|
31 | 33 |
|
32 | 34 |
public static String publicCaptchaKey = ""; |
33 | 35 |
|
... | ... | |
123 | 125 |
|
124 | 126 |
} else { |
125 | 127 |
|
126 |
userService.getUserByEmail(Crypto.decrypt(encryptedEmail), new AsyncCallback<UserProfile>() {
|
|
128 |
userService.getUserByEmail(Crypto.decrypt(encryptedEmail), new AsyncCallback<Tuple<UserProfile, String>>() {
|
|
127 | 129 |
|
128 | 130 |
@Override |
129 |
public void onFailure(Throwable t) { |
|
131 |
public void onFailure(Throwable caught) {
|
|
130 | 132 |
|
131 | 133 |
Cookies.removeCookie("currentUser"); |
132 | 134 |
|
... | ... | |
136 | 138 |
} |
137 | 139 |
|
138 | 140 |
@Override |
139 |
public void onSuccess(UserProfile userProfile) {
|
|
141 |
public void onSuccess(Tuple<UserProfile, String> result) {
|
|
140 | 142 |
|
141 |
RepositoryManager.currentUser = userProfile; |
|
143 |
RepositoryManager.currentUser = result.getFirst(); |
|
144 |
RepositoryManager.currentUserRole = result.getSecond(); |
|
145 |
|
|
142 | 146 |
if (RepositoryManager.currentUser != null) |
143 | 147 |
Document.get().getElementById("currentUser").setInnerText(RepositoryManager.currentUser.getFirstname() |
144 | 148 |
+ " " + RepositoryManager.currentUser.getLastname()); |
145 | 149 |
|
146 | 150 |
//TODO use role instead of email |
147 |
if(RepositoryManager.currentUser.getEmail().equals("stefania.martziou@gmail.com")) { |
|
148 |
Document.get().getElementById("helpAdmin_li").getStyle().setDisplay(Style.Display.BLOCK); |
|
151 |
if(RepositoryManager.currentUserRole.equals("admin")) { |
|
152 |
Document.get().getElementById("admin1").getStyle().setDisplay(Style.Display.BLOCK); |
|
153 |
Document.get().getElementById("admin2").getStyle().setDisplay(Style.Display.BLOCK); |
|
149 | 154 |
} |
150 | 155 |
|
151 | 156 |
String finalHistoryToken = getFinalHistoryToken(hashValue); |
... | ... | |
167 | 172 |
|
168 | 173 |
Cookies.removeCookie("currentUser"); |
169 | 174 |
RepositoryManager.currentUser = null; |
175 |
RepositoryManager.currentUserRole = null; |
|
170 | 176 |
|
171 | 177 |
if(RepositoryManager.currentToken.equals("landing")) |
172 | 178 |
NavigationManager.getInstance().navigate("landing"); |
... | ... | |
186 | 192 |
historyToken = "landing"; |
187 | 193 |
} |
188 | 194 |
|
195 |
} else if(!RepositoryManager.currentUserRole.equals("admin")) { |
|
196 |
if(historyToken.equals("admin/helpTexts") || historyToken.equals("admin/metrics")) { |
|
197 |
historyToken = "dashboard"; |
|
198 |
} |
|
189 | 199 |
} |
190 | 200 |
|
191 | 201 |
return historyToken; |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/RepositoryManagerController.java | ||
---|---|---|
4 | 4 |
import com.google.gwt.query.client.Function; |
5 | 5 |
import com.google.gwt.user.client.ui.FlowPanel; |
6 | 6 |
import com.google.gwt.user.client.ui.RootPanel; |
7 |
import eu.dnetlib.repo.manager.client.admin.AdminController; |
|
7 | 8 |
import eu.dnetlib.repo.manager.client.browsehistory.BrowseHistoryController; |
8 | 9 |
import eu.dnetlib.repo.manager.client.dashboard.DashboardController; |
9 | 10 |
import eu.dnetlib.repo.manager.client.datasources.register.DatasourceRegisterController; |
10 | 11 |
import eu.dnetlib.repo.manager.client.datasources.update.DatasourceUpdateController; |
11 | 12 |
import eu.dnetlib.repo.manager.client.enrichcontent.EnrichContentController; |
12 | 13 |
import eu.dnetlib.repo.manager.client.getimpact.GetImpactController; |
13 |
import eu.dnetlib.repo.manager.client.helpadmin.HelpAdminController;
|
|
14 |
import eu.dnetlib.repo.manager.client.admin.helptexts.HelpTextsAdminController;
|
|
14 | 15 |
import eu.dnetlib.repo.manager.client.validator.test.RunCompatibilityTestController; |
15 | 16 |
|
16 | 17 |
import static com.google.gwt.query.client.GQuery.$; |
... | ... | |
37 | 38 |
subControllers.put("manageDatasource", DatasourceUpdateController.getInstance()); |
38 | 39 |
subControllers.put("validate", RunCompatibilityTestController.getInstance()); |
39 | 40 |
subControllers.put("browseHistory", BrowseHistoryController.getInstance()); |
40 |
subControllers.put("helpAdmin", HelpAdminController.getInstance()); |
Also available in: Unified diff
svn merge -r49522:HEAD https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-repository-manager-gui/trunk .