93f43d928860a345d712a07428af3170a34facb9
chmalee
  Fri Apr 5 12:33:42 2024 -0700
Make web accessible user directory link available at start time. Added a symlink to upload directory in /usr/local/apache

diff --git src/hg/js/hgMyData.js src/hg/js/hgMyData.js
index b8a7ca0..9ca1d9e 100644
--- src/hg/js/hgMyData.js
+++ src/hg/js/hgMyData.js
@@ -7,30 +7,31 @@
     } else if (num < (1000 * 1000 * 1024)) {
         return `${((num/1000)/1000).toFixed(1)}mb`;
     } else {
         return `${(((num/1000)/1000)/1000).toFixed(1)}gb`;
     }
 }
 
 var hubCreate = (function() {
     let uiState = { // our object for keeping track of the current UI and what to do
         toUpload: {}, // set of file objects keyed by name
         input: null, // the hidden input element
         pickedList: null, // the <div> for displaying files in toUpload
         pendingQueue: [], // our queue of pending [tus.Upload, file], kind of like the toUpload object
         fileList: [], // the files this user has uploaded, initially populated by the server
                         // on page load, but gets updated as the user uploades/deletes files
+        userUrl: "", // the web accesible path where the uploads are stored for this user
     };
 
     // We can use XMLHttpRequest if necessary or a mirror can't use tus
     var useTus = tus.isSupported && true;
 
     function getTusdEndpoint() {
         // return the port and basepath of the tusd server
         // NOTE: the port and basepath are specified in hg.conf
         //let currUrl = parseUrl(window.location.href);
         return "https://hgwdev-hubspace.gi.ucsc.edu/files";
     }
 
     function togglePickStateMessage(showMsg = false) {
         if (showMsg) {
             let para = document.createElement("p");
@@ -318,42 +319,44 @@
         console.log(`sending delete req for ${fname}`);
         const endpoint = "../cgi-bin/hgHubConnect?deleteFile=" + fname;
         if (!(endpoint in pendingDeletes)) {
             const xhr = new XMLHttpRequest();
             pendingDeletes[endpoint] = xhr;
             this.xhr = xhr;
             this.xhr.open("DELETE", endpoint, true);
             this.xhr.send();
             deleteFileFromTable(rowIx, fname);
             delete pendingDeletes[endpoint];
         }
     }
 
     function viewInGenomeBrowser(rowIx, fname) {
         // redirect to hgTracks with this track as a custom track
+        if (typeof uiState.userUrl !== "undefined" && uiState.userUrl.length > 0) {
             bigBedExts = [".bb", ".bigBed"];
             let i;
             for (i = 0; i < bigBedExts.length; i++) {
                 if (fname.toLowerCase().endsWith(bigBedExts[i])) {
                     // TODO: tusd should return this location in it's response after
                     // uploading a file and then we can look it up somehow, the cgi can
                     // write the links directly into the html directly for prev uploaded files maybe?
-                window.location.assign("../cgi-bin/hgTracks?db=hg38&hgt.customText=" + "/hive/users/chmalee/tmp/userDataDir/4f/chmalee/" + fname);
+                    window.location.assign("../cgi-bin/hgTracks?db=hg38&hgt.customText=" + uiState.userUrl + fname);
                     return false;
                 }
             }
         }
+    }
 
     function addNewUploadedFileToTable(req) {
         // req is an object with properties of an uploaded file, make a new row
         // for it in the filesTable
         let table = null;
         if ($.fn.dataTable.isDataTable("#filesTable")) {
             table = $("#filesTable").DataTable();
             let newRow = table.row.add(req).draw();
         } else {
             showExistingFiles([req]);
         }
     }
 
     let tableInitOptions = {
         //columnDefs: [{orderable: false, targets: [0,1]}],
@@ -504,30 +507,31 @@
             //     choosing file types
             //     creating default trackDbs
             //     editing trackDbs
             // TODO: make hgHubConnect respond to requests
             // TODO: initialize tus-client
             // TODO: get user name
             // TODO: send a request with username
             // TODO: have tusd respond on server
             let uploadSection = document.getElementById("chosenFilesSection");
             if (uploadSection.style.display === "none") {
                 uploadSection.style.display = "";
             }
             if (typeof userFiles !== 'undefined' && typeof userFiles.fileList !== 'undefined' &&
                     userFiles.fileList.length > 0) { 
                 uiState.fileList= userFiles.fileList;
+                uiState.userUrl = userFiles.userUrl;
                 showExistingFiles(uiState.fileList);
             }
             inputBtn.addEventListener("click", (e) => uiState.input.click());
             //uiState.input.addEventListener("change", listPickedFiles);
             // TODO: add event handler for when file is succesful upload
             // TODO: add event handlers for editing defaults, grouping into hub
             // TODO: display quota somewhere
             // TODO: customize the li to remove the picked file
         }
     }
     return { init: init,
              uiState: uiState,
            };
 
 }());