From 465b741b9bba67fd21d3932db01268faab31f351 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 27 May 2015 12:00:07 +0200 Subject: [PATCH] feature #3748: Add template general tab --- src/sunstone/public/app/main.js | 12 ++- .../tabs/templates-tab/form-panels/create.js | 4 +- .../form-panels/create/wizard-tabs/general.js | 93 +++++++++++++++++++ .../create/wizard-tabs/general/html.hbs | 78 ++++++++++++++++ .../create/wizard-tabs/general/wizardTabId.js | 3 + src/sunstone/views/index.erb | 7 +- 6 files changed, 190 insertions(+), 7 deletions(-) create mode 100644 src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js create mode 100644 src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/html.hbs create mode 100644 src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/wizardTabId.js diff --git a/src/sunstone/public/app/main.js b/src/sunstone/public/app/main.js index 8de54bac71..25ef50d128 100644 --- a/src/sunstone/public/app/main.js +++ b/src/sunstone/public/app/main.js @@ -45,7 +45,10 @@ require.config({ 'flot.stack': '../bower_components/flot/jquery.flot.stack', 'flot.resize': '../bower_components/flot/jquery.flot.resize', 'flot.time': '../bower_components/flot/jquery.flot.time', - 'flot.tooltip': '../bower_components/flot.tooltip/js/jquery.flot.tooltip.min' + 'flot.tooltip': '../bower_components/flot.tooltip/js/jquery.flot.tooltip.min', + + /* noUiSlider */ + 'nouislider': '../vendor/4.0/nouislider/jquery.nouislider.min' }, shim: { /* jQuery */ @@ -143,7 +146,12 @@ require.config({ }, 'flot.tooltip': { deps: ['flot'] - } + }, + + /* noUiSlider */ + 'nouislider': { + deps: ['jquery'] + }, } }); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js index 2ba551e1b0..93e660c6be 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js @@ -93,7 +93,7 @@ define(function(require) { function _setup(context) { $.each(this.wizardTabs, function(index, wizardTab) { - wizardTab.setup(); + wizardTab.setup(context); }); context.foundation('reflow', 'tab'); @@ -101,7 +101,7 @@ define(function(require) { } function _onShow() { - + } function _submitWizard() { diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js new file mode 100644 index 0000000000..92dbae6556 --- /dev/null +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js @@ -0,0 +1,93 @@ +define(function(require) { + /* + DEPENDENCIES + */ + + var Locale = require('utils/locale'); + var Tips = require('utils/tips'); + var CapacityInputs = require('./general/capacity-inputs'); + + /* + TEMPLATES + */ + + var TemplateHTML = require('hbs!./general/html'); + + /* + CONSTANTS + */ + + var WIZARD_TAB_ID = require('./general/wizardTabId'); + var LOGOS = [ + {'path': "images/logos/arch.png", 'title': Locale.tr("Arch Linux")}, + {'path': "images/logos/centos.png", 'title': Locale.tr("CentOS")}, + {'path': "images/logos/debian.png", 'title': Locale.tr("Debian")}, + {'path': "images/logos/fedora.png", 'title': Locale.tr("Fedora")}, + {'path': "images/logos/linux.png", 'title': Locale.tr("Linux")}, + {'path': "images/logos/redhat.png", 'title': Locale.tr("Redhat")}, + {'path': "images/logos/ubuntu.png", 'title': Locale.tr("Ubuntu")}, + {'path': "images/logos/windowsxp.png", 'title': Locale.tr("Windows XP/2003")}, + {'path': "images/logos/windows8.png", 'title': Locale.tr("Windows 8")} + ] + + /* + CONSTRUCTOR + */ + + function WizardTab() { + this.wizardTabId = WIZARD_TAB_ID; + this.icon = 'fa-laptop'; + this.title = Locale.tr("General"); + } + + WizardTab.prototype.constructor = WizardTab; + WizardTab.prototype.html = _html; + WizardTab.prototype.setup = _setup; + WizardTab.prototype.onShow = _onShow; + WizardTab.prototype.retrieve = _retrieve; + WizardTab.prototype.fill = _fill; + + return WizardTab; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + return TemplateHTML({ + 'capacityInputsHTML': CapacityInputs.html(), + 'logos': LOGOS + }); + } + + function _onShow() { + + } + + function _setup(context) { + Tips.setup(context); + + context.on("change", "#LOGO", function() { + $("#template_create_logo", context).show(); + $("#template_create_logo", context).html('' + + '' + + ''); + }); + + context.on("change", "input[name='hypervisor']", function() { + var context = $(this).closest("#create_template_form_wizard"); + $(".hypervisor", context).hide(); + $(".only_" + this.value, context).show(); + }); + + CapacityInputs.setup(context); + } + + function _retrieve() { + + } + + function _fill() { + + } +}); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/html.hbs new file mode 100644 index 0000000000..6aa39e2622 --- /dev/null +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/html.hbs @@ -0,0 +1,78 @@ +
+
+ +
+
+ + + + + + + + + +
+
+
+
+ +