From 55a1289d763515b68c6b15c907a4e5adc3a87790 Mon Sep 17 00:00:00 2001
From: Daniel K Lyons <dlyons@nrao.edu>
Date: Thu, 4 Mar 2021 14:30:13 -0700
Subject: [PATCH] Prefill the form with a product locator (for testing)

---
 .../services/capability-launcher.service.ts        |  6 ++----
 .../src/app/workspaces/workspaces.component.html   |  2 +-
 .../web/src/app/workspaces/workspaces.component.ts | 14 +++++++-------
 3 files changed, 10 insertions(+), 12 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 a50ef7c38..4b47559c6 100644
--- a/apps/web/src/app/workspaces/services/capability-launcher.service.ts
+++ b/apps/web/src/app/workspaces/services/capability-launcher.service.ts
@@ -20,16 +20,14 @@ export class CapabilityLauncherService {
    */
   createRequest(
     capabilityName: string,
-    parameters: string
+    parameters: any
   ): Observable<CapabilityRequest> {
     const url =
       environment.workspacesUrl +
       this.endpoint +
       capabilityName +
       '/request/create';
-    const requestParams = JSON.stringify({
-      parameters,
-    });
+    const requestParams = JSON.stringify({'parameters': parameters});
     return this.httpClient.post<CapabilityRequest>(url, requestParams);
   }
 
diff --git a/apps/web/src/app/workspaces/workspaces.component.html b/apps/web/src/app/workspaces/workspaces.component.html
index 2179fa900..9a20be8a2 100644
--- a/apps/web/src/app/workspaces/workspaces.component.html
+++ b/apps/web/src/app/workspaces/workspaces.component.html
@@ -10,7 +10,7 @@
 
   <div class="md-form">
     <label for="splInput" class="">Science Product</label>
-    <input type="text" id="splInput" [value]="splInput" (change)="setSPLInput($event.target.value)" class="form-control">
+    <input type="text" id="splInput" [value]="productLocator" (change)="setProductLocator($event.target.value)" class="form-control" placeholder="e.g. uid://evla/execblock/27561b56-4c6a-4614-bc26-67e436b5e92c">
   </div>
 
   <br/>
diff --git a/apps/web/src/app/workspaces/workspaces.component.ts b/apps/web/src/app/workspaces/workspaces.component.ts
index f7be9e399..99bc7cbb5 100644
--- a/apps/web/src/app/workspaces/workspaces.component.ts
+++ b/apps/web/src/app/workspaces/workspaces.component.ts
@@ -13,11 +13,12 @@ export class WorkspacesComponent implements OnInit {
   public capabilityRequests: Array<CapabilityRequest> = [];
   public capabilityExecutions: Array<CapabilityExecution> = [];
 
-  public splInput: string;
+  public productLocator: string;
   public userEmail: string;
 
   constructor(private capabilityLauncher: CapabilityLauncherService) {
-    this.splInput = null;
+    // this is the famous 394 MB 13B-014 execblock, a useful smallish test
+    this.productLocator = "uid://evla/execblock/27561b56-4c6a-4614-bc26-67e436b5e92c";
     this.userEmail = null;
   }
 
@@ -36,8 +37,7 @@ export class WorkspacesComponent implements OnInit {
   downloadButtonOnClick(): void {
     this.launchCapability(
       'test_download',
-      this.splInput,
-      this.userEmail
+      {'product_locator': this.productLocator, 'user_email': this.userEmail}
     );
   }
 
@@ -45,8 +45,8 @@ export class WorkspacesComponent implements OnInit {
    * method that sets the user input Science Product Locator for the download capability
    * @param spl the Science Product Locator to download
    */
-  setSPLInput(spl: string){
-    this.splInput = spl;
+  setProductLocator(spl: string){
+    this.productLocator = spl;
   }
 
   /**
@@ -63,7 +63,7 @@ export class WorkspacesComponent implements OnInit {
    * @param parameters      Parameters of capability request
    * @param email           User email for notifications (Optional)
    */
-  launchCapability(capabilityName: string, parameters: string, email?: string): void {
+  launchCapability(capabilityName: string, parameters: any): void {
     // Create capability request
     this.capabilityLauncher.createRequest(capabilityName, parameters).subscribe(
       (requestResponse) => {
-- 
GitLab