[Kimchi-devel] [PATCH V2] Sort device paths shown when creating a logical storage pool
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Apr 1 17:59:59 UTC 2014
On 03/26/2014 03:22 PM, Rodrigo Trujillo wrote:
> Backend return a list of objects, with name, path, size, etc. The
> list is usually sorted by name due to the architecture of
> get_list, lookup, etc.
> But here I want to sort by the path, which is the field shown in the
> UI. Thats why I sorted in the front end.
>
> Well, I think any other part of code is using HostPartition, so, I can
> rewrite its 'get' base method to sort like we want.
> Do you think its better ?
The idea is correct.
But you don't need to rewrite the get() just order the dict
You can use sorted() with lambda to do it
>
> On 03/26/2014 12:37 PM, Aline Manera wrote:
>>
>> We usually do that on backend because of the better performance.
>>
>> On 03/26/2014 11:10 AM, Rodrigo Trujillo wrote:
>>> This patch sorts the output list of devices by their paths,
>>> improving the
>>> user experience.
>>>
>>> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
>>> ---
>>> ui/js/src/kimchi.storagepool_add_main.js | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/ui/js/src/kimchi.storagepool_add_main.js
>>> b/ui/js/src/kimchi.storagepool_add_main.js
>>> index f347747..7a751aa 100644
>>> --- a/ui/js/src/kimchi.storagepool_add_main.js
>>> +++ b/ui/js/src/kimchi.storagepool_add_main.js
>>> @@ -26,6 +26,7 @@ kimchi.initStorageAddPage = function() {
>>> kimchi.listHostPartitions(function(data) {
>>> if (data.length > 0) {
>>> var deviceHtml = $('#partitionTmpl').html();
>>> + data.sort(function (a, b){return
>>> a.path.localeCompare(b.path)});
>>> var listHtml = '';
>>> $.each(data, function(index, value) {
>>> if (value.type === 'part' || value.type === 'disk') {
>>
>> _______________________________________________
>> Kimchi-devel mailing list
>> Kimchi-devel at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>
>
More information about the Kimchi-devel
mailing list