Permalink
Browse files

Added initial toolbar implementation and some other minor cleanups (A…

…chim Hasenmueller).

git-svn-id: http://vboxweb.googlecode.com/svn/trunk@30 729376a8-6c6b-11de-afdd-bb9f892af8c1
  • Loading branch information...
1 parent 9f02896 commit afb5b1faac240370256301454216024ec753772b vboxweb committed Aug 7, 2009
@@ -34,7 +34,7 @@ body {
.outer-layout-north {
background: #5889AB;
color: #FFFFFF;
- padding: 5px 5px;
+ padding: 5px 10px;
}
/* VM List. */
@@ -22,6 +22,22 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
+
+VMState =
+{
+ PoweredOff: 1,
+ Saved: 2,
+ Aborted: 3,
+ Running: 4,
+ Paused: 5,
+ Stuck: 6,
+ Starting: 7,
+ Stopping: 8,
+ Saving: 9,
+ Restoring: 10,
+ Discarding: 11,
+ SettingUp: 12
+};
var vboxGlobal = Class.create(
{
@@ -112,57 +128,46 @@ var vboxGlobal = Class.create(
vmStateDescription: function(state)
{
+ /** @todo use an array instead of this huge switch statement */
var strState = tr("Unknown");
switch(state)
{
- case 1:
+ case VMState.PoweredOff:
strState = tr("Powered Off");
break;
-
- case 2:
+ case VMState.Saved:
strState = tr("Saved");
break;
-
- case 3:
+ case VMState.Aborted:
strState = tr("Aborted");
break;
-
- case 4:
+ case VMState.Running:
strState = tr("Running");
break;
-
- case 5:
+ case VMState.Paused:
strState = tr("Paused");
break;
-
- case 6:
+ case VMState.Stuck:
strState = tr("Stuck");
break;
-
- case 7:
+ case VMState.Starting:
strState = tr("Starting");
break;
-
- case 8:
+ case VMState.Stopping:
strState = tr("Stopping");
break;
-
- case 9:
+ case VMState.Saving:
strState = tr("Saving");
break;
-
- case 10:
+ case VMState.Restoring:
strState = tr("Restoring");
break;
-
- case 11:
+ case VMState.Discarding:
strState = tr("Discarding");
break;
-
- case 12:
+ case VMState.SettingUp:
strState = tr("Setting Up");
break;
-
default:
break;
}
@@ -25,12 +25,15 @@
var vboxSelectorWnd = Class.create(
{
- initialize: function(vboxVMListView, vboxTabWidget)
+ initialize: function(vboxVMListView, vboxTabWidget, vboxVMToolbar)
{
+ console.log("vboxSelectorWnd::initialize");
+ this.mVMToolbar = vboxVMToolbar;
this.mVMListView = vboxVMListView;
this.mVMModel = new vboxVMModel(this.mVMListView);
this.mTabWidget = vboxTabWidget;
+ this.mVMToolbar.setParent(this);
this.mVMListView.setParent(this);
this.mVMListView.setModel(this.mVMModel);
this.mTabWidget.setParent(this);
@@ -102,6 +105,7 @@ var vboxSelectorWnd = Class.create(
invalidate: function()
{
/* Refresh widgets. */
+ this.mVMToolbar.invalidate();
this.mVMListView.invalidate();
this.mTabWidget.invalidate();
@@ -176,7 +176,7 @@ var vboxTabWidget = Class.create(
strHardDisk = hardDisk.getName() + ' (' + vbGlobal.hardDiskType(hardDisk.getType()) +
', ' + hardDisk.getLogicalSizeGB() + ' GB)';
strListItem = '<div class="tab-details-vm-attribute">' +
- attachment.getController() + ' ' + port + ' ' + device + ':' +
+ attachment.getController() + ' ' + port + device + ':' +
'</div><div class="tab-details-vm-value">' + strHardDisk +
'</div><div style="clear: both"></div>';
jQuery("#tab-details-vm-harddisks-list").append("<li class='harddisks-list-item'>" + strListItem + "</li>");
@@ -174,7 +174,7 @@ var vboxVMListView = Class.create(
selectItemByRow: function(row)
{
- this.mCurItem = this.mVMModel.itemByRow(0);
+ this.mCurItem = this.mVMModel.itemByRow(row);
console.log("vboxVMListView::selectItemByRow: Row = %d, mCurItem = %s", row, this.mCurItem.name());
return this.mCurItem;
},
@@ -0,0 +1,74 @@
+
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+var vboxVMToolbar = Class.create(
+{
+ initialize: function()
+ {
+ },
+
+ setParent: function(parent)
+ {
+ this.mParent = parent;
+ },
+
+ invalidate: function()
+ {
+ this.selectionChanged();
+ },
+
+ selectionChanged: function()
+ {
+ var curItem = this.mParent.curItem();
+
+ if (curItem == undefined)
+ {
+ console.log("vboxVMToolbar::invalidatePage: Current item is undefined.");
+ return false;
+ }
+
+ /* settings can only be changed for powered off and aborted VMs */
+ if (curItem.state() == VMState.PoweredOff ||
+ curItem.state() == VMState.Aborted)
+ jQuery("#toolbar-button-vm-settings").html('<img src="/images/vbox/vm_settings_32px.png"/>');
+ else
+ jQuery("#toolbar-button-vm-settings").html('<img src="/images/vbox/vm_settings_disabled_32px.png"/>');
+
+ /* powered off / aborted and saved VMs can be started */
+ /** @todo when saved, start means "show" in the Qt GUI, we can go to the RDP console */
+ if (curItem.state() == VMState.PoweredOff ||
+ curItem.state() == VMState.Aborted ||
+ curItem.state() == VMState.Saved)
+ jQuery("#toolbar-button-vm-start").html('<img src="/images/vbox/vm_start_32px.png"/>');
+ else
+ jQuery("#toolbar-button-vm-start").html('<img src="/images/vbox/vm_start_disabled_32px.png"/>');
+
+ /* saved VMs can be discarded */
+ if (curItem.state() == VMState.Saved)
+ jQuery("#toolbar-button-vm-discard").html('<img src="/images/vbox/vm_discard_32px.png"/>');
+ else
+ jQuery("#toolbar-button-vm-discard").html('<img src="/images/vbox/vm_discard_disabled_32px.png"/>');
+ }
+});
View
@@ -75,13 +75,15 @@
<script type="text/javascript" src="/static/js/vboxVirtualBox.js"></script>
<script type="text/javascript" src="/static/js/vboxGlobal.js"></script>
<!-- UI classes. -->
+ <script type="text/javascript" src="/static/js/vboxVMToolbar.js"></script>
<script type="text/javascript" src="/static/js/vboxVMListView.js"></script>
<script type="text/javascript" src="/static/js/vboxTabWidget.js"></script>
<script type="text/javascript" src="/static/js/vboxSelectorWnd.js"></script>
<!-- Inline code. -->
<script type="text/javascript">
var vbGlobal;
+ var vmToolbar;
var vmListView;
var vmTabView;
var vmSelWnd;
@@ -128,6 +130,8 @@
north__paneSelector: ".outer-layout-north"
, north__resizable: false
, north__slidable: false
+ /* unfortunately, Safari does not choose the right width, it becomes 1px */
+ , north__size: 40
, north__togglerLength_open: 0
, north__togglerLength_close: -1
@@ -151,13 +155,15 @@
selected: function(event, ui) {
vmListView.selectionChanged(event, ui);
vmTabView.selectionChanged();
+ vmToolbar.selectionChanged();
}
});
vbGlobal = new vboxGlobal();
+ vmToolbar = new vboxVMToolbar();
vmListView = new vboxVMListView();
vmTabView = new vboxTabWidget();
- vmSelWnd = new vboxSelectorWnd(vmListView, vmTabView);
+ vmSelWnd = new vboxSelectorWnd(vmListView, vmTabView, vmToolbar);
vbGlobal.setSelectorWnd(vmSelWnd);
jQuery('#vmTab').bind('tabsselect', function(event, ui) {
@@ -166,6 +172,7 @@
jQuery(window).resize(vmSelWnd.onResize); /* On Mozilla, *only* the window itself has a resize event! */
+
var flashvars = {};
var params = {};
params.wmode="opaque";
@@ -230,8 +237,11 @@
</head>
<body font="Verdana" onload="onDocumentLoad()">
- <div class="outer-layout-north" style="display: none;">
- <b>VirtualBox Web Console</b>
+ <div id="vmToolbar" class="outer-layout-north" style="display: none;">
+ <img src="/images/vbox/vm_new_32px.png"/>
+ <span id="toolbar-button-vm-settings"></span>
+ <span id="toolbar-button-vm-start"></span>
+ <span id="toolbar-button-vm-discard"></span>
</div>
<ol id="vmList" class="outer-layout-west" style="display: none; list-style-type: none;"></ol>

0 comments on commit afb5b1f

Please sign in to comment.