Bläddra i källkod

HUE-7779 [jb] Add job type in the API calls

Romain Rigaux 8 år sedan
förälder
incheckning
922a44a

+ 3 - 3
apps/jobbrowser/src/jobbrowser/api2.py

@@ -48,7 +48,7 @@ def api_error_handler(func):
 
 
 @api_error_handler
-def jobs(request):
+def jobs(request, interface=None):
   response = {'status': -1}
 
   interface = json.loads(request.POST.get('interface'))
@@ -64,7 +64,7 @@ def jobs(request):
 
 
 @api_error_handler
-def job(request):
+def job(request, interface=None):
   response = {'status': -1}
 
   interface = json.loads(request.POST.get('interface'))
@@ -81,7 +81,7 @@ def job(request):
 
 
 @api_error_handler
-def action(request):
+def action(request, interface=None, action=None):
   response = {'status': -1, 'message': ''}
 
   interface = json.loads(request.POST.get('interface'))

+ 3 - 3
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -1835,7 +1835,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       var lastUpdateJobRequest = null;
 
       self._fetchJob = function (callback) {
-        return $.post("/jobbrowser/api/job", {
+        return $.post("/jobbrowser/api/job/" + vm.interface(), {
           app_id: ko.mapping.toJSON(self.id),
           interface: ko.mapping.toJSON(vm.interface)
         }, function (data) {
@@ -2252,7 +2252,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
 
 
       self._fetchJobs = function (callback) {
-        return $.post("/jobbrowser/api/jobs", {
+        return $.post("/jobbrowser/api/jobs/" + vm.interface(), {
           interface: ko.mapping.toJSON(vm.interface),
           filters: ko.mapping.toJSON(self.filters),
         }, function (data) {
@@ -2371,7 +2371,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       }
 
       self._control = function (app_ids, action, callback) {
-        $.post("/jobbrowser/api/job/action", {
+        $.post("/jobbrowser/api/job/action/" + vm.interface() + "/" + action, {
           app_ids: ko.mapping.toJSON(app_ids),
           interface: ko.mapping.toJSON(vm.interface),
           operation: ko.mapping.toJSON({action: action})

+ 3 - 3
apps/jobbrowser/src/jobbrowser/urls.py

@@ -55,9 +55,9 @@ urlpatterns += patterns('jobbrowser.views',
 )
 
 urlpatterns += patterns('jobbrowser.api2',
-  url(r'api/jobs', 'jobs', name='jobs'),
+  url(r'api/jobs/?(?P<interface>.+)?', 'jobs', name='jobs'),
   url(r'api/job/logs', 'logs', name='logs'),
   url(r'api/job/profile', 'profile', name='profile'),
-  url(r'api/job/action', 'action', name='action'),
-  url(r'api/job', 'job', name='job'),
+  url(r'api/job/action/?(?P<interface>.+)?/?(?P<action>.+)?', 'action', name='action'),
+  url(r'api/job/?(?P<interface>.+)?', 'job', name='job'),
 )