use of cz.metacentrum.perun.webgui.json.rtMessagesManager.SendMessageToRt in project perun by CESNET.
the class JsonErrorHandler method reportBox.
/**
* Creates and display a report box used for reporting errors
*
* @param error Error object returned from RPC
*/
public static void reportBox(final PerunError error) {
// clear password fields if present
final JSONObject postObject = new JSONObject(JsonUtils.parseJson(error.getPostData()));
if (postObject.getJavaScriptObject() != null) {
clearPasswords(postObject);
}
String s = "unknown";
if (PerunWebSession.getInstance().getTabManager() != null) {
s = PerunWebSession.getInstance().getTabManager().getCurrentUrl(true);
}
final String status = s;
final TextBox boxSubject = new TextBox();
boxSubject.setValue("Reported error: " + error.getRequest().getManager() + "/" + error.getRequest().getMethod() + " (" + error.getErrorId() + ")");
boxSubject.setWidth("100%");
final TextArea messageTextBox = new TextArea();
messageTextBox.setSize("335px", "100px");
// ok click - report
ClickHandler sendReportHandler = new ClickHandler() {
public void onClick(ClickEvent event) {
String text = getErrorFullMessage(messageTextBox, error, postObject, status);
final String finalText = text;
// request itself
SendMessageToRt msg = new SendMessageToRt(new JsonCallbackEvents() {
@Override
public void onError(PerunError error) {
FlexTable layout = new FlexTable();
TextArea scrollPanel = new TextArea();
scrollPanel.setText(finalText);
layout.setWidget(0, 0, new HTML("<p>" + new Image(LargeIcons.INSTANCE.errorIcon())));
layout.setHTML(0, 1, "<p>Reporting errors is not working at the moment. We are sorry for inconvenience. <p>Please send following text to <strong>perun@cesnet.cz</strong>.");
layout.getFlexCellFormatter().setColSpan(1, 0, 2);
layout.setWidget(1, 0, scrollPanel);
scrollPanel.setSize("350px", "150px");
layout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
layout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
layout.getFlexCellFormatter().setStyleName(0, 0, "alert-box-image");
Confirm c = new Confirm("Error report is not working", layout, true);
c.setNonScrollable(true);
c.setAutoHide(false);
c.show();
}
});
if (boxSubject.getValue().isEmpty()) {
msg.sendMessage(SendMessageToRt.DEFAULT_QUEUE, "Reported error: " + error.getRequest().getManager() + "/" + error.getRequest().getMethod() + " (" + error.getErrorId() + ")", text);
} else {
msg.sendMessage(SendMessageToRt.DEFAULT_QUEUE, boxSubject.getValue(), text);
}
}
};
FlexTable baseLayout = new FlexTable();
baseLayout.setStyleName("alert-box-table");
baseLayout.setWidth("350px");
baseLayout.setHTML(0, 0, "<p>You can provide any message for this error report (e.g. describing what you tried to do). When you are done, click on send button.");
baseLayout.setHTML(1, 0, "<strong>Subject:</strong>");
baseLayout.setWidget(2, 0, boxSubject);
baseLayout.setHTML(3, 0, "<strong>Message:</strong>");
baseLayout.setWidget(4, 0, messageTextBox);
final Anchor showDetails = new Anchor("Show message preview");
final TextArea fullMessage = new TextArea();
fullMessage.setReadOnly(true);
fullMessage.setVisible(false);
fullMessage.setSize("335px", "100px");
showDetails.addClickHandler(new ClickHandler() {
boolean pressed = false;
@Override
public void onClick(ClickEvent clickEvent) {
if (pressed) {
showDetails.setText("Show message preview");
fullMessage.setVisible(false);
} else {
showDetails.setText("Hide preview");
fullMessage.setText(getErrorFullMessage(messageTextBox, error, postObject, status));
fullMessage.setVisible(true);
}
pressed = !pressed;
}
});
messageTextBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
if (fullMessage.isVisible()) {
fullMessage.setText(getErrorFullMessage(messageTextBox, error, postObject, status));
}
}
});
baseLayout.setWidget(5, 0, showDetails);
baseLayout.setWidget(6, 0, fullMessage);
// box definition
final Confirm conf = new Confirm(WidgetTranslation.INSTANCE.jsonClientSendErrorButton(), baseLayout, sendReportHandler, WidgetTranslation.INSTANCE.jsonClientSendErrorButton(), true);
conf.setOkIcon(SmallIcons.INSTANCE.emailIcon());
conf.setNonScrollable(true);
conf.setAutoHide(false);
conf.setFocusOkButton(true);
conf.show();
messageTextBox.setFocus(true);
}
use of cz.metacentrum.perun.webgui.json.rtMessagesManager.SendMessageToRt in project perun by CESNET.
the class TestRtReportingTabItem method sendToRt.
protected void sendToRt() {
String message = messageTextBox.getText();
String subject = subjectTextBox.getText();
String voIdString = voIdTextBox.getText();
String rtQueue = rtQueueTextBox.getText();
int voId = -1;
if (!voIdString.isEmpty()) {
try {
voId = Integer.parseInt(voIdString);
} catch (NumberFormatException e) {
Window.alert("Incorrect VO id format");
return;
}
}
SendMessageToRt query = new SendMessageToRt();
if (voId == -1) {
query.sendMessage(rtQueue, subject, message);
} else {
query.sendMessage(rtQueue, subject, message, voId);
}
}
use of cz.metacentrum.perun.webgui.json.rtMessagesManager.SendMessageToRt in project perun by CESNET.
the class RequestQuotaChangeTabItem method requestQuotaChange.
protected void requestQuotaChange(String newQuota, String reason) {
SendMessageToRt rt = new SendMessageToRt(JsonCallbackEvents.closeTabEvents(session, this));
// quota change will use per-vo (or per-resource in a future) queue
rt.sendMessage("", RT_SUBJECT, getRequestText(newQuota, reason), resource.getVoId());
}
Aggregations