1 |
41092
|
stefania.m
|
package eu.dnetlib.repo.manager.client.datasources.update;
|
2 |
|
|
|
3 |
|
|
import com.google.gwt.core.client.GWT;
|
4 |
48932
|
antonis.le
|
import com.google.gwt.dom.client.Document;
|
5 |
51030
|
panagiotis
|
import com.google.gwt.event.dom.client.ClickEvent;
|
6 |
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
7 |
|
|
import com.google.gwt.query.client.Function;
|
8 |
|
|
import com.google.gwt.user.client.Event;
|
9 |
|
|
import com.google.gwt.user.client.Window;
|
10 |
41092
|
stefania.m
|
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 com.google.gwt.user.client.ui.Widget;
|
14 |
|
|
import eu.dnetlib.domain.data.Repository;
|
15 |
51030
|
panagiotis
|
import eu.dnetlib.domain.functionality.validator.JobResultEntry;
|
16 |
41625
|
stefania.m
|
import eu.dnetlib.gwt.client.help.HelpService;
|
17 |
|
|
import eu.dnetlib.gwt.client.help.HelpServiceAsync;
|
18 |
48932
|
antonis.le
|
import eu.dnetlib.repo.manager.client.AbstractRepositoryManagerWidget;
|
19 |
41625
|
stefania.m
|
import eu.dnetlib.repo.manager.client.HelpCallback;
|
20 |
41637
|
stefania.m
|
import eu.dnetlib.repo.manager.client.RepositoryManager;
|
21 |
41092
|
stefania.m
|
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget;
|
22 |
51030
|
panagiotis
|
import eu.dnetlib.repo.manager.client.enrichcontent.EventsSubscriptionForm;
|
23 |
41093
|
stefania.m
|
import eu.dnetlib.repo.manager.client.services.RepositoryService;
|
24 |
|
|
import eu.dnetlib.repo.manager.client.services.RepositoryServiceAsync;
|
25 |
51030
|
panagiotis
|
import eu.dnetlib.repo.manager.client.widgets.*;
|
26 |
41092
|
stefania.m
|
import eu.dnetlib.repo.manager.shared.DatasourceVocabularies;
|
27 |
51030
|
panagiotis
|
import eu.dnetlib.repo.manager.shared.broker.OpenaireSubscription;
|
28 |
|
|
import eu.dnetlib.repo.manager.shared.broker.Subscription;
|
29 |
|
|
import org.gwtbootstrap3.client.ui.*;
|
30 |
|
|
import org.gwtbootstrap3.client.ui.TextBox;
|
31 |
41092
|
stefania.m
|
import org.gwtbootstrap3.client.ui.constants.AlertType;
|
32 |
51030
|
panagiotis
|
import org.gwtbootstrap3.client.ui.constants.ButtonType;
|
33 |
|
|
import org.gwtbootstrap3.client.ui.constants.ModalBackdrop;
|
34 |
41092
|
stefania.m
|
|
35 |
51030
|
panagiotis
|
import static com.google.gwt.query.client.GQuery.$;
|
36 |
|
|
|
37 |
41092
|
stefania.m
|
/**
|
38 |
|
|
* Created by stefania on 1/14/16.
|
39 |
|
|
*/
|
40 |
48932
|
antonis.le
|
public class UpdateRepositoryWidget extends AbstractRepositoryManagerWidget implements RepositoryManagerWidget {
|
41 |
41092
|
stefania.m
|
|
42 |
|
|
private String parentToken = "";
|
43 |
|
|
private String restToken = "";
|
44 |
|
|
|
45 |
51030
|
panagiotis
|
private static HTML title = new HTML();
|
46 |
41092
|
stefania.m
|
private FlowPanel updateRepositoryBoxContent = new FlowPanel();
|
47 |
|
|
|
48 |
|
|
private Alert errorAlert = new Alert();
|
49 |
51030
|
panagiotis
|
private Alert successAlert = new Alert();
|
50 |
41092
|
stefania.m
|
|
51 |
|
|
private RepositoryServiceAsync repositoryService = GWT.create(RepositoryService.class);
|
52 |
41625
|
stefania.m
|
private static HelpServiceAsync helpService = GWT.create(HelpService.class);
|
53 |
41092
|
stefania.m
|
|
54 |
|
|
public UpdateRepositoryWidget() {
|
55 |
|
|
|
56 |
48932
|
antonis.le
|
title.addStyleName("uk-margin-medium-bottom");
|
57 |
|
|
contentPanel.add(title);
|
58 |
41092
|
stefania.m
|
|
59 |
|
|
errorAlert.setType(AlertType.DANGER);
|
60 |
|
|
errorAlert.setDismissable(false);
|
61 |
|
|
errorAlert.setVisible(false);
|
62 |
|
|
updateRepositoryBoxContent.add(errorAlert);
|
63 |
|
|
|
64 |
51030
|
panagiotis
|
successAlert.setType(AlertType.SUCCESS);
|
65 |
|
|
successAlert.setDismissable(false);
|
66 |
|
|
successAlert.setVisible(false);
|
67 |
|
|
updateRepositoryBoxContent.add(successAlert);
|
68 |
|
|
|
69 |
48932
|
antonis.le
|
contentPanel.add(updateRepositoryBoxContent);
|
70 |
41092
|
stefania.m
|
}
|
71 |
|
|
|
72 |
|
|
@Override
|
73 |
|
|
public void clear() {
|
74 |
|
|
updateRepositoryBoxContent.clear();
|
75 |
|
|
errorAlert.setVisible(false);
|
76 |
51030
|
panagiotis
|
successAlert.setVisible(false);
|
77 |
48932
|
antonis.le
|
gridPanel.remove(helpPanel);
|
78 |
41092
|
stefania.m
|
}
|
79 |
|
|
|
80 |
|
|
@Override
|
81 |
|
|
public void reload() {
|
82 |
|
|
|
83 |
48932
|
antonis.le
|
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent");
|
84 |
41092
|
stefania.m
|
updateRepositoryBoxContent.add(errorAlert);
|
85 |
51030
|
panagiotis
|
updateRepositoryBoxContent.add(successAlert);
|
86 |
41092
|
stefania.m
|
|
87 |
|
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\" style=\"text-align: center; padding-top: 170px; " +
|
88 |
|
|
"color: rgb(47, 64, 80); font-weight: bold;\">Retrieving repository...</div>" +
|
89 |
|
|
"<div class=\"whiteFilm\"></div>");
|
90 |
|
|
updateRepositoryBoxContent.addStyleName("loading-big");
|
91 |
|
|
updateRepositoryBoxContent.add(loadingWheel);
|
92 |
|
|
|
93 |
48932
|
antonis.le
|
helpService.getHelpById(parentToken + "_updateRepo", new HelpCallback(helpPanel, gridPanel));
|
94 |
41625
|
stefania.m
|
|
95 |
41092
|
stefania.m
|
repositoryService.getRepository(restToken, new AsyncCallback<Repository>() {
|
96 |
|
|
|
97 |
|
|
@Override
|
98 |
|
|
public void onFailure(Throwable caught) {
|
99 |
|
|
|
100 |
|
|
updateRepositoryBoxContent.removeStyleName("loading-big");
|
101 |
|
|
updateRepositoryBoxContent.remove(loadingWheel);
|
102 |
|
|
|
103 |
|
|
errorAlert.setText("System error retrieving repository");
|
104 |
|
|
errorAlert.setVisible(true);
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
@Override
|
108 |
|
|
public void onSuccess(final Repository repository) {
|
109 |
|
|
|
110 |
51030
|
panagiotis
|
String logoURLSource = "";
|
111 |
|
|
if(repository.getLogoUrl()==null || repository.getLogoUrl().isEmpty())
|
112 |
|
|
logoURLSource = "img/yourLogoHere.jpg";
|
113 |
|
|
else
|
114 |
|
|
logoURLSource = repository.getLogoUrl();
|
115 |
|
|
|
116 |
|
|
title.setHTML("<h1 class=\"uk-article-title\">" +
|
117 |
|
|
"<a id=\"updateLogoURL\" href=\"javascript:;\">" +
|
118 |
|
|
"<img src=\"" + logoURLSource + "\" alt=\"[Repo Logo]\" width=\"60px\" style=\"margin-right: 15px; margin-top:-8px\"></a>" +
|
119 |
|
|
repository.getOfficialName() + "</h1>");
|
120 |
|
|
|
121 |
48932
|
antonis.le
|
// RepositoryManager.pageHeader.clear();
|
122 |
|
|
//
|
123 |
|
|
// String logoURLSource = "";
|
124 |
|
|
// if(repository.getLogoUrl()==null || repository.getLogoUrl().isEmpty())
|
125 |
|
|
// logoURLSource = "img/yourLogoHere.jpg";
|
126 |
|
|
// else
|
127 |
|
|
// logoURLSource = repository.getLogoUrl();
|
128 |
|
|
//
|
129 |
|
|
// RepositoryManager.pageHeader.add(new HTML("<div class=\"col-sm-9\"><h2><img src=\"" + logoURLSource + "\" alt=[Repo Logo]" +
|
130 |
|
|
// "width=\"35px\" height=\"35px\" style=\"margin-right: 15px; margin-top:-2px\">" + repository.getOfficialName() + "</h2>" +
|
131 |
|
|
// "<ol class=\"breadcrumb\"><li><a href=\"#dashboard\">Home</a></li><li><a href=\"#" + parentToken +
|
132 |
|
|
// "\">Manage Datasources</a></li><li class=\"active\"><strong>" + repository.getOfficialName() +
|
133 |
|
|
// "</strong></li></ol></div><div class=\"col-sm-3\"><div class=\"nav navbar-top-links navbar-right\">" +
|
134 |
|
|
// "<button id=\"addLogoURL\" style=\"margin-top: 30px; margin-right: 20px\" type=\"button\" " +
|
135 |
|
|
// "class=\"btn btn-w-m btn-white\">Update Logo URL</button></div></div>"));
|
136 |
41637
|
stefania.m
|
|
137 |
41092
|
stefania.m
|
repositoryService.getDatasourceVocabularies(repository.getDatasourceType(),
|
138 |
|
|
new AsyncCallback<DatasourceVocabularies>() {
|
139 |
|
|
|
140 |
|
|
@Override
|
141 |
|
|
public void onFailure(Throwable caught) {
|
142 |
|
|
|
143 |
|
|
updateRepositoryBoxContent.removeStyleName("loading-big");
|
144 |
|
|
updateRepositoryBoxContent.remove(loadingWheel);
|
145 |
|
|
|
146 |
|
|
errorAlert.setText("System error retrieving datasource vocabularies");
|
147 |
|
|
errorAlert.setVisible(true);
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
@Override
|
151 |
|
|
public void onSuccess(DatasourceVocabularies datasourceVocabularies) {
|
152 |
|
|
|
153 |
|
|
updateRepositoryBoxContent.removeStyleName("loading-big");
|
154 |
|
|
updateRepositoryBoxContent.remove(loadingWheel);
|
155 |
|
|
|
156 |
|
|
UpdateRepositoryForm updateRepositoryForm =
|
157 |
|
|
new UpdateRepositoryForm(repository.getDatasourceType(), datasourceVocabularies, repository);
|
158 |
|
|
updateRepositoryBoxContent.add(updateRepositoryForm.asWidget());
|
159 |
51030
|
panagiotis
|
|
160 |
|
|
addHandlers(repository);
|
161 |
41092
|
stefania.m
|
}
|
162 |
|
|
});
|
163 |
|
|
}
|
164 |
|
|
});
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
@Override
|
168 |
|
|
public void setToken(String parentToken, String rest) {
|
169 |
|
|
this.parentToken = parentToken;
|
170 |
|
|
this.restToken = rest;
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
@Override
|
174 |
|
|
public void afterAdditionToRootPanel() {
|
175 |
|
|
|
176 |
|
|
}
|
177 |
51030
|
panagiotis
|
|
178 |
|
|
private void addHandlers(final Repository repository) {
|
179 |
|
|
|
180 |
|
|
$("#updateLogoURL").click(new Function() {
|
181 |
|
|
|
182 |
|
|
public boolean f(Event e) {
|
183 |
|
|
|
184 |
|
|
errorAlert.setVisible(false);
|
185 |
|
|
successAlert.setVisible(false);
|
186 |
|
|
|
187 |
|
|
openModalToEnterLogoURL(repository);
|
188 |
|
|
|
189 |
|
|
return true;
|
190 |
|
|
}
|
191 |
|
|
});
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
private void openModalToEnterLogoURL(final Repository repository) {
|
195 |
|
|
|
196 |
|
|
final Modal updateLogoURLModal = new Modal();
|
197 |
|
|
updateLogoURLModal.setDataBackdrop(ModalBackdrop.STATIC);
|
198 |
|
|
|
199 |
|
|
FlowPanel modalContent = new FlowPanel();
|
200 |
|
|
|
201 |
|
|
HTML title = new HTML("<h2 class=\"uk-modal-title\">Update Logo URL</h2>\n");
|
202 |
|
|
modalContent.add(title);
|
203 |
|
|
|
204 |
|
|
Form logoURLForm = new Form();
|
205 |
|
|
|
206 |
|
|
final TextBox logoURLTextBox = new TextBox();
|
207 |
|
|
if(repository.getLogoUrl()==null || repository.getLogoUrl().isEmpty())
|
208 |
|
|
logoURLTextBox.setPlaceholder("Logo URL");
|
209 |
|
|
else
|
210 |
|
|
logoURLTextBox.setValue(repository.getLogoUrl());
|
211 |
|
|
|
212 |
|
|
logoURLForm.addStyleName("uk-margin uk-grid");
|
213 |
|
|
|
214 |
|
|
FlowPanel logoURLTextBoxWrapper = new FlowPanel();
|
215 |
|
|
logoURLTextBoxWrapper.addStyleName("uk-width-1-1");
|
216 |
|
|
logoURLTextBoxWrapper.add(logoURLTextBox);
|
217 |
|
|
logoURLForm.add(logoURLTextBoxWrapper);
|
218 |
|
|
|
219 |
|
|
modalContent.add(logoURLForm);
|
220 |
|
|
|
221 |
|
|
FlowPanel actionButtons = new FlowPanel();
|
222 |
|
|
actionButtons.addStyleName("uk-text-right uk-margin-bottom");
|
223 |
|
|
modalContent.add(actionButtons);
|
224 |
|
|
|
225 |
|
|
Button no = new Button("Cancel");
|
226 |
|
|
no.addStyleName("uk-button uk-button-default");
|
227 |
|
|
no.addClickHandler(new ClickHandler() {
|
228 |
|
|
@Override
|
229 |
|
|
public void onClick(ClickEvent event) {
|
230 |
|
|
updateLogoURLModal.hide();
|
231 |
|
|
updateLogoURLModal.removeFromParent();
|
232 |
|
|
}
|
233 |
|
|
});
|
234 |
|
|
actionButtons.add(no);
|
235 |
|
|
|
236 |
|
|
Button yes = new Button("Update");
|
237 |
|
|
yes.addStyleName("uk-button uk-button-primary");
|
238 |
|
|
yes.addClickHandler(new ClickHandler() {
|
239 |
|
|
@Override
|
240 |
|
|
public void onClick(ClickEvent event) {
|
241 |
|
|
|
242 |
|
|
repository.setLogoUrl(logoURLTextBox.getValue().trim());
|
243 |
|
|
repositoryService.updateRepositoryInformation(repository, new AsyncCallback<Void>() {
|
244 |
|
|
|
245 |
|
|
@Override
|
246 |
|
|
public void onFailure(Throwable throwable) {
|
247 |
|
|
|
248 |
|
|
errorAlert.setText("System error updating logo URL");
|
249 |
|
|
errorAlert.setVisible(true);
|
250 |
|
|
|
251 |
|
|
updateLogoURLModal.hide();
|
252 |
|
|
updateLogoURLModal.removeFromParent();
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
@Override
|
256 |
|
|
public void onSuccess(Void aVoid) {
|
257 |
|
|
|
258 |
|
|
successAlert.setVisible(true);
|
259 |
|
|
successAlert.setText("Logo updated successfully");
|
260 |
|
|
|
261 |
|
|
String logoURLSource = "";
|
262 |
|
|
if(repository.getLogoUrl()==null || repository.getLogoUrl().isEmpty())
|
263 |
|
|
logoURLSource = "img/yourLogoHere.jpg";
|
264 |
|
|
else
|
265 |
|
|
logoURLSource = repository.getLogoUrl();
|
266 |
|
|
|
267 |
|
|
UpdateRepositoryWidget.title.setHTML("<h1 class=\"uk-article-title\">" +
|
268 |
|
|
"<a id=\"updateLogoURL\" href=\"javascript:;\">" +
|
269 |
|
|
"<img src=\"" + logoURLSource + "\" alt=\"[Repo Logo]\" width=\"60px\" style=\"margin-right: 15px; margin-top:-8px\"></a>" +
|
270 |
|
|
repository.getOfficialName() + "</h1>");
|
271 |
|
|
|
272 |
|
|
addHandlers(repository);
|
273 |
|
|
|
274 |
|
|
updateLogoURLModal.hide();
|
275 |
|
|
updateLogoURLModal.removeFromParent();
|
276 |
|
|
}
|
277 |
|
|
});
|
278 |
|
|
}
|
279 |
|
|
});
|
280 |
|
|
actionButtons.add(yes);
|
281 |
|
|
|
282 |
|
|
ModalBody modalBody = new ModalBody();
|
283 |
|
|
modalBody.add(modalContent);
|
284 |
|
|
updateLogoURLModal.add(modalBody);
|
285 |
|
|
updateLogoURLModal.getElement().getChild(0).getChild(0).getChild(0).removeFromParent();
|
286 |
|
|
|
287 |
|
|
updateLogoURLModal.show();
|
288 |
|
|
}
|
289 |
41092
|
stefania.m
|
}
|