diff --git a/widgets/xenclient/DisplayPCI.js b/widgets/xenclient/DisplayPCI.js new file mode 100644 index 0000000..48c25db --- /dev/null +++ b/widgets/xenclient/DisplayPCI.js @@ -0,0 +1,63 @@ +define([ + "dojo", + "dojo/_base/declare", + // Resources + "dojo/i18n!citrix/xenclient/nls/DisplayPCI", + "dojo/text!citrix/xenclient/templates/DisplayPCI.html", + // Mixins + "citrix/common/Dialog", + "citrix/common/_BoundContainerMixin", + // Required in template + "citrix/common/Repeater", + "citrix/common/BoundWidget", + "citrix/common/Button" +], +function(dojo, declare, displayPCINls, template, dialog, _boundContainerMixin) { +return declare("citrix.xenclient.DisplayPCI", [dialog, _boundContainerMixin], { + + templateString: template, + widgetsInTemplate: true, + canExecute: true, + destroyOnHide: true, + + constructor: function(args) { + this.vm = XUICache.getVM(args.path); + this.devicesOnGPUBus = args.devicesOnGPUBus; + this.cancelCallback = args.cancelCallback; + }, + + postMixInProperties: function() { + dojo.mixin(this, displayPCINls); + this.inherited(arguments); + }, + postCreate: function() { + this.inherited(arguments); + this.subscribe(this.vm.publish_topic, this._messageHandler); + this._bindDijit(); + }, + + _bindDijit: function() { + this.bind(this); + this.set("title", this.DISPLAY_DEVICE); + }, + + onExecute: function(){ + this.inherited(arguments); + }, + + onCancel: function(){ + this.inherited(arguments); + this.cancelCallback(); + }, + + _messageHandler: function(message) { + switch(message.type) { + case XenConstants.TopicTypes.MODEL_STATE_CHANGED: + case XenConstants.TopicTypes.MODEL_CHANGED: { + this._bindDijit(); + break; + } + } + } +}); +}); diff --git a/widgets/xenclient/VMDetails.js b/widgets/xenclient/VMDetails.js index 66ac609..c5481e3 100755 --- a/widgets/xenclient/VMDetails.js +++ b/widgets/xenclient/VMDetails.js @@ -16,6 +16,7 @@ define([ "citrix/xenclient/AddDisk", "citrix/xenclient/ConnectDevice", "citrix/xenclient/ConnectPCI", + "citrix/xenclient/DisplayPCI", "citrix/xenclient/RestoreSnapshot", "citrix/common/ItemFileReadStore", "citrix/common/EditableWidget", @@ -39,7 +40,7 @@ define([ "citrix/common/ProgressBar", "citrix/common/CheckBox" ], -function(dojo, declare, registry, vmDetailsNls, vmNls, template, dialog, _boundContainerMixin, _editableMixin, _citrixTooltipMixin, addNic, addDisk, connectDevice, connectPCI, restoreSnapshot, itemFileReadStore, editableWidget, label, boundWidget, domConstruct) { +function(dojo, declare, registry, vmDetailsNls, vmNls, template, dialog, _boundContainerMixin, _editableMixin, _citrixTooltipMixin, addNic, addDisk, connectDevice, connectPCI, displayPCI, restoreSnapshot, itemFileReadStore, editableWidget, label, boundWidget, domConstruct) { return declare("citrix.xenclient.VMDetails", [dialog, _boundContainerMixin, _editableMixin, _citrixTooltipMixin], { templateString: template, @@ -341,6 +342,27 @@ return declare("citrix.xenclient.VMDetails", [dialog, _boundContainerMixin, _edi } }, + onThreeDChange: function(addr) { + // find all devices on the same bus + var devicesOnGPUBus = this.vm.getPCIDevices().filter(function(device){ + return device.addr != addr && //difference address than gpu itself + parseInt(device.addr.split(":")[1]) == parseInt(addr.split(":")[1]); + }) + if (!!addr && // assigning new address + typeof this.value.gpu != "undefined" && // is undefined when vm is running + this.value.gpu != addr && // don't prompt when it is already selected + devicesOnGPUBus.length){ // only prompt when there are other devices + var popup = new displayPCI({ + path: this.vm.vm_path, + devicesOnGPUBus: devicesOnGPUBus, + cancelCallback: dojo.hitch(this, function(){ + this.threed.set('value', this.vm.gpu); + }) + }); + popup.show(); + } + }, + onPciAdd: function() { var popup = new connectPCI({ path: this.vm.vm_path }); popup.show(); diff --git a/widgets/xenclient/nls/DisplayPCI.js b/widgets/xenclient/nls/DisplayPCI.js new file mode 100644 index 0000000..023dac3 --- /dev/null +++ b/widgets/xenclient/nls/DisplayPCI.js @@ -0,0 +1,8 @@ +({ + // Layout + DISPLAY_DEVICE: "Attention", + DEVICE_PROMPT: "When this guest is started, the following additional PCI devices and functions will be passed through:", + DISPLAY_ACTION: "OK", + DISPLAY_CANCEL: "Cancel", + PCI_INFO: "Address: {0}, Class: {1}", +}) diff --git a/widgets/xenclient/nls/de-de/DisplayPCI.js b/widgets/xenclient/nls/de-de/DisplayPCI.js new file mode 100644 index 0000000..023dac3 --- /dev/null +++ b/widgets/xenclient/nls/de-de/DisplayPCI.js @@ -0,0 +1,8 @@ +({ + // Layout + DISPLAY_DEVICE: "Attention", + DEVICE_PROMPT: "When this guest is started, the following additional PCI devices and functions will be passed through:", + DISPLAY_ACTION: "OK", + DISPLAY_CANCEL: "Cancel", + PCI_INFO: "Address: {0}, Class: {1}", +}) diff --git a/widgets/xenclient/nls/es-es/DisplayPCI.js b/widgets/xenclient/nls/es-es/DisplayPCI.js new file mode 100644 index 0000000..023dac3 --- /dev/null +++ b/widgets/xenclient/nls/es-es/DisplayPCI.js @@ -0,0 +1,8 @@ +({ + // Layout + DISPLAY_DEVICE: "Attention", + DEVICE_PROMPT: "When this guest is started, the following additional PCI devices and functions will be passed through:", + DISPLAY_ACTION: "OK", + DISPLAY_CANCEL: "Cancel", + PCI_INFO: "Address: {0}, Class: {1}", +}) diff --git a/widgets/xenclient/nls/fr-fr/DisplayPCI.js b/widgets/xenclient/nls/fr-fr/DisplayPCI.js new file mode 100644 index 0000000..023dac3 --- /dev/null +++ b/widgets/xenclient/nls/fr-fr/DisplayPCI.js @@ -0,0 +1,8 @@ +({ + // Layout + DISPLAY_DEVICE: "Attention", + DEVICE_PROMPT: "When this guest is started, the following additional PCI devices and functions will be passed through:", + DISPLAY_ACTION: "OK", + DISPLAY_CANCEL: "Cancel", + PCI_INFO: "Address: {0}, Class: {1}", +}) diff --git a/widgets/xenclient/nls/ja-jp/DisplayPCI.js b/widgets/xenclient/nls/ja-jp/DisplayPCI.js new file mode 100644 index 0000000..023dac3 --- /dev/null +++ b/widgets/xenclient/nls/ja-jp/DisplayPCI.js @@ -0,0 +1,8 @@ +({ + // Layout + DISPLAY_DEVICE: "Attention", + DEVICE_PROMPT: "When this guest is started, the following additional PCI devices and functions will be passed through:", + DISPLAY_ACTION: "OK", + DISPLAY_CANCEL: "Cancel", + PCI_INFO: "Address: {0}, Class: {1}", +}) diff --git a/widgets/xenclient/nls/zh-cn/DisplayPCI.js b/widgets/xenclient/nls/zh-cn/DisplayPCI.js new file mode 100644 index 0000000..023dac3 --- /dev/null +++ b/widgets/xenclient/nls/zh-cn/DisplayPCI.js @@ -0,0 +1,8 @@ +({ + // Layout + DISPLAY_DEVICE: "Attention", + DEVICE_PROMPT: "When this guest is started, the following additional PCI devices and functions will be passed through:", + DISPLAY_ACTION: "OK", + DISPLAY_CANCEL: "Cancel", + PCI_INFO: "Address: {0}, Class: {1}", +}) diff --git a/widgets/xenclient/templates/DisplayPCI.html b/widgets/xenclient/templates/DisplayPCI.html new file mode 100644 index 0000000..d220e91 --- /dev/null +++ b/widgets/xenclient/templates/DisplayPCI.html @@ -0,0 +1,27 @@ +