浏览代码

HUE-1176 [jb] Open notification in notification panel

Romain Rigaux 9 年之前
父节点
当前提交
7f21f15c07

+ 2 - 1
desktop/core/src/desktop/lib/tasks/extract_archive/extract_utils.py

@@ -29,7 +29,8 @@ def extract_archive_in_hdfs(request, upload_path, file_name):
   output_path = upload_path + '/' + file_name.split('.')[0]
   shell_notebook = Notebook(
       description=_('HDFS Extraction of %(upload_path)s/%(file_name)s') % {'upload_path': upload_path, 'file_name': file_name},
-      isManaged=True
+      isManaged=True,
+      onSuccessUrl=upload_path
   )
 
   shell_notebook.add_shell_snippet(

+ 24 - 3
desktop/core/src/desktop/templates/responsive.mako

@@ -204,9 +204,29 @@ ${ hueIcons.symbols() }
         </div>
         <div class="jobs-panel" data-bind="visible: historyPanelVisible" style="display: none;">
           <!-- ko if: editorVM.selectedNotebook() -->
+          <!-- ko with: editorVM.selectedNotebook() -->
+            <div>
+              Showing
+              <span data-bind="text: uuid"></span>
+              <a href="javascript:void(0)" data-bind="attr: { href: onSuccessUrl() }, text: onSuccessUrl" target="_blank"></a>
+              <!-- ko if: selectedSnippet() -->
+              <div>
+                Progress
+                <span data-bind="text: selectedSnippet().progress"></span>
+              </div>
+              <!-- ko if: selectedSnippet().result -->
+              <div>
+                Logs
+                <span data-bind="text: selectedSnippet().result.logs"></span>
+              </div>
+              <!-- /ko -->
+              <!-- /ko -->
+            </div>
+            <hr>
+            X Clear History
             <ul>
-              <!-- ko foreach: editorVM.selectedNotebook().history -->
-                <li style="font-size: 15px; font-weight: 300">
+              <!-- ko foreach: history -->
+                <li style="font-size: 15px; font-weight: 300" data-bind="click: function() { editorVM.openNotebook(uuid()); }">
                   <span data-bind="text: lastExecuted"></span>
                   <i class="fa fa-fighter-jet fa-fw"></i>
                   <span data-bind="text: status"></span>
@@ -217,6 +237,7 @@ ${ hueIcons.symbols() }
               <!-- /ko -->
             </ul>
           <!-- /ko -->
+          <!-- /ko -->
         </div>
 
         <div class="compose-action btn-group">
@@ -803,7 +824,6 @@ ${ assist.assistPanel() }
         user: '${ user.username }',
         userId: ${ user.id },
         languages: [{name: "Java", type: "java"}, {name: "Hive SQL", type: "hive"}], // TODO reuse
-        is_history: true, // Important
         snippetViewSettings: {
           java : {
             snippetIcon: 'fa-file-archive-o '
@@ -829,6 +849,7 @@ ${ assist.assistPanel() }
         }
       });
       self.editorVM.editorMode(true);
+      self.editorVM.isNotificationManager(true);
       self.editorVM.newNotebook();
 
       huePubSub.subscribe("notebook.task.submitted", function (history_id) {

+ 1 - 1
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -1319,7 +1319,7 @@ ${ assist.assistPanel() }
             }
           });
           self.editorVM.editorMode(true);
-          self.editorVM.isHistory(true);
+          self.editorVM.isNotificationManager(true);
           ko.cleanNode($("#importerNotebook")[0]);
           ko.applyBindings(self.editorVM, $("#importerNotebook")[0]);
 

+ 2 - 2
desktop/libs/notebook/src/notebook/api.py

@@ -420,9 +420,9 @@ def get_history(request):
   doc_type = request.GET.get('doc_type')
   doc_text = request.GET.get('doc_text')
   limit = min(request.GET.get('len', 50), 100)
-  is_history = request.GET.get('is_history', 'false') == 'true'
+  is_notification_manager = request.GET.get('is_notification_manager', 'false') == 'true'
 
-  if is_history:
+  if is_notification_manager:
     docs = Document2.objects.get_tasks_history(user=request.user)
   else:
     docs = Document2.objects.get_history(doc_type='query-%s' % doc_type, user=request.user)

+ 6 - 6
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -971,7 +971,7 @@ var EditorViewModel = (function() {
         self.statusForButtons('executed');
         stopLongOperationTimeout();
 
-        if (vm.editorMode() && data.history_id && ! vm.isHistory()) {
+        if (vm.editorMode() && data.history_id && ! vm.isNotificationManager()) {
           var url = '/notebook/editor' + (vm.isMobile() ? '_m' : '') + '?editor=' + data.history_id;
           if (vm.isResponsive()){
             url = vm.URLS.responsive + '&editor=' + data.history_id;
@@ -1559,7 +1559,7 @@ var EditorViewModel = (function() {
     }
     self.history = ko.observableArray(vm.selectedNotebook() ? vm.selectedNotebook().history() : []);
     self.history.subscribe(function(val) {
-      if (self.id() == null && val.length == 0 && self.historyFilter() === '') {
+      if (self.id() == null && val.length == 0 && self.historyFilter() === '' && ! vm.isNotificationManager()) {
         self.snippets()[0].currentQueryTab('savedQueries');
       }
     });
@@ -1920,7 +1920,7 @@ var EditorViewModel = (function() {
         doc_type: self.selectedSnippet(),
         limit: 50,
         doc_text: self.historyFilter(),
-        is_history: vm.isHistory()
+        is_notification_manager: vm.isNotificationManager()
       }, function(data) {
         var parsedHistory = [];
         if (data && data.history){
@@ -2170,7 +2170,7 @@ var EditorViewModel = (function() {
     self.userId = options.userId;
     self.isMobile = ko.observable(options.mobile);
     self.isResponsive = ko.observable(options.responsive);
-    self.isHistory = ko.observable(options.is_history || false);
+    self.isNotificationManager = ko.observable(options.is_notification_manager || false);
     self.editorType = ko.observable(options.editor_type);
     self.editorType.subscribe(function(newVal) {
       self.editorMode(newVal != 'notebook');
@@ -2407,7 +2407,7 @@ var EditorViewModel = (function() {
           data.data.can_write = data.user_perms.can_write;
           var notebook = data.data;
           self.loadNotebook(notebook, queryTab);
-          if (typeof skipUrlChange === 'undefined'){
+          if (typeof skipUrlChange === 'undefined' && ! self.isNotificationManager()){
             if (self.editorMode()) {
               if (self.isResponsive()){
                 hueUtils.changeURL(self.URLS.responsive + '&editor=' + data.document.id);
@@ -2442,7 +2442,7 @@ var EditorViewModel = (function() {
         directory_uuid: window.location.getParameter('directory_uuid')
       }, function (data) {
         self.loadNotebook(data.notebook);
-        if (self.editorMode()) {
+        if (self.editorMode() && ! self.isNotificationManager()) {
           self.selectedNotebook().newSnippet(self.editorType());
           huePubSub.publish('detach.scrolls', self.selectedNotebook().snippets()[0]);