1
|
package eu.dnetlib.repo.manager.client.monitor;
|
2
|
|
3
|
import com.google.gwt.core.client.GWT;
|
4
|
import com.google.gwt.dom.client.Document;
|
5
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
6
|
import com.google.gwt.user.client.ui.FlowPanel;
|
7
|
import com.google.gwt.user.client.ui.HTML;
|
8
|
import eu.dnetlib.gwt.client.help.HelpService;
|
9
|
import eu.dnetlib.gwt.client.help.HelpServiceAsync;
|
10
|
import eu.dnetlib.repo.manager.client.AbstractRepositoryManagerWidget;
|
11
|
import eu.dnetlib.repo.manager.client.HelpCallback;
|
12
|
import eu.dnetlib.repo.manager.client.RepositoryManager;
|
13
|
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget;
|
14
|
import eu.dnetlib.repo.manager.client.services.RepositoryService;
|
15
|
import eu.dnetlib.repo.manager.client.services.RepositoryServiceAsync;
|
16
|
import eu.dnetlib.repo.manager.client.widgets.ListOrGridViewOfDatasourcesWidget;
|
17
|
import eu.dnetlib.repo.manager.client.widgets.OpenAIRECompliantLogoDownloadWidget;
|
18
|
import eu.dnetlib.repo.manager.shared.DatasourcesCollection;
|
19
|
import org.gwtbootstrap3.client.ui.Alert;
|
20
|
import org.gwtbootstrap3.client.ui.constants.AlertType;
|
21
|
|
22
|
/**
|
23
|
* Created by stefania on 11/30/17.
|
24
|
*/
|
25
|
public class MonitorWidget extends AbstractRepositoryManagerWidget implements RepositoryManagerWidget {
|
26
|
|
27
|
private String parentToken = "";
|
28
|
private String restToken = "";
|
29
|
|
30
|
private Alert errorAlert = new Alert();
|
31
|
|
32
|
private FlowPanel monitorContent = new FlowPanel();
|
33
|
|
34
|
private static HelpServiceAsync helpService = GWT.create(HelpService.class);
|
35
|
private RepositoryServiceAsync repositoryService = GWT.create(RepositoryService.class);
|
36
|
|
37
|
public MonitorWidget() {
|
38
|
|
39
|
super();
|
40
|
|
41
|
HTML title = new HTML("<h1 class=\"uk-article-title\">Monitor</h1>");
|
42
|
title.addStyleName("uk-margin-medium-bottom");
|
43
|
contentPanel.add(title);
|
44
|
|
45
|
errorAlert.setType(AlertType.DANGER);
|
46
|
errorAlert.setDismissable(false);
|
47
|
errorAlert.setVisible(false);
|
48
|
contentPanel.add(errorAlert);
|
49
|
|
50
|
contentPanel.add(monitorContent);
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
public void clear() {
|
55
|
monitorContent.clear();
|
56
|
errorAlert.setVisible(false);
|
57
|
gridPanel.remove(helpPanel);
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
public void reload() {
|
62
|
|
63
|
errorAlert.setVisible(false);
|
64
|
|
65
|
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent");
|
66
|
|
67
|
helpService.getHelpById(parentToken, new HelpCallback(helpPanel, gridPanel));
|
68
|
|
69
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\" style=\"text-align: center; padding-top: 170px; " +
|
70
|
"color: rgb(47, 64, 80); font-weight: bold;\">Retrieving repositories...</div>" +
|
71
|
"<div class=\"whiteFilm\"></div>");
|
72
|
monitorContent.addStyleName("loading-big");
|
73
|
monitorContent.add(loadingWheel);
|
74
|
|
75
|
repositoryService.getRepositoriesOfUser(RepositoryManager.currentUser.getEmail(), true, false,
|
76
|
new AsyncCallback<DatasourcesCollection>() {
|
77
|
|
78
|
@Override
|
79
|
public void onFailure(Throwable caught) {
|
80
|
|
81
|
monitorContent.removeStyleName("loading-big");
|
82
|
monitorContent.remove(loadingWheel);
|
83
|
|
84
|
Alert errorAlert = new Alert();
|
85
|
errorAlert.setType(AlertType.DANGER);
|
86
|
errorAlert.setText("System error retrieving repositories.");
|
87
|
errorAlert.setDismissable(false);
|
88
|
monitorContent.add(errorAlert);
|
89
|
}
|
90
|
|
91
|
@Override
|
92
|
public void onSuccess(DatasourcesCollection datasourcesCollection) {
|
93
|
|
94
|
monitorContent.removeStyleName("loading-big");
|
95
|
monitorContent.remove(loadingWheel);
|
96
|
|
97
|
ListOrGridViewOfDatasourcesWidget listOrGridViewOfDatasourcesWidget =
|
98
|
new ListOrGridViewOfDatasourcesWidget(datasourcesCollection, "Choose the Datasource you would like to manage",
|
99
|
parentToken, "<i class=\"fa fa-pencil\" aria-hidden=\"true\"></i>", false);
|
100
|
|
101
|
monitorContent.add(listOrGridViewOfDatasourcesWidget.asWidget());
|
102
|
}
|
103
|
});
|
104
|
}
|
105
|
|
106
|
@Override
|
107
|
public void setToken(String parentToken, String rest) {
|
108
|
this.parentToken = parentToken;
|
109
|
this.restToken = rest;
|
110
|
}
|
111
|
|
112
|
@Override
|
113
|
public void afterAdditionToRootPanel() {
|
114
|
|
115
|
}
|
116
|
}
|