This is an automated email from the ASF dual-hosted git repository.

jfthomps pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/vcl.git

commit c49d93f70c4bdf9d28e81b5b4f92bacac6f85914
Author: Josh Thompson <[email protected]>
AuthorDate: Fri Mar 8 10:07:01 2024 -0500

    VCL-1151 - modify sorting for image profiles to numerically sort RAM
    
    utils.php: modified getDojoHTML: in case viewResources, modified 
conditional to print initPage() when restype is image in addition to restype 
being computer
    
    images.js:
    -added Image.prototype.numericsort = function(a, b)
    -added initPage
---
 web/.ht-inc/utils.php     |  3 ++-
 web/js/resources/image.js | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/web/.ht-inc/utils.php b/web/.ht-inc/utils.php
index c2a1d0bf..191341b1 100644
--- a/web/.ht-inc/utils.php
+++ b/web/.ht-inc/utils.php
@@ -14233,7 +14233,8 @@ function getDojoHTML($refresh) {
                        foreach($dojoRequires as $req)
                                $rt .= "   dojo.require(\"$req\");\n";
                        $rt .= "      setTimeout(initViewResources, 100);\n";
-                       if($cdata['obj']->restype == 'computer')
+                       if($cdata['obj']->restype == 'computer' ||
+                          $cdata['obj']->restype == 'image')
                                $rt .= "      initPage();\n";
                        $rt .= "   });\n";
                        $rt .= "</script>\n";
diff --git a/web/js/resources/image.js b/web/js/resources/image.js
index 4ad565d8..d179d4f7 100644
--- a/web/js/resources/image.js
+++ b/web/js/resources/image.js
@@ -62,8 +62,39 @@ Image.prototype.colformatter = function(value, rowIndex, 
obj) {
        return value;
 }
 
+Image.prototype.numericsort = function(a, b) {
+       if(typeof a != 'string' && typeof b != 'string')
+               return 0;
+       if(typeof a != 'string')
+               return -1;
+       if(typeof b != 'string')
+               return 1;
+       var al = parseInt(a, 10);
+       var bl = parseInt(b, 10);
+       if(al < bl)
+               return -1;
+       if(bl < al)
+               return 1;
+       return 0;
+}
+
 var resource = new Image();
 
+function initPage() {
+       if(! ('resourcegrid' in window)) {
+               setTimeout(function() {
+                       initPage();
+               }, 100);
+               return;
+       }
+       else {
+               if(! resourcestore.comparatorMap) {
+                       resourcestore.comparatorMap = {};
+               }
+               resourcestore.comparatorMap['minram'] = resource.numericsort;
+       }
+}
+
 function inlineEditResourceCB(data, ioArgs) {
        if(data.items.status == 'success') {
                if(dijit.byId('advancedoptions').open)

Reply via email to