mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-4973: Specified keyboard language is not showing as default in consoleView passed during deployVM.
This commit is contained in:
parent
46c6b91832
commit
f6b063de79
@ -23,7 +23,7 @@ public class ConsoleProxyClientParam {
|
||||
private String clientHostPassword;
|
||||
private String clientTag;
|
||||
private String ticket;
|
||||
|
||||
private String locale;
|
||||
private String clientTunnelUrl;
|
||||
private String clientTunnelSession;
|
||||
|
||||
@ -89,6 +89,14 @@ public class ConsoleProxyClientParam {
|
||||
this.clientTunnelSession = clientTunnelSession;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public String getAjaxSessionId() {
|
||||
return this.ajaxSessionId;
|
||||
}
|
||||
|
||||
@ -57,8 +57,10 @@ import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.vm.UserVmDetailVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
|
||||
/**
|
||||
* Thumbnail access : /console?cmd=thumbnail&vm=xxx&w=xxx&h=xxx
|
||||
@ -82,6 +84,8 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
IdentityService _identityService;
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
@Inject
|
||||
UserVmDetailsDao _userVmDetailsDao;
|
||||
|
||||
static ManagementServer s_ms;
|
||||
|
||||
@ -391,6 +395,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
|
||||
Ternary<String, String, String> parsedHostInfo = parseHostInfo(portInfo.first());
|
||||
|
||||
UserVmDetailVO details = _userVmDetailsDao.findDetail(vm.getId(), "keyboard");
|
||||
String sid = vm.getVncPassword();
|
||||
String tag = vm.getUuid();
|
||||
String ticket = genAccessTicket(host, String.valueOf(portInfo.second()), sid, tag);
|
||||
@ -401,7 +406,10 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
param.setClientHostPassword(sid);
|
||||
param.setClientTag(tag);
|
||||
param.setTicket(ticket);
|
||||
if (parsedHostInfo.second() != null && parsedHostInfo.third() != null) {
|
||||
if (details != null) {
|
||||
param.setLocale(details.getValue());
|
||||
}
|
||||
if (parsedHostInfo.second() != null && parsedHostInfo.third() != null) {
|
||||
param.setClientTunnelUrl(parsedHostInfo.second());
|
||||
param.setClientTunnelSession(parsedHostInfo.third());
|
||||
}
|
||||
|
||||
@ -79,6 +79,7 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
||||
String eventStr = queryMap.get("event");
|
||||
String console_url = queryMap.get("consoleurl");
|
||||
String console_host_session = queryMap.get("sessionref");
|
||||
String vm_locale = queryMap.get("locale");
|
||||
|
||||
if (tag == null)
|
||||
tag = "";
|
||||
@ -126,6 +127,7 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
||||
param.setTicket(ticket);
|
||||
param.setClientTunnelUrl(console_url);
|
||||
param.setClientTunnelSession(console_host_session);
|
||||
param.setLocale(vm_locale);
|
||||
|
||||
viewer = ConsoleProxy.getAjaxVncViewer(param, ajaxSessionIdStr);
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -287,11 +287,11 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
|
||||
}
|
||||
|
||||
return getAjaxViewerPageContent(sbTileSequence.toString(), imgUrl, updateUrl, width, height, tileWidth, tileHeight, title,
|
||||
ConsoleProxy.keyboardType == ConsoleProxy.KEYBOARD_RAW, languages, guest);
|
||||
ConsoleProxy.keyboardType == ConsoleProxy.KEYBOARD_RAW, languages, guest, this.clientParam.getLocale());
|
||||
}
|
||||
|
||||
private String getAjaxViewerPageContent(String tileSequence, String imgUrl, String updateUrl, int width, int height, int tileWidth, int tileHeight, String title,
|
||||
boolean rawKeyboard, List<String> languages, String guest) {
|
||||
boolean rawKeyboard, List<String> languages, String guest, String locale) {
|
||||
|
||||
StringBuffer sbLanguages = new StringBuffer("");
|
||||
if (languages != null) {
|
||||
@ -323,7 +323,7 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
|
||||
"<li><a href=\"#\" cmd=\"keyboard_jp\"><span>Japanese keyboard</span></a></li>", "</ul>", "</li>", "</ul>",
|
||||
"<span id=\"light\" class=\"dark\" cmd=\"toggle_logwin\"></span>", "</div>", "<div id=\"main_panel\" tabindex=\"1\"></div>",
|
||||
"<script language=\"javascript\">", "var acceptLanguages = '" + sbLanguages.toString() + "';", "var tileMap = [ " + tileSequence + " ];",
|
||||
"var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', tileMap, ",
|
||||
"var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', '" + locale + "', tileMap, ",
|
||||
String.valueOf(width) + ", " + String.valueOf(height) + ", " + String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight) + ");",
|
||||
|
||||
"$(function() {", "ajaxViewer.start();", "});",
|
||||
|
||||
@ -30,7 +30,7 @@ public class ConsoleProxyClientParam {
|
||||
|
||||
private String clientTunnelUrl;
|
||||
private String clientTunnelSession;
|
||||
|
||||
private String locale;
|
||||
private String ajaxSessionId;
|
||||
|
||||
public ConsoleProxyClientParam() {
|
||||
@ -101,6 +101,14 @@ public class ConsoleProxyClientParam {
|
||||
this.ajaxSessionId = ajaxSessionId;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public String getClientMapKey() {
|
||||
if (clientTag != null && !clientTag.isEmpty())
|
||||
return clientTag;
|
||||
|
||||
@ -68,6 +68,8 @@ public class ConsoleProxyHttpHandlerHelper {
|
||||
map.put("sessionref", param.getClientTunnelSession());
|
||||
if (param.getTicket() != null)
|
||||
map.put("ticket", param.getTicket());
|
||||
if (param.getLocale() != null)
|
||||
map.put("locale", param.getLocale());
|
||||
}
|
||||
} else {
|
||||
// we no longer accept information from parameter other than token
|
||||
@ -85,5 +87,6 @@ public class ConsoleProxyHttpHandlerHelper {
|
||||
map.remove("consoleurl");
|
||||
map.remove("sessionref");
|
||||
map.remove("ticket");
|
||||
map.remove("locale");
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ KeyboardMapper.prototype = {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class AjaxViewer
|
||||
//
|
||||
function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWidth, tileHeight) {
|
||||
function AjaxViewer(panelId, imageUrl, updateUrl, locale, tileMap, width, height, tileWidth, tileHeight) {
|
||||
// logging is disabled by default so that it won't have negative impact on performance
|
||||
// however, a back door key-sequence can trigger to open the logger window, it is designed to help
|
||||
// trouble-shooting
|
||||
@ -358,8 +358,12 @@ function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWi
|
||||
this.tileWidth = tileWidth;
|
||||
this.tileHeight = tileHeight;
|
||||
this.maxTileZIndex = 1;
|
||||
|
||||
this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_ENGLISH;
|
||||
|
||||
if (locale == AjaxViewer.KEYBOARD_TYPE_UK_ENGLISH || locale == AjaxViewer.KEYBOARD_TYPE_JAPANESE)
|
||||
this.currentKeyboard = locale;
|
||||
else
|
||||
this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_ENGLISH;
|
||||
|
||||
this.keyboardMappers = [];
|
||||
|
||||
this.timer = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user