1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Added dialog in Revert Snapshots (#228)

This commit is contained in:
Abel Coronado 2017-03-22 13:31:09 +01:00 committed by Tino Vázquez
parent e2d38abe06
commit dec4ac7b57
5 changed files with 156 additions and 2 deletions

View File

@ -33,6 +33,7 @@ define(function(require) {
require('./vms-tab/dialogs/disk-resize'),
require('./vms-tab/dialogs/attach-nic'),
require('./vms-tab/dialogs/snapshot'),
require('./vms-tab/dialogs/revert'),
require('./vms-tab/dialogs/vnc'),
require('./vms-tab/dialogs/spice'),
require('./vms-tab/dialogs/saveas-template')

View File

@ -0,0 +1,92 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2016, 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!./revert/html');
var Sunstone = require('sunstone');
var Tips = require('utils/tips');
/*
CONSTANTS
*/
var DIALOG_ID = require('./revert/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.setup = _setup;
Dialog.prototype.setElement = _setElement;
return Dialog;
/*
FUNCTION DEFINITIONS
*/
function _html() {
return TemplateHTML({
'dialogId': this.dialogId
});
}
function _setup(context) {
var that = this;
Tips.setup(context);
$('#' + DIALOG_ID + 'Form', context).submit(function() {
var snapshot_id = $(this).parents('tr').attr('snapshot_id');
Sunstone.runAction('VM.snapshot_revert', that.element.ID, {"snapshot_id": snapshot_id});
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
return false;
});
return false;
}
function _onShow(context) {
this.setNames( {tabId: TAB_ID} );
return false;
}
function _setElement(element) {
this.element = element
}
});

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2016, 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 'revertVMDialog';
});

View File

@ -0,0 +1,40 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2016, 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 small" data-reveal>
<div class="row">
<h3 class="subheader">
{{tr "Revert"}}
</h3>
</div>
<div class="confirm-resources-header"></div>
<div class="reveal-body">
<form id="{{dialogId}}Form" action="">
<div class="row">
<div id="confirm_tip">{{tr "You have to confirm this action."}}</div>
<br/>
<div id="question">{{tr "Do you want to proceed?"}}</div>
<br />
</div>
<div class="form_buttons">
<button class="button radius right success" type="submit">{{tr "OK"}}</button>
</div>
<button class="close-button" data-close aria-label="{{tr "Close modal"}}" type="button">
<span aria-hidden="true">&times;</span>
</button>
</form>
</div>
</div>

View File

@ -34,6 +34,7 @@ define(function(require) {
var TAB_ID = require('../tabId');
var PANEL_ID = require('./snapshots/panelId');
var SNAPSHOT_DIALOG_ID = require('../dialogs/snapshot/dialogId');
var REVERT_DIALOG_ID = require('../dialogs/revert/dialogId');
var RESOURCE = "VM"
var XML_ROOT = "VM"
@ -165,8 +166,9 @@ define(function(require) {
if (Config.isTabActionEnabled("vms-tab", "VM.snapshot_revert")) {
context.off('click', '.snapshot_revert');
context.on('click', '.snapshot_revert', function() {
var snapshot_id = $(this).parents('tr').attr('snapshot_id');
Sunstone.runAction('VM.snapshot_revert', that.element.ID, {"snapshot_id": snapshot_id});
var dialog = Sunstone.getDialog(REVERT_DIALOG_ID);
dialog.setElement(that.element);
dialog.show();
return false;
});
}