diff --git a/app_templates.ini b/app_templates.ini
deleted file mode 100644
index 2766077..0000000
--- a/app_templates.ini
+++ /dev/null
@@ -1,177 +0,0 @@
-[Nextcloud]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/nextcloud.png
-description = A safe home for all your data – community-driven, free & open source
-open_in = this_tab
-
-[Home Assistant]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/home-assistant.png
-description = Open source home automation that puts local control and privacy first
-open_in = this_tab
-
-[Emby]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/emby.png
-description = Emby Server is a personal media server with apps on just about every device
-open_in = this_tab
-
-[Bitwarden]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/bitwarden.png
-description = A free and open-source password management service
-open_in = this_tab
-
-[Deluge]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/deluge.png
-description = Deluge is a lightweight, Free Software, cross-platform BitTorrent client
-open_in = this_tab
-
-[Gitea]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/gitea.png
-description = A painless self-hosted Git service
-open_in = this_tab
-
-[SSH]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/terminal.png
-description = SSH, terminal, shell, shellinabox
-open_in = this_tab
-
-[Portainer]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/portainer.png
-description = Making Docker management easy
-open_in = this_tab
-
-[Nginx Proxy Manager]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/nginxproxymanager.png
-description = Docker container for managing Nginx proxy hosts with a simple, powerful interface
-open_in = this_tab
-
-[Sonarr]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/sonarr.png
-description = Smart PVR for newsgroup and bittorrent users
-open_in = this_tab
-
-[Radarr]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/radarr.png
-description = A fork of Sonarr to work with movies à la Couchpotato
-open_in = this_tab
-
-[Jackett]
-prefix = http://
-url = 192.168.39.175:9117
-icon = static/images/apps/jackett.png
-description = API Support for your favorite torrent trackers
-open_in = this_tab
-
-[Riot]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/riot.png
-description = A glossy Matrix collaboration client for the web
-open_in = this_tab
-
-[Jellyfin]
-prefix = https://
-url = your-website.com
-icon = static/images/apps/jellyfin.png
-description = The Free Software Media System
-open_in = this_tab
-
-[Lidarr]
-prefix = http://
-url = 192.168.39.175:8686
-icon = static/images/apps/lidarr.png
-description = Looks and smells like Sonarr but made for music
-open_in = this_tab
-
-[Airsonic]
-prefix = http://
-url = 192.168.39.175:4040
-icon = static/images/apps/airsonic.png
-description = A Free and Open Source community driven media server
-open_in = this_tab
-
-[Tautulli]
-prefix = http://
-url = 192.168.39.175:8181
-icon = static/images/apps/tautulli.png
-description = A Python based monitoring and tracking tool for Plex Media Server
-open_in = this_tab
-
-[Bazarr]
-prefix = http://
-url = 192.168.39.175:6767
-icon = static/images/apps/bazarr.png
-description = A companion application to Sonarr and Radarr
-open_in = this_tab
-
-[Ombi]
-prefix = http://
-url = 192.168.39.175:3579
-icon = static/images/apps/ombi.png
-description = Want a Movie or TV Show on Plex or Emby? Use Ombi!
-open_in = this_tab
-
-[Syncthing]
-prefix = http://
-url = 192.168.39.175:8384
-icon = static/images/apps/Syncthing.png
-description = Open Source Continuous File Synchronization
-open_in = this_tab
-
-[The Lounge]
-prefix = http://
-url = 192.168.39.175:9000
-icon = static/images/apps/thelounge.png
-description = Modern, responsive, cross-platform, self-hosted web IRC client
-open_in = this_tab
-
-[Traefik]
-prefix = http://
-url = 192.168.39.175:8080
-icon = static/images/apps/traefik.png
-description = The Cloud Native Edge Router
-open_in = this_tab
-
-[HandBrake]
-prefix = https://
-url = 192.168.39.175:7803
-icon = static/images/apps/handbrake.png
-sidebar_icon = static/images/icons/handbrake.png
-description = HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded video transcoder
-open_in = this_tab
-
-[OPNsense]
-prefix = https://
-url = 192.168.39.1
-icon = static/images/apps/opnsense.png
-sidebar_icon = static/images/apps/opnsense.png
-description = Secure Your Network with ease. From Virtual Private Networking to Intrusion Detection, Best in class, FREE Open Source Project
-open_in = new_tab
-
-[BookStack]
-prefix = http://
-url = 192.168.39.175:8197
-icon = static/images/apps/bookstack.png
-sidebar_icon = static/images/apps/bookstack.png
-description = BookStack is a simple, self-hosted, easy-to-use platform for organising and storing information
-open_in = new_tab
\ No newline at end of file
diff --git a/dashmachine/main/models.py b/dashmachine/main/models.py
index 9637d1e..c5ea5af 100644
--- a/dashmachine/main/models.py
+++ b/dashmachine/main/models.py
@@ -30,17 +30,6 @@ class Apps(db.Model):
tags = db.Column(db.String())
-class TemplateApps(db.Model):
- id = db.Column(db.Integer, primary_key=True)
- name = db.Column(db.String())
- prefix = db.Column(db.String())
- url = db.Column(db.String())
- icon = db.Column(db.String())
- sidebar_icon = db.Column(db.String())
- description = db.Column(db.String())
- open_in = db.Column(db.String())
-
-
class DataSources(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String())
diff --git a/dashmachine/main/utils.py b/dashmachine/main/utils.py
index 29ec71c..fe90e06 100755
--- a/dashmachine/main/utils.py
+++ b/dashmachine/main/utils.py
@@ -1,11 +1,8 @@
import os
-import subprocess
import importlib
from shutil import copyfile
-from requests import get
-from configparser import ConfigParser
from dashmachine.paths import dashmachine_folder, images_folder, root_folder
-from dashmachine.main.models import TemplateApps, Groups
+from dashmachine.main.models import Groups
from dashmachine.main.read_config import read_config
from dashmachine.settings_system.models import Settings
from dashmachine.user_system.models import User
@@ -21,31 +18,6 @@ def row2dict(row):
return d
-def read_template_apps():
- config = ConfigParser()
- try:
- config.read("app_templates.ini")
- except Exception as e:
- return {"msg": f"Invalid Config: {e}."}
-
- TemplateApps.query.delete()
-
- for section in config.sections():
- template_app = TemplateApps()
- template_app.name = section
- template_app.prefix = config[section]["prefix"]
- template_app.url = config[section]["url"]
- template_app.icon = config[section]["icon"]
- if "sidebar_icon" in config[section]:
- template_app.sidebar_icon = config[section]["sidebar_icon"]
- else:
- template_app.sidebar_icon = template_app.icon
- template_app.description = config[section]["description"]
- template_app.open_in = config[section]["open_in"]
- db.session.add(template_app)
- db.session.commit()
-
-
# establishes routes decorated w/ @public_route as accessible while not signed
# in. See login and register routes for usage
def public_route(decorated_function):
@@ -57,7 +29,6 @@ def dashmachine_init():
db.create_all()
db.session.commit()
- read_template_apps()
user_data_folder = os.path.join(dashmachine_folder, "user_data")
# create the user_data subdirectories, link them to static
diff --git a/dashmachine/paths.py b/dashmachine/paths.py
index 800487e..74cf543 100755
--- a/dashmachine/paths.py
+++ b/dashmachine/paths.py
@@ -13,6 +13,8 @@ root_folder = get_root_folder()
dashmachine_folder = os.path.join(root_folder, "dashmachine")
+template_apps_folder = os.path.join(root_folder, "template_apps")
+
platform_folder = os.path.join(dashmachine_folder, "platform")
user_data_folder = os.path.join(dashmachine_folder, "user_data")
diff --git a/dashmachine/platform/deluge.py b/dashmachine/platform/deluge.py
index 2afd7d3..0f6bb65 100644
--- a/dashmachine/platform/deluge.py
+++ b/dashmachine/platform/deluge.py
@@ -1,3 +1,44 @@
+"""
+
+##### deluge
+Display information from Deluge web ui.
+```ini
+[variable_name]
+platform = deluge
+resource = https://deluge.example.com:8112/json
+value_template = ↓{{download_rate|filesizeformat}}/s ↑{{upload_rate|filesizeformat}}/s
+password = MySecretPassword
+```
+> **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 your deluge instance + '/json' | url |
+| value_template | Yes | Jinja template for how the returned data from api is displayed. | jinja template |
+| password | No | Password to use for auth. | string |
+
+> **Working example:**
+>```
+>[deluge]
+>platform = deluge
+>resource = https://deluge.example.com:8112/json
+>value_template = ↓{{download_rate|filesizeformat}}/s ↑{{upload_rate|filesizeformat}}/s
+>password = MySecretPassword
+>
+>[Deluge]
+>prefix = https://
+>url = https://deluge.example.com:8112
+>icon = static/images/apps/deluge.png
+>sidebar_icon = static/images/apps/deluge.png
+>description = Deluge is a lightweight, Free Software, cross-platform BitTorrent client
+>open_in = iframe
+>data_sources = deluge
+>```
+
+"""
+
from flask import render_template_string
import requests
@@ -16,14 +57,10 @@ class Platform:
self.id = 1
self.session = requests.Session()
self._api_call("auth.login", [self.password])
- self.password = None # Discard password, no longer needed.
+ self.password = None # Discard password, no longer needed.
def _api_call(self, method, params=[]):
- json = {
- "id": self.id,
- "method": method,
- "params": params
- }
+ json = {"id": self.id, "method": method, "params": params}
return self.session.post(self.resource, json=json)
def process(self):
diff --git a/dashmachine/settings_system/routes.py b/dashmachine/settings_system/routes.py
index ba794d0..5635057 100644
--- a/dashmachine/settings_system/routes.py
+++ b/dashmachine/settings_system/routes.py
@@ -1,13 +1,14 @@
import os
from shutil import move
+from configparser import ConfigParser
from flask_login import current_user
from flask import render_template, request, Blueprint, jsonify, redirect, url_for
from dashmachine.user_system.forms import UserForm
from dashmachine.user_system.utils import add_edit_user
from dashmachine.user_system.models import User
-from dashmachine.main.utils import row2dict, public_route, check_groups
+from dashmachine.main.utils import public_route, check_groups
from dashmachine.main.read_config import read_config
-from dashmachine.main.models import Files, TemplateApps
+from dashmachine.main.models import Files
from dashmachine.settings_system.forms import ConfigForm
from dashmachine.settings_system.utils import load_files_html, get_config_html
from dashmachine.settings_system.models import Settings
@@ -15,6 +16,7 @@ from dashmachine.paths import (
backgrounds_images_folder,
icons_images_folder,
user_data_folder,
+ template_apps_folder,
)
from dashmachine.version import version
from dashmachine import db
@@ -35,10 +37,13 @@ def settings():
with open(os.path.join(user_data_folder, "config.ini"), "r") as config_file:
config_form.config.data = config_file.read()
files_html = load_files_html()
+
template_apps = []
- t_apps = TemplateApps.query.all()
- for t_app in t_apps:
- template_apps.append(f"{t_app.name}&&{t_app.icon}")
+ config = ConfigParser()
+ for template_app_ini in os.listdir(template_apps_folder):
+ config.read(os.path.join(template_apps_folder, template_app_ini))
+ entry = config[template_app_ini.replace(".ini", "")]
+ template_apps.append(f"{template_app_ini.replace('.ini', '')}&&{entry['icon']}")
users = User.query.all()
config_readme = get_config_html()
@@ -87,11 +92,15 @@ def delete_file():
@settings_system.route("/settings/get_app_template", methods=["GET"])
def get_app_template():
- template_app = TemplateApps.query.filter_by(name=request.args.get("name")).first()
- template = f"[{template_app.name}]
"
- for key, value in row2dict(template_app).items():
- if key not in ["id", "name"]:
- template += f"{key} = {value}
"
+ # template_app = TemplateApps.query.filter_by(name=request.args.get("name")).first()
+ # template = f"[{template_app.name}]
"
+ # for key, value in row2dict(template_app).items():
+ # if key not in ["id", "name"]:
+ # template += f"{key} = {value}
"
+
+ fn = os.path.join(template_apps_folder, f"{request.args.get('name')}.ini")
+ with open(fn, "r") as template_app_ini:
+ template = template_app_ini.read().replace("\n", "
")
return template
diff --git a/dashmachine/static/images/apps/pihole.png b/dashmachine/static/images/apps/pihole.png
new file mode 100644
index 0000000..9758df4
Binary files /dev/null and b/dashmachine/static/images/apps/pihole.png differ
diff --git a/dashmachine/templates/settings_system/settings.html b/dashmachine/templates/settings_system/settings.html
index f7fdbc7..6359c85 100644
--- a/dashmachine/templates/settings_system/settings.html
+++ b/dashmachine/templates/settings_system/settings.html
@@ -102,7 +102,7 @@