move platform readmes to the their modules
This commit is contained in:
parent
25c530e5fc
commit
91c5350330
@ -76,61 +76,3 @@ 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
|
> 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:
|
**above** the application entry in config.ini, then add the following to your app config entry:
|
||||||
`data_source = variable_name`
|
`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
|
|
||||||
>```
|
|
@ -13,6 +13,8 @@ root_folder = get_root_folder()
|
|||||||
|
|
||||||
dashmachine_folder = os.path.join(root_folder, "dashmachine")
|
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")
|
user_data_folder = os.path.join(dashmachine_folder, "user_data")
|
||||||
|
|
||||||
static_folder = os.path.join(dashmachine_folder, "static")
|
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 platform
|
||||||
import subprocess
|
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
|
import json
|
||||||
from requests import get, post
|
from requests import get, post
|
||||||
from requests.auth import HTTPBasicAuth, HTTPDigestAuth
|
from requests.auth import HTTPBasicAuth, HTTPDigestAuth
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
from shutil import move
|
from shutil import move
|
||||||
from markdown2 import markdown_path
|
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask import render_template, request, Blueprint, jsonify, redirect, url_for
|
from flask import render_template, request, Blueprint, jsonify, redirect, url_for
|
||||||
from dashmachine.user_system.forms import UserForm
|
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.read_config import read_config
|
||||||
from dashmachine.main.models import Files, TemplateApps
|
from dashmachine.main.models import Files, TemplateApps
|
||||||
from dashmachine.settings_system.forms import ConfigForm
|
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.settings_system.models import Settings
|
||||||
from dashmachine.paths import (
|
from dashmachine.paths import (
|
||||||
backgrounds_images_folder,
|
backgrounds_images_folder,
|
||||||
icons_images_folder,
|
icons_images_folder,
|
||||||
user_data_folder,
|
user_data_folder,
|
||||||
root_folder,
|
|
||||||
)
|
)
|
||||||
from dashmachine.version import version
|
from dashmachine.version import version
|
||||||
|
|
||||||
@ -41,16 +39,7 @@ def settings():
|
|||||||
template_apps.append(f"{t_app.name}&&{t_app.icon}")
|
template_apps.append(f"{t_app.name}&&{t_app.icon}")
|
||||||
|
|
||||||
users = User.query.all()
|
users = User.query.all()
|
||||||
config_readme = markdown_path(
|
config_readme = get_config_html()
|
||||||
os.path.join(root_folder, "config_readme.md"),
|
|
||||||
extras=[
|
|
||||||
"tables",
|
|
||||||
"fenced-code-blocks",
|
|
||||||
"break-on-newline",
|
|
||||||
"header-ids",
|
|
||||||
"code-friendly",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"settings_system/settings.html",
|
"settings_system/settings.html",
|
||||||
config_form=config_form,
|
config_form=config_form,
|
||||||
@ -123,4 +112,6 @@ def edit_user():
|
|||||||
for err in errorMessages:
|
for err in errorMessages:
|
||||||
err_str += f"{err} "
|
err_str += f"{err} "
|
||||||
return jsonify(data={"err": err_str})
|
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 flask import render_template
|
||||||
from os import listdir
|
|
||||||
|
|
||||||
|
|
||||||
def load_files_html():
|
def load_files_html():
|
||||||
backgrounds = listdir(backgrounds_images_folder)
|
backgrounds = os.listdir(backgrounds_images_folder)
|
||||||
icons = listdir(icons_images_folder)
|
icons = os.listdir(icons_images_folder)
|
||||||
return render_template(
|
return render_template(
|
||||||
"settings_system/files.html", backgrounds=backgrounds, icons=icons,
|
"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'){
|
if (data.data.err !== 'success'){
|
||||||
M.toast({html: data.data.err, classes: 'theme-failure'});
|
M.toast({html: data.data.err, classes: 'theme-failure'});
|
||||||
} else {
|
} else {
|
||||||
$("#user-form-password").val('');
|
$("#users-div").empty();
|
||||||
$("#user-form-confirm_password").val('');
|
$("#users-div").append(data.data.html);
|
||||||
M.toast({html: 'User updated'});
|
$("#edit-user-modal").modal('close');
|
||||||
|
M.toast({html: 'User saved'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -60,6 +60,22 @@
|
|||||||
<i class="material-icons-outlined theme-secondary-text icon-btn ml-2 toggle-config-help" style="position: relative; top: 4px;">add</i>
|
<i class="material-icons-outlined theme-secondary-text icon-btn ml-2 toggle-config-help" style="position: relative; top: 4px;">add</i>
|
||||||
</a>
|
</a>
|
||||||
</h5>
|
</h5>
|
||||||
|
|
||||||
|
<div class="users-div">
|
||||||
|
{{ Users(users) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row mt-4">
|
||||||
|
<h5>DashMachine</h5>
|
||||||
|
<p class="mb-2">version: {{ version }}</p>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro Users(users) %}
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<div class="card theme-surface-1">
|
<div class="card theme-surface-1">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
@ -77,13 +93,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="row mt-4">
|
|
||||||
<h5>DashMachine</h5>
|
|
||||||
<p class="mb-2">version: {{ version }}</p>
|
|
||||||
</div>
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{{UserTab()}}
|
|
||||||
|
{{Users(users)}}
|
Loading…
x
Reference in New Issue
Block a user