fixed naming for facility_name and testbed_name in QueryTable plugin
[myslice.git] / plugins / querytable / __init__.py
index b435b38..995e935 100644 (file)
@@ -33,6 +33,13 @@ Current implementation makes the following assumptions
   as we use 'aoColumnDefs' instead.
 """
 
+    MAP = {
+        'facility_name' :   'Facility',
+        'testbed_name'  :   'Testbed',
+        'hostname'      :   'Resource name',
+        'type'          :   'Type',
+    }
+
     def __init__ (self, query=None, query_all=None, 
                   checkboxes=False, columns=None, 
                   init_key=None,
@@ -43,20 +50,28 @@ Current implementation makes the following assumptions
         self.query_all      = query_all
         self.query_all_uuid = query_all.query_uuid if query_all else None
         self.checkboxes     = checkboxes
+
         # XXX We need to have some hidden columns until we properly handle dynamic queries
         if columns is not None:
-            self.columns=columns
-            self.hidden_columns = []
+            _columns = columns
+            _hidden_columns = []
         elif self.query:
-            self.columns = self.query.fields
+            _columns = [field for field in self.query.fields if not field == 'urn']
             if query_all:
                 # We need a list because sets are not JSON-serializable
-                self.hidden_columns = list(self.query_all.fields - self.query.fields)
+                _hidden_columns = list(self.query_all.fields - self.query.fields)
+                _hidden_columns.append('urn')
             else:
-                self.hidden_columns = []
+                _hidden_columns = []
         else:
-            self.columns = []
-            self.hidden_columns = []
+            _columns = []
+            _hidden_columns = []
+
+        print "_columns=", _columns
+        self.columns = { self.MAP.get(c, c) : c for c in _columns }
+        self.hidden_columns = { self.MAP.get(c, c) : c for c in _hidden_columns }
+        print "self.columns", self.columns
+
         self.init_key=init_key
         self.datatables_options=datatables_options
         # if checkboxes were required, we tell datatables about this column's type
@@ -71,7 +86,7 @@ Current implementation makes the following assumptions
             aoColumnDefs = self.datatables_options.setdefault ('aoColumnDefs',[])
             # here 'checkbox' is the class that we give to the <th> dom elem
             # dom-checkbox is a sorting type that we define in querytable.js
-            aoColumnDefs.append ( {'aTargets': ['checkbox'], 'sSortDataType': 'dom-checkbox' } )
+            #aoColumnDefs.insert (0, {'aTargets': ['checkbox'], 'sSortDataType': 'dom-checkbox' } )
 
     def template_file (self):
         return "querytable.html"
@@ -84,7 +99,7 @@ Current implementation makes the following assumptions
 
     def requirements (self):
         reqs = {
-            'js_files' : [ "js/spin.presets.js", "js/spin.min.js", "js/jquery.spin.js", 
+            'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js", 
                            "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js",
                            "js/manifold.js", "js/manifold-query.js", 
                            "js/unfold-helper.js",
@@ -92,10 +107,10 @@ Current implementation makes the following assumptions
                           # dataTableExt.afnSortData
                            "js/querytable.js", 
                            ] ,
-            'css_files': [ "css/dataTables.bootstrap.css",
+            'css_files': [ #"css/dataTables.bootstrap.css",
                            # hopefully temporary, when/if datatables supports sPaginationType=bootstrap3
                            # for now we use full_numbers, with our own ad hoc css 
-                           "css/dataTables.full_numbers.css",
+                           #"css/dataTables.full_numbers.css",
                            "css/querytable.css" , 
                            ],
             }