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.Window;
|
6
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
7
|
import com.google.gwt.user.client.ui.FlowPanel;
|
8
|
import com.google.gwt.user.client.ui.HTML;
|
9
|
import eu.dnetlib.domain.data.Repository;
|
10
|
import eu.dnetlib.gwt.client.help.HelpService;
|
11
|
import eu.dnetlib.gwt.client.help.HelpServiceAsync;
|
12
|
import eu.dnetlib.repo.manager.client.AbstractRepositoryManagerWidget;
|
13
|
import eu.dnetlib.repo.manager.client.HelpCallback;
|
14
|
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget;
|
15
|
import eu.dnetlib.repo.manager.client.services.RepositoryService;
|
16
|
import eu.dnetlib.repo.manager.client.services.RepositoryServiceAsync;
|
17
|
import eu.dnetlib.repo.manager.shared.Aggregations;
|
18
|
import org.gwtbootstrap3.client.ui.Alert;
|
19
|
import org.gwtbootstrap3.client.ui.constants.AlertType;
|
20
|
|
21
|
/**
|
22
|
* Created by stefania on 1/16/18.
|
23
|
*/
|
24
|
public class CollectionMonitorWidget extends AbstractRepositoryManagerWidget implements RepositoryManagerWidget {
|
25
|
|
26
|
private String parentToken = "";
|
27
|
private String restToken = "";
|
28
|
|
29
|
private Alert errorAlert = new Alert();
|
30
|
|
31
|
private HTML title = new HTML();
|
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 CollectionMonitorWidget() {
|
38
|
|
39
|
super();
|
40
|
|
41
|
title.addStyleName("uk-margin-medium-bottom");
|
42
|
contentPanel.add(title);
|
43
|
|
44
|
errorAlert.setType(AlertType.DANGER);
|
45
|
errorAlert.setDismissable(false);
|
46
|
errorAlert.setVisible(false);
|
47
|
contentPanel.add(errorAlert);
|
48
|
|
49
|
contentPanel.add(monitorContent);
|
50
|
}
|
51
|
|
52
|
@Override
|
53
|
public void clear() {
|
54
|
|
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 repository info...</div>" +
|
71
|
"<div class=\"whiteFilm\"></div>");
|
72
|
monitorContent.addStyleName("loading-big");
|
73
|
monitorContent.add(loadingWheel);
|
74
|
|
75
|
repositoryService.getRepository(restToken, new AsyncCallback<Repository>() {
|
76
|
|
77
|
@Override
|
78
|
public void onFailure(Throwable throwable) {
|
79
|
|
80
|
monitorContent.removeStyleName("loading-big");
|
81
|
monitorContent.remove(loadingWheel);
|
82
|
|
83
|
Alert errorAlert = new Alert();
|
84
|
errorAlert.setType(AlertType.DANGER);
|
85
|
errorAlert.setText("System error retrieving repository info.");
|
86
|
errorAlert.setDismissable(false);
|
87
|
monitorContent.add(errorAlert);
|
88
|
}
|
89
|
|
90
|
@Override
|
91
|
public void onSuccess(Repository repository) {
|
92
|
|
93
|
title.setHTML("<h1 class=\"uk-article-title\">Aggregation history for " + repository.getOfficialName() + "</h1>");
|
94
|
|
95
|
repositoryService.getRepositoryAggregations(restToken, new AsyncCallback<Aggregations>() {
|
96
|
|
97
|
@Override
|
98
|
public void onFailure(Throwable throwable) {
|
99
|
|
100
|
monitorContent.removeStyleName("loading-big");
|
101
|
monitorContent.remove(loadingWheel);
|
102
|
|
103
|
Alert errorAlert = new Alert();
|
104
|
errorAlert.setType(AlertType.DANGER);
|
105
|
errorAlert.setText("System error retrieving repository aggregation history.");
|
106
|
errorAlert.setDismissable(false);
|
107
|
monitorContent.add(errorAlert);
|
108
|
}
|
109
|
|
110
|
@Override
|
111
|
public void onSuccess(Aggregations aggregations) {
|
112
|
|
113
|
monitorContent.removeStyleName("loading-big");
|
114
|
monitorContent.remove(loadingWheel);
|
115
|
|
116
|
if(aggregations==null || aggregations.getAggregationHistory()==null
|
117
|
|| aggregations.getAggregationHistory().isEmpty()) {
|
118
|
HTML message = new HTML("<div>There is no aggregation history for this repository at the moment</div>");
|
119
|
monitorContent.add(message);
|
120
|
} else {
|
121
|
AggregationHistoryTimeline aggregationHistoryTimeline = new AggregationHistoryTimeline(aggregations.getAggregationHistory());
|
122
|
monitorContent.add(aggregationHistoryTimeline.asWidget());
|
123
|
}
|
124
|
}
|
125
|
});
|
126
|
}
|
127
|
});
|
128
|
}
|
129
|
|
130
|
@Override
|
131
|
public void setToken(String parentToken, String rest) {
|
132
|
this.parentToken = parentToken;
|
133
|
this.restToken = rest;
|
134
|
}
|
135
|
|
136
|
@Override
|
137
|
public void afterAdditionToRootPanel() {
|
138
|
|
139
|
}
|
140
|
}
|