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 clientHostPassword;
|
||||||
private String clientTag;
|
private String clientTag;
|
||||||
private String ticket;
|
private String ticket;
|
||||||
|
private String locale;
|
||||||
private String clientTunnelUrl;
|
private String clientTunnelUrl;
|
||||||
private String clientTunnelSession;
|
private String clientTunnelSession;
|
||||||
|
|
||||||
@ -89,6 +89,14 @@ public class ConsoleProxyClientParam {
|
|||||||
this.clientTunnelSession = clientTunnelSession;
|
this.clientTunnelSession = clientTunnelSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLocale() {
|
||||||
|
return this.locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocale(String locale) {
|
||||||
|
this.locale = locale;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAjaxSessionId() {
|
public String getAjaxSessionId() {
|
||||||
return this.ajaxSessionId;
|
return this.ajaxSessionId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,8 +57,10 @@ import com.cloud.utils.Pair;
|
|||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.db.EntityManager;
|
import com.cloud.utils.db.EntityManager;
|
||||||
import com.cloud.utils.db.TransactionLegacy;
|
import com.cloud.utils.db.TransactionLegacy;
|
||||||
|
import com.cloud.vm.UserVmDetailVO;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.VirtualMachineManager;
|
import com.cloud.vm.VirtualMachineManager;
|
||||||
|
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thumbnail access : /console?cmd=thumbnail&vm=xxx&w=xxx&h=xxx
|
* Thumbnail access : /console?cmd=thumbnail&vm=xxx&w=xxx&h=xxx
|
||||||
@ -82,6 +84,8 @@ public class ConsoleProxyServlet extends HttpServlet {
|
|||||||
IdentityService _identityService;
|
IdentityService _identityService;
|
||||||
@Inject
|
@Inject
|
||||||
EntityManager _entityMgr;
|
EntityManager _entityMgr;
|
||||||
|
@Inject
|
||||||
|
UserVmDetailsDao _userVmDetailsDao;
|
||||||
|
|
||||||
static ManagementServer s_ms;
|
static ManagementServer s_ms;
|
||||||
|
|
||||||
@ -391,6 +395,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
|||||||
|
|
||||||
Ternary<String, String, String> parsedHostInfo = parseHostInfo(portInfo.first());
|
Ternary<String, String, String> parsedHostInfo = parseHostInfo(portInfo.first());
|
||||||
|
|
||||||
|
UserVmDetailVO details = _userVmDetailsDao.findDetail(vm.getId(), "keyboard");
|
||||||
String sid = vm.getVncPassword();
|
String sid = vm.getVncPassword();
|
||||||
String tag = vm.getUuid();
|
String tag = vm.getUuid();
|
||||||
String ticket = genAccessTicket(host, String.valueOf(portInfo.second()), sid, tag);
|
String ticket = genAccessTicket(host, String.valueOf(portInfo.second()), sid, tag);
|
||||||
@ -401,6 +406,9 @@ public class ConsoleProxyServlet extends HttpServlet {
|
|||||||
param.setClientHostPassword(sid);
|
param.setClientHostPassword(sid);
|
||||||
param.setClientTag(tag);
|
param.setClientTag(tag);
|
||||||
param.setTicket(ticket);
|
param.setTicket(ticket);
|
||||||
|
if (details != null) {
|
||||||
|
param.setLocale(details.getValue());
|
||||||
|
}
|
||||||
if (parsedHostInfo.second() != null && parsedHostInfo.third() != null) {
|
if (parsedHostInfo.second() != null && parsedHostInfo.third() != null) {
|
||||||
param.setClientTunnelUrl(parsedHostInfo.second());
|
param.setClientTunnelUrl(parsedHostInfo.second());
|
||||||
param.setClientTunnelSession(parsedHostInfo.third());
|
param.setClientTunnelSession(parsedHostInfo.third());
|
||||||
|
|||||||
@ -79,6 +79,7 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
|||||||
String eventStr = queryMap.get("event");
|
String eventStr = queryMap.get("event");
|
||||||
String console_url = queryMap.get("consoleurl");
|
String console_url = queryMap.get("consoleurl");
|
||||||
String console_host_session = queryMap.get("sessionref");
|
String console_host_session = queryMap.get("sessionref");
|
||||||
|
String vm_locale = queryMap.get("locale");
|
||||||
|
|
||||||
if (tag == null)
|
if (tag == null)
|
||||||
tag = "";
|
tag = "";
|
||||||
@ -126,6 +127,7 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
|||||||
param.setTicket(ticket);
|
param.setTicket(ticket);
|
||||||
param.setClientTunnelUrl(console_url);
|
param.setClientTunnelUrl(console_url);
|
||||||
param.setClientTunnelSession(console_host_session);
|
param.setClientTunnelSession(console_host_session);
|
||||||
|
param.setLocale(vm_locale);
|
||||||
|
|
||||||
viewer = ConsoleProxy.getAjaxVncViewer(param, ajaxSessionIdStr);
|
viewer = ConsoleProxy.getAjaxVncViewer(param, ajaxSessionIdStr);
|
||||||
} catch (Exception e) {
|
} 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,
|
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,
|
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("");
|
StringBuffer sbLanguages = new StringBuffer("");
|
||||||
if (languages != null) {
|
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>",
|
"<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>",
|
"<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 + " ];",
|
"<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) + ");",
|
String.valueOf(width) + ", " + String.valueOf(height) + ", " + String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight) + ");",
|
||||||
|
|
||||||
"$(function() {", "ajaxViewer.start();", "});",
|
"$(function() {", "ajaxViewer.start();", "});",
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public class ConsoleProxyClientParam {
|
|||||||
|
|
||||||
private String clientTunnelUrl;
|
private String clientTunnelUrl;
|
||||||
private String clientTunnelSession;
|
private String clientTunnelSession;
|
||||||
|
private String locale;
|
||||||
private String ajaxSessionId;
|
private String ajaxSessionId;
|
||||||
|
|
||||||
public ConsoleProxyClientParam() {
|
public ConsoleProxyClientParam() {
|
||||||
@ -101,6 +101,14 @@ public class ConsoleProxyClientParam {
|
|||||||
this.ajaxSessionId = ajaxSessionId;
|
this.ajaxSessionId = ajaxSessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLocale() {
|
||||||
|
return this.locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocale(String locale) {
|
||||||
|
this.locale = locale;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClientMapKey() {
|
public String getClientMapKey() {
|
||||||
if (clientTag != null && !clientTag.isEmpty())
|
if (clientTag != null && !clientTag.isEmpty())
|
||||||
return clientTag;
|
return clientTag;
|
||||||
|
|||||||
@ -68,6 +68,8 @@ public class ConsoleProxyHttpHandlerHelper {
|
|||||||
map.put("sessionref", param.getClientTunnelSession());
|
map.put("sessionref", param.getClientTunnelSession());
|
||||||
if (param.getTicket() != null)
|
if (param.getTicket() != null)
|
||||||
map.put("ticket", param.getTicket());
|
map.put("ticket", param.getTicket());
|
||||||
|
if (param.getLocale() != null)
|
||||||
|
map.put("locale", param.getLocale());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we no longer accept information from parameter other than token
|
// we no longer accept information from parameter other than token
|
||||||
@ -85,5 +87,6 @@ public class ConsoleProxyHttpHandlerHelper {
|
|||||||
map.remove("consoleurl");
|
map.remove("consoleurl");
|
||||||
map.remove("sessionref");
|
map.remove("sessionref");
|
||||||
map.remove("ticket");
|
map.remove("ticket");
|
||||||
|
map.remove("locale");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -332,7 +332,7 @@ KeyboardMapper.prototype = {
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// class AjaxViewer
|
// 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
|
// 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
|
// however, a back door key-sequence can trigger to open the logger window, it is designed to help
|
||||||
// trouble-shooting
|
// trouble-shooting
|
||||||
@ -359,7 +359,11 @@ function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWi
|
|||||||
this.tileHeight = tileHeight;
|
this.tileHeight = tileHeight;
|
||||||
this.maxTileZIndex = 1;
|
this.maxTileZIndex = 1;
|
||||||
|
|
||||||
|
if (locale == AjaxViewer.KEYBOARD_TYPE_UK_ENGLISH || locale == AjaxViewer.KEYBOARD_TYPE_JAPANESE)
|
||||||
|
this.currentKeyboard = locale;
|
||||||
|
else
|
||||||
this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_ENGLISH;
|
this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_ENGLISH;
|
||||||
|
|
||||||
this.keyboardMappers = [];
|
this.keyboardMappers = [];
|
||||||
|
|
||||||
this.timer = 0;
|
this.timer = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user