From 7afa50ba9b572dbe36d1b15f1d70c0e6e3245914 Mon Sep 17 00:00:00 2001
From: Chris Hines <chris.hines@monash.edu>
Date: Tue, 25 Feb 2020 13:23:58 +1100
Subject: [PATCH] make v1 desktops work. Add custom juyputer doco

---
 src/app/joblist/joblist.component.html        |  2 +-
 src/app/joblist/joblist.component.ts          | 14 ++++++--
 .../launch-dialog/launch-dialog.component.ts  |  5 ++-
 src/app/strudelapps.service.ts                | 36 +++++++++++++++++--
 src/app/tes.service.ts                        |  1 +
 src/assets/config/m3apps.dev.json             |  2 +-
 src/assets/config/m3apps.test.json            |  1 +
 7 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/src/app/joblist/joblist.component.html b/src/app/joblist/joblist.component.html
index 064cae3..cad2c94 100644
--- a/src/app/joblist/joblist.component.html
+++ b/src/app/joblist/joblist.component.html
@@ -55,7 +55,7 @@
                 </mat-list-item>
             <mat-divider style="background-color: var(--panel-border-color)"></mat-divider>
             <div *ngFor="let job of joblist ; let lastItem = last">
-                <div *ngIf="job.app !== null && app.name == job.app.name && job.state == 'Finished'">
+                <div *ngIf="job.app !== null && app.name == job.appname && job.state == 'Finished'">
                     <app-job [jobdata]=job></app-job>
                     <mat-divider></mat-divider>
                 </div>
diff --git a/src/app/joblist/joblist.component.ts b/src/app/joblist/joblist.component.ts
index 92d3ff9..7b70313 100644
--- a/src/app/joblist/joblist.component.ts
+++ b/src/app/joblist/joblist.component.ts
@@ -112,16 +112,24 @@ export class JoblistComponent implements OnInit {
     app = applist[0];
     for ( let item of applist) {
       sapp = <Strudelapp>item;
-      let sname = sapp.name.toLowerCase().replace(/\s/g, '');
-      let jname = name.toLowerCase().replace(/\s/g, '');
-      idx = sname.indexOf(jname)
+      //let sname = sapp.name.toLowerCase().replace(/\s/g, '');
+      //let jname = name.toLowerCase().replace(/\s/g, '');
+      let sname = sapp.name;
+      let jname = name;
+      idx = sname.indexOf(jname);
+      console.log('sname',sname);
+      console.log('jname',jname);
       if (idx == 0) {
         app = item;
+        console.log('found an app1',jname,sname);
+          console.log(app.startscript);
         return app;
       }
       if (sapp.applist != null) {
         app = this.getApp(name,sapp.applist);
         if (app != null) {
+          console.log('found an app1',jname,sname);
+          console.log(app.startscript);
           return app;
         }
       }
diff --git a/src/app/launch-dialog/launch-dialog.component.ts b/src/app/launch-dialog/launch-dialog.component.ts
index cb84042..df5ae51 100644
--- a/src/app/launch-dialog/launch-dialog.component.ts
+++ b/src/app/launch-dialog/launch-dialog.component.ts
@@ -70,7 +70,7 @@ export class LaunchDialogComponent implements OnInit {
     this.setFocus = false;
     this.updateURLs();
     this.clearInfo();
-    this.subscriptions.push(this.appSubject.subscribe(() => { this.app = this.appSubject.value; this.updateURLs() ; this.clearInfo()}));
+    this.subscriptions.push(this.appSubject.subscribe(() => { this.app = this.appSubject.value; console.log('updated app',this.app); this.updateURLs() ; this.clearInfo()}));
   }
 
   configdialog(){
@@ -201,13 +201,16 @@ export class LaunchDialogComponent implements OnInit {
   }
 
   canILaunch() {
+    console.log('called canIlaunch');
     if (this.app == null) {
+      console.log('setready false');
       this.setReady(false);
       return
     }
     if (this.submitcmd.value != null) {
         console.log(this.app.url);
         if (this.app.url === null || this.appData.value != null ) {
+            console.log('setready true');
             this.setReady(true);
             return;
         }
diff --git a/src/app/strudelapps.service.ts b/src/app/strudelapps.service.ts
index 0ca4fbd..a941fbc 100644
--- a/src/app/strudelapps.service.ts
+++ b/src/app/strudelapps.service.ts
@@ -7,9 +7,41 @@ import { Strudelapp } from './strudelapp';
 export class StrudelappsService {
 
   constructor() { }
+  getApp(name: string,applist: any): any {
+
+    var idx: number;
+    var app: any;
+    var sapp: Strudelapp;
+    app = applist[0];
+    for ( let item of applist) {
+      sapp = <Strudelapp>item;
+      //let sname = sapp.name.toLowerCase().replace(/\s/g, '');
+      //let jname = name.toLowerCase().replace(/\s/g, '');
+      let sname = sapp.name;
+      let jname = name;
+      idx = sname.indexOf(jname);
+      console.log('sname',sname);
+      console.log('jname',jname);
+      if (idx == 0) {
+        app = item;
+        console.log('found an app1',jname,sname);
+          console.log(app.startscript);
+        return app;
+      }
+      if (sapp.applist != null) {
+        app = this.getApp(name,sapp.applist);
+        if (app != null) {
+          console.log('found an app1',jname,sname);
+          console.log(app.startscript);
+          return app;
+        }
+      }
+    }
+    return null;
+  }
 
   // getApp(name: string,applist: Strudelapp[]): Strudelapp {
-  getApp(name: string,applist: any): any {
+    /*getApp(name: string,applist: any): any {
 
     var idx: number;
     var app: any;
@@ -32,6 +64,6 @@ export class StrudelappsService {
       }
     }
     return null;
-  }
+  }*/
 
 }
diff --git a/src/app/tes.service.ts b/src/app/tes.service.ts
index a44e849..c071f81 100644
--- a/src/app/tes.service.ts
+++ b/src/app/tes.service.ts
@@ -207,6 +207,7 @@ private addUserHealth(identity,resp) {
      }
    }
    let body = {'app': app, 'appparams': appparams, 'keys': keys, 'ids': JSON.stringify(JSON.stringify(ids))}
+   console.log('submit body',body);
    this.http.post<any>(this.Base+'/submit'+'?'+paramstr, body, options)
                                           .subscribe(resp => { this.notifications.notify(null) },
                                                      error => this.submissionError(error));
diff --git a/src/assets/config/m3apps.dev.json b/src/assets/config/m3apps.dev.json
index a9a4adc..9c8bffb 100644
--- a/src/assets/config/m3apps.dev.json
+++ b/src/assets/config/m3apps.dev.json
@@ -132,7 +132,7 @@
        }
 
    ],
-   "desc": "this is a description of how to run jupyter with a <a href=https://www.cvl.org.au>link</a>",
+   "desc": "To run your own installation of jupyter you must first <ul> <li> Install Jupyter </li> <li> Create a file called <code>~/.jupytervenv</code> containg the path where you installed. For example if you have the program <code>/home/user/myenv/bin/jupyter</code>, you would put <code>/home/user/myenv</code> in that file.</li></ul>",
    "localbind": true,
    "applist": null
   },
diff --git a/src/assets/config/m3apps.test.json b/src/assets/config/m3apps.test.json
index 1a86a9a..70573d3 100644
--- a/src/assets/config/m3apps.test.json
+++ b/src/assets/config/m3apps.test.json
@@ -103,6 +103,7 @@
        }
 
    ],
+   "desc": "To run your own installation of jupyter you must first <ul> <li> Install Jupyter </li> <li> Create a file called <code>~/.jupytervenv</code> containg the path where you installed. For example if you have the program <code>/home/user/myenv/bin/jupyter</code>, you would put <code>/home/user/myenv</code> in that file.</li></ul>",
    "localbind": true,
    "applist": null
   },
-- 
GitLab