'+i18n['GINNET0056M']+'';
- $('#ovsbridgeList').append(emptyIList);
- if($('#ovsbridgeGrid').hasClass('wok-datagrid')) {
- $('#ovsbridgeGrid').dataGrid('destroy');
+ } else {
+ var emptyIList = '
' + i18n['GINNET0056M'] + '';
+ $('#ovsbridgeList').append(emptyIList);
+ if ($('#ovsbridgeGrid').hasClass('wok-datagrid')) {
+ $('#ovsbridgeGrid').dataGrid('destroy');
+ }
+ $('#ovsbridgeGrid').dataGrid({ enableSorting: false });
+ $('#ovsbridgeGrid').removeClass('hidden');
+ $('#ovsbridge-content-area .wok-mask').addClass('hidden');
}
- $('#ovsbridgeGrid').dataGrid({enableSorting: false});
- $('#ovsbridgeGrid').removeClass('hidden');
- $('#ovsbridge-content-area .wok-mask').addClass('hidden');
- }
}, function(err) {
- $('#add_ovsbridge_button').prop('disabled',true);
- $('#ovs_search_input').prop('disabled',true);
+ $('#add_ovsbridge_button').prop('disabled', true);
+ $('#ovs_search_input').prop('disabled', true);
$('#ovsbridge-content-area .wok-mask').addClass('hidden');
- wok.message.error(err.responseJSON.reason,'#ovs-alert-container');
+ wok.message.error(err.responseJSON.reason, '#ovs-alert-container');
});
}
ginger.initOvsClickHandler = function() {
- $('#add_ovsbridge_button').on('click',function(e){
- e.preventDefault();
- e.stopPropagation();
- wok.window.open('plugins/ginger/host-network-ovs-add.html');
- });
- $('#ovsbridgeGrid').on('click','.edit-bridge',function(e){
- e.preventDefault();
- e.stopPropagation();
- ginger.selectedBridge = $(this).data('name');
- wok.window.open('plugins/ginger/host-network-ovs-edit.html');
- });
- $('#ovsbridgeGrid').on('click','.remove-bridge',function(e){
- e.preventDefault();
- e.stopPropagation();
- ginger.selectedBridge = $(this).data('name');
- var settings = {
- title: i18n['GINNET0048M'],
- content: i18n['GINNET0049M'].replace("%1", '
'+ginger.selectedBridge+''),
- confirm: i18n['GINNET0045M'],
- cancel: i18n['GINNET0046M']
- };
- wok.confirm(settings, function() {
- ginger.delOvsBridge(ginger.selectedBridge, function() {
- var bridgeItem = $('div.wok-datagrid-row[data-name="'+ginger.selectedBridge+'"');
- wok.message.success(i18n['GINNET0050M'].replace("%1", '
'+ginger.selectedBridge+''),'#ovs-alert-container');
- bridgeItem.remove();
- $('body').animate({ scrollTop: 0 }, 1000);
- }, function(err) {
- wok.message.error(err.responseJSON.reason,'#ovs-alert-container');
- $('body').animate({ scrollTop: 0 }, 1000);
- });
- }, function() {});
- });
+ $('#add_ovsbridge_button').on('click', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ wok.window.open('plugins/ginger/host-network-ovs-add.html');
+ });
+ $('#ovsbridgeGrid').on('click', '.edit-bridge', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ ginger.selectedBridge = $(this).data('name');
+ wok.window.open('plugins/ginger/host-network-ovs-edit.html');
+ });
+ $('#ovsbridgeGrid').on('click', '.remove-bridge', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ ginger.selectedBridge = $(this).data('name');
+ var settings = {
+ title: i18n['GINNET0048M'],
+ content: i18n['GINNET0049M'].replace("%1", '
' + ginger.selectedBridge + ''),
+ confirm: i18n['GINNET0045M'],
+ cancel: i18n['GINNET0046M']
+ };
+ wok.confirm(settings, function() {
+ ginger.delOvsBridge(ginger.selectedBridge, function() {
+ var bridgeItem = $('div.wok-datagrid-row[data-name="' + ginger.selectedBridge + '"');
+ wok.message.success(i18n['GINNET0050M'].replace("%1", '
' + ginger.selectedBridge + ''), '#ovs-alert-container');
+ bridgeItem.remove();
+ $('body').animate({ scrollTop: 0 }, 1000);
+ }, function(err) {
+ wok.message.error(err.responseJSON.reason, '#ovs-alert-container');
+ $('body').animate({ scrollTop: 0 }, 1000);
+ });
+ }, function() {});
+ });
}
-ginger.addOvsBridgeModal = function(){
- $('#addButton').prop('disabled',true);
- $('input#bridge[name="name"]').on('keyup', function(){
- if($(this).val().length !=0) {
- $('#addButton').prop('disabled', false);
- } else{
- $('#addButton').prop('disabled',true);
- }
- });
- $('#addButton').on('click',function(){
- $('form[name="ovsbridgeadd"]').submit();
- });
- $('form[name="ovsbridgeadd"]').on('submit',function(e){
- e.preventDefault();
- var name = $("#bridge").val();
- var data = {};
- data = {
- name: name
- };
- ginger.addOvsBridge(data, function() {
- $('form[name="ovsbridgeadd"] input').prop('disabled', true);
- $('#addButton').prop('disabled',true);
- ginger.refreshOvsBridges();
- wok.window.close();
- $('body').animate({ scrollTop: 0 }, 1000);
- }, function(err) {
- wok.message.error(err.responseJSON.reason, '#alert-modal-container');
- $('form[name="ovsbridgeadd"] input').prop('disabled', false);
- $('#addButton').prop('disabled',false);
- $("#bridge").focus();
- });
- });
+ginger.addOvsBridgeModal = function() {
+ $('#addButton').prop('disabled', true);
+ $('input#bridge[name="name"]').on('keyup', function() {
+ if ($(this).val().length != 0) {
+ $('#addButton').prop('disabled', false);
+ } else {
+ $('#addButton').prop('disabled', true);
+ }
+ });
+ $('#addButton').on('click', function() {
+ $('form[name="ovsbridgeadd"]').submit();
+ });
+ $('form[name="ovsbridgeadd"]').on('submit', function(e) {
+ e.preventDefault();
+ var name = $("#bridge").val();
+ var data = {};
+ data = {
+ name: name
+ };
+ ginger.addOvsBridge(data, function() {
+ $('form[name="ovsbridgeadd"] input').prop('disabled', true);
+ $('#addButton').prop('disabled', true);
+ ginger.refreshOvsBridges();
+ wok.window.close();
+ $('body').animate({ scrollTop: 0 }, 1000);
+ }, function(err) {
+ wok.message.error(err.responseJSON.reason, '#alert-modal-container');
+ $('form[name="ovsbridgeadd"] input').prop('disabled', false);
+ $('#addButton').prop('disabled', false);
+ $("#bridge").focus();
+ });
+ });
}
ginger.initNetworkConfig = function() {
- ginger.opts_nw_if = {};
- ginger.opts_nw_if['id'] = 'nw-configuration';
- ginger.opts_nw_if['gridId'] = "nwConfigGrid";
- ginger.opts_nw_if['identifier'] = "device";
- ginger.opts_nw_if['loadingMessage'] = i18n['GINNET0025M'];
-
- ginger.listNetworkConfig();
+ // Redesigned Network Configuration table
+ //ginger.renderNetworkConfig();
+ ginger.listNetworkConfig = ginger.renderNetworkConfig();
}
-ginger.loadBootgridNWActions = function() {
-
- var addActionsId = "nw-configuration-add";
- var tabActionsId = "nw-configuration-actions";
- // Add actions for Network Configuration
- var addButton = [{
- id: 'nw-add-bond-button',
- class: 'fa fa-plus-circle',
- label: i18n['GINNET0006M'],
- onClick: function(event) {
- ginger.selectedInterface = null;
- wok.window.open('plugins/ginger/host-network-bond.html');
- }
- }, {
- id: 'nw-add-vlan-button',
- class: 'fa fa-plus-circle',
- label: i18n['GINNET0007M'],
- onClick: function(event) {
- ginger.selectedInterface = null;
- wok.window.open('plugins/ginger/host-network-vlan.html');
- }
- }];
-
- // Actions for Network Configuration
- var actionButton = [{
- id: 'nw-up-button',
- class: 'fa fa-power-off',
- label: i18n['GINNET0009M'],
- onClick: function(event) {
- var selectedIf = ginger.getSelectedRowsData(ginger.opts_nw_if);
- if ((selectedIf && selectedIf.length == 1) && (selectedIf[0]["status"] == "down")) {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- ginger.enableInterface(selectedIf[0]["device"], "up", function(result) {
- var message = i18n['GINNET0016M'] + " " + selectedIf[0]["device"] + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- wok.message.error(error.responseJSON.reason, '#message-nw-container-area', true);
+ginger.renderNetworkConfig = function() {
+ var networkConfigTable;
+ var nwConfigDataSet = new Array();
+ var rows_indexes = new Array();
+
+ var updateDataTableSelectAllCtrl = function(table) {
+ updateDataTableSelectAllCtrl = function() {};
+ var $table = networkConfigTable.table().node();
+ var $chkbox_all = $('tbody input[type="checkbox"]', $table);
+ var $chkbox_checked = $('tbody input[type="checkbox"]:checked', $table);
+ var chkbox_select_all = $('thead input[name="select_all"]', $table).get(0);
+
+ // If none of the checkboxes are checked
+ if ($chkbox_checked.length === 0) {
+ chkbox_select_all.checked = false;
+ if ('indeterminate' in chkbox_select_all) {
+ chkbox_select_all.indeterminate = false;
+ }
+
+ // If all of the checkboxes are checked
+ } else if ($chkbox_checked.length === $chkbox_all.length) {
+ chkbox_select_all.checked = true;
+ if ('indeterminate' in chkbox_select_all) {
+ chkbox_select_all.indeterminate = false;
+ }
+
+ // If some of the checkboxes are checked
+ } else {
+ chkbox_select_all.checked = true;
+ if ('indeterminate' in chkbox_select_all) {
+ chkbox_select_all.indeterminate = true;
+ }
+ }
+ };
+
+ var updateButtonStatus = function() {
+ if (rows_indexes.length && rows_indexes.length === 1) {
+ ginger.nwConfiguration.enableActions();
+ var networkStatus = networkConfigTable.row(rows_indexes[0]).data()[1];
+ var networkType = networkConfigTable.row(rows_indexes[0]).data()[3];
+ var networkNicType = networkConfigTable.row(rows_indexes[0]).data()[4];
+ var networkModule = networkConfigTable.row(rows_indexes[0]).data()[7];
+ // 1 - Enable settings button
+ ginger.nwConfiguration.enableSettings();
+ if (networkStatus === 'up' || networkStatus === 'unknown') {
+ // 2 - Disable up button, enable down & restart
+ ginger.nwConfiguration.disableUp();
+ ginger.nwConfiguration.enableDown();
+ ginger.nwConfiguration.enableRestart();
+ } else {
+ // 2 - Disable down button, enable down & restart
+ ginger.nwConfiguration.enableUp();
+ ginger.nwConfiguration.disableDown();
+ ginger.nwConfiguration.disableRestart();
+ }
+ if ((networkModule !== 'mlx5_core' && networkModule === 'mlx5-core') || networkNicType === 'virtual') {
+ // 3 - Hide and disable SR-IOV
+ ginger.nwConfiguration.showSrIov();
+ } else {
+ ginger.nwConfiguration.hideSrIov();
+ }
+ if (networkType.toLowerCase() === 'nic') {
+ // 4 - Disable delete button
+ ginger.nwConfiguration.disableDelete();
+ } else {
+ ginger.nwConfiguration.enableDelete();
+ }
+ } else if (rows_indexes.length && rows_indexes.length > 1) {
+ var networkType = 0;
+ ginger.nwConfiguration.enableActions();
+ // 1 - Disable settings button;
+ ginger.nwConfiguration.disableSettings();
+ ginger.nwConfiguration.disableSrIov();
+ $.each(rows_indexes, function(key, value) {
+ if (networkConfigTable.row(rows_indexes[key]).data()[3] == "nic") {
+ networkType = 1;
+ }
+ if (networkConfigTable.row(rows_indexes[key]).data()[1] == "up" || networkConfigTable.row(rows_indexes[key]).data()[1] == "unknown") {
+ // 2 - Disable up button, enable down & restart
+ ginger.nwConfiguration.disableUp();
+ ginger.nwConfiguration.enableDown();
+ ginger.nwConfiguration.enableRestart();
+ } else if (networkConfigTable.row(rows_indexes[key]).data()[1] == "down") {
+ // 2 - Disable down button, enable down & restart
+ ginger.nwConfiguration.enableUp();
+ ginger.nwConfiguration.disableDown();
+ ginger.nwConfiguration.disableRestart();
+
+ }
+ });
+ if (networkType === 1) {
+ ginger.nwConfiguration.disableDelete();
+ }
+ } else {
+ ginger.nwConfiguration.disableActions();
+ }
+ };
+
+ var loadNetworkConfigDatatable = function(nwConfigDataSet) {
+ networkConfigTable = $('#network-configuration').DataTable({
+ "processing": true,
+ "data": nwConfigDataSet,
+ "order": [],
+ "dom": '<"row"<"col-sm-12 filter"<"pull-left buttons"<"#network-configuration-actions.row.grid-control">><"pull-right"f>>><"row"<"col-sm-12"t>><"row datatable-footer"<"col-sm-6 pages"p><"col-sm-6 info"i>>',
+ "scrollY": "269px",
+ "columnDefs": [{
+ "targets": 0,
+ "searchable": false,
+ "orderable": false,
+ "width": "2%",
+ "className": "nw-config-align-center",
+ "render": function(data, type, full, meta) {
+ return '
';
+ }
+ }, {
+ "targets": 1,
+ "searchable": false,
+ "orderable": false,
+ "width": "4%",
+ "className": "nw-config-align-center",
+ "render": function(data, type, full, meta) {
+ if (data === 'up') {
+ return '
';
+ } else {
+ return '
';
+ }
+ }
+ }, {
+ "targets": 2,
+ "width": "10%"
+ }, {
+ "targets": 3,
+ "width": "7%"
+ }, {
+ "targets": 4,
+ "width": "7%"
+ }, {
+ "targets": 5,
+ 'type': 'ip-address',
+ "className": "tabular-data",
+ "width": "23%"
+ }, {
+ "targets": 6,
+ "searchable": true,
+ "orderable": true,
+ "width": "13%",
+ "render": function(data, type, full, meta) {
+ if (data === true) {
+ return i18n['GINNET0077M'];
+ } else {
+ return i18n['GINNET0078M'];
+ }
+ }
+ }, {
+ "targets": 7,
+ "width": "8%"
+ }, {
+ "targets": 8,
+ "className": "tabular-data",
+ "width": "25%"
+ }],
+ "initComplete": function(settings, json) {
+ wok.initCompleteDataTableCallback(settings);
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ }
});
- } else if (selectedIf && selectedIf.length > 1) {
- $.each(selectedIf, function(key, value) {
- if (value.status == "down") {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- ginger.enableInterface(value.device, "up", function(result) {
- var message = i18n['GINNET0016M'] + " " + value.device + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = i18n['GINNET0016M'] + " " + value.device + " " + i18n['GINNET0021M'];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
- });
- }
- });
- } else {
- var settings = {
- content: i18n["GINNET0022M"],
- confirm: i18n["GINNET0015M"]
- };
- wok.confirm(settings, function() {});
- }
- }
- }, {
- id: 'nw-down-button',
- class: 'fa fa-ban',
- label: i18n['GINNET0010M'],
- onClick: function(event) {
- var selectedIf = ginger.getSelectedRowsData(ginger.opts_nw_if);
- if ((selectedIf && selectedIf.length == 1) &&
- ((selectedIf[0]["status"] == "up") || (selectedIf[0]["status"] == "unknown"))) {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- ginger.enableInterface(selectedIf[0]["device"], "down", function(result) {
- var message = i18n['GINNET0017M'] + " " + selectedIf[0]["device"] + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = i18n['GINNET0017M'] + " " + selectedIf[0]["device"] + " " + i18n['GINNET0021M'];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
+ //$(globalNetworkConfigTable.column('1').header()).wrapInner('
');
+ $('input[name="select_all"]', networkConfigTable.table().container()).prop('checked', false);
+ var buttons = $.parseHTML(wok.substitute($("#networkConfigButtonsTmpl").html(), {}));
+ $('#network-configuration-actions').append(buttons);
+ ginger.nwConfiguration.enableRefresh();
+ ginger.nwConfiguration.toggleAdd();
+ //tableAdd();
+
+ // Handle click on checkbox
+ $('#network-configuration tbody').on('click', 'input[type="checkbox"]', function(e) {
+ var $row = $(this).closest('tr');
+
+ // Get row ID
+ var rowId = networkConfigTable.row($row).index();
+
+ // Determine whether row ID is in the list of selected row IDs
+ var index = $.inArray(rowId, rows_indexes);
+
+ // If checkbox is checked and row ID is not in list of selected row IDs
+ if (this.checked && index === -1) {
+ rows_indexes.push(rowId);
+
+ // Otherwise, if checkbox is not checked and row ID is in list of selected row IDs
+ } else if (!this.checked && index !== -1) {
+ rows_indexes.splice(index, 1);
+ }
+
+ if (this.checked) {
+ $row.addClass('active');
+ } else {
+ $row.removeClass('active');
+ }
+
+ // Update state of "Select all" control
+ updateDataTableSelectAllCtrl(networkConfigTable);
+ updateButtonStatus();
+
+ // Prevent click event from propagating to parent
+ e.stopPropagation();
});
- } else if (selectedIf && selectedIf.length > 1) {
- $.each(selectedIf, function(key, value) {
- if ((value.status == "up") || (value.status == "unknown")) {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- ginger.enableInterface(value.device, "down", function(result) {
- var message = i18n['GINNET0017M'] + " " + value.device + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = i18n['GINNET0017M'] + " " + value.device + " " + i18n['GINNET0021M'];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
- });
- }
- });
- } else {
- var settings = {
- content: i18n["GINNET0022M"],
- confirm: i18n["GINNET0015M"]
- };
- wok.confirm(settings, function() {});
- }
- }
- }, {
- id: 'nw-restart-button',
- class: 'fa fa-undo',
- label: i18n['GINNET0011M'],
- onClick: function(event) {
- var selectedIf = ginger.getSelectedRowsData(ginger.opts_nw_if);
- if ((selectedIf && selectedIf.length == 1) &&
- ((selectedIf[0]["status"] == "up") || (selectedIf[0]["status"] == "unknown"))) {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- // First Bring down the interface
- ginger.enableInterface(selectedIf[0]["device"], "down", function(result) {
- // Second Bring the interface up back again
- ginger.enableInterface(selectedIf[0]["device"], "up", function(result) {
- var message = i18n['GINNET0018M'] + " " + selectedIf[0]["device"] + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = i18n['GINNET0018M'] + " " + selectedIf[0]["device"] + " " + i18n['GINNET0021M'];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = "Failed to brought down the interface " + selectedIf[0]["device"];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
+
+ // Handle click on table cells with checkboxes
+ $('#network-configuration').on('click', 'tbody td, thead th:first-child', function(e) {
+ $(this).parent().find('input[type="checkbox"]').trigger('click');
+ });
+
+ // Handle click on "Select all" control
+ $('input[name="select_all"]', networkConfigTable.table().container()).on('click', function(e) {
+ if (this.checked) {
+ $('tbody input[type="checkbox"]:not(:checked)', networkConfigTable.table().container()).trigger('click');
+ } else {
+ $('tbody input[type="checkbox"]:checked', networkConfigTable.table().container()).trigger('click');
+ }
+
+ // Prevent click event from propagating to parent
+ e.stopPropagation();
});
- } else if (selectedIf && selectedIf.length == 1 && (selectedIf[0]["status"] == "down")) {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- // Assuming interface is down already and just needs to brought up
- ginger.enableInterface(selectedIf[0]["device"], "up", function(result) {
- var message = i18n['GINNET0018M'] + " " + selectedIf[0]["device"] + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
+
+ // Handle table draw event
+ networkConfigTable.on('draw', function() {
+ // Update state of "Select all" control
+ updateDataTableSelectAllCtrl(networkConfigTable);
+ });
+
+ };
+
+ var getNetworkConfiguration = function(callback) {
+ ginger.getInterfaces(function(result) {
+ nwConfigDataSet.length = 0;
+ for (var i = 0; i < result.length; i++) {
+ var tempArr = [];
+ tempArr.push("");
+ tempArr.push(result[i].status);
+ tempArr.push(result[i].device);
+ tempArr.push(result[i].type);
+ tempArr.push(result[i].nic_type);
+ tempArr.push(result[i].ipaddr);
+ tempArr.push(result[i].rdma_enabled);
+ tempArr.push(result[i].module);
+ tempArr.push(result[i].macaddr);
+ nwConfigDataSet.push(tempArr);
+ }
+ if (callback !== 'refresh') {
+ loadNetworkConfigDatatable(nwConfigDataSet);
+ }
}, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = i18n['GINNET0018M'] + " " + selectedIf[0]["device"] + " " + i18n['GINNET0021M'];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
+ errmsg = i18n['GINNET0035E'] + ' ' + error.responseJSON.reason;
+ wok.message.error(errmsg, '#message-network-configuration-container-area', true);
});
- }else if (selectedIf && selectedIf.length > 1) {
- $.each(selectedIf, function(key, value) {
- //this is for up
- if (value.status == 'up' || value.status == "unknown") {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- // First Bring down the interface
- ginger.enableInterface(value.device, "down", function(result) {
- // Second Bring the interface up back again
- ginger.enableInterface(value.device, "up", function(result) {
- var message = i18n['GINNET0018M'] + " " + value.device + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = i18n['GINNET0018M'] + " " + value.device + " " + i18n['GINNET0021M'];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = "Failed to brought down the interface " + value.device;
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
- });
- } else if (value.status == 'down') {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- // Assuming interface is down already and just needs to brought up
- ginger.enableInterface(value.device, "up", function(result) {
- var message = i18n['GINNET0018M'] + " " + value.device + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = i18n['GINNET0018M'] + " " + value.device + " " + i18n['GINNET0021M'];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
- });
- }
- });
- } else {
- var settings = {
- content: i18n["GINNET0022M"],
- confirm: i18n["GINNET0015M"]
- };
- wok.confirm(settings, function() {});
- }
}
- }, {
- id: 'nw-settings-button',
- class: 'fa fa-cog',
- label: i18n['GINNET0012M'],
- onClick: function(event) {
- var selectedIf = ginger.getSelectedRowsData(ginger.opts_nw_if);
- if (selectedIf && (selectedIf.length == 1)) {
- ginger.selectedInterface = (selectedIf[0]["device"] == "undefined" ? null : selectedIf[0]["device"]);
- ginger.retrieveCfgInterface(ginger.selectedInterface, function (result) {
- if ((selectedIf[0]["type"]).toLowerCase() == "vlan") {
- wok.window.open('plugins/ginger/host-network-vlan.html');
- } else if ((selectedIf[0]["type"]).toLowerCase() == "bonding") {
- wok.window.open('plugins/ginger/host-network-bond.html');
- } else if (((selectedIf[0]["type"]).toLowerCase() == "ethernet") || ((selectedIf[0]["type"]).toLowerCase() == "nic")) {
- // condition nic should go away if #104 to be correct and resolved
- wok.window.open('plugins/ginger/host-network-settings.html');
+ getNetworkConfiguration();
+
+ var refreshNetworkConfigurationDatatable = function() {
+ rows_indexes = [];
+ $('#network-configuration tbody').off('click', 'input[type="checkbox"]');
+ $('#network-configuration').off('click', 'tbody td, thead th:first-child');
+ $('#network-configuration').off('click', 'input[name="select_all"]');
+ networkConfigTable.destroy();
+ getNetworkConfiguration('refresh');
+ loadNetworkConfigDatatable(nwConfigDataSet);
+ };
+
+ var networkConfigurationClickHandler = function() {
+ // Refresh Button
+ $('#network-configuration-content-area').on('click', '#nw-config-refresh-btn', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ refreshNetworkConfigurationDatatable();
+ });
+
+ // Network Up Button
+ $('#network-configuration-content-area').on('click', '.nw-up', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!$(this).parent().is('.disabled')) {
+ $('.nw-configuration-action > .dropdown-toggle').dropdown('toggle');
+ if ((rows_indexes && rows_indexes.length === 1)) {
+ var selectedIf = networkConfigTable.row(rows_indexes[0]).data();
+ var ifStatus = selectedIf[1];
+ var ifDevice = selectedIf[2];
+ if (ifStatus === "down") {
+ $('#network-configuration-content-area > .wok-mask').removeClass('hidden');
+ ginger.enableInterface(ifDevice, "up", function(result) {
+ var message = i18n['GINNET0081M'].replace('%1', '
' + ifDevice + '');
+ wok.message.success(message, '#message-network-configuration-container-area');
+ refreshNetworkConfigurationDatatable();
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0082M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }
+ } else if (rows_indexes && rows_indexes.length > 1) {
+ $.each(rows_indexes, function(key, value) {
+ var ifStatus = networkConfigTable.row(rows_indexes[key]).data()[1];
+ var ifDevice = networkConfigTable.row(rows_indexes[key]).data()[2];
+ if (ifStatus === "down") {
+ $('#network-configuration-content-area > .wok-mask').removeClass('hidden');
+ ginger.enableInterface(ifDevice, "up", function(result) {
+ var message = i18n['GINNET0081M'].replace('%1', '
' + ifDevice + '');
+ wok.message.success(message, '#message-network-configuration-container-area');
+ refreshNetworkConfigurationDatatable();
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0082M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }
+ });
+ } else {
+ var settings = {
+ content: i18n["GINNET0022M"],
+ confirm: i18n["GINNET0015M"]
+ };
+ wok.confirm(settings, function() {});
+ }
+ } else {
+ return false;
}
- }, function(error){
- wok.message.error(i18n['GINNET0034E'].replace("%1", ginger.selectedInterface), '#message-nw-container-area', true);
- //Re-load the network interfaces after to clear other inactive interfaces without ifcfg files
- ginger.initNetworkConfigGridData();
});
- } else {
- var settings = {
- content: i18n["GINNET0022M"],
- confirm: i18n["GINNET0015M"]
- };
- wok.confirm(settings, function() {});
- }
- }
- },{
- id: 'nw-enable-sriov',
- class: 'fa fa-minus-circle',
- label: i18n['GINNET0037E'],
- onClick: function(event) {
- var selectedIf = ginger.getSelectedRowsData(ginger.opts_nw_if);
- ginger.selectedInterface = selectedIf[0];
- wok.window.open('plugins/ginger/host-network-enable-sriov.html');
- }
- },{
- id: 'nw-delete-button',
- class: 'fa fa-minus-circle',
- label: i18n['GINNET0013M'],
- critical: true,
- onClick: function(event) {
- var selectedIf = ginger.getSelectedRowsData(ginger.opts_nw_if);
- if (selectedIf && (selectedIf.length == 1) && (selectedIf[0]["type"]).toLowerCase() != 'nic') {
- ginger.selectedNWInterface = selectedIf[0]["device"];
- var settings = {
- content: i18n['GINNET0028M'].replace("%1", ginger.selectedNWInterface),
- confirm: i18n["GINNET0015M"]
- };
- wok.confirm(settings, function() {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- ginger.deleteInterface(ginger.selectedNWInterface, function(result) {
- var message = i18n['GINNET0019M'] + " " + ginger.selectedNWInterface + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
-
- //Re-load the network interfaces after delete action
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = i18n['GINNET0019M'] + " " + ginger.selectedNWInterface + " " + i18n['GINNET0021M'];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
- });
- }, function() {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- } else if (selectedIf && selectedIf.length > 1) {
- var checkNetworkType = 0;
- $.each(selectedIf, function(key, value) {
- if ((value.type).toLowerCase() == "nic") {
- checkNetworkType = 1;
- }
- });
- if (checkNetworkType == 0) {
- $.each(selectedIf, function(key, value) {
- ginger.selectedNWInterface = value.device;
- var settings = {
- content: i18n['GINNET0028M'].replace("%1", ginger.selectedNWInterface),
- confirm: i18n["GINNET0015M"]
- };
- wok.confirm(settings, function() {
- ginger.showBootgridLoading(ginger.opts_nw_if);
- ginger.deleteInterface(ginger.selectedNWInterface, function(result) {
- var message = i18n['GINNET0019M'] + " " + ginger.selectedNWInterface + " " + i18n['GINNET0020M'];
- wok.message.success(message, '#message-nw-container-area');
-
- //Re-load the network interfaces after delete action
- ginger.getInterfaces(function(result) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- }, function(error) {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- var message = i18n['GINNET0019M'] + " " + ginger.selectedNWInterface + " " + i18n['GINNET0021M'];
- wok.message.error(message + " " + error.responseJSON.reason, '#message-nw-container-area', true);
- });
- }, function() {
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- });
- });
- }
- }
- }
- }];
-
- ginger.opts_nw_if['addButtons'] = JSON.stringify(addButton);
- ginger.opts_nw_if['actions'] = JSON.stringify(actionButton);
-
- var addListSettings = {
- panelID: addActionsId,
- buttons: addButton,
- type: 'add'
- };
-
- var actionListSettings = {
- panelID: tabActionsId,
- buttons: actionButton,
- type: 'action'
- };
-
- ginger.createActionList(addListSettings);
-
- // Hide button "Add VLAN" and "Add BOND "in case of capability "cfginterfaces" false
- if (ginger.cfginterfaces != undefined && !ginger.cfginterfaces) {
- $('#nw-add-bond-button').hide();
- $('#nw-add-vlan-button').hide();
- $('#nw-configuration-add').hide();
- } else {
- $('#nw-add-bond-button').show();
- $('#nw-add-vlan-button').show();
- $('#nw-configuration-add').show();
- }
-
- ginger.createActionList(actionListSettings);
-
- $("#nw-configuration-refresh-btn").on('click', function() {
- ginger.networkConfiguration.disableAllButtons();
- ginger.initNetworkConfigGridData();
- });
- ginger.networkConfiguration.disableActions();
-}
-ginger.listNetworkConfig = function() {
-
- var nwGrid = [];
- var gridFields = [];
-
- ginger.loadBootgridNWActions();
- //Network Configuration grid columns
- gridFields = [{
- "column-id": 'status',
- "type": 'string',
- "width": "3%",
- "formatter": "nw-interface-status",
- "title": ""
- }, {
- "column-id": 'device',
- "type": 'string',
- "width": "10%",
- "identifier": true,
- "title": i18n['GINNET0001M']
- }, {
- "column-id": 'type',
- "type": 'string',
- "width": "7%",
- "title": i18n['GINNET0003M']
- }, {
- "column-id": 'nic_type',
- "type": 'string',
- "width": "7%",
- "title": i18n['GINNET0062M']
- }, {
- "column-id": 'ipaddr',
- "formatter": "nw-address-space",
- "type": 'string',
- "width": "23%",
- "title": i18n['GINNET0004M']
- },
- {
- "column-id": 'rdma_enabled',
- "type": 'string',
- "width": "13%",
- "title": i18n['GINNET0039E']
- },
- {
- "column-id": 'module',
- "type": 'string',
- "width": "8%",
- "title": i18n['GINNET0036E']
- },
- {
- "column-id": 'macaddr',
- "type": 'string',
- "width": "25%",
- "title": i18n['GINNET0005M']
- }
- ];
-
- ginger.opts_nw_if['gridFields'] = JSON.stringify(gridFields);
-
- nwGrid = ginger.createBootgrid(ginger.opts_nw_if);
- ginger.hideBootgridLoading(ginger.opts_nw_if);
-
- nwGrid.bootgrid().on("selected.rs.jquery.bootgrid", function(e, rows) {
- changeActionButtonsState();
- }).on("deselected.rs.jquery.bootgrid", function(e, rows) {
- changeActionButtonsState();
- }).on("loaded.rs.jquery.bootgrid", function(e, rows) {
- changeActionButtonsState();
- });
-
- var changeActionButtonsState = function() {
- // By default enable them all
- ginger.changeButtonStatus(["nw-up-button", "nw-down-button", "nw-restart-button", "nw-delete-button", "nw-enable-sriov"
- ], true);
- //hide or show settings button based on cfginterfaces value
- ginger.changeButtonStatus(["nw-settings-button"], ginger.cfginterfaces);
- // Based on the interface status hide/show the right buttons
- var selectedIf = ginger.getSelectedRowsData(ginger.opts_nw_if);
- if (selectedIf && selectedIf.length == 1) {
- ginger.networkConfiguration.enableActions();
- if (selectedIf && (selectedIf[0]["status"] == 'up' || selectedIf[0]["status"] == 'unknown')) {
- ginger.changeButtonStatus(["nw-up-button"], false);
- } else {
- ginger.changeButtonStatus(["nw-down-button"], false);
- }
- if ((selectedIf[0]["module"] != 'mlx5_core' && selectedIf[0]["module"] != 'mlx5-core') || (selectedIf[0]["nic_type"] === 'virtual' )) {
- ginger.changeButtonStatus(["nw-enable-sriov"], false);
- }
- if ((selectedIf[0]["type"]).toLowerCase() == 'nic') {
- ginger.changeButtonStatus(["nw-delete-button"], false);
- }
- } else if(selectedIf && selectedIf.length > 1){
- ginger.networkConfiguration.enableActions();
- var networkType = 0;
- ginger.changeButtonStatus(["nw-enable-sriov"], false);
- ginger.changeButtonStatus(["nw-settings-button"], false);
- $.each(selectedIf, function(key, value){
- if((value.type).toLowerCase() == 'nic'){
- networkType = 1;
- }
- });
-
- if(networkType == 1){
- ginger.changeButtonStatus(["nw-delete-button"], false);
- }
- }
- else{
- ginger.networkConfiguration.disableActions();
- }
- };
- ginger.initNetworkConfigGridData();
-};
+ // Network Down Button
+ $('#network-configuration-content-area').on('click', '.nw-down', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!$(this).parent().is('.disabled')) {
+ $('.nw-configuration-action > .dropdown-toggle').dropdown('toggle');
+ if ((rows_indexes && rows_indexes.length === 1)) {
+ var selectedIf = networkConfigTable.row(rows_indexes[0]).data();
+ var ifStatus = selectedIf[1];
+ var ifDevice = selectedIf[2];
+ if (ifStatus === "up" || ifStatus === "unknown") {
+ $('#network-configuration-content-area > .wok-mask').removeClass('hidden');
+ ginger.enableInterface(ifDevice, "down", function(result) {
+ var message = i18n['GINNET0079M'].replace('%1', '
' + ifDevice + '');
+ wok.message.success(message, '#message-network-configuration-container-area');
+ refreshNetworkConfigurationDatatable();
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0080M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }
+ } else if (rows_indexes && rows_indexes.length > 1) {
+ $.each(rows_indexes, function(key, value) {
+ var ifStatus = networkConfigTable.row(rows_indexes[key]).data()[1];
+ var ifDevice = networkConfigTable.row(rows_indexes[key]).data()[2];
+ if ((ifStatus === "up") || (ifStatus === "unknown")) {
+ $('#network-configuration-content-area > .wok-mask').removeClass('hidden');
+ ginger.enableInterface(ifDevice, "down", function(result) {
+ var message = i18n['GINNET0079M'].replace('%1', '
' + ifDevice + '');
+ wok.message.success(message, '#message-network-configuration-container-area');
+ refreshNetworkConfigurationDatatable();
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0080M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }
+ });
+ } else {
+ var settings = {
+ content: i18n["GINNET0022M"],
+ confirm: i18n["GINNET0015M"]
+ };
+ wok.confirm(settings, function() {});
+ }
+ } else {
+ return false;
+ }
+ });
-ginger.initNetworkConfigGridData = function() {
- ginger.clearBootgridData(ginger.opts_nw_if['gridId']);
- ginger.hideBootgridData(ginger.opts_nw_if);
- ginger.showBootgridLoading(ginger.opts_nw_if);
+ // Network Restart Button
+ $('#network-configuration-content-area').on('click', '.nw-restart', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!$(this).parent().is('.disabled')) {
+ $('.nw-configuration-action > .dropdown-toggle').dropdown('toggle');
+ if ((rows_indexes && rows_indexes.length === 1)) {
+ var selectedIf = networkConfigTable.row(rows_indexes[0]).data();
+ var ifStatus = selectedIf[1];
+ var ifDevice = selectedIf[2];
+ if (ifStatus === "up" || ifStatus === "unknown") {
+ $('#network-configuration-content-area > .wok-mask').removeClass('hidden');
+ // First Bring down the interface
+ ginger.enableInterface(ifDevice, "down", function(result) {
+ // Second Bring the interface up back again
+ ginger.enableInterface(ifDevice, "up", function(result) {
+ var message = i18n['GINNET0084M'].replace('%1', '
' + ifDevice + '');
+ wok.message.success(message, '#message-network-configuration-container-area', true);
+ refreshNetworkConfigurationDatatable();
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0084M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0084M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ } else if (ifStatus === "down") {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ // Assuming interface is down already and just needs to brought up
+ ginger.enableInterface(ifDevice, "up", function(result) {
+ var message = i18n['GINNET0083M'].replace('%1', '
' + ifDevice + '');
+ wok.message.success(message, '#message-network-configuration-container-area', true);
+ refreshNetworkConfigurationDatatable();
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0084M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }
+ } else if (rows_indexes && rows_indexes.length > 1) {
+ $.each(rows_indexes, function(key, value) {
+ var ifStatus = networkConfigTable.row(rows_indexes[key]).data()[1];
+ var ifDevice = networkConfigTable.row(rows_indexes[key]).data()[2];
+ //this is for up
+ if (ifStatus === 'up' || ifStatus === "unknown") {
+ $('#network-configuration-content-area > .wok-mask').removeClass('hidden');
+ // First Bring down the interface
+ ginger.enableInterface(value.device, "down", function(result) {
+ // Second Bring the interface up back again
+ ginger.enableInterface(value.device, "up", function(result) {
+ var message = i18n['GINNET0083M'].replace('%1', '
' + ifDevice + '');
+ wok.message.success(message, '#message-network-configuration-container-area', true);
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0084M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0084M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ } else if (value.status == 'down') {
+ // Assuming interface is down already and just needs to brought up
+ ginger.enableInterface(value.device, "up", function(result) {
+ var message = i18n['GINNET0083M'].replace('%1', '
' + ifDevice + '');
+ wok.message.success(message, '#message-network-configuration-container-area', true);
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0084M'].replace('%1', '
' + ifDevice + '');
+ wok.message.error(message + " " + error.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }
+ });
+ } else {
+ var settings = {
+ content: i18n["GINNET0022M"],
+ confirm: i18n["GINNET0015M"]
+ };
+ wok.confirm(settings, function() {});
+ }
+ } else {
+ return false;
+ }
+ });
- ginger.getInterfaces(function(result) {
+ // Network SR-IOV Button
+ $('#network-configuration-content-area').on('click', '.nw-sriov', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!$(this).parent().is('.disabled') && (rows_indexes && rows_indexes.length === 1)) {
+ var selectedIf = networkConfigTable.row(rows_indexes[0]).data();
+ ginger.selectedInterface = selectedIf[2];
+ wok.window.open('plugins/ginger/host-network-enable-sriov.html');
+ } else {
+ return false;
+ }
+ });
- $.each(result, function(index, value){
- if(value.rdma_enabled) {
- value.rdma_enabled = 'Yes';
- } else {
- value.rdma_enabled = 'No';
- }
- });
+ // Network Delete Button
+ $('#network-configuration-content-area').on('click', '.nw-delete', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!$(this).parent().is('.disabled')) {
+ var selectedIf = networkConfigTable.row(rows_indexes[0]).data();
+ var ifDevice = selectedIf[2];
+ var ifType = selectedIf[3];
+ $('.nw-configuration-action > .dropdown-toggle').dropdown('toggle');
+ if (ifDevice && (rows_indexes.length == 1) && (ifType).toLowerCase() != 'nic') {
+ ginger.selectedNWInterface = ifDevice;
+ var settings = {
+ content: i18n['GINNET0028M'].replace("%1", '
' + ginger.selectedNWInterface + ''),
+ confirm: i18n["GINNET0015M"]
+ };
+ wok.confirm(settings, function() {
+ $('#network-configuration-content-area > .wok-mask').removeClass('hidden');
+ ginger.deleteInterface(ginger.selectedNWInterface, function(result) {
+ var message = i18n['GINNET0085M'].replace('%1', '
' + ginger.selectedNWInterface + '');
+ wok.message.success(message, '#message-network-configuration-container-area', true);
+ //Re-load the network interfaces after delete action
+ refreshNetworkConfigurationDatatable();
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0086M'].replace('%1', '
' + ginger.selectedNWInterface + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }, function() {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ });
+ } else if (rows_indexes && rows_indexes.length > 1) {
+ var checkNetworkType = 0;
+ $.each(rows_indexes, function(key, value) {
+ selectedIf = networkConfigTable.row(rows_indexes[key]).data();
+ ifDevice = selectedIf[2];
+ ifType = selectedIf[3];
+ if ((ifType).toLowerCase() == "nic") {
+ checkNetworkType = 1;
+ }
+ });
+ if (checkNetworkType == 0) {
+ $.each(rows_indexes, function(key, value) {
+ ginger.selectedNWInterface = networkConfigTable.row(rows_indexes[key]).data()[2];
+ var settings = {
+ content: i18n['GINNET0028M'].replace("%1", '
' + ginger.selectedNWInterface + ''),
+ confirm: i18n["GINNET0015M"]
+ };
+ wok.confirm(settings, function() {
+ $('#network-configuration-content-area > .wok-mask').removeClass('hidden');
+ ginger.deleteInterface(ginger.selectedNWInterface, function(result) {
+ var message = i18n['GINNET0085M'].replace('%1', '
' + ginger.selectedNWInterface + '');
+ wok.message.success(message, '#message-network-configuration-container-area', true);
+ refreshNetworkConfigurationDatatable();
+ }, function(err) {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ var message = i18n['GINNET0086M'].replace('%1', '
' + ginger.selectedNWInterface + '');
+ wok.message.error(message + " " + err.responseJSON.reason, '#message-network-configuration-container-area', true);
+ });
+ }, function() {
+ $('#network-configuration-content-area > .wok-mask').addClass('hidden');
+ });
+ });
+ }
+ }
+ } else {
+ return false;
+ }
+ });
- ginger.loadBootgridData(ginger.opts_nw_if['gridId'], result);
- ginger.showBootgridData(ginger.opts_nw_if);
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.networkConfiguration.enableAllButtons();
- }, function(error) {
- var errmessage = i18n['GINNET0033E'];
- wok.message.error(errmessage + " " + error.responseJSON.reason, '#message-nw-container-area', true);
- ginger.hideBootgridLoading(ginger.opts_nw_if);
- ginger.networkConfiguration.enableAllButtons();
- });
-};
+ // Network Settings Button
+ $('#network-configuration-content-area').on('click', '.nw-settings', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!$(this).parent().is('.disabled')) {
+ $('.nw-configuration-action > .dropdown-toggle').dropdown('toggle');
+ if ((rows_indexes && rows_indexes.length === 1)) {
+ var selectedIf = networkConfigTable.row(rows_indexes[0]).data();
+ var ifDevice = selectedIf[2];
+ var ifType = selectedIf[3];
+ ginger.selectedInterface = (ifDevice === "undefined" ? null : ifDevice);
+ ginger.retrieveCfgInterface(ginger.selectedInterface, function(result) {
+ if ((ifType).toLowerCase() == "vlan") {
+ wok.window.open('plugins/ginger/host-network-vlan.html');
+ } else if ((ifType).toLowerCase() == "bonding") {
+ wok.window.open('plugins/ginger/host-network-bond.html');
+ } else if (((ifType).toLowerCase() == "ethernet") || ((ifType).toLowerCase() == "nic")) {
+ // condition nic should go away if #104 to be correct and resolved
+ wok.window.open('plugins/ginger/host-network-settings.html');
+ }
+ }, function(error) {
+ wok.message.error(i18n['GINNET0034E'].replace("%1", '
' + ginger.selectedInterface + ''), '#message-network-configuration-container-area', true);
+ //Re-load the network interfaces after to clear other inactive interfaces without ifcfg files
+ refreshNetworkConfigurationDatatable();
+ });
+ } else {
+ var settings = {
+ content: i18n["GINNET0022M"],
+ confirm: i18n["GINNET0015M"]
+ };
+ wok.confirm(settings, function() {});
+ }
+ } else {
+ return false;
+ }
+ });
+
+ // Network Add Bond
+ $('#network-configuration-content-area').on('click', '.nw-add-bond', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ wok.window.open('plugins/ginger/host-network-bond.html');
+ });
+
+ // Network VLAN
+ $('#network-configuration-content-area').on('click', '.nw-add-vlan', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ wok.window.open('plugins/ginger/host-network-vlan.html');
+ });
+
+ }
+ networkConfigurationClickHandler();
+ return {
+ refreshNetworkConfigurationDatatable: refreshNetworkConfigurationDatatable
+ };
+}
ginger.loadGlobalNetworkConfig = function() {
var globalNetworkConfigTable;
@@ -1078,15 +1165,15 @@ ginger.loadGlobalNetworkConfig = function() {
var gatewayInputValidation = function() {
$('#global-network-config-gateway').on('keyup', function(e) {
- var gatewayIP = $('#global-network-config-gateway').val();
-
- if(gatewayIP.trim() == "") {
- $(this).parent().toggleClass('has-error',true);
- $('#nw-global-config-apply-btn').prop('disabled', true);
- } else {
- $(this).parent().toggleClass("has-error", !((ginger.isValidIPv6(gatewayIP)) || ginger.validateIp(gatewayIP)));
- $('#nw-global-config-apply-btn').prop('disabled', !((ginger.isValidIPv6(gatewayIP)) || ginger.validateIp(gatewayIP)));
- }
+ var gatewayIP = $('#global-network-config-gateway').val();
+
+ if (gatewayIP.trim() == "") {
+ $(this).parent().toggleClass('has-error', true);
+ $('#nw-global-config-apply-btn').prop('disabled', true);
+ } else {
+ $(this).parent().toggleClass("has-error", !((ginger.isValidIPv6(gatewayIP)) || ginger.validateIp(gatewayIP)));
+ $('#nw-global-config-apply-btn').prop('disabled', !((ginger.isValidIPv6(gatewayIP)) || ginger.validateIp(gatewayIP)));
+ }
});
}
gatewayInputValidation();
@@ -1116,65 +1203,153 @@ ginger.loadGlobalNetworkConfig = function() {
ginger.initNetwork = function() {
- $(".content-area", "#gingerHostNetwork").css("height", "100%");
- ginger.getHostDetails(function(result) {
- ginger.hostarch = result["architecture"];
- ginger.getCapabilities(function(result) {
- $.each(result, function(enableItem, capability) {
- var itemLowCase = enableItem.toLowerCase();
- switch (itemLowCase) {
- case "network":
- ginger.initNetworkConfig();
- ginger.loadGlobalNetworkConfig();
- break;
- case "cfginterfaces":
- ginger.cfginterfaces = capability;
- ginger.changeButtonStatus(["nw-add-bond-button", "nw-add-vlan-button", "nw-configuration-add"], capability);
- break;
- case "ovsbridges":
- ginger.ovsbridges = capability;
- ginger.initOvsBridges();
- break;
- }
- });
+ $(".content-area", "#gingerHostNetwork").css("height", "100%");
+ ginger.getHostDetails(function(result) {
+ ginger.hostarch = result["architecture"];
+ ginger.getCapabilities(function(result) {
+ $.each(result, function(enableItem, capability) {
+ var itemLowCase = enableItem.toLowerCase();
+ switch (itemLowCase) {
+ case "network":
+ ginger.initNetworkConfig();
+ ginger.loadGlobalNetworkConfig();
+ break;
+ case "cfginterfaces":
+ ginger.cfginterfaces = capability;
+ ginger.cfginterfaces;
+ break;
+ case "ovsbridges":
+ ginger.ovsbridges = capability;
+ ginger.initOvsBridges();
+ break;
+ }
+ });
+ });
});
- });
};
-ginger.networkConfiguration = {};
+// Redesigned Network Configuration cfginterfaces Button status handlers
-ginger.networkConfiguration.enableAllButtons = function(){
- ginger.networkConfiguration.enableActions();
- ginger.networkConfiguration.enableRefresh();
- ginger.networkConfiguration.enableAdd();
+ginger.changeButtonStatus = function(buttonIds, state) {
+ $.each(buttonIds, function(i, buttonId) {
+ if (state) {
+ $('#' + buttonId).show();
+ } else {
+ $('#' + buttonId).hide();
+ }
+ });
}
-ginger.networkConfiguration.disableAllButtons = function(){
- ginger.networkConfiguration.disableActions();
- ginger.networkConfiguration.disableRefresh();
- ginger.networkConfiguration.disableAdd();
+// Redesigned Network Configuration Button status handlers
+
+ginger.nwConfiguration = {};
+
+ginger.nwConfiguration.enableAllButtons = function() {
+ ginger.nwConfiguration.enableActions();
+ ginger.nwConfiguration.enableRefresh();
+ ginger.nwConfiguration.enableAdd();
}
-ginger.networkConfiguration.enableActions = function (){
- $("#action-dropdown-button-nw-configuration-actions").prop("disabled", false);
+ginger.nwConfiguration.disableAllButtons = function() {
+ ginger.nwConfiguration.disableActions();
+ ginger.nwConfiguration.disableRefresh();
+ ginger.nwConfiguration.disableAdd();
+}
+
+ginger.nwConfiguration.enableActions = function() {
+ $(".nw-configuration-action > .btn").prop("disabled", false);
+};
+
+ginger.nwConfiguration.disableActions = function() {
+ $(".nw-configuration-action").removeClass('open');
+ $(".nw-configuration-action > .btn").prop("disabled", true);
+};
+
+ginger.nwConfiguration.enableUp = function() {
+ $('.nw-configuration-action .nw-up').parent().removeClass('disabled');
+};
+
+ginger.nwConfiguration.disableUp = function() {
+ $('.nw-configuration-action .nw-up').parent().addClass('disabled');
+};
+
+ginger.nwConfiguration.enableDown = function() {
+ $('.nw-configuration-action .nw-down').parent().removeClass('disabled');
+};
+
+ginger.nwConfiguration.disableDown = function() {
+ $('.nw-configuration-action .nw-down').parent().addClass('disabled');
+};
+
+ginger.nwConfiguration.enableRestart = function() {
+ $('.nw-configuration-action .nw-restart').parent().removeClass('disabled');
+};
+
+ginger.nwConfiguration.disableRestart = function() {
+ $('.nw-configuration-action .nw-restart').parent().addClass('disabled');
+};
+
+ginger.nwConfiguration.showSrIov = function() {
+ $('.nw-configuration-action .nw-sriov').parent().removeClass('hidden');
+};
+
+ginger.nwConfiguration.hideSrIov = function() {
+ $('.nw-configuration-action .nw-sriov').parent().addClass('hidden');
+};
+ginger.nwConfiguration.enableSrIov = function() {
+ $('.nw-configuration-action .nw-sriov').parent().removeClass('disabled');
+};
+
+ginger.nwConfiguration.disableSrIov = function() {
+ $('.nw-configuration-action .nw-sriov').parent().addClass('disabled');
+};
+
+ginger.nwConfiguration.enableDelete = function() {
+ $('.nw-configuration-action .nw-delete').parent().removeClass('disabled');
+};
+
+ginger.nwConfiguration.disableDelete = function() {
+ $('.nw-configuration-action .nw-delete').parent().addClass('disabled');
+};
+
+ginger.nwConfiguration.enableSettings = function() {
+ $('.nw-configuration-action .nw-settings').parent().removeClass('disabled');
};
-ginger.networkConfiguration.disableActions = function (){
- $("#action-dropdown-button-nw-configuration-actions").parent().removeClass('open');
- $("#action-dropdown-button-nw-configuration-actions").prop("disabled", true);
+ginger.nwConfiguration.disableSettings = function() {
+ $('.nw-configuration-action .nw-settings').parent().addClass('disabled');
};
-ginger.networkConfiguration.enableRefresh = function (){
- $("#nw-configuration-refresh-btn").prop("disabled", false);
+ginger.nwConfiguration.enableRefresh = function() {
+ $("#nw-config-refresh-btn").prop("disabled", false);
};
-ginger.networkConfiguration.disableRefresh = function (){
- $("#nw-configuration-refresh-btn").prop("disabled", true);
+ginger.nwConfiguration.disableRefresh = function() {
+ $("#nw-config-refresh-btn").prop("disabled", true);
};
-ginger.networkConfiguration.enableAdd = function (){
- $("#action-dropdown-button-nw-configuration-add").prop("disabled", false);
+
+ginger.nwConfiguration.enableAdd = function() {
+ $(".nw-configuration-add > .btn").prop("disabled", false);
};
-ginger.networkConfiguration.disableAdd = function (){
- $("#action-dropdown-button-nw-configuration-add").prop("disabled", true);
+ginger.nwConfiguration.disableAdd = function() {
+ $(".nw-configuration-add > .btn").prop("disabled", true);
+};
+
+ginger.nwConfiguration.showAdd = function() {
+ ginger.nwConfiguration.enableAdd();
+ $(".nw-configuration-add").show();
+};
+
+ginger.nwConfiguration.hideAdd = function() {
+ ginger.nwConfiguration.disableAdd();
+ $(".nw-configuration-add").hide();
+};
+
+ginger.nwConfiguration.toggleAdd = function() {
+ if (ginger.cfginterfaces) {
+ ginger.nwConfiguration.showAdd();
+ } else {
+ ginger.nwConfiguration.hideAdd();
+ }
};
diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl
index 9ef5e69d..e1c8ce68 100644
--- a/ui/pages/i18n.json.tmpl
+++ b/ui/pages/i18n.json.tmpl
@@ -48,7 +48,7 @@
"GINNET0018M": "$_("Restart interface")",
"GINNET0019M": "$_("Delete interface")",
"GINNET0020M": "$_("successfully")",
- "GINNET0021M": "$_("failed !")",
+ "GINNET0021M": "$_("failed!")",
"GINNET0022M": "$_("Either no network interface or multiple network interfaces selected. Please select one.")",
"GINNET0024M": "$_("Global DNS and Gateway applied ")",
"GINNET0025M": "$_("Please wait...")",
@@ -100,6 +100,20 @@
"GINNET0074M": "$_("Edit")",
"GINNET0075M": "$_("Ok")",
"GINNET0076M": "$_("You have unsaved changes and this will discard them. Do you want to continue?")",
+ "GINNET0077M": "$_("Yes")",
+ "GINNET0078M": "$_("No")",
+ "GINNET0079M": "$_("Successfully brought down the interface %1.")",
+ "GINNET0080M": "$_("Failed to bring down the interface %1.")",
+ "GINNET0081M": "$_("Successfully brought up the interface %1.")",
+ "GINNET0082M": "$_("Failed to bring up the interface %1.")",
+ "GINNET0083M": "$_("Successfully restarted the interface %1.")",
+ "GINNET0084M": "$_("Failed to restart the interface %1.")",
+ "GINNET0085M": "$_("Successfully deleted the interface %1.")",
+ "GINNET0086M": "$_("Failed to delete the interface %1.")",
+ "GINNET0087M": "$_("Successfully created the interface %1.")",
+ "GINNET0088M": "$_("Failed to create the interface %1.")",
+ "GINNET0089M": "$_("Successfully updated the interface %1.")",
+ "GINNET0090M": "$_("Failed to update the interface %1.")",
"GINBG00001M": "$_("Loading...")",
"GINBG00002M": "$_("Filter")",
diff --git a/ui/pages/tabs/host-network.html.tmpl b/ui/pages/tabs/host-network.html.tmpl
index 6c041be1..985f3779 100644
--- a/ui/pages/tabs/host-network.html.tmpl
+++ b/ui/pages/tabs/host-network.html.tmpl
@@ -48,7 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA