1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

feature #3748: Add file selector for context and os tabs

This commit is contained in:
Daniel Molina 2015-06-03 17:38:20 +02:00
parent 8e2649bb0d
commit 3de33928e1
7 changed files with 66 additions and 61 deletions

View File

@ -60,6 +60,7 @@ define(function(require) {
'Group': Group,
'Host': Host,
'Image': Image,
'File': Image,
'Marketplace': Marketplace,
'Network': Network,
'Role': Role,

View File

@ -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
};
/*

View File

@ -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(
'<tr>' +
@ -158,6 +157,7 @@ define(function(require) {
}
function _fill(context, templateJSON) {
var that = this;
$("#ssh_context", context).removeAttr('checked');
$("#network_context", context).removeAttr('checked');
@ -207,17 +207,15 @@ define(function(require) {
$("input#INIT_SCRIPTS").val(TemplateUtils.htmlDecode(value));
} else if ("FILES_DS" == key) {
$('#FILES_DS', context).val(TemplateUtils.escapeDoubleQuotes(TemplateUtils.htmlDecode(contextJSON["FILES_DS"])))
/* TODO var files = [];
var files = [];
while (match = file_ds_regexp.exec(value)) {
files.push(match[1])
}
var dataTable_context = $("#datatable_context").dataTable();
// TODO updateView should not be required. Currently the dataTable
// is filled twice.
update_datatable_template_files(dataTable_context, function() {
});*/
var selectedResources = {
ids : files
}
that.contextFilesTable.selectResourceTableSelect(selectedResources);
} else {
customTagsJSON[key] = value;
}
@ -228,4 +226,15 @@ define(function(require) {
delete templateJSON['CONTEXT'];
}
}
function _generateContextFiles(context) {
var req_string=[];
var selected_files = this.contextFilesTable.retrieveResourceTableSelect();
$.each(selected_files, function(index, fileId) {
req_string.push("$FILE[IMAGE_ID="+ fileId +"]");
});
$('#FILES_DS', context).val(req_string.join(" "));
};
});

View File

@ -56,7 +56,7 @@
</div>
</div>
<div class="wizard_internal_tab content" id="filesTab">
{{! TODO contextFilesTableSelectHTML}}
{{{contextFilesTableHTML}}}
<div class="row">
<div class="large-12 columns">
<label for="FILES_DS">

View File

@ -8,6 +8,7 @@ define(function(require) {
var Locale = require('utils/locale');
var Tips = require('utils/tips');
var WizardFields = require('utils/wizard-fields');
var FilesTable = require('tabs/files-tab/datatable');
/*
TEMPLATES
@ -129,10 +130,18 @@ define(function(require) {
this.title = Locale.tr("OS Booting");
this.classes = "hypervisor only_kvm only_vmware only_xen"
/* TODO
this.kernelFilesTable = new FilesTable(this.wizardTabId + 'KernelTable', {'select': true});
this.initrdFilesTable = new FilesTable(this.wizardTabId + 'InitrdTable', {'select': true});
*/
this.kernelFilesTable = new FilesTable(this.wizardTabId + 'KernelTable', {
'select': true,
'selectOptions': {
"filter_fn": function(file) { return file.TYPE == 3; } // KERNEL
}
});
this.initrdFilesTable = new FilesTable(this.wizardTabId + 'InitrdTable', {
'select': true,
'selectOptions': {
"filter_fn": function(file) { return file.TYPE == 4; } // RAMDISK
}
});
}
WizardTab.prototype.constructor = WizardTab;
@ -150,7 +159,9 @@ define(function(require) {
function _html() {
return TemplateHTML({
'guestOS': GUESTOS
'guestOS': GUESTOS,
'kernelFilesTableHTML': this.kernelFilesTable.dataTableHTML,
'initrdFilesTableHTML': this.initrdFilesTable.dataTableHTML
});
}
@ -158,6 +169,7 @@ define(function(require) {
}
function _setup(context) {
var that = this;
Tips.setup(context);
context.foundation('reflow', 'tab');
@ -193,27 +205,24 @@ define(function(require) {
}
});
/* TODO
that.kernelFileTable.initialize({
that.kernelFilesTable.initialize({
'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.kernelFileTable.refreshResourceTableSelect();
that.kernelFilesTable.refreshResourceTableSelect();
that.initrdFilesTable.initialize({
'selectOptions': {
'select_callback': function(aData, options) {
$('#INITRD', context).text(aData[options.name_index]);
$('#INITRD_DS', context).val("$FILE[IMAGE_ID="+ aData[options.id_index] +"]");
}
}
});
that.initrdFilesTable.refreshResourceTableSelect();*/
that.initrdFilesTable.refreshResourceTableSelect();
}
function _retrieve(context) {
@ -258,21 +267,6 @@ define(function(require) {
}
}
/* TODO
var selectedResources = {
ids : templateJSON.NETWORK_ID
}
this.kernelFilesTable.selectResourceTableSelect(selectedResources);
var selectedResources = {
ids : templateJSON.NETWORK_ID
}
this.initrdFilesTable.selectResourceTableSelect(selectedResources);
*/
delete templateJSON['OS'];
}

View File

@ -128,7 +128,7 @@
</div>
<br>
<div class="kernel_ds">
{{! TODO kernelFilesTableSelectHTML}}
{{{kernelFilesTableHTML}}}
<div id="kernel_ds_inputs" class="row">
<div class="large-12 columns">
<label for="KERNEL_DS">{{tr "KERNEL_DS"}}</label>
@ -157,7 +157,7 @@
</div>
<br>
<div class="initrd_ds">
{{! TODO initrdFilesTableSelectHTML}}
{{{initrdFilesTableHTML}}}
<div class="row">
<div class="large-12 columns">
<label for="INITRD_DS">{{tr "INITRD_DS"}}</label>

View File

@ -202,12 +202,12 @@ define(function(require) {
var selected_hosts = this.hostsTable.retrieveResourceTableSelect();
var selected_clusters = this.clustersTable.retrieveResourceTableSelect();
$.each(selected_hosts, function(key, value) {
req_string.push('ID=\\"'+key+'\\"');
$.each(selected_hosts, function(index, hostId) {
req_string.push('ID=\\"'+hostId+'\\"');
});
$.each(selected_clusters, function(key, value) {
req_string.push('CLUSTER_ID=\\"'+key+'\\"');
$.each(selected_clusters, function(index, clusterId) {
req_string.push('CLUSTER_ID=\\"'+clusterId+'\\"');
});
$('#SCHED_REQUIREMENTS', context).val(req_string.join(" | "));