Revision 51030
Added by Panagiotis Kanakakis about 6 years ago
UpdateRepositoryWidget.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import com.google.gwt.core.client.GWT; |
4 | 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.query.client.Function; |
|
8 |
import com.google.gwt.user.client.Event; |
|
9 |
import com.google.gwt.user.client.Window; |
|
5 | 10 |
import com.google.gwt.user.client.rpc.AsyncCallback; |
6 | 11 |
import com.google.gwt.user.client.ui.FlowPanel; |
7 | 12 |
import com.google.gwt.user.client.ui.HTML; |
8 | 13 |
import com.google.gwt.user.client.ui.Widget; |
9 | 14 |
import eu.dnetlib.domain.data.Repository; |
15 |
import eu.dnetlib.domain.functionality.validator.JobResultEntry; |
|
10 | 16 |
import eu.dnetlib.gwt.client.help.HelpService; |
11 | 17 |
import eu.dnetlib.gwt.client.help.HelpServiceAsync; |
12 | 18 |
import eu.dnetlib.repo.manager.client.AbstractRepositoryManagerWidget; |
13 | 19 |
import eu.dnetlib.repo.manager.client.HelpCallback; |
14 | 20 |
import eu.dnetlib.repo.manager.client.RepositoryManager; |
15 | 21 |
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget; |
22 |
import eu.dnetlib.repo.manager.client.enrichcontent.EventsSubscriptionForm; |
|
16 | 23 |
import eu.dnetlib.repo.manager.client.services.RepositoryService; |
17 | 24 |
import eu.dnetlib.repo.manager.client.services.RepositoryServiceAsync; |
25 |
import eu.dnetlib.repo.manager.client.widgets.*; |
|
18 | 26 |
import eu.dnetlib.repo.manager.shared.DatasourceVocabularies; |
19 |
import org.gwtbootstrap3.client.ui.Alert; |
|
27 |
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; |
|
20 | 31 |
import org.gwtbootstrap3.client.ui.constants.AlertType; |
32 |
import org.gwtbootstrap3.client.ui.constants.ButtonType; |
|
33 |
import org.gwtbootstrap3.client.ui.constants.ModalBackdrop; |
|
21 | 34 |
|
35 |
import static com.google.gwt.query.client.GQuery.$; |
|
36 |
|
|
22 | 37 |
/** |
23 | 38 |
* Created by stefania on 1/14/16. |
24 | 39 |
*/ |
... | ... | |
27 | 42 |
private String parentToken = ""; |
28 | 43 |
private String restToken = ""; |
29 | 44 |
|
45 |
private static HTML title = new HTML(); |
|
30 | 46 |
private FlowPanel updateRepositoryBoxContent = new FlowPanel(); |
31 | 47 |
|
32 | 48 |
private Alert errorAlert = new Alert(); |
49 |
private Alert successAlert = new Alert(); |
|
33 | 50 |
|
34 | 51 |
private RepositoryServiceAsync repositoryService = GWT.create(RepositoryService.class); |
35 | 52 |
private static HelpServiceAsync helpService = GWT.create(HelpService.class); |
36 | 53 |
|
37 | 54 |
public UpdateRepositoryWidget() { |
38 | 55 |
|
39 |
HTML title = new HTML("<h1 class=\"uk-article-title\">Update your datasource</h1>"); |
|
40 | 56 |
title.addStyleName("uk-margin-medium-bottom"); |
41 | 57 |
contentPanel.add(title); |
42 | 58 |
|
... | ... | |
45 | 61 |
errorAlert.setVisible(false); |
46 | 62 |
updateRepositoryBoxContent.add(errorAlert); |
47 | 63 |
|
64 |
successAlert.setType(AlertType.SUCCESS); |
|
65 |
successAlert.setDismissable(false); |
|
66 |
successAlert.setVisible(false); |
|
67 |
updateRepositoryBoxContent.add(successAlert); |
|
68 |
|
|
48 | 69 |
contentPanel.add(updateRepositoryBoxContent); |
49 | 70 |
} |
50 | 71 |
|
... | ... | |
52 | 73 |
public void clear() { |
53 | 74 |
updateRepositoryBoxContent.clear(); |
54 | 75 |
errorAlert.setVisible(false); |
76 |
successAlert.setVisible(false); |
|
55 | 77 |
gridPanel.remove(helpPanel); |
56 | 78 |
} |
57 | 79 |
|
... | ... | |
60 | 82 |
|
61 | 83 |
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent"); |
62 | 84 |
updateRepositoryBoxContent.add(errorAlert); |
85 |
updateRepositoryBoxContent.add(successAlert); |
|
63 | 86 |
|
64 | 87 |
final HTML loadingWheel = new HTML("<div class=\"loader-big\" style=\"text-align: center; padding-top: 170px; " + |
65 | 88 |
"color: rgb(47, 64, 80); font-weight: bold;\">Retrieving repository...</div>" + |
... | ... | |
84 | 107 |
@Override |
85 | 108 |
public void onSuccess(final Repository repository) { |
86 | 109 |
|
110 |
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 |
|
|
87 | 121 |
// RepositoryManager.pageHeader.clear(); |
88 | 122 |
// |
89 | 123 |
// String logoURLSource = ""; |
... | ... | |
122 | 156 |
UpdateRepositoryForm updateRepositoryForm = |
123 | 157 |
new UpdateRepositoryForm(repository.getDatasourceType(), datasourceVocabularies, repository); |
124 | 158 |
updateRepositoryBoxContent.add(updateRepositoryForm.asWidget()); |
159 |
|
|
160 |
addHandlers(repository); |
|
125 | 161 |
} |
126 | 162 |
}); |
127 | 163 |
} |
... | ... | |
138 | 174 |
public void afterAdditionToRootPanel() { |
139 | 175 |
|
140 | 176 |
} |
177 |
|
|
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 |
} |
|
141 | 289 |
} |
Also available in: Unified diff
1. Properties file changes.
2. Aggregation details / aggregation object add.
3. Other changes from stef