diff --git a/src/sunstone/public/app/opennebula.js b/src/sunstone/public/app/opennebula.js index 0ae41e0e3e..9b7ae33c87 100644 --- a/src/sunstone/public/app/opennebula.js +++ b/src/sunstone/public/app/opennebula.js @@ -60,6 +60,7 @@ define(function(require) { 'Group': Group, 'Host': Host, 'Image': Image, + 'File': Image, 'Marketplace': Marketplace, 'Network': Network, 'Role': Role, diff --git a/src/sunstone/public/app/tabs/files-tab/datatable.js b/src/sunstone/public/app/tabs/files-tab/datatable.js index 5bdf5a60e2..66c6c2da2e 100644 --- a/src/sunstone/public/app/tabs/files-tab/datatable.js +++ b/src/sunstone/public/app/tabs/files-tab/datatable.js @@ -18,7 +18,8 @@ define(function(require) { var XML_ROOT = "IMAGE"; var TAB_NAME = require('./tabId'); var COLUMN_IDS = { - "DATASTORE": 5 + "DATASTORE": 5, + "TYPE": 7 }; /* diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js index 53e92c6e63..5d64285503 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js @@ -9,6 +9,7 @@ define(function(require) { var WizardFields = require('utils/wizard-fields'); var TemplateUtils = require('utils/template-utils'); var CustomTagsTable = require('utils/custom-tags-table'); + var FilesTable = require('tabs/files-tab/datatable') /* TEMPLATES @@ -36,9 +37,12 @@ define(function(require) { this.title = Locale.tr("Context"); this.classes = "hypervisor only_kvm only_vmware only_xen only_vcenter"; - /* TODO - this.contextFilesTable = new FilesTable(this.wizardTabId + 'ContextTable', {'select': true}); - */ + this.contextFilesTable = new FilesTable(this.wizardTabId + 'ContextTable', { + 'select': true, + 'selectOptions': { + 'multiple_choice': true, + "filter_fn": function(file) { return file.TYPE == 5; } // CONTEXT + }}); } WizardTab.prototype.constructor = WizardTab; @@ -47,6 +51,7 @@ define(function(require) { WizardTab.prototype.onShow = _onShow; WizardTab.prototype.retrieve = _retrieve; WizardTab.prototype.fill = _fill; + WizardTab.prototype.generateContextFiles = _generateContextFiles; return WizardTab; @@ -56,7 +61,8 @@ define(function(require) { function _html() { return TemplateHTML({ - 'customTagsTableHTML': CustomTagsTable.html() + 'customTagsTableHTML': CustomTagsTable.html(), + 'contextFilesTableHTML': this.contextFilesTable.dataTableHTML }); } @@ -64,32 +70,25 @@ define(function(require) { } function _setup(context) { + var that = this; Tips.setup(context); CustomTagsTable.setup(context); - /* TODO - that.context.initialize({ + var selectOptions = { 'selectOptions': { 'select_callback': function(aData, options) { - $('#KERNEL', context).text(aData[options.name_index]); - $('#KERNEL_DS', context).val("$FILE[IMAGE_ID="+ aData[options.id_index] +"]"); + that.generateContextFiles(context) + }, + 'unselect_callback': function(aData, options) { + that.generateContextFiles(context) } } - }); - that.context.refreshResourceTableSelect(); + } - var generate_context_files = function() { - var req_string = []; + that.contextFilesTable.initialize(selectOptions); + that.contextFilesTable.refreshResourceTableSelect(); - $.each($("span.image", $("#selected_files_spans")), function() { - req_string.push("$FILE[IMAGE_ID=" + $(this).attr("image_id") + "]"); - }); - - $('#FILES_DS', context).val(req_string.join(" ")); - }; - */ - context.on("click", ".add_service_custom_attr", function() { $(".service_custom_attrs tbody").append( '