Преглед на файлове

HUE-1829 [beeswax] Add back MapReduce job list

Added overlay to logs with job links
Enrico Berti преди 11 години
родител
ревизия
8d34bef
променени са 3 файла, в които са добавени 40 реда и са изтрити 3 реда
  1. 10 1
      apps/beeswax/src/beeswax/api.py
  2. 23 2
      apps/beeswax/src/beeswax/templates/execute.mako
  3. 7 0
      apps/beeswax/static/js/beeswax.vm.js

+ 10 - 1
apps/beeswax/src/beeswax/api.py

@@ -175,7 +175,7 @@ def watch_query_refresh_json(request, id):
     log = str(ex)
 
   jobs = _parse_out_hadoop_jobs(log)
-  job_urls = dict([(job, reverse('jobbrowser.views.single_job', kwargs={'job': job})) for job in jobs])
+  job_urls = massage_job_urls_for_json(jobs)
 
   result = {
     'status': 0,
@@ -200,6 +200,15 @@ def watch_query_refresh_json(request, id):
 
   return HttpResponse(json.dumps(result), mimetype="application/json")
 
+def massage_job_urls_for_json(jobs):
+  massaged_jobs = []
+  for job in jobs:
+    massaged_jobs.append({
+      'name': job,
+      'url': reverse('jobbrowser.views.single_job', kwargs={'job': job})
+    })
+  return massaged_jobs
+
 
 def close_operation(request, query_history_id):
   response = {

+ 23 - 2
apps/beeswax/src/beeswax/templates/execute.mako

@@ -352,8 +352,13 @@ ${layout.menubar(section='query')}
 
         <!-- ko if: !design.explain() -->
         <div class="tab-pane" id="log">
-          <pre data-bind="visible: $root.design.watch.logs().length == 0">${_('There are currently no logs to visualize.')} <img src="/static/art/spinner.gif" data-bind="visible: $root.design.isRunning()"/></pre>
-          <pre data-bind="visible: $root.design.watch.logs().length > 0, text: $root.design.watch.logs().join('\n')"></pre>
+          <div style="position:relative">
+            <ul data-bind="foreach: $root.design.watch.jobUrls" class="unstyled jobs-overlay">
+              <li><a data-bind="text: $.trim($data.name), attr: { href: $data.url }" target="_blank"></a></li>
+            </ul>
+            <pre data-bind="visible: $root.design.watch.logs().length == 0">${_('There are currently no logs to visualize.')} <img src="/static/art/spinner.gif" data-bind="visible: $root.design.isRunning()"/></pre>
+            <pre data-bind="visible: $root.design.watch.logs().length > 0, text: $root.design.watch.logs().join('\n')"></pre>
+          </div>
         </div>
 
         <div class="tab-pane" id="columns">
@@ -865,6 +870,22 @@ ${layout.menubar(section='query')}
     margin: 0;
   }
 
+  .jobs-overlay {
+    background-color: #FFF;
+    opacity: 0.8;
+    position: absolute;
+    top: 10px;
+    right: 15px;
+  }
+
+  .jobs-overlay li {
+    padding: 5px;
+  }
+
+  .jobs-overlay:hover {
+    opacity: 1;
+  }
+
 </style>
 
 <link href="/static/ext/css/leaflet.css" rel="stylesheet">

+ 7 - 0
apps/beeswax/static/js/beeswax.vm.js

@@ -63,6 +63,7 @@ function BeeswaxViewModel(server) {
     },
     'watch': {
       'logs': [],
+      'jobUrls': [],
       'url': null,
       'errors': []
     },
@@ -459,6 +460,7 @@ function BeeswaxViewModel(server) {
       success: function(data) {
         if (data.status == 0) {
           self.design.watch.logs.removeAll();
+          self.design.watch.jobUrls.removeAll();
           self.design.statement(data.statement);
           self.design.results.rows.removeAll();
           self.design.results.columns.removeAll();
@@ -544,6 +546,7 @@ function BeeswaxViewModel(server) {
       success: function(data) {
         if (data.status == 0) {
           self.design.watch.logs.removeAll();
+          self.design.watch.jobUrls.removeAll();
           self.design.statement(data.statement);
           self.design.watch.url(data.watch_url);
           self.design.results.url('/' + self.server() + '/results/' + data.id + '/0?format=json');
@@ -601,6 +604,7 @@ function BeeswaxViewModel(server) {
 
     self.design.isRunning(true);
     self.design.watch.logs.removeAll();
+    self.design.watch.jobUrls.removeAll();
     self.design.results.rows.removeAll();
     self.design.results.columns.removeAll();
     self.resetErrors();
@@ -614,6 +618,7 @@ function BeeswaxViewModel(server) {
           if (data.log) {
             self.design.watch.logs(data.log.split("\n"));
             // scroll logs
+            self.design.watch.jobUrls(data.jobUrls);
           }
           if (!failed) {
             $(document).trigger('stop_watch.query');
@@ -629,6 +634,7 @@ function BeeswaxViewModel(server) {
           if (data.log) {
             self.design.watch.logs(data.log.split("\n"));
             // scroll logs
+            self.design.watch.jobUrls(data.jobUrls);
           }
 
           TIMEOUT = Math.min(TIMEOUT + 100, 2000);
@@ -819,6 +825,7 @@ function BeeswaxViewModel(server) {
               // watch this ID.
               self.design.watch.url(data.watch_url);
               self.design.watch.logs.removeAll();
+              self.design.watch.jobUrls.removeAll();
               self.watchQueryLoop(redirect_fn);
             } else {
               // redirect to metastore app.