[Kimchi-devel] [PATCH] UI: change some code of storage add page

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue Apr 1 19:33:41 UTC 2014


Reviewed-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>

On 03/31/2014 11:48 PM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> Actually there is no bug.
> But we think, we can improve the codes.
> We can remove the reduplicate codes.
>
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> Signed-off-by: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
> ---
>   ui/js/src/kimchi.storagepool_add_main.js | 42 +++++++++-----------------------
>   1 file changed, 11 insertions(+), 31 deletions(-)
>
> diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js
> index ea9f68b..86dbe7f 100644
> --- a/ui/js/src/kimchi.storagepool_add_main.js
> +++ b/ui/js/src/kimchi.storagepool_add_main.js
> @@ -123,37 +123,17 @@ kimchi.initStorageAddPage = function() {
>       });
>
>       $('#poolTypeInputId').change(function() {
> -        if ($(this).val() === 'dir') {
> -            $('.path-section').removeClass('tmpl-html');
> -            $('.logical-section').addClass('tmpl-html');
> -            $('.nfs-section').addClass('tmpl-html');
> -            $('.iscsi-section').addClass('tmpl-html');
> -            $('.scsi-section').addClass('tmpl-html');
> -        } else if ($(this).val() === 'netfs') {
> -            $('.path-section').addClass('tmpl-html');
> -            $('.logical-section').addClass('tmpl-html');
> -            $('.nfs-section').removeClass('tmpl-html');
> -            $('.iscsi-section').addClass('tmpl-html');
> -            $('.scsi-section').addClass('tmpl-html');
> -        } else if ($(this).val() === 'iscsi') {
> -            $('.path-section').addClass('tmpl-html');
> -            $('.logical-section').addClass('tmpl-html');
> -            $('.nfs-section').addClass('tmpl-html');
> -            $('.iscsi-section').removeClass('tmpl-html');
> -            $('.scsi-section').addClass('tmpl-html');
> -        } else if ($(this).val() === 'logical') {
> -            $('.path-section').addClass('tmpl-html');
> -            $('.logical-section').removeClass('tmpl-html');
> -            $('.nfs-section').addClass('tmpl-html');
> -            $('.iscsi-section').addClass('tmpl-html');
> -            $('.scsi-section').addClass('tmpl-html');
> -        } else if ($(this).val() === 'scsi') {
> -            $('.scsi-section').removeClass('tmpl-html');
> -            $('.path-section').addClass('tmpl-html');
> -            $('.logical-section').addClass('tmpl-html');
> -            $('.nfs-section').addClass('tmpl-html');
> -            $('.iscsi-section').addClass('tmpl-html');
> -        }
> +        var poolObject = {'dir': ".path-section", 'netfs': '.nfs-section',
> +                          'iscsi': '.iscsi-section', 'scsi': '.scsi-section',
> +                          'logical': '.logical-section'}
> +        var selectType = $(this).val();
> +        $.each(poolObject, function(type, value) {
> +            if(selectType == type){
> +                $(value).removeClass('tmpl-html');
> +            } else {
> +                $(value).addClass('tmpl-html');
> +            }
> +        });
>       });
>       $('#authId').click(function() {
>           if ($(this).prop("checked")) {




More information about the Kimchi-devel mailing list