Metadata-Version: 2.1
Name: trame-remote-control
Version: 0.1.0
Summary: A trame extension to allow outside programs to send instructions to a trame app
Author-email: Jonathan Windgassen <j.windgassen@fz-juelich.de>
License: MIT License
        
        Copyright (c) 2024, Jonathan Windgassen, Forschungszentrum Jülich e.V.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Repository, https://github.com/jwindgassen/trame-remote-control
Project-URL: Issues, https://github.com/jwindgassen/trame-remote-control/issues
Keywords: Python,Interactive,Web,Application,Framework,ParaView,trame
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: trame
Requires-Dist: trame-vuetify
Requires-Dist: aiohttp

# trame-remote-control
A trame extension to allow outside programs to send instructions to a trame app.

*trame-remote-control* attaches a REST-API endpoint, which can be used by outside programs to send instrctions, 
called **actions** to the program. This can, e.g., be used to initialite a Connection between a trame app and a ParaView Server.

## Supported Actions
The API endpoint will by default initialized on the `/api` path, which can be changed be setting the `REMOTE_CONTROL_ENDPOINT` 
environment variable to a different location.

To trigger an action, send a POST request to the API path. The body must contain a JSON, which specifies the action to trigger 
and might contain the parameters for that action. See the list below for the supported actions and their required parameters:

```json
{
  "action": "connect",
  "url": "localhost",
  "port": 11111
}
```

| Action Name     | Parameters                              | Description                                                           |
|-----------------|-----------------------------------------|-----------------------------------------------------------------------|
| `connect`       | url: string, port: optional int = 11111 | Connect a trame-vtk app to a ParaView Serverrunning on `<url>:<port>` |
| `diconnect`     |                                         | Disconnect from a previously connected ParaView Server                |
| `open_catalyst` |                                         | Open a Catalyst connection                                            |

## Installing
To install this extension, execute `pip install trame-remote-control`

For a Development install, clone the repository and execute `pip install -e .`


## Usage
After you installed the extension, import the module via trame.
To initialize the API endpoint, execute the `initialize` method. 
If you, optionally, want to create the UI Elements to trigger action from within the application, you can execute `create_panel`:

```python
from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vuetify, remote_control

def main():
    server = get_server()
    
    ... # Other initialization
    
    remote_control.initialize(server)

    # Create UI
    with SinglePageLayout(server):
        ...

        with vuetify.VCol():
            remote_control.create_panel(server)
```

## ToDos
- Allow developers to specify which Actions are initialized
- Add ping route to retrieve if application has finished loading and which Actions are available
- Create more Actions
