From bc58b41a438714c83341c88b9ebbef490da5347e Mon Sep 17 00:00:00 2001
From: nhertz <nhertz@nrao.edu>
Date: Fri, 19 Feb 2021 16:09:46 -0700
Subject: [PATCH] Updated front-end yet again; this time, to use the newly
 created submit_capability_request view

---
 .../services/capability-launcher.service.ts   | 11 +++++----
 .../app/workspaces/workspaces.component.ts    | 23 ++++++++++---------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/apps/web/src/app/workspaces/services/capability-launcher.service.ts b/apps/web/src/app/workspaces/services/capability-launcher.service.ts
index f379c48a8..8b72b099a 100644
--- a/apps/web/src/app/workspaces/services/capability-launcher.service.ts
+++ b/apps/web/src/app/workspaces/services/capability-launcher.service.ts
@@ -21,7 +21,7 @@ export class CapabilityLauncherService {
   createRequest(
     capabilityName: string,
     parameters: string
-  ): Observable<string> {
+  ): Observable<CapabilityRequest> {
     const url =
       environment.workspacesUrl +
       this.endpoint +
@@ -30,15 +30,18 @@ export class CapabilityLauncherService {
     const requestParams = JSON.stringify({
       parameters: parameters,
     });
-    return this.httpClient.post<string>(url, requestParams);
+    return this.httpClient.post<CapabilityRequest>(url, requestParams);
   }
 
   /**
    * Submit capability request
    * @param: requestId  ID of capability request to submit
    */
-  submit(requestId: string): Observable<CapabilityExecution> {
-    const url = `${environment.workspacesUrl}${this.endpoint}request/${requestId}/submit`;
+  submit(
+    capabilityName: string,
+    requestId: string
+  ): Observable<CapabilityExecution> {
+    const url = `${environment.workspacesUrl}${this.endpoint}${capabilityName}/request/${requestId}/submit`;
     return this.httpClient.post<CapabilityExecution>(url, null);
   }
 }
diff --git a/apps/web/src/app/workspaces/workspaces.component.ts b/apps/web/src/app/workspaces/workspaces.component.ts
index cf7ef8c2d..ece8a7caf 100644
--- a/apps/web/src/app/workspaces/workspaces.component.ts
+++ b/apps/web/src/app/workspaces/workspaces.component.ts
@@ -42,19 +42,20 @@ export class WorkspacesComponent implements OnInit {
     // Create capability request
     this.capabilityLauncher.createRequest(capabilityName, parameters).subscribe(
       (requestResponse) => {
-        const capabilityRequest = JSON.parse(requestResponse);
-        this.capabilityRequests.push(capabilityRequest);
-        if (capabilityRequest.id) {
+        this.capabilityRequests.push(requestResponse);
+        if (requestResponse.id) {
           // Capability request created; ID found
           // Submit capability request
-          this.capabilityLauncher.submit(capabilityRequest.id).subscribe(
-            (submitResponse) => {
-              this.capabilityExecutions.push(submitResponse);
-            },
-            (error) => {
-              console.log(error);
-            }
-          );
+          this.capabilityLauncher
+            .submit(capabilityName, requestResponse.id)
+            .subscribe(
+              (submitResponse) => {
+                this.capabilityExecutions.push(submitResponse);
+              },
+              (error) => {
+                console.log(error);
+              }
+            );
         }
       },
       (error) => {
-- 
GitLab