success: function (request, item_list){ datatable.fnClearTable(true); if (item_list.length == 0) { datatable.html('<div class="text-center">'+ '<span class="fa-stack fa-5x">'+ '<i class="fa fa-cloud fa-stack-2x"></i>'+ '<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+ '</span>'+ '<br>'+ '<br>'+ '<span>'+ Locale.tr("There are no templates available")+ '</span>'+ '</div>'); } else { datatable.fnAddData(item_list); LabelsUtils.clearLabelsFilter(datatable, TEMPLATE_LABELS_COLUMN); var context = $('.labels-dropdown', datatable.closest('.content')); LabelsUtils.insertLabelsMenu({ 'context': context, 'dataTable': datatable, 'labelsColumn': TEMPLATE_LABELS_COLUMN, 'labelsPath': 'VMTEMPLATE.TEMPLATE.LABELS', 'placeholder': Locale.tr("No labels defined") }); } },
success: function (request, item_list){ datatable.fnClearTable(true); item_list = item_list.filter(function(tmpl){ return (tmpl.VMTEMPLATE.TEMPLATE.VROUTER == undefined || tmpl.VMTEMPLATE.TEMPLATE.VROUTER.toUpperCase() != "YES"); }); if (item_list.length == 0) { datatable.html('<div class="text-center">'+ '<span class="fa-stack fa-5x">'+ '<i class="fa fa-cloud fa-stack-2x"></i>'+ '<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+ '</span>'+ '<br>'+ '<br>'+ '<span>'+ Locale.tr("There are no templates available")+ '</span>'+ '</div>'); } else { datatable.fnAddData(item_list); } // Labels are inserted only in the new VM wizard LabelsUtils.clearLabelsFilter(datatable, TEMPLATE_LABELS_COLUMN); var context = $('.labels-dropdown', datatable.closest('#provisionVMInstantiateTemplatesRow')); context.html(""); LabelsUtils.insertLabelsMenu({ 'context': context, 'dataTable': datatable, 'labelsColumn': TEMPLATE_LABELS_COLUMN, 'labelsPath': 'VMTEMPLATE.TEMPLATE.LABELS', 'placeholder': Locale.tr("No labels defined") }); },
success: function (request, item_list){ datatable.fnClearTable(true); item_list = item_list.filter(function(tmpl){ return (tmpl.VMTEMPLATE.TEMPLATE.VROUTER == undefined || tmpl.VMTEMPLATE.TEMPLATE.VROUTER.toUpperCase() != "YES"); }); if (item_list.length == 0) { datatable.html("<div class=\"text-center\">"+ "<span class=\"fa-stack fa-5x\">"+ "<i class=\"fas fa-cloud fa-stack-2x\"></i>"+ "<i class=\"fas fa-info-circle fa-stack-1x fa-inverse\"></i>"+ "</span>"+ "<br>"+ "<br>"+ "<span>"+ Locale.tr("There are no templates available")+ "</span>"+ "</div>"); } else { datatable.fnAddData(item_list); } // Labels are inserted only in the new VM wizard LabelsUtils.clearLabelsFilter(datatable, TEMPLATE_LABELS_COLUMN); var context = $(".labels-dropdown", datatable.closest("#provisionVMInstantiateTemplatesRow")); context.html(""); LabelsUtils.insertLabelsMenu({ "context": context, "dataTable": datatable, "labelsColumn": TEMPLATE_LABELS_COLUMN, "labelsPath": "VMTEMPLATE.TEMPLATE.LABELS", "placeholder": Locale.tr("No labels defined") }); },
// Updates a data_table, with a 2D array containing the new values // Does a partial redraw, so the filter and pagination are kept // fromArray if true do not process the list since it is already an array of elements function _updateView(request, list, fromArray) { var selected_row_id = null; var checked_row_ids = new Array(); var that = this; if (that.preUpdateView) { that.preUpdateView(); } if(that.conf.searchDropdownHTML != undefined){ that.searchSets = {}; try { that.searchFields.forEach(function(name){ that.searchSets[name] = new Set(); }); } catch(e){} } that.dataTable.DataTable().page.len(parseInt(config['user_config']['page_length'])); var row_id_index = this.dataTable.attr("row_id"); if (row_id_index != undefined) { $.each($(that.dataTable.fnGetNodes()), function() { if ($('td.markrow', this).length != 0) { var aData = that.dataTable.fnGetData(this); selected_row_id = aData[row_id_index]; } }); } $.each($(that.dataTable.fnGetNodes()), function() { if ($('td.markrowchecked', this).length != 0) { if (!isNaN($($('td', $(this))[1]).html())) { checked_row_ids.push($($('td', $(this))[1]).html()); } else { checked_row_ids.push($($('td', $(this))[0]).html()); } } }); // dataTable.fnSettings is undefined when the table has been detached from // the DOM if (that.dataTable && that.dataTable.fnSettings()) { var dTable_settings = that.dataTable.fnSettings(); var prev_start = dTable_settings._iDisplayStart; that.dataTable.fnClearTable(false); var item_list; if (fromArray) { item_list = list; } else { item_list = []; $.each(list, function() { var item = that.elementArray(this); if (item){ item_list.push(item); if(that.searchColumn != undefined){ try{ var values = JSON.parse(atob(item[that.searchColumn])); that.searchFields.forEach(function(name){ that.searchSets[name].add(values[name]); }); }catch(e){} } } }); } if (item_list.length > 0) { that.dataTable.fnAddData(item_list, false); } var new_start = prev_start; if (new_start > item_list.length - 1) { if (item_list.length > 0) new_start = item_list.length - 1; else new_start = 0; } dTable_settings.iInitDisplayStart = new_start; that.dataTable.fnDraw(true); }; if (selected_row_id != undefined) { $.each($(that.dataTable.fnGetNodes()), function() { var aData = that.dataTable.fnGetData(this); if (aData[row_id_index] == selected_row_id) { $('td', this)[0].click(); } }); } if (checked_row_ids.length != 0) { $.each($(that.dataTable.fnGetNodes()), function() { var current_id = $($('td', this)[1]).html(); if (isNaN(current_id)) { current_id = $($('td', this)[0]).html(); } if (current_id) { if ($.inArray(current_id, checked_row_ids) != -1) { $('input.check_item:not(:checked)', this).first().click(); $('td', this).addClass('markrowchecked'); } } }); } if (that.labelsColumn && SunstoneConfig.isTabEnabled(that.tabId) && $("#" + that.tabId).is(':visible')) { LabelsUtils.insertLabelsDropdown(that.tabId); if (SunstoneConfig.isTabActionEnabled(that.tabId, that.resource+".menu_labels")){ LabelsUtils.insertLabelsMenu({'tabName': that.tabId}); } } if (that.postUpdateView) { that.postUpdateView(); } if(that.conf.searchDropdownHTML != undefined){ try { that.searchFields.forEach(function(name){ var st = ""; var dlist = $("datalist[search-datalist="+name+"]", $("#"+that.tabId)); if(dlist.length > 0){ that.searchSets[name].forEach(function(val){ st += '<option value="' + val + '">'; }); dlist.html(st); } }); } catch(e){} } }
function _clearLabelsFilter() { LabelsUtils.clearLabelsFilter(this.dataTable, this.labelsColumn); LabelsUtils.insertLabelsMenu({'tabName': this.tabId}); }
// Updates a data_table, with a 2D array containing the new values // Does a partial redraw, so the filter and pagination are kept // fromArray if true do not process the list since it is already an array of elements function _updateView(request, list, fromArray) { var selected_row_id = null; var checked_row_ids = new Array(); var that = this; if (that.preUpdateView) { that.preUpdateView(); } that.dataTable.DataTable().page.len(parseInt(config['user_config']['page_length'])); var row_id_index = this.dataTable.attr("row_id"); if (row_id_index != undefined) { $.each($(that.dataTable.fnGetNodes()), function() { if ($('td.markrow', this).length != 0) { var aData = that.dataTable.fnGetData(this); selected_row_id = aData[row_id_index]; } }); } $.each($(that.dataTable.fnGetNodes()), function() { if ($('td.markrowchecked', this).length != 0) { if (!isNaN($($('td', $(this))[1]).html())) { checked_row_ids.push($($('td', $(this))[1]).html()); } else { checked_row_ids.push($($('td', $(this))[0]).html()); } } }); // dataTable.fnSettings is undefined when the table has been detached from // the DOM if (that.dataTable && that.dataTable.fnSettings()) { var dTable_settings = that.dataTable.fnSettings(); var prev_start = dTable_settings._iDisplayStart; that.dataTable.fnClearTable(false); var item_list; if (fromArray) { item_list = list; } else { item_list = []; $.each(list, function() { var item = that.elementArray(this); if (item){ item_list.push(item); } }); } if (item_list.length > 0) { that.dataTable.fnAddData(item_list, false); } var new_start = prev_start; if (new_start > item_list.length - 1) { if (item_list.length > 0) new_start = item_list.length - 1; else new_start = 0; } dTable_settings.iInitDisplayStart = new_start; that.dataTable.fnDraw(true); }; if (selected_row_id != undefined) { $.each($(that.dataTable.fnGetNodes()), function() { var aData = that.dataTable.fnGetData(this); if (aData[row_id_index] == selected_row_id) { $('td', this)[0].click(); } }); } if (checked_row_ids.length != 0) { $.each($(that.dataTable.fnGetNodes()), function() { var current_id = $($('td', this)[1]).html(); if (isNaN(current_id)) { current_id = $($('td', this)[0]).html(); } if (current_id) { if ($.inArray(current_id, checked_row_ids) != -1) { $('input.check_item:not(:checked)', this).first().click(); $('td', this).addClass('markrowchecked'); } } }); } if (that.labelsColumn && !SunstoneConfig.isTabEnabled("provision-tab")) { if (SunstoneConfig.isTabEnabled(that.tabId)) { if ($("#" + that.tabId).is(':visible')) { LabelsUtils.insertLabelsMenu({'tabName': that.tabId}); LabelsUtils.insertLabelsDropdown(that.tabId); } } } if (that.postUpdateView) { that.postUpdateView(); } }