[Kimchi-devel] [PATCH] Addendum to [PATCH v2 0/4] Host Repository Management Support

Adam King rak at linux.vnet.ibm.com
Thu Mar 13 04:14:20 UTC 2014


On 03/12/2014 11:24 PM, Hongliang Wang wrote:
> On 03/13/2014 07:53 AM, Adam King wrote:
>> This patch addendum addresses the remaining issues with Repository management
>> UI except providing the ability to enable/disable a repository.
>> Reviewing API.md I found that "enabled" is not a valid parameter as input to
>> the PUT method of a repository. We need to add enable/disable actions to the
>> menu, and invoke the appropriate POST action on the selected repo.
>>
>> Signed-off-by: Adam King<rak at linux.vnet.ibm.com>
>> ---
>>   ui/js/src/kimchi.grid.js                 |  2 +-
>>   ui/js/src/kimchi.repository_add_main.js  |  3 ++-
>>   ui/js/src/kimchi.repository_edit_main.js | 17 ++---------------
>>   ui/pages/repository-add.html.tmpl        |  2 +-
>>   ui/pages/repository-edit.html.tmpl       | 22 ----------------------
>>   5 files changed, 6 insertions(+), 40 deletions(-)
>>
>> diff --git a/ui/js/src/kimchi.grid.js b/ui/js/src/kimchi.grid.js
>> index 215d6ea..4cc7807 100644
>> --- a/ui/js/src/kimchi.grid.js
>> +++ b/ui/js/src/kimchi.grid.js
>> @@ -158,7 +158,7 @@ kimchi.widget.Grid = function(params) {
>>               var rowNode = $('<tr></tr>').appendTo(tbody);
>>               $.each(fields, function(fi, field) {
>>                   var fieldName = field['name'];
>> -                var value = row[fieldName];
>> +                var value = row[fieldName]==null ? '' : row[fieldName];
>>                   $('<td><div class="cell-text-wrapper"' +
>>                        (field['makeTitle'] === true
>>                            ? ' title="' + value + '"'
>> diff --git a/ui/js/src/kimchi.repository_add_main.js b/ui/js/src/kimchi.repository_add_main.js
>> index 75b785e..1e57214 100644
>> --- a/ui/js/src/kimchi.repository_add_main.js
>> +++ b/ui/js/src/kimchi.repository_add_main.js
>> @@ -47,7 +47,7 @@ kimchi.repository_add_main = function() {
>>
>>           var formData = $(addForm).serializeObject();
>>           for(var p in formData) {
>> -            if(formData[p] == '') {
>> +            if((formData[p] == '') || (formData[p] == null)) {
> Value of <input type="text"> will *always be* the empty string '', 
> other than null. Checking for null is unnecessary here.
I was trying to get rid of some nulls that were appearing in the object. 
Turned out they were coming form the backend, and I forgot
to come back and clean up. Fixed in v2 of the addendum.
>>                   delete formData[p];
>>               }
>>           }
>> @@ -61,6 +61,7 @@ kimchi.repository_add_main = function() {
>>                   formData[f] = false;
>>                   break;
>>               default:
>
>> +                formData[f] = false;
> What's the purpose? This field is to be deleted in next line.
Same as above:
I was trying to get rid of some nulls that were appearing in the object. 
Turned out they were coming form the backend, and I forgot
to come back and clean up. Fixed in v2 of the addendum.
>>                   delete formData[f];
>>                   break;
>>               }
>> diff --git a/ui/js/src/kimchi.repository_edit_main.js b/ui/js/src/kimchi.repository_edit_main.js
>> index 0ab008e..6083327 100644
>> --- a/ui/js/src/kimchi.repository_edit_main.js
>> +++ b/ui/js/src/kimchi.repository_edit_main.js
>> @@ -47,24 +47,11 @@ kimchi.repository_edit_main = function() {
>>           });
>>       });
>>
>> -    var booleanFields = ['is_mirror', 'gpgcheck'];
>> -
>>       var editRepository = function(event) {
>>           var formData = $(editForm).serializeObject();
>>
>> -        $(booleanFields).each(function(i, f) {
>> -            switch(formData[f]) {
>> -            case 'true':
>> -                formData[f] = true;
>> -                break;
>> -            case 'false':
>> -                formData[f] = false;
>> -                break;
>> -            default:
>> -                delete formData[f];
>> -                break;
>> -            }
>> -        });
>
>> +        formData["is_mirror"] = (formData["is_mirror"]=="true") ? true : false;
>> +        formData["gpgcheck"] = (formData["gpgkey"])? true : false;
> Leave it as it was. Unnecessary to change. If there are new Boolean 
> fields added, we can simply add the field names in the array an no 
> need to write new lines.
This is actually intentional. gpgcheck is now calculated based on 
gpgkey. Its not simply read from the form input anymore.
>>           kimchi.updateRepository(kimchi.selectedRepository, formData, function() {
>>               kimchi.topic('kimchi/repositoryUpdated').publish();
>> diff --git a/ui/pages/repository-add.html.tmpl b/ui/pages/repository-add.html.tmpl
>> index a170f1d..4a97fd3 100644
>> --- a/ui/pages/repository-add.html.tmpl
>> +++ b/ui/pages/repository-add.html.tmpl
>> @@ -62,7 +62,7 @@
>>                       <div class="textbox-wrapper">
>>                           <input type="radio" id="isMirrorRadioTrue" name="is_mirror" value="true" />
>>                           <label for="isMirrorRadioTrue">$_("Yes")</label>
>> -                        <input type="radio" id="isMirrorRadioFalse" name="is_mirror" value="false" />
>> +                        <input type="radio" id="isMirrorRadioFalse" checked="checked" name="is_mirror" value="false" />
>>                           <label for="isMirrorRadioFalse">$_("No")</label>
>>                       </div>
>>                   </div>
>> diff --git a/ui/pages/repository-edit.html.tmpl b/ui/pages/repository-edit.html.tmpl
>> index 9adf0a1..d6baf2f 100644
>> --- a/ui/pages/repository-edit.html.tmpl
>> +++ b/ui/pages/repository-edit.html.tmpl
>> @@ -48,17 +48,6 @@
>>                   </div>
>>                   <div>
>>                       <div class="repository-edit-wrapper-label">
>> -                        <label>$_("Enabled")</label>
>> -                    </div>
>> -                    <div class="repository-edit-wrapper-controls">
>> -                        <input id="repository-edit-enabled-radio-true" name="enabled" type="radio" value="true" disabled="disabled" />
>> -                        <label for="repository-edit-enabled-radio-true">$_("Yes")</label>
>> -                        <input id="repository-edit-enabled-radio-false" name="enabled" type="radio" value="false" disabled="disabled" />
>> -                        <label for="repository-edit-enabled-radio-false">$_("No")</label>
>> -                    </div>
>> -                </div>
>> -                <div>
>> -                    <div class="repository-edit-wrapper-label">
>>                           <label for="repository-edit-baseurl-textbox">$_("Base URL")</label>
>>                       </div>
>>                       <div class="repository-edit-wrapper-controls">
>> @@ -88,17 +77,6 @@
>>                   </div>
>>                   <div>
>>                       <div class="repository-edit-wrapper-label">
>> -                        <label>$_("GPG Check")</label>
>> -                    </div>
>> -                    <div class="repository-edit-wrapper-controls">
>> -                        <input id="repository-edit-gpgcheck-radio-true" name="gpgcheck" type="radio" value="true" />
>> -                        <label for="repository-edit-gpgcheck-radio-true">$_("Yes")</label>
>> -                        <input id="repository-edit-gpgcheck-radio-false" name="gpgcheck" type="radio" value="false" />
>> -                        <label for="repository-edit-gpgcheck-radio-false">$_("No")</label>
>> -                    </div>
>> -                </div>
>> -                <div>
>> -                    <div class="repository-edit-wrapper-label">
>>                           <label for="repository-edit-gpgkey-textbox">$_("GPG Key")</label>
>>                       </div>
>>                       <div class="repository-edit-wrapper-controls">
>


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20140313/8c63a560/attachment.html>


More information about the Kimchi-devel mailing list