IDEMPIERE-5463 Help on Role Panel selection page (#1548)
* IDEMPIERE-5463 Help on Role Panel selection page - SysConfig LOGIN_SELECTION_HELP_URL defaulting to https://wiki.idempiere.org/{lang}/Login_Selection_Help - added WebUtil.isUrlOk - verify if the login and selection help page exists before opening, otherwise default to english version * - rename SysConfig LOGIN_SELECTION_HELP_URL to LOGIN_SELECT_ROLE_HELP_URL * - fix wrong SysConfig name
This commit is contained in:
parent
ed7fb79cd7
commit
193141324e
|
@ -44,7 +44,7 @@ public class MSysConfig extends X_AD_SysConfig
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1225938049955333281L;
|
||||
private static final long serialVersionUID = 6202541582080272987L;
|
||||
|
||||
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
|
||||
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
|
||||
|
@ -128,6 +128,7 @@ public class MSysConfig extends X_AD_SysConfig
|
|||
public static final String LOCATION_MAX_CITY_ROWS = "LOCATION_MAX_CITY_ROWS";
|
||||
public static final String LOGIN_HELP_URL = "LOGIN_HELP_URL";
|
||||
public static final String LOGIN_PREFIX_SEPARATOR = "LOGIN_PREFIX_SEPARATOR";
|
||||
public static final String LOGIN_SELECT_ROLE_HELP_URL = "LOGIN_SELECT_ROLE_HELP_URL";
|
||||
public static final String LOGIN_SHOW_RESETPASSWORD = "LOGIN_SHOW_RESETPASSWORD";
|
||||
public static final String LOGIN_WITH_TENANT_PREFIX = "LOGIN_WITH_TENANT_PREFIX";
|
||||
public static final String MAIL_DONT_SEND_TO_ADDRESS = "MAIL_DONT_SEND_TO_ADDRESS";
|
||||
|
|
|
@ -24,9 +24,11 @@ import java.io.IOException;
|
|||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.UnknownHostException;
|
||||
|
@ -1130,4 +1132,23 @@ public final class WebUtil
|
|||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if the URL exists and answer with a 200 code
|
||||
* @param urlString
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isUrlOk(String urlString) {
|
||||
int responseCode = 0;
|
||||
URL url;
|
||||
try {
|
||||
url = new URL(urlString);
|
||||
HttpURLConnection huc = (HttpURLConnection) url.openConnection();
|
||||
huc.setRequestMethod("HEAD");
|
||||
responseCode = huc.getResponseCode();
|
||||
} catch (IOException e) {
|
||||
responseCode = -1;
|
||||
}
|
||||
return responseCode == HttpURLConnection.HTTP_OK;
|
||||
}
|
||||
|
||||
} // WebUtil
|
||||
|
|
|
@ -65,6 +65,7 @@ import org.compiere.util.Language;
|
|||
import org.compiere.util.Login;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
import org.compiere.util.WebUtil;
|
||||
import org.zkoss.lang.Strings;
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.web.Attributes;
|
||||
|
@ -475,11 +476,15 @@ public class LoginPanel extends Window implements EventListener<Event>
|
|||
}
|
||||
|
||||
private void openLoginHelp() {
|
||||
String langName = (String) lstLanguage.getSelectedItem().getValue();
|
||||
langName = langName.substring(0, 2);
|
||||
String helpURL = MSysConfig.getValue(MSysConfig.LOGIN_HELP_URL, "http://wiki.idempiere.org/{lang}/Login_Help");
|
||||
if (helpURL.contains("{lang}"))
|
||||
helpURL = Util.replace(helpURL, "{lang}", langName);
|
||||
String lang = (String) lstLanguage.getSelectedItem().getValue();
|
||||
lang = lang.substring(0, 2);
|
||||
String helpURL = MSysConfig.getValue(MSysConfig.LOGIN_HELP_URL, "https://wiki.idempiere.org/{lang}/Login_Help");
|
||||
if (helpURL.contains("{lang}")) {
|
||||
String rawURL = helpURL;
|
||||
helpURL = Util.replace(rawURL, "{lang}", lang);
|
||||
if (!"en".equals(lang) && !WebUtil.isUrlOk(helpURL))
|
||||
helpURL = Util.replace(rawURL, "{lang}", "en"); // default to English
|
||||
}
|
||||
try {
|
||||
Executions.getCurrent().sendRedirect(helpURL, "_blank");
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Properties;
|
|||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.webui.AdempiereIdGenerator;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.ComboItem;
|
||||
import org.adempiere.webui.component.Combobox;
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
|
@ -51,18 +52,19 @@ import org.compiere.util.Language;
|
|||
import org.compiere.util.Login;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
import org.compiere.util.WebUtil;
|
||||
import org.zkoss.zhtml.Table;
|
||||
import org.zkoss.zhtml.Td;
|
||||
import org.zkoss.zhtml.Tr;
|
||||
import org.zkoss.zk.au.out.AuFocus;
|
||||
import org.zkoss.zk.au.out.AuScript;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.WrongValueException;
|
||||
import org.zkoss.zk.ui.event.Deferrable;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.Clients;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Comboitem;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Image;
|
||||
|
@ -274,6 +276,11 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
Button okBtn = pnlButtons.getButton(ConfirmPanel.A_OK);
|
||||
okBtn.setWidgetListener("onClick", "zAu.cmd0.showBusy(null)");
|
||||
|
||||
Button helpButton = pnlButtons.createButton(ConfirmPanel.A_HELP);
|
||||
helpButton.addEventListener(Events.ON_CLICK, this);
|
||||
helpButton.setSclass(ITheme.LOGIN_BUTTON_CLASS);
|
||||
pnlButtons.addComponentsRight(helpButton);
|
||||
|
||||
LayoutUtils.addSclass(ITheme.LOGIN_BOX_FOOTER_PANEL_CLASS, pnlButtons);
|
||||
ZKUpdateUtil.setWidth(pnlButtons, null);
|
||||
pnlButtons.getButton(ConfirmPanel.A_OK).setSclass(ITheme.LOGIN_BUTTON_CLASS);
|
||||
|
@ -545,6 +552,10 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
{
|
||||
validateRoles(false);
|
||||
}
|
||||
else if (event.getTarget().getId().equals(ConfirmPanel.A_HELP))
|
||||
{
|
||||
openLoginHelp();
|
||||
}
|
||||
else if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
|
||||
{
|
||||
if (isChangeRole()) {
|
||||
|
@ -563,6 +574,25 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
}
|
||||
}
|
||||
|
||||
private void openLoginHelp() {
|
||||
String lang = Env.getContext(Env.getCtx(), Env.LANGUAGE);
|
||||
lang = lang.substring(0, 2);
|
||||
String helpURL = MSysConfig.getValue(MSysConfig.LOGIN_SELECT_ROLE_HELP_URL, "https://wiki.idempiere.org/{lang}/Login_Select_Role_Help");
|
||||
if (helpURL.contains("{lang}")) {
|
||||
String rawURL = helpURL;
|
||||
helpURL = Util.replace(rawURL, "{lang}", lang);
|
||||
if (!"en".equals(lang) && !WebUtil.isUrlOk(helpURL))
|
||||
helpURL = Util.replace(rawURL, "{lang}", "en"); // default to English
|
||||
}
|
||||
try {
|
||||
Executions.getCurrent().sendRedirect(helpURL, "_blank");
|
||||
}
|
||||
catch (Exception e) {
|
||||
String message = e.getMessage();
|
||||
Dialog.warn(0, "URLnotValid", message);
|
||||
}
|
||||
}
|
||||
|
||||
private void setUserID() {
|
||||
if (lstClient.getSelectedItem() != null) {
|
||||
Env.setContext(m_ctx, Env.AD_CLIENT_ID, (String) lstClient.getSelectedItem().getValue());
|
||||
|
|
Loading…
Reference in New Issue