Kitware / paraview-lite

Lite Client to a ParaView server which rely on Web technologies
https://kitware.github.io/paraview-lite/
BSD 3-Clause "New" or "Revised" License
32 stars 17 forks source link

How to make dynamic http path using single host for paraview-lite? #12

Closed rasunag27 closed 3 years ago

rasunag27 commented 3 years ago

Dear all,

How do I run the Paraview lite with multiple requests for single host using apache.

Now, I am able to run with apache where the paraview-lite is hosted at http//localhost/lite.

How do I modify this so that it can run dynamically as http://localhost/page1 and the page1 should change to other forms depending on new data.

I need this because I have multiple test cases to be visualized in a separate page.

Hopefully, the question is well understood. Any leads will be appreciated.

Regards,

Sunag R A.

jourdain commented 3 years ago

If I understood your question correctly, I would say

/page1 should redirect to /lite?fileToLoad=....&application=LiteWithFile

Where you config will add an entry for LiteWithFile and the usage of fileToLoad like you used to.

rasunag27 commented 3 years ago

Dear Jourdain,

That is correct.

  1. Page1 should redirect to one particular data which I give.
  2. Page2 should redirect to another particular data which I give. Basically, the Page numbers should act dynamically.

So, how to proceed with LineWithFile in launcher config for this?

Also, it will in the form of http://localhost/lite/page1 ??

Regards,

Sunag R A.

jourdain commented 3 years ago

LineWithFile would what you use to have in your launcher command but with a different command entry.

"apps": {
      "paraview-lite": {
        "cmd": [
          "${python_exec}", 
          "-dr",
      "${web_path}/lite/server/pvw-lite.py",
          "--port", "${port}",
      "--data", "${dataDir}",
          "--authKey", "${secret}",
      "--content", "${content}"
        ],
        "ready_line" : "Starting factory"
      },
     "paraview-lite-file": {
        "cmd": [
          "${python_exec}", 
          "-dr",
      "${web_path}/lite/server/pvw-lite.py",
          "--port", "${port}",
      "--data", "${dataDir}",
      "--load-file", "${fileName}",  
          "--authKey", "${secret}",
      "--content", "${content}"
        ],
        "ready_line" : "Starting factory"
      }
  }

Then in page 1

<html>
<body>
<script>
location= '/lite?application=paraview-lite-file&fileName=test.vtp'
</script>
</body>
</html>
rasunag27 commented 3 years ago

Dear Jourdain,

I have added paraview-lite-file in the launcher along with edits in index.html to add the content from page1.html.

Here are the contents from index.html and page1.html.

Index.html

In here, I have added <a> to include the page1.html file contents

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="google" value="notranslate">
    <title>ParaView Lite</title>
    <meta name="description" content="Lite ParaView client for Scientific Visualization on the Web">
    <link inline rel="icon" type="image/png" href="ParaView.png">
    <style type="text/css">
      /* override vuetify */
      html {
        overflow: hidden !important;
      }
    </style>
    <script inline type="text/javascript" src="version.js"></script>

      <script
         inline 
        type="text/javascript"
        src="runtime.js"
      ></script>

      <script
         inline 
        type="text/javascript"
        src="vendors.js"
      ></script>

      <script
         inline 
        type="text/javascript"
        src="ParaViewLite.js"
      ></script>
    <a href="page1.html">paraview-lite-file</a>
  </head>
  <body>
    <div id="root-container"></div>
    <script type="text/javascript">
      const container = document.querySelector('#root-container');
      const viewer = ParaViewLite.createViewer(container);
    </script>
  </body>
</html>

Page1.html

<!DOCTYPE html>
<html>
<body>
<script>
location = '/home/data/pv/pv-5.7.0/share/paraview-5.7/web/lite?application=paraview-lite-file&fileName=48_left.vtk'
</script>
</body>
</html>

I am not able to understand how I could possilbly show the contents via http://localhost/lite/page1.

What changes/addition need to be done in order to make these correct?

Regards, Sunag R A.

jourdain commented 3 years ago

Indeed, the browser use URL, providing a path to your filesystem is not going to work. Also adding a link in the is not going to help either.

Based on your lack of understanding it might be too hard for me to help you. I can only spare a couple minutes here and there.

I'm going to try again:

rasunag27 commented 3 years ago

Dear Jourdain,

Thank you very much for your patience. I was able to visualize the data as a separate URL when I type this: http://localhost/lite/?data=48/48_left.vtk

  1. I added --load-file and check with the URL. I followed the instructions from old discussion which got me through this link as below.

Load_file

  1. Now, my only concern is, the --load-file loads the file and not directory. How to load the directory say as http://localhost/lite/?data=48, so that it shows all the files present in it?

Thanks and Regards, Sunag R A.

jourdain commented 3 years ago

To load a directory you will need to add a new arg yourself to perform that action.

rasunag27 commented 3 years ago

Dear jourdain,

Due to some other work, I was not able to work much on the paraview web side. But from past a week I have been working on the issue related to default directory loading in the paraview lite.

  1. Say, I have two directories namely, directory1 and directory2. In each directory, there are vtk files present in it.

  2. So, I managed to get the file loaded as default into paraview lite.

  3. Now, I wanted the directory to be loaded as default, showing the files page as default for that directory. Eg : http://localhost/lite/?data=directory1 . (Not vtk files, vtk files should be shown in the left side of the paraview lite.

  4. As u mentioned in the previous message related to add new argument for default directory loading, How do I do that?

Thanks for Patience.

Regards, Sunag R A.

jourdain commented 3 years ago

I'm not sure what you mean?

rasunag27 commented 3 years ago

Hi Jourdain,

My question is related to the launcher to use those url parameters.

  1. I understand that using --load-file we can specify while file to load from the directory. I actually wanted some directory itself to load as default.
  2. So, when I give the url in the webpage, it should go to the directory where vtk files are present. With regards to this, I want to customize the launcher.

Eg. There is a directory named directory1 and directory2. How to customize the launcher such that when the url is typed as http://localhost/lite/?data=directory1 goes to the directory and not file as in http://localhost/lite/?data=file.vtk ??

Hope the framework of questioning is clear.

Regards, Sunag R A.

jourdain commented 3 years ago

What about cmd: [ ..., "--data", "${key1}", "--data2", "${key2}"]?

rasunag27 commented 3 years ago

From this I understand that for each directory, I need to add new arguments as data and key pair?

  1. So, If there are some 50 directories, the launcher should have 50 lines?

  2. I am asking this because, the directories are automatically created through codes. So, for each new directory, there needs to be new argument.?

  3. So, I need to add/change in below line for pvw-lite.py everytime a new directory is added/created.? parser.add_argument("--data", default=os.getcwd(), help="path to data directory to list, or else multiple directories given as 'name1=path1|name2=path2|...'", dest="path")

  4. Also, new line for the launcher as data and key pair?

Regards, Sunag R A.

jourdain commented 3 years ago
  1. I would not do that. I was just explaining how you link url to command line
  2. Can you provide 1 arg that let the server figure out all the directories that needs to be loaded?
  3. That would be bad design. But you can do what ever you see fit.
  4. I don't know, read my (1) point