> Version 0.6 brings DashMachine one big step forward to being a finished product by adding a gui to edit the various settings in the config.ini. **Changelog** - improvements to /home including 'pinned' cards, multi-select tag filtering, 'action providers' allowing you to do web searches from the searchbar - rebuilt sidenav with list view, mirroring filter/search/collapse state of the homepage - /settings and /home now on same route - dynamic reloading of settings (no more page reloads) - dedicated config.ini editor slide-out - settings editor slide-out - card editor slide-out - better access group control - dedicated documentation pages - improved documentation - new system for automatically generating documentation for platforms - ability to load custom platforms - added an 'on_starup' method for platforms allowing for registering api routes. (example coming soon)
67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
import platform
|
|
import subprocess
|
|
|
|
|
|
class Platform:
|
|
def docs(self):
|
|
documentation = {
|
|
"name": "ping",
|
|
"author": "Nixellion",
|
|
"author_url": "https://github.com/Nixellion",
|
|
"version": 1.0,
|
|
"description": "Check if a service is online.",
|
|
"example": """
|
|
```ini
|
|
[ping_test]
|
|
platform = ping
|
|
resource = localhost
|
|
|
|
[localhost]
|
|
prefix = http://
|
|
url = localhost
|
|
icon = static/images/apps/default.png
|
|
open_in = this_tab
|
|
data_sources = ping_test
|
|
```
|
|
""",
|
|
"returns": "a right-aligned colored bullet point on the app card.",
|
|
"variables": [
|
|
{
|
|
"variable": "[variable_name]",
|
|
"description": "Name for the data source.",
|
|
"default": "",
|
|
"options": ".ini header",
|
|
},
|
|
{
|
|
"variable": "platform",
|
|
"description": "Name of the platform.",
|
|
"default": "ping",
|
|
"options": "ping",
|
|
},
|
|
{
|
|
"variable": "resource",
|
|
"description": "Url of rest api resource.",
|
|
"default": "localhost",
|
|
"options": "url",
|
|
},
|
|
],
|
|
}
|
|
return documentation
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
# parse the user's options from the config entries
|
|
for key, value in kwargs.items():
|
|
self.__dict__[key] = value
|
|
|
|
def process(self):
|
|
param = "-n" if platform.system().lower() == "windows" else "-c"
|
|
command = ["ping", param, "1", self.resource]
|
|
up = subprocess.call(command) == 0
|
|
|
|
if up is True:
|
|
icon_class = "theme-success-text"
|
|
else:
|
|
icon_class = "theme-failure-text"
|
|
|
|
return f"<i class='material-icons right {icon_class}'>fiber_manual_record </i>"
|