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.shared.DatasourcesCollection;
|
18
|
import org.gwtbootstrap3.client.ui.Alert;
|
19
|
import org.gwtbootstrap3.client.ui.constants.AlertType;
|
20
|
|
21
|
/**
|
22
|
* Created by stefania on 11/30/17.
|
23
|
*/
|
24
|
public class MonitorWidget extends AbstractRepositoryManagerWidget implements RepositoryManagerWidget {
|
25
|
|
26
|
private String parentToken = "";
|
27
|
private String restToken = "";
|
28
|
|
29
|
private Alert errorAlert = new Alert();
|
30
|
|
31
|
private FlowPanel monitorContent = new FlowPanel();
|
32
|
|
33
|
private static HelpServiceAsync helpService = GWT.create(HelpService.class);
|
34
|
private RepositoryServiceAsync repositoryService = GWT.create(RepositoryService.class);
|
35
|
|
36
|
public MonitorWidget() {
|
37
|
|
38
|
super();
|
39
|
|
40
|
HTML title = new HTML("<h1 class=\"uk-article-title\">Monitor</h1>");
|
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
|
monitorContent.clear();
|
55
|
errorAlert.setVisible(false);
|
56
|
gridPanel.remove(helpPanel);
|
57
|
}
|
58
|
|
59
|
@Override
|
60
|
public void reload() {
|
61
|
|
62
|
errorAlert.setVisible(false);
|
63
|
|
64
|
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent");
|
65
|
|
66
|
helpService.getHelpById(parentToken, new HelpCallback(helpPanel, gridPanel));
|
67
|
|
68
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\" style=\"text-align: center; padding-top: 170px; " +
|
69
|
"color: rgb(47, 64, 80); font-weight: bold;\">Retrieving repositories...</div>" +
|
70
|
"<div class=\"whiteFilm\"></div>");
|
71
|
monitorContent.addStyleName("loading-big");
|
72
|
monitorContent.add(loadingWheel);
|
73
|
|
74
|
repositoryService.getRepositoriesOfUser(RepositoryManager.currentUser.getEmail(), true, false,
|
75
|
new AsyncCallback<DatasourcesCollection>() {
|
76
|
|
77
|
@Override
|
78
|
public void onFailure(Throwable caught) {
|
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 repositories.");
|
86
|
errorAlert.setDismissable(false);
|
87
|
monitorContent.add(errorAlert);
|
88
|
}
|
89
|
|
90
|
@Override
|
91
|
public void onSuccess(DatasourcesCollection datasourcesCollection) {
|
92
|
|
93
|
monitorContent.removeStyleName("loading-big");
|
94
|
monitorContent.remove(loadingWheel);
|
95
|
|
96
|
ListOrGridViewOfDatasourcesWidget listOrGridViewOfDatasourcesWidget =
|
97
|
new ListOrGridViewOfDatasourcesWidget(datasourcesCollection, "Choose the Datasource you would like to manage",
|
98
|
parentToken, "<i class=\"fa fa-pencil\" aria-hidden=\"true\"></i>", false);
|
99
|
|
100
|
monitorContent.add(listOrGridViewOfDatasourcesWidget.asWidget());
|
101
|
}
|
102
|
});
|
103
|
}
|
104
|
|
105
|
@Override
|
106
|
public void setToken(String parentToken, String rest) {
|
107
|
this.parentToken = parentToken;
|
108
|
this.restToken = rest;
|
109
|
}
|
110
|
|
111
|
@Override
|
112
|
public void afterAdditionToRootPanel() {
|
113
|
|
114
|
}
|
115
|
}
|