move platform readmes to the their modules
This commit is contained in:
parent
25c530e5fc
commit
91c5350330
@ -75,62 +75,4 @@ permanent, submit a pull request for it to be added by default!
|
||||
|
||||
> To add a data source to your app, add a data source config entry from one of the samples below
|
||||
**above** the application entry in config.ini, then add the following to your app config entry:
|
||||
`data_source = variable_name`
|
||||
|
||||
##### ping
|
||||
Check if a service is online.
|
||||
```ini
|
||||
[variable_name]
|
||||
platform = ping
|
||||
resource = 192.168.1.1
|
||||
```
|
||||
> **Returns:** a right-aligned colored bullet point on the app card.
|
||||
|
||||
| Variable | Required | Description | Options |
|
||||
|-----------------|----------|-----------------------------------------------------------------|-------------------|
|
||||
| [variable_name] | Yes | Name for the data source. | [variable_name] |
|
||||
| plaform | Yes | Name of the platform. | rest |
|
||||
| resource | Yes | Url of whatever you want to ping | url |
|
||||
|
||||
##### rest
|
||||
Make a call on a REST API and display the results as a jinja formatted string.
|
||||
```ini
|
||||
[variable_name]
|
||||
platform = rest
|
||||
resource = https://your-website.com/api
|
||||
value_template = {{value}}
|
||||
method = post
|
||||
authentication = basic
|
||||
username = my_username
|
||||
password = my_password
|
||||
payload = {"var1": "hi", "var2": 1}
|
||||
```
|
||||
> **Returns:** `value_template` as rendered string
|
||||
|
||||
| Variable | Required | Description | Options |
|
||||
|-----------------|----------|-----------------------------------------------------------------|-------------------|
|
||||
| [variable_name] | Yes | Name for the data source. | [variable_name] |
|
||||
| plaform | Yes | Name of the platform. | rest |
|
||||
| resource | Yes | Url of rest api resource. | url |
|
||||
| value_template | Yes | Jinja template for how the returned data from api is displayed. | jinja template |
|
||||
| method | No | Method for the api call, default is GET | GET,POST |
|
||||
| authentication | No | Authentication for the api call, default is None | None,basic,digest |
|
||||
| username | No | Username to use for auth. | string |
|
||||
| password | No | Password to use for auth. | string |
|
||||
| payload | No | Payload for post request. | json |
|
||||
|
||||
> **Working example:**
|
||||
>```ini
|
||||
>[test]
|
||||
>platform = rest
|
||||
>resource = https://pokeapi.co/api/v2/pokemon
|
||||
>value_template = Pokemon: {{value['count']}}
|
||||
>
|
||||
>[Pokemon]
|
||||
>prefix = https://
|
||||
>url = pokemon.com
|
||||
>icon = static/images/apps/default.png
|
||||
>description = Data sources example
|
||||
>open_in = this_tab
|
||||
>data_sources = test
|
||||
>```
|
||||
`data_source = variable_name`
|
@ -13,6 +13,8 @@ root_folder = get_root_folder()
|
||||
|
||||
dashmachine_folder = os.path.join(root_folder, "dashmachine")
|
||||
|
||||
platform_folder = os.path.join(dashmachine_folder, "platform")
|
||||
|
||||
user_data_folder = os.path.join(dashmachine_folder, "user_data")
|
||||
|
||||
static_folder = os.path.join(dashmachine_folder, "static")
|
||||
|
@ -1,3 +1,23 @@
|
||||
"""
|
||||
|
||||
##### ping
|
||||
Check if a service is online.
|
||||
```ini
|
||||
[variable_name]
|
||||
platform = ping
|
||||
resource = 192.168.1.1
|
||||
```
|
||||
> **Returns:** a right-aligned colored bullet point on the app card.
|
||||
|
||||
| Variable | Required | Description | Options |
|
||||
|-----------------|----------|-----------------------------------------------------------------|-------------------|
|
||||
| [variable_name] | Yes | Name for the data source. | [variable_name] |
|
||||
| plaform | Yes | Name of the platform. | rest |
|
||||
| resource | Yes | Url of whatever you want to ping | url |
|
||||
|
||||
|
||||
"""
|
||||
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
|
@ -1,3 +1,50 @@
|
||||
"""
|
||||
|
||||
##### rest
|
||||
Make a call on a REST API and display the results as a jinja formatted string.
|
||||
```ini
|
||||
[variable_name]
|
||||
platform = rest
|
||||
resource = https://your-website.com/api
|
||||
value_template = {{value}}
|
||||
method = post
|
||||
authentication = basic
|
||||
username = my_username
|
||||
password = my_password
|
||||
payload = {"var1": "hi", "var2": 1}
|
||||
```
|
||||
> **Returns:** `value_template` as rendered string
|
||||
|
||||
| Variable | Required | Description | Options |
|
||||
|-----------------|----------|-----------------------------------------------------------------|-------------------|
|
||||
| [variable_name] | Yes | Name for the data source. | [variable_name] |
|
||||
| plaform | Yes | Name of the platform. | rest |
|
||||
| resource | Yes | Url of rest api resource. | url |
|
||||
| value_template | Yes | Jinja template for how the returned data from api is displayed. | jinja template |
|
||||
| method | No | Method for the api call, default is GET | GET,POST |
|
||||
| authentication | No | Authentication for the api call, default is None | None,basic,digest |
|
||||
| username | No | Username to use for auth. | string |
|
||||
| password | No | Password to use for auth. | string |
|
||||
| payload | No | Payload for post request. | json |
|
||||
|
||||
> **Working example:**
|
||||
>```ini
|
||||
>[test]
|
||||
>platform = rest
|
||||
>resource = https://pokeapi.co/api/v2/pokemon
|
||||
>value_template = Pokemon: {{value['count']}}
|
||||
>
|
||||
>[Pokemon]
|
||||
>prefix = https://
|
||||
>url = pokemon.com
|
||||
>icon = static/images/apps/default.png
|
||||
>description = Data sources example
|
||||
>open_in = this_tab
|
||||
>data_sources = test
|
||||
>```
|
||||
|
||||
"""
|
||||
|
||||
import json
|
||||
from requests import get, post
|
||||
from requests.auth import HTTPBasicAuth, HTTPDigestAuth
|
||||
|
@ -1,6 +1,5 @@
|
||||
import os
|
||||
from shutil import move
|
||||
from markdown2 import markdown_path
|
||||
from flask_login import current_user
|
||||
from flask import render_template, request, Blueprint, jsonify, redirect, url_for
|
||||
from dashmachine.user_system.forms import UserForm
|
||||
@ -10,13 +9,12 @@ from dashmachine.main.utils import row2dict, public_route, check_groups
|
||||
from dashmachine.main.read_config import read_config
|
||||
from dashmachine.main.models import Files, TemplateApps
|
||||
from dashmachine.settings_system.forms import ConfigForm
|
||||
from dashmachine.settings_system.utils import load_files_html
|
||||
from dashmachine.settings_system.utils import load_files_html, get_config_html
|
||||
from dashmachine.settings_system.models import Settings
|
||||
from dashmachine.paths import (
|
||||
backgrounds_images_folder,
|
||||
icons_images_folder,
|
||||
user_data_folder,
|
||||
root_folder,
|
||||
)
|
||||
from dashmachine.version import version
|
||||
|
||||
@ -41,16 +39,7 @@ def settings():
|
||||
template_apps.append(f"{t_app.name}&&{t_app.icon}")
|
||||
|
||||
users = User.query.all()
|
||||
config_readme = markdown_path(
|
||||
os.path.join(root_folder, "config_readme.md"),
|
||||
extras=[
|
||||
"tables",
|
||||
"fenced-code-blocks",
|
||||
"break-on-newline",
|
||||
"header-ids",
|
||||
"code-friendly",
|
||||
],
|
||||
)
|
||||
config_readme = get_config_html()
|
||||
return render_template(
|
||||
"settings_system/settings.html",
|
||||
config_form=config_form,
|
||||
@ -123,4 +112,6 @@ def edit_user():
|
||||
for err in errorMessages:
|
||||
err_str += f"{err} "
|
||||
return jsonify(data={"err": err_str})
|
||||
return jsonify(data={"err": "success"})
|
||||
users = User.query.all()
|
||||
html = render_template("settings_system/user.html", users=users)
|
||||
return jsonify(data={"err": "success", "html": html})
|
||||
|
@ -1,11 +1,43 @@
|
||||
from dashmachine.paths import backgrounds_images_folder, icons_images_folder
|
||||
import os
|
||||
import importlib
|
||||
from markdown2 import markdown
|
||||
from dashmachine.paths import (
|
||||
backgrounds_images_folder,
|
||||
icons_images_folder,
|
||||
root_folder,
|
||||
platform_folder,
|
||||
)
|
||||
from flask import render_template
|
||||
from os import listdir
|
||||
|
||||
|
||||
def load_files_html():
|
||||
backgrounds = listdir(backgrounds_images_folder)
|
||||
icons = listdir(icons_images_folder)
|
||||
backgrounds = os.listdir(backgrounds_images_folder)
|
||||
icons = os.listdir(icons_images_folder)
|
||||
return render_template(
|
||||
"settings_system/files.html", backgrounds=backgrounds, icons=icons,
|
||||
)
|
||||
|
||||
|
||||
def get_config_html():
|
||||
with open(os.path.join(root_folder, "config_readme.md")) as readme_file:
|
||||
md = readme_file.read()
|
||||
platforms = os.listdir(platform_folder)
|
||||
platforms = sorted(platforms)
|
||||
for platform in platforms:
|
||||
name, extension = os.path.splitext(platform)
|
||||
if extension.lower() == ".py":
|
||||
module = importlib.import_module(f"dashmachine.platform.{name}", ".")
|
||||
if module.__doc__:
|
||||
md += module.__doc__
|
||||
|
||||
config_html = markdown(
|
||||
md,
|
||||
extras=[
|
||||
"tables",
|
||||
"fenced-code-blocks",
|
||||
"break-on-newline",
|
||||
"header-ids",
|
||||
"code-friendly",
|
||||
],
|
||||
)
|
||||
return config_html
|
||||
|
@ -71,9 +71,10 @@ $( document ).ready(function() {
|
||||
if (data.data.err !== 'success'){
|
||||
M.toast({html: data.data.err, classes: 'theme-failure'});
|
||||
} else {
|
||||
$("#user-form-password").val('');
|
||||
$("#user-form-confirm_password").val('');
|
||||
M.toast({html: 'User updated'});
|
||||
$("#users-div").empty();
|
||||
$("#users-div").append(data.data.html);
|
||||
$("#edit-user-modal").modal('close');
|
||||
M.toast({html: 'User saved'});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -60,23 +60,11 @@
|
||||
<i class="material-icons-outlined theme-secondary-text icon-btn ml-2 toggle-config-help" style="position: relative; top: 4px;">add</i>
|
||||
</a>
|
||||
</h5>
|
||||
{% for user in users %}
|
||||
<div class="card theme-surface-1">
|
||||
<div class="card-content">
|
||||
<span style="font-size: 1.3rem">
|
||||
{{ user.username }}
|
||||
<span class="theme-secondary-text">{{ user.role }}</span>
|
||||
</span>
|
||||
<span class="right pb-2">
|
||||
<i class="material-icons-outlined icon-btn edit-user-btn"
|
||||
data-role="{{ user.role }}"
|
||||
data-id="{{ user.id }}"
|
||||
data-username="{{ user.username }}">edit</i>
|
||||
<i class="material-icons-outlined icon-btn">close</i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="users-div">
|
||||
{{ Users(users) }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -86,4 +74,25 @@
|
||||
<p class="mb-2">version: {{ version }}</p>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
{{UserTab()}}
|
||||
|
||||
{% macro Users(users) %}
|
||||
{% for user in users %}
|
||||
<div class="card theme-surface-1">
|
||||
<div class="card-content">
|
||||
<span style="font-size: 1.3rem">
|
||||
{{ user.username }}
|
||||
<span class="theme-secondary-text">{{ user.role }}</span>
|
||||
</span>
|
||||
<span class="right pb-2">
|
||||
<i class="material-icons-outlined icon-btn edit-user-btn"
|
||||
data-role="{{ user.role }}"
|
||||
data-id="{{ user.id }}"
|
||||
data-username="{{ user.username }}">edit</i>
|
||||
<i class="material-icons-outlined icon-btn">close</i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{{Users(users)}}
|
Loading…
x
Reference in New Issue
Block a user