-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Frederick Borges
authored
Feb 11, 2022
1 parent
869d2a8
commit 6ab6f3f
Showing
26 changed files
with
470 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
src/sunstone/public/app/tabs/vms-tab/dialogs/attach-sg.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* -------------------------------------------------------------------------- */ | ||
/* Copyright 2002-2021, 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 Notifier = require("utils/notifier"); | ||
var SecgroupsTable = require('tabs/secgroups-tab/datatable'); | ||
var Sunstone = require("sunstone"); | ||
var TemplateHTML = require("hbs!./attach-sg/html"); | ||
|
||
|
||
/* | ||
CONSTANTS | ||
*/ | ||
|
||
var DIALOG_ID = require("./attach-sg/dialogId"); | ||
var TAB_ID = require("../tabId"); | ||
|
||
/* | ||
CONSTRUCTOR | ||
*/ | ||
|
||
function Dialog() { | ||
var that = this; | ||
this.dialogId = DIALOG_ID; | ||
|
||
var secgroupSelectOptions = { | ||
'select': true, | ||
'selectOptions': { | ||
"multiple_choice": false, | ||
'unselect_callback': function(aData, options){ | ||
if (that.secGroups && that.secGroups.includes(aData[options.id_index])){ | ||
$("div[name='str_nic_tab_id'] table tbody tr td:contains('" + aData[options.name_index] + "')").click(); | ||
} | ||
}, | ||
'filter_fn': function(sg) { | ||
if (that.nic && that.nic.SECURITY_GROUPS) { | ||
var security_groups = that.nic.SECURITY_GROUPS ? that.nic.SECURITY_GROUPS.split(",") : []; | ||
return !security_groups.includes(sg.ID); | ||
} | ||
return true; | ||
} | ||
} | ||
}; | ||
|
||
this.secgroupsTable = new SecgroupsTable(this.dialogId + 'SGTable', secgroupSelectOptions); | ||
|
||
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, | ||
"secGroupsDataTableHTML": this.secgroupsTable.dataTableHTML | ||
}); | ||
} | ||
|
||
function _setup(context) { | ||
var that = this; | ||
that.secgroupsTable.initialize(); | ||
that.secgroupsTable.refreshResourceTableSelect(); | ||
|
||
$("#" + DIALOG_ID + "Form", context).submit(function() { | ||
var sg_id = that.secgroupsTable.retrieveResourceTableSelect(); | ||
|
||
if(sg_id !== ''){ | ||
var obj = { | ||
'nic_id': parseInt(that.nic.NIC_ID), | ||
'sg_id': parseInt(sg_id) | ||
}; | ||
Sunstone.runAction("VM.attachsg", that.element.ID, obj); | ||
Sunstone.getDialog(DIALOG_ID).hide(); | ||
Sunstone.getDialog(DIALOG_ID).reset(); | ||
}else{ | ||
Notifier.notifyError("Select a security group"); | ||
} | ||
|
||
return false; | ||
}); | ||
return false; | ||
} | ||
|
||
function _onShow(context) { | ||
return false; | ||
} | ||
|
||
function _setElement(element, nic_id) { | ||
this.element = element; | ||
var nic_array = []; | ||
|
||
nic_array = Array.isArray(element.TEMPLATE.NIC) ? element.TEMPLATE.NIC : [element.TEMPLATE.NIC]; | ||
this.nic = nic_array.filter(function(nic) { | ||
return nic.NIC_ID == nic_id; | ||
})[0]; | ||
|
||
this.secgroupsTable.refreshResourceTableSelect(); | ||
} | ||
}); |
19 changes: 19 additions & 0 deletions
19
src/sunstone/public/app/tabs/vms-tab/dialogs/attach-sg/dialogId.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* -------------------------------------------------------------------------- */ | ||
/* Copyright 2002-2021, 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 'attachSGVMDialog'; | ||
}); |
37 changes: 37 additions & 0 deletions
37
src/sunstone/public/app/tabs/vms-tab/dialogs/attach-sg/html.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{{! -------------------------------------------------------------------------- }} | ||
{{! Copyright 2002-2021, 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 large" data-reveal> | ||
<div class="row"> | ||
<div class="large-12 columns"> | ||
<h3 class="subheader" id="">{{tr "Attach new security group to NIC"}}</h3> | ||
</div> | ||
</div> | ||
<div class="confirm-resources-header"></div> | ||
<div class="reveal-body"> | ||
<form id="{{dialogId}}Form" action=""> | ||
{{{secGroupsDataTableHTML}}} | ||
<div class="reveal-footer"> | ||
<div class="form_buttons"> | ||
<button class="button radius right success" id="attach_sg_button" type="submit" value="VM.attachsg">{{tr "Attach"}}</button> | ||
</div> | ||
</div> | ||
<button class="close-button" data-close aria-label="{{tr "Close modal"}}" type="button"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</form> | ||
</div> | ||
</div> |
Oops, something went wrong.