[Kimchi-devel] [PATCH V2] UI: template support spice

Adam King rak at linux.vnet.ibm.com
Mon Mar 3 20:01:21 UTC 2014


Reviewed-by: Adam King <rak at linux.vnet.ibm.com>
Tested-by: Adam King <rak at linux.vnet.ibm.com>

One suggestion...
We should provide a kimchi wide configuration  to specify whether the 
default should be vnc as it is hardcoded now, or spice.

If this is too much effort to add to this series, open an enhancement 
issue so we come back to it.

On 03/03/2014 02:56 AM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> The backend already support spice.
> Just need to add a graphics selection in template edit page.
>
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> ---
>   ui/js/src/kimchi.template_edit_main.js | 14 ++++++++++++--
>   ui/pages/template-edit.html.tmpl       | 15 +++++++++++++++
>   2 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
> index 17e9a41..79c6427 100644
> --- a/ui/js/src/kimchi.template_edit_main.js
> +++ b/ui/js/src/kimchi.template_edit_main.js
> @@ -22,10 +22,16 @@ kimchi.template_edit_main = function() {
>       kimchi.retrieveTemplate(kimchi.selectedTemplate, function(template) {
>           origDisks =  template.disks;
>           for ( var prop in template) {
> -            $('input[name="' + prop + '"]', templateEditForm).val(template[prop]);
> +            var value = template[prop];
> +            if (prop == 'graphics') {
> +               value = value["type"];
> +            }
> +            $('input[name="' + prop + '"]', templateEditForm).val(value);
>           }
>           var disks = template.disks;
>           $('input[name="disks"]').val(disks[0].size);
> +        var options = [{label: 'vnc', value: 'vnc'}, {label: 'spice', value: 'spice'}];
> +        kimchi.select('template-edit-graphics-list', options);
>           kimchi.listStoragePools(function(result) {
>               var options = [];
>               if (result && result.length) {
> @@ -67,7 +73,7 @@ kimchi.template_edit_main = function() {
>       });
>
>       $('#tmpl-edit-button-save').on('click', function() {
> -        var editableFields = [ 'name', 'cpus', 'memory', 'storagepool', 'disks'];
> +        var editableFields = [ 'name', 'cpus', 'memory', 'storagepool', 'disks', 'graphics'];
>           var data = {};
>           $.each(editableFields, function(i, field) {
>               /* Support only 1 disk at this moment */
> @@ -75,6 +81,10 @@ kimchi.template_edit_main = function() {
>                  origDisks[0].size = Number($('#form-template-edit [name="' + field + '"]').val());
>                  data[field] = origDisks;
>               }
> +            else if (field == 'graphics') {
> +               var type = $('#form-template-edit [name="' + field + '"]').val();
> +               data[field] = {'type': type};
> +            }
>               else {
>                  data[field] = $('#form-template-edit [name="' + field + '"]').val();
>               }
> diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl
> index 6056997..0f663d4 100644
> --- a/ui/pages/template-edit.html.tmpl
> +++ b/ui/pages/template-edit.html.tmpl
> @@ -91,6 +91,21 @@
>                   </div>
>                   <div>
>                       <div class="template-edit-wrapper-label">
> +                        <label>$_("graphics")</label>
> +                    </div>
> +                    <div class="template-edit-wrapper-controls">
> +                        <div class="btn dropdown popable">
> +                            <input id="template-edit-graphics" name="graphics" type="hidden" />
> +                            <span class="text" id="template-edit-graphics-label"></span><span class="arrow"></span>
> +                            <div class="popover" style="width: 100%">
> +                                <ul class="select-list" id="template-edit-graphics-list" data-target="template-edit-graphics" data-label="template-edit-graphics-label">
> +                                </ul>
> +                            </div>
> +                        </div>
> +                    </div>
> +                </div>
> +                <div>
> +                    <div class="template-edit-wrapper-label">
>                           <label>$_("Storage Pool")</label>
>                       </div>
>                       <div class="template-edit-wrapper-controls">


-- 
Adam King <rak at linux.vnet.ibm.com>
IBM CSI




More information about the Kimchi-devel mailing list