West-Life Virtual Research Environment Docs
  • Introduction
  • Data Management
  • Virtual Folder
    • User's guide
      • Settings
        • Import settings from another Virtual Folder
      • File Manager
      • File Picker
      • Related applications
        • Jupyter notebook
      • Metadata
    • Installation guide
      • Cloud installation
      • Local installation
      • Integration with SSO
    • Integration guide
      • Select File or Dir from Virtual Folder
      • Working with WEBDAV
      • Embedding Virtual Folder Component
      • Adding component into Virtual Folder
    • Developer's guide
      • Backend
      • Frontend - Web Application
      • Metadata and API
        • Dataset metadata and API
        • File metadata and API
      • Import Export Settings API
      • Related application and services
      • Untitled
  • Virtual Machines and Containers
    • Preparing vagrant VM template
    • Preparing docker container
  • Repository
    • Installation guide
      • Prerequisites
      • Automatic installation
      • Manual installation from source codes
    • User's guide
      • Scientist imports project proposal
      • Staff uploads data
      • Scientist works with dataset
      • Metadata
    • Developer's guide
      • Metadata generation
      • ARIA integration
Powered by GitBook
On this page
  • Shared Script Code
  • File picker
  • Upload Dir Picker component
  • References
  1. Virtual Folder
  2. Integration guide

Select File or Dir from Virtual Folder

Virtual Folder contains File Picker and Upload-Dir Picker components. They can send a message containing an URL of the selected File or Directory using cross-document messaging API. The integration is done by following:

  • The web page (e.g.myfilepicker.html) is hosted by [yourweb]

  • the following Javascript code in your web pages opens pop-up browser window with filepickercomponent.html and uploaddirpickercomponent.html hosted by West-Life portal.

  • The receiveMessage Javascript function gets the url of picked file or dir via cross-document messaging API.

Shared Script Code

Add the following javascript code into your web page (myfilepicker.html):

<script>
var popup;
var target;
//opens popup window in defined location, sets the target element id.
function openwindow(_target,href) {
  target = _target;
  popup=window.open(href, 'newwindow', 'width=640, height=480');
}
//receives message from popup window, fills target element with the data received
function receiveMessage(event) {
  document.getElementById(target).innerHTML=event.data;
  document.getElementById(target).setAttribute("href",event.data);
}
window.addEventListener("message", receiveMessage, false);
</script>

File picker

The filepickercomponent.html is hosted by west-life portal and returns an URL pointing to the file. HTTP GET of that URL lead to download the file.

Add the following HTML snippet into your web page (myfilepicker.html). It will open West-life filepicker component in popup window:

<a href="enablejavascript"

   onclick="openwindow('fileid',
   'https://portal.west-life.eu/virtualfolder/filepickercomponent.html'
   ); return false;">West-life File</a>

<p>File:<a id="fileid" href=""></a></p>

Note: 'fileid' links to the element where the URL of chosen file will appear later.

Upload Dir Picker component

The uploaddirpickercomponent.html is hosted by west-life portal and returns an URL pointing to the directory. You can HTTP POST or use WEBDAV access to that directory to upload files.

Add the following HTML snippet into your web page (myfilepicker.html). It will open West-life uploaddir picker component in popup window:

<a href="enablejavascript.html" 
   onclick="openwindow('uploaddirid',
   'https://portal.west-life.eu/virtualfolder/uploaddirpickercomponent.html'
   ); return false;"> West-life Upload Dir..</a>

  <p>Directory URL:<a id="uploaddirid" href=""></a></p>
</div>

Note: 'uploaddirid' links to the element where the URL of chosen file will appear later. This reuses the same javascript as for filepicker component.

References

PreviousIntegration guideNextWorking with WEBDAV

Last updated 7 years ago

:Cross-document Messaging:

https://html.spec.whatwg.org/multipage/comms.html#web-messaging