Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F #2312: Add HTML5 console #4902

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/sunstone/public/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ require.config({
"flot.time": "../bower_components/flot/jquery.flot.time",
"flot.tooltip": "../bower_components/flot.tooltip/js/jquery.flot.tooltip",

/* WMKS */
"wmks" : "../bower_components/wmks/wmks.min",

/* VNC */
"vnc-rfb": "../bower_components/no-vnc/lib/rfb",

Expand Down Expand Up @@ -119,6 +122,8 @@ require.config({
deps: [
"foundation",
"jquery",
"jquery-ui",
"wmks",
"tabs/provision-tab",
"tabs/dashboard-tab",
"tabs/system-top-tab",
Expand Down Expand Up @@ -168,6 +173,16 @@ require.config({
deps: ["jquery"]
},

/* JQuery-UI */
"jquery-ui": {
deps: ["jquery"]
},

/* WMKS */
"wmks": {
deps: ["jquery", "jquery-ui"]
},

/* Foundation */
"foundation": {
deps: ["jquery"]
Expand Down
21 changes: 21 additions & 0 deletions src/sunstone/public/app/opennebula/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,27 @@ define(function(require) {
}
});
},
"vmrc" : function(params, startstop) {
var callback = params.success;
var callback_error = params.error;
var id = params.data.id;
var resource = RESOURCE;

var method = startstop;
var request = OpenNebulaHelper.request(resource, method, params.data);
$.ajax({
url: "vm/" + id + "/startvnc",
type: "POST",
dataType: "json",
success: function(response) {
return callback ? callback(request, response) : null;
},
error: function(response) {
return callback_error ?
callback_error(request, OpenNebulaError(response)) : null;
}
});
},
"append": function(params) {
var action_obj = {"template_raw" : params.data.extra_param, append : true};
OpenNebulaAction.simple_action(params, RESOURCE, "update", action_obj);
Expand Down
1 change: 1 addition & 0 deletions src/sunstone/public/app/tabs/vms-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ define(function(require) {
require("./vms-tab/dialogs/snapshot"),
require("./vms-tab/dialogs/revert"),
require("./vms-tab/dialogs/vnc"),
require("./vms-tab/dialogs/vmrc"),
require("./vms-tab/dialogs/spice"),
require("./vms-tab/dialogs/saveas-template")
];
Expand Down
30 changes: 30 additions & 0 deletions src/sunstone/public/app/tabs/vms-tab/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ define(function(require) {
var OpenNebulaVM = require('opennebula/vm');
var CommonActions = require('utils/common-actions');
var Vnc = require('utils/vnc');
var Vmrc = require('utils/vmrc');
var Spice = require('utils/spice');
var Files = require('utils/files');

Expand All @@ -30,6 +31,7 @@ define(function(require) {
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 VMRC_DIALOG_ID = require('./dialogs/vmrc/dialogId');
var SPICE_DIALOG_ID = require('./dialogs/spice/dialogId');
var SAVE_AS_TEMPLATE_DIALOG_ID = require('./dialogs/saveas-template/dialogId');
var UPDATECONF_FORM_ID = require('./form-panels/updateconf/formPanelId');
Expand Down Expand Up @@ -282,6 +284,34 @@ define(function(require) {
},
notify: true
},
"VM.startvmrc" : {
type: "custom",
call: function() {
$.each(Sunstone.getDataTable(TAB_ID).elements(), function(index, elem) {
if (!Vmrc.lockStatus()) {
Vmrc.lock();
Sunstone.runAction("VM.startvmrc_action", elem);
} else {
Notifier.notifyError(Locale.tr("VMRC Connection in progress"))
return false;
}
});
}
},
"VM.startvmrc_action" : {
type: "single",
call: OpenNebulaVM.vmrc,
callback: function(request, response) {
var dialog = Sunstone.getDialog(VMRC_DIALOG_ID);
dialog.setElement(response);
dialog.show();
},
error: function(req, resp) {
Notifier.onError(req, resp);
Vmrc.unlock();
},
notify: true
},
"VM.startspice" : {
type: "custom",
call: function() {
Expand Down
6 changes: 6 additions & 0 deletions src/sunstone/public/app/tabs/vms-tab/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ define(function(require) {
layout: "vmsremote_buttons",
custom_classes: "only-sunstone-info vnc-sunstone-info"
},
"VM.startvmrc" : {
type: "action",
text: Locale.tr("VMRC"),
layout: "vmsremote_buttons",
custom_classes: "only-sunstone-info vmrc-sunstone-info"
},
"VM.startspice" : {
type: "action",
text: Locale.tr("SPICE"),
Expand Down
95 changes: 95 additions & 0 deletions src/sunstone/public/app/tabs/vms-tab/dialogs/vmrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2020, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */

define(function(require) {
/*
DEPENDENCIES
*/

var BaseDialog = require('utils/dialogs/dialog');
var TemplateHTML = require('hbs!./vmrc/html');
var Sunstone = require('sunstone');
var Vmrc = require('utils/vmrc');

/*
CONSTANTS
*/

var DIALOG_ID = require('./vmrc/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", context).on("click", function() {
var dialog = Sunstone.getDialog(DIALOG_ID);
dialog.hide();
});

$('#sendCtrlAltDelButton', context).click(function() {
Vmrc.sendCtrlAltDel();
return false;
});

return false;
}

function _onShow(context) {
Vmrc.vmrcCallback(this.element);
return false;
}

function _onClose(context) {
Vmrc.disconnect();
Vmrc.unlock();
return false;
}

function _setElement(element) {
this.element = element
}
});
19 changes: 19 additions & 0 deletions src/sunstone/public/app/tabs/vms-tab/dialogs/vmrc/dialogId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2020, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */

define(function(require) {
return 'vmrcVMDialog';
});
40 changes: 40 additions & 0 deletions src/sunstone/public/app/tabs/vms-tab/dialogs/vmrc/html.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2020, OpenNebula Project, OpenNebula Systems }}
{{! }}
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
{{! not use this file except in compliance with the License. You may obtain }}
{{! a copy of the License at }}
{{! }}
{{! http://www.apache.org/licenses/LICENSE-2.0 }}
{{! }}
{{! Unless required by applicable law or agreed to in writing, software }}
{{! distributed under the License is distributed on an "AS IS" BASIS, }}
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
{{! See the License for the specific language governing permissions and }}
{{! limitations under the License. }}
{{! -------------------------------------------------------------------------- }}

<div id="{{dialogId}}" class="reveal full" data-reveal>
<div class="row text-center">
<div class="large-12 columns">
<h5 class="subheader" id="vmrc_dialog">
<span id="VMRC_status"></span>
<span id="VMRC_buttons" class="right">
<button class="button alert" value="Send CtrlAltDel" id="sendCtrlAltDelButton">{{tr "Send CtrlAltDel"}}</button>
<a class="button" id="open_in_a_new_window" href="" target="_blank" title="{{tr "Open in a new window"}}">
<i class="fas fa-external-link-alt detach-vmrc-icon"/>
</a>
<button class="button secondary" data-close aria-label="{{tr "Close modal"}}" type="button" title="Close VMRC">
<i class="fas fa-times-circle"></i>
</button>
</span>
</h5>
</div>
</div>
<div class="reveal-body text-center" style="width:100%; overflow-x:auto">
<div id="VMRC_canvas" width="640px">
<div class="VMRC_message"></div>
</div>
<div id="VMRC_status_bar" class="VMRC_status_bar"></div>
</div>
</div>
Loading