Skip to content

Commit

Permalink
Improved the list view regarding the currently selected VM, full them…
Browse files Browse the repository at this point in the history
…e support and easier sibling handling. This also prevents multi-selecting VMs.

git-svn-id: http://vboxweb.googlecode.com/svn/trunk@43 729376a8-6c6b-11de-afdd-bb9f892af8c1
  • Loading branch information
vboxweb committed Aug 11, 2009
1 parent 50f568d commit 4752828
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 30 deletions.
18 changes: 8 additions & 10 deletions VBoxWebSrv.py
Expand Up @@ -71,19 +71,17 @@ def __init__(self, ctx, arrMach, type):
# Currently this involves too much copying around.
#
class jsVRDPServer:
def __init__(self, ctx, machine):
global g_serverAddress

self.enabled = machine.VRDPServer.enabled
self.port = machine.VRDPServer.port
def __init__(self, ctx, vrdp):
self.enabled = vrdp.enabled
self.port = vrdp.port

self.netAddress = machine.VRDPServer.netAddress
self.netAddress = vrdp.netAddress
if not self.netAddress:
self.netAddress = ctx['serverAdr']

self.authType = machine.VRDPServer.authType
self.allowMultiConnection = machine.VRDPServer.allowMultiConnection
self.reuseSingleConnection = machine.VRDPServer.reuseSingleConnection
self.authType = vrdp.authType
self.allowMultiConnection = vrdp.allowMultiConnection
self.reuseSingleConnection = vrdp.reuseSingleConnection

class jsGuestOSType:
def __init__(self, guestOSType):
Expand Down Expand Up @@ -126,7 +124,7 @@ def __init__(self, ctx, machine):
self.accelerate3DEnabled = machine.accelerate3DEnabled
self.HWVirtExEnabled = machine.HWVirtExEnabled
self.HWVirtExNestedPagingEnabled = machine.HWVirtExNestedPagingEnabled
self.VRDPServer = jsVRDPServer(ctx, machine)
self.VRDPServer = jsVRDPServer(ctx, machine.VRDPServer)
self.state = machine.state
self.sessState = machine.sessionState

Expand Down
39 changes: 30 additions & 9 deletions www/static/js/vboxVMListView.js
Expand Up @@ -215,18 +215,39 @@ var vboxVMListView = Class.create(
'</li>';
jQuery(newItem).appendTo('ol#vmList');
}

/* Select first item */
/* @todo Save old selected item, create list (see above) and select the old
VM again (if still present). Otherwise set first entry. */
jQuery("#vmList li:first").toggleClass('ui-selected');

/* (Re-)connect all handlers */
jQuery('ol#vmList li').
mouseover(function()
{
jQuery(this).toggleClass('ui-state-hover');
}).
mouseout(function()
{
jQuery(this).toggleClass('ui-state-hover');
}).
click(function(event, ui)
{
jQuery(this).
toggleClass('ui-selected').
siblings().removeClass('ui-selected');

vmListView.selectionChanged(event);
vmTabView.selectionChanged();
vmToolbar.selectionChanged();
});
},

selectionChanged: function(event, ui)
selectionChanged: function(event)
{
/* The following line works around the bug to use the 'option' -> 'active' getter: jQuery('#vmList').accordion('option', 'active'); */
var curIndex = jQuery("#vmList tr").index(jQuery("#vmList tr.ui-selected"));
if (curIndex >= 0)
{
this.mCurItem = this.mVMModel.itemByRow(curIndex);
console.log("vboxVMListView::selectionChanged: mCurItem = %s", this.mCurItem.name());
}
else console.log("vboxVMListView::selectionChanged: Invalid index (%d)!", curIndex);
var curIndex = jQuery("#vmList li").index(event.currentTarget);
this.mCurItem = this.mVMModel.itemByRow(curIndex);
console.log("vboxVMListView::selectionChanged: mCurItem = %s", this.mCurItem.name());
},

selectedItem: function()
Expand Down
13 changes: 2 additions & 11 deletions www/templates/index.html
Expand Up @@ -89,7 +89,7 @@

/* Set global jQuery handle (instead of using "jQuery(...)" all the time.
var $j = jQuery.noConflict();*/

function onDocumentLoad()
{
}
Expand Down Expand Up @@ -123,7 +123,7 @@

jQuery(document).ready(onDocumentReady);
function onDocumentReady()
{
{
/* Use different outer-layout classNames to simplify/clarify CSS. */
OuterLayout = jQuery('body').layout({
north__paneSelector: ".outer-layout-north"
Expand All @@ -149,15 +149,6 @@

OuterLayout.resizeAll();

/* Then init the VM list. */
jQuery('#vmList').selectable({
selected: function(event, ui) {
vmListView.selectionChanged(event, ui);
vmTabView.selectionChanged();
vmToolbar.selectionChanged();
}
});

vbGlobal = new vboxGlobal();
vmToolbar = new vboxVMToolbar();
vmListView = new vboxVMListView();
Expand Down

0 comments on commit 4752828

Please sign in to comment.