فهرست منبع

HUE-6698 [oozie] Add link from bundle browser to editor if available

Romain Rigaux 8 سال پیش
والد
کامیت
e89e5615ba

+ 15 - 12
apps/jobbrowser/src/jobbrowser/apis/bundle_api.py

@@ -24,7 +24,8 @@ from liboozie.oozie_api import get_oozie
 
 from jobbrowser.apis.base_api import Api, MockDjangoRequest
 from jobbrowser.apis.workflow_api import _manage_oozie_job, _filter_oozie_jobs
-from liboozie.utils import format_time
+from jobbrowser.apis.schedule_api import MockGet
+from oozie.views.dashboard import list_oozie_bundle
 
 
 LOG = logging.getLogger(__name__)
@@ -32,7 +33,7 @@ LOG = logging.getLogger(__name__)
 
 try:
   from oozie.conf import OOZIE_JOBS_COUNT
-  from oozie.views.dashboard import get_oozie_job_log, massaged_bundle_actions_for_json, massaged_oozie_jobs_for_json
+  from oozie.views.dashboard import get_oozie_job_log, massaged_oozie_jobs_for_json
 except Exception, e:
   LOG.exception('Some application are not enabled: %s' % e)
 
@@ -65,23 +66,25 @@ class BundleApi(Api):
 
 
   def app(self, appid):
-    oozie_api = get_oozie(self.user)
-    bundle = oozie_api.get_bundle(jobid=appid)
+    request = MockDjangoRequest(self.user, get=MockGet())
+    response = list_oozie_bundle(request, job_id=appid)
+    bundle = json.loads(response.content)
 
     common = {
-        'id': bundle.bundleJobId,
-        'name': bundle.bundleJobName,
-        'status': bundle.status,
-        'apiStatus': self._api_status(bundle.status),
-        'progress': bundle.get_progress(),
+        'id': bundle['id'],
+        'name': bundle['name'],
+        'status': bundle['status'],
+        'apiStatus': self._api_status(bundle['status']),
+        'progress': bundle['progress'],
         'type': 'bundle',
-        'user': bundle.user,
-        'submitted': format_time(bundle.kickoffTime),
+        'user': bundle['user'],
+        'submitted': bundle['submitted'],
         'properties': {}
     }
-    common['properties']['actions'] = massaged_bundle_actions_for_json(bundle)
+    common['properties']['actions'] = bundle['actions']
     common['properties']['xml'] = ''
     common['properties']['properties'] = ''
+    common['doc_url'] = bundle.get('doc_url')
 
     return common
 

+ 10 - 0
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -1206,8 +1206,18 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         <ul class="nav nav-list">
           <li class="nav-header">${ _('Id') }</li>
           <li><span data-bind="text: id, attr: { 'title': id }"></span></li>
+          <!-- ko if: doc_url -->
+          <li class="nav-header">${ _('Document') }</li>
+          <li>
+            <a data-bind="hueLink: doc_url" href="javascript: void(0);" title="${ _('Open in editor') }">
+              <span data-bind="text: name"></span>
+            </a>
+          </li>
+          <!-- /ko -->
+          <!-- ko ifnot: doc_url -->
           <li class="nav-header">${ _('Name') }</li>
           <li><span data-bind="text: name"></span></li>
+          <!-- /ko -->
           <li class="nav-header">${ _('Type') }</li>
           <li><span data-bind="text: type"></span></li>
           <li class="nav-header">${ _('Status') }</li>

+ 5 - 1
apps/oozie/src/oozie/views/dashboard.py

@@ -519,10 +519,14 @@ def list_oozie_bundle(request, job_id):
   if request.GET.get('format') == 'json':
     return_obj = {
       'id': oozie_bundle.id,
+      'user': oozie_bundle.user,
+      'name': oozie_bundle.bundleJobName,
       'status':  oozie_bundle.status,
       'progress': oozie_bundle.get_progress(),
       'endTime': format_time(oozie_bundle.endTime),
-      'actions': massaged_bundle_actions_for_json(oozie_bundle)
+      'actions': massaged_bundle_actions_for_json(oozie_bundle),
+      'submitted': format_time(oozie_bundle.kickoffTime),
+      'doc_url': bundle.get_absolute_url() if bundle else '',
     }
     return HttpResponse(json.dumps(return_obj).replace('\\\\', '\\'), content_type="application/json")