mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #3748: Add spice dialog
This commit is contained in:
parent
70c64fa30b
commit
2323d995bd
@ -14,7 +14,8 @@ define(function(require) {
|
||||
require('./vms-tab/dialogs/attach-disk'),
|
||||
require('./vms-tab/dialogs/attach-nic'),
|
||||
require('./vms-tab/dialogs/snapshot'),
|
||||
require('./vms-tab/dialogs/vnc')
|
||||
require('./vms-tab/dialogs/vnc'),
|
||||
require('./vms-tab/dialogs/spice')
|
||||
];
|
||||
|
||||
var _panels = [
|
||||
|
@ -5,12 +5,14 @@ define(function(require) {
|
||||
var OpenNebulaVM = require('opennebula/vm');
|
||||
var CommonActions = require('utils/common-actions');
|
||||
var Vnc = require('utils/vnc');
|
||||
var Vnc = require('utils/spice');
|
||||
|
||||
var TAB_ID = require('./tabId');
|
||||
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
var DEPLOY_DIALOG_ID = require('./dialogs/deploy/dialogId');
|
||||
var MIGRATE_DIALOG_ID = require('./dialogs/migrate/dialogId');
|
||||
var VNC_DIALOG_ID = require('./dialogs/vnc/dialogId');
|
||||
var SPICE_DIALOG_ID = require('./dialogs/spice/dialogId');
|
||||
|
||||
var XML_ROOT = "VM";
|
||||
var RESOURCE = "VM";
|
||||
@ -114,6 +116,34 @@ define(function(require) {
|
||||
},
|
||||
notify: true
|
||||
},
|
||||
"VM.startspice" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
$.each(Sunstone.getDataTable(TAB_ID).elements(), function(index, elem) {
|
||||
if (!Vnc.lockStatus()) {
|
||||
Spice.lock();
|
||||
Sunstone.runAction("VM.startspice_action", elem);
|
||||
} else {
|
||||
Notifier.notifyError(Locale.tr("VNC Connection in progress"))
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"VM.startspice_action" : {
|
||||
type: "single",
|
||||
call: OpenNebulaVM.vnc,
|
||||
callback: function(request, response) {
|
||||
var dialog = Sunstone.getDialog(SPICE_DIALOG_ID);
|
||||
dialog.setElement(response);
|
||||
dialog.show();
|
||||
},
|
||||
error: function(req, resp) {
|
||||
Notifier.onError(req, resp);
|
||||
Spice.unlock();
|
||||
},
|
||||
notify: true
|
||||
},
|
||||
//"VM.startspice" : {
|
||||
// type: "custom",
|
||||
// call: function() {
|
||||
|
@ -12,6 +12,7 @@ define(function(require) {
|
||||
var StateActions = require('./utils/state-actions');
|
||||
var Sunstone = require('sunstone');
|
||||
var Vnc = require('utils/vnc');
|
||||
var Spice = require('utils/spice');
|
||||
var Notifier = require('utils/notifier');
|
||||
|
||||
/*
|
||||
@ -156,7 +157,7 @@ define(function(require) {
|
||||
var vmId = $(this).attr('vm_id');
|
||||
|
||||
if (!Vnc.lockStatus()) {
|
||||
Vnc.lock();
|
||||
Spice.lock();
|
||||
Sunstone.runAction("VM.startvnc_action", vmId);
|
||||
} else {
|
||||
Notifier.notifyError(tr("VNC Connection in progress"))
|
||||
@ -164,5 +165,18 @@ define(function(require) {
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#' + this.dataTableId).on("click", '.spice', function() {
|
||||
var vmId = $(this).attr('vm_id');
|
||||
|
||||
if (!Spice.lockStatus()) {
|
||||
Spice.lock();
|
||||
Sunstone.runAction("VM.startspice_action", vmId);
|
||||
} else {
|
||||
Notifier.notifyError(tr("SPICE Connection in progress"))
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
74
src/sunstone/public/app/tabs/vms-tab/dialogs/spice.js
Normal file
74
src/sunstone/public/app/tabs/vms-tab/dialogs/spice.js
Normal file
@ -0,0 +1,74 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var BaseDialog = require('utils/dialogs/dialog');
|
||||
var TemplateHTML = require('hbs!./spice/html');
|
||||
var Sunstone = require('sunstone');
|
||||
var Spice = require('utils/spice');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var DIALOG_ID = require('./spice/dialogId');
|
||||
var TAB_ID = require('../tabId')
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Dialog() {
|
||||
this.dialogId = DIALOG_ID;
|
||||
|
||||
BaseDialog.call(this);
|
||||
};
|
||||
|
||||
Dialog.DIALOG_ID = DIALOG_ID;
|
||||
Dialog.prototype = Object.create(BaseDialog.prototype);
|
||||
Dialog.prototype.constructor = Dialog;
|
||||
Dialog.prototype.html = _html;
|
||||
Dialog.prototype.onShow = _onShow;
|
||||
Dialog.prototype.onClose = _onClose;
|
||||
Dialog.prototype.setup = _setup;
|
||||
Dialog.prototype.setElement = _setElement;
|
||||
|
||||
return Dialog;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _html() {
|
||||
return TemplateHTML({
|
||||
'dialogId': this.dialogId
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
$("#open_in_a_new_window_spice", context).on("click", function() {
|
||||
var dialog = Sunstone.getDialog(DIALOG_ID);
|
||||
dialog.hide();
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _onShow(context) {
|
||||
Spice.spiceCallback(this.element);
|
||||
return false;
|
||||
}
|
||||
|
||||
function _onClose(context) {
|
||||
Spice.disconnect();
|
||||
Spice.unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
function _setElement(element) {
|
||||
this.element = element
|
||||
}
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
define(function(require) {
|
||||
return 'spiceVMDialog';
|
||||
});
|
19
src/sunstone/public/app/tabs/vms-tab/dialogs/spice/html.hbs
Normal file
19
src/sunstone/public/app/tabs/vms-tab/dialogs/spice/html.hbs
Normal file
@ -0,0 +1,19 @@
|
||||
<div id="{{dialogId}}" class="reveal-modal large max-height" style="width:auto; max-width:70%" data-reveal >
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<h3 class="subheader" id="spice_dialog">
|
||||
{{tr "SPICE"}}
|
||||
<span id="vnc_buttons">
|
||||
<a id="open_in_a_new_window_spice" href="" target="_blank" title="{{tr "Open in a new window"}}"> <i class="fa fa-external-link detach-spice-icon"/></a>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="reveal-body" style="width:100%; overflow-x:overlay">
|
||||
<div id="spice-area">
|
||||
<div id="spice-screen" class="spice-screen"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="message-div" class="spice-message"></div>
|
||||
<a class="close-reveal-modal">×</a>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user