scriptedforms icon indicating copy to clipboard operation
scriptedforms copied to clipboard

Add custom buttons to the toolbar using section-button

Open robmarkcole opened this issue 7 years ago • 11 comments

Button to upload files. Use case image processing, parsing csv

robmarkcole avatar Feb 28 '18 03:02 robmarkcole

I think all I would do is make it so that the file is placed in a temp directory that can be accessed within python.

How does that sound?

SimonBiggs avatar Feb 28 '18 04:02 SimonBiggs

That sounds fine. The workflow I envisage is: upload image

  1. process image and review result in form
  2. save form to pdf
  3. post result of processing to db

cheers

robmarkcole avatar Feb 28 '18 06:02 robmarkcole

Can you elaborate on the 'post result of processing to db' step? Will that need anything on the ScriptedForms end?

I had been thinking of a way to create sections that influence the toolbar. Like a "section-toolbar" which creates a button on the toolbar using material icons (https://material.io/icons/) which then runs the internal code when that toolbar item is clicked. It might look like:

<section-toolbar icon="save">

```python
code that sends results to db written here
```

</section-toolbar>

The icon would then look like the following:

https://material.io/icons/#ic_save

SimonBiggs avatar Feb 28 '18 06:02 SimonBiggs

Post using a REST API - I've not looked at QAtrack in a while but recall an API was on its roadmap. In this case you would just need Requests. I like the toolbar shortcut idea, that way auth credentials could also be hidden.

Im familiar with material design icons as used by home-assistant, perhaps their code might be instructive

robmarkcole avatar Feb 28 '18 06:02 robmarkcole

Actually, thinking further, it would be better to have it be just the following:

<section-button icon="save" toolbar>

```python
code that sends results to db written here
```

</section-button>

Just make it so the already existing <section-button> can have the 'toolbar' parameter added to it which makes the button move up to the toolbar instead of displaying next to the section itself.

SimonBiggs avatar Feb 28 '18 07:02 SimonBiggs

I wouldn't assume any code within the form is truly hidden.

You could use the scriptedforms API to run the following code:

filename = 'robins-template-with-credentials.md'
with open(filename, 'r') as file:
    markdown_template = file.read()

print(markdown_template)

SimonBiggs avatar Feb 28 '18 07:02 SimonBiggs

Good point. Perhaps just have a constants.py or equivalent where people can define credentials, IP of servers etc, so that scripts can share

robmarkcole avatar Feb 28 '18 07:02 robmarkcole

That's a good candidate for a yaml metadata file. Just don't think you can hide the contents of any file on or accessible by the host server from the user of a form.

SimonBiggs avatar Feb 28 '18 07:02 SimonBiggs

Hi @robmarkcole,

What did I need to do for this issue again?

SimonBiggs avatar Mar 31 '18 03:03 SimonBiggs

My original request was for a file upload button in the toolbar, such that upload files are available to scripts

robmarkcole avatar Mar 31 '18 04:03 robmarkcole

Yup, okay. So if I make the ability to make custom buttons that should solve this.

SimonBiggs avatar Mar 31 '18 04:03 SimonBiggs