Explorar el Código

HUE-3652 [editor] Add query name to history list

Romain Rigaux hace 9 años
padre
commit
c062110

+ 4 - 3
desktop/libs/notebook/src/notebook/api.py

@@ -37,7 +37,7 @@ from notebook.views import upgrade_session_properties
 LOG = logging.getLogger(__name__)
 
 
-DEFAULT_HISTORY_NAME = _('Query history')
+DEFAULT_HISTORY_NAME = ''
 
 
 @require_POST
@@ -275,7 +275,7 @@ def save_notebook(request):
 
 def _historify(notebook, user):
   query_type = notebook['type']
-  name = notebook['name'] if notebook['name'] and notebook['name'].strip() != '' else DEFAULT_HISTORY_NAME
+  name = notebook['name'] if (notebook['name'] and notebook['name'].strip() != '') else DEFAULT_HISTORY_NAME
 
   history_doc = Document2.objects.create(
     name=name,
@@ -326,7 +326,8 @@ def get_history(request):
         'data': {
             'statement_raw': notebook['snippets'][0]['statement_raw'][:1001],
             'lastExecuted':  notebook['snippets'][0]['lastExecuted'],
-            'status':  notebook['snippets'][0]['status']
+            'status':  notebook['snippets'][0]['status'],
+            'parentUuid': notebook.get('parentUuid', '')
         },
         'absoluteUrl': doc.get_absolute_url(),
       })

+ 4 - 2
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -600,7 +600,6 @@
           notebook.id(data.history_id);
           notebook.uuid(data.history_uuid);
           notebook.isHistory(true);
-//          notebook.isSaved(true);
           notebook.parentUuid(data.history_parent_uuid);
 
           notebook.history.unshift(
@@ -609,6 +608,7 @@
               self.statement_raw(),
               self.lastExecuted(),
               self.status(),
+              notebook.name(),
               notebook.uuid()
             )
           );
@@ -1303,6 +1303,7 @@
                 nbk.data.statement_raw,
                 nbk.data.lastExecuted,
                 nbk.data.status,
+                nbk.name,
                 nbk.uuid
               )
             );
@@ -1312,12 +1313,13 @@
       });
     };
 
-    self._makeHistoryRecord = function(url, statement, lastExecuted, status, uuid) {
+    self._makeHistoryRecord = function(url, statement, lastExecuted, status, name, uuid) {
       return {
           url: url,
           query: statement.substring(0, 1000) + (statement.length > 1000 ? '...' : ''),
           lastExecuted: lastExecuted,
           status: status,
+          name: name,
           uuid: uuid
       };
     };

+ 2 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1033,7 +1033,7 @@ ${ hueIcons.symbols() }
           <table class="table table-condensed margin-top-10 history-table">
             <tbody data-bind="foreach: $parent.history">
               <tr class="pointer" data-bind="click: function() { if (getSelection().toString().length == 0) { $root.openNotebook(uuid) } }">
-                <td style="width: 100px" class="muted" data-bind="style: {'border-top-width': $index() == 0 ? '0' : ''}"><span data-bind="text: moment(lastExecuted).fromNow(), attr: {title: moment(lastExecuted).format('LLL')}"></span></td>
+                <td style="width: 100px" class="muted" data-bind="style: {'border-top-width': $index() == 0 ? '0' : ''}"><span data-bind="text: moment(lastExecuted).fromNow(), attr: {title: moment(lastExecuted).format('LLL')}"></span></td>                
                 <td style="width: 25px" class="muted" data-bind="style: {'border-top-width': $index() == 0 ? '0' : ''}">
                   <!-- ko switch: status -->
                   <!-- ko case: 'running' -->
@@ -1050,6 +1050,7 @@ ${ hueIcons.symbols() }
                   <!-- /ko -->
                   <!-- /ko -->
                 </td>
+                <td style="width: 25px" class="muted" data-bind="text: name"></td>
                 <td data-bind="style: {'border-top-width': $index() == 0 ? '0' : ''}"><div data-bind="highlight: query, flavor: $parent.type" class="history-item"></div></td>
               </tr>
             </tbody>