diff --git a/app_templates.ini b/app_templates.ini new file mode 100644 index 0000000..f23de31 --- /dev/null +++ b/app_templates.ini @@ -0,0 +1,6 @@ +[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 diff --git a/dashmachine/dashmachine_init.py b/dashmachine/dashmachine_init.py deleted file mode 100644 index 08c9c50..0000000 --- a/dashmachine/dashmachine_init.py +++ /dev/null @@ -1,30 +0,0 @@ -import os -from shutil import copyfile -from dashmachine.paths import dashmachine_folder, images_folder -from dashmachine.main.utils import read_config -from dashmachine.user_system.models import User -from dashmachine.user_system.utils import add_edit_user - - -def dashmachine_init(): - user_data_folder = os.path.join(dashmachine_folder, "user_data") - - # create the user_data subdirectories, link them to static - user_backgrounds_folder = os.path.join(user_data_folder, "backgrounds") - if not os.path.isdir(user_backgrounds_folder): - os.mkdir(user_backgrounds_folder) - os.symlink(user_backgrounds_folder, os.path.join(images_folder, "backgrounds")) - - user_icons_folder = os.path.join(user_data_folder, "user_icons") - if not os.path.isdir(user_icons_folder): - os.mkdir(user_icons_folder) - os.symlink(user_icons_folder, os.path.join(images_folder, "user_icons")) - - config_file = os.path.join(user_data_folder, "config.ini") - if not os.path.exists(config_file): - copyfile("default_config.ini", config_file) - read_config() - - user = User.query.first() - if not user: - add_edit_user(username="admin", password="admin") diff --git a/dashmachine/error_pages/routes.py b/dashmachine/error_pages/routes.py index 861f19d..10e4eb9 100755 --- a/dashmachine/error_pages/routes.py +++ b/dashmachine/error_pages/routes.py @@ -1,6 +1,6 @@ from flask import Blueprint, render_template -error_pages = Blueprint('error_pages', __name__) +error_pages = Blueprint("error_pages", __name__) # ------------------------------------------------------------------------------ @@ -8,14 +8,14 @@ error_pages = Blueprint('error_pages', __name__) # ------------------------------------------------------------------------------ @error_pages.app_errorhandler(404) def error_404(error): - return render_template('/error_pages/404.html'), 404 + return render_template("/error_pages/404.html"), 404 @error_pages.app_errorhandler(403) def error_403(error): - return render_template('/error_pages/403.html'), 403 + return render_template("/error_pages/403.html"), 403 @error_pages.app_errorhandler(500) def error_500(error): - return render_template('/error_pages/500.html'), 500 + return render_template("/error_pages/500.html"), 500 diff --git a/dashmachine/main/utils.py b/dashmachine/main/utils.py index dec7bb3..d62a0e5 100755 --- a/dashmachine/main/utils.py +++ b/dashmachine/main/utils.py @@ -1,6 +1,12 @@ +import os +from shutil import copyfile from configparser import ConfigParser + +from dashmachine.paths import dashmachine_folder, images_folder from dashmachine.main.models import Apps from dashmachine.settings_system.models import Settings +from dashmachine.user_system.models import User +from dashmachine.user_system.utils import add_edit_user from dashmachine import db @@ -77,3 +83,27 @@ def read_config(): def public_route(decorated_function): decorated_function.is_public = True return decorated_function + + +def dashmachine_init(): + user_data_folder = os.path.join(dashmachine_folder, "user_data") + + # create the user_data subdirectories, link them to static + user_backgrounds_folder = os.path.join(user_data_folder, "backgrounds") + if not os.path.isdir(user_backgrounds_folder): + os.mkdir(user_backgrounds_folder) + os.symlink(user_backgrounds_folder, os.path.join(images_folder, "backgrounds")) + + icons_folder = os.path.join(user_data_folder, "icons") + if not os.path.isdir(icons_folder): + os.mkdir(icons_folder) + os.symlink(icons_folder, os.path.join(images_folder, "icons")) + + config_file = os.path.join(user_data_folder, "config.ini") + if not os.path.exists(config_file): + copyfile("default_config.ini", config_file) + read_config() + + user = User.query.first() + if not user: + add_edit_user(username="admin", password="admin") \ No newline at end of file diff --git a/dashmachine/paths.py b/dashmachine/paths.py index a84f302..7397a4f 100755 --- a/dashmachine/paths.py +++ b/dashmachine/paths.py @@ -21,6 +21,8 @@ apps_images_folder = os.path.join(images_folder, "apps") backgrounds_images_folder = os.path.join(images_folder, "backgrounds") +icons_images_folder = os.path.join(images_folder, "icons") + cache_folder = os.path.join(static_folder, "cache") user_images_folder = os.path.join(images_folder, "user") diff --git a/dashmachine/rest_api/resources.py b/dashmachine/rest_api/resources.py index d7b5da5..0bad2d9 100755 --- a/dashmachine/rest_api/resources.py +++ b/dashmachine/rest_api/resources.py @@ -6,16 +6,16 @@ from dashmachine.version import tcmachine_version class GetVersion(Resource): def get(self): - return {'Version': tcmachine_version} + return {"Version": tcmachine_version} class ServerShutdown(Resource): def get(self): - os.system('shutdown now') - return {'Done'} + os.system("shutdown now") + return {"Done"} class ServerReboot(Resource): def get(self): - os.system('reboot') - return {'Done'} + os.system("reboot") + return {"Done"} diff --git a/dashmachine/settings_system/routes.py b/dashmachine/settings_system/routes.py index 7d93dfa..b3f4a6e 100644 --- a/dashmachine/settings_system/routes.py +++ b/dashmachine/settings_system/routes.py @@ -1,9 +1,10 @@ import os -from flask import render_template, url_for, redirect, request, Blueprint, jsonify +from flask import render_template, request, Blueprint, jsonify from dashmachine.settings_system.forms import ConfigForm +from dashmachine.user_system.forms import UserForm from dashmachine.main.utils import read_config from dashmachine.main.models import Files -from dashmachine.paths import backgrounds_images_folder, apps_images_folder +from dashmachine.paths import backgrounds_images_folder, icons_images_folder from dashmachine.settings_system.utils import load_files_html settings_system = Blueprint("settings_system", __name__) @@ -12,11 +13,12 @@ settings_system = Blueprint("settings_system", __name__) @settings_system.route("/settings", methods=["GET"]) def settings(): config_form = ConfigForm() + user_form = UserForm() with open("dashmachine/user_data/config.ini", "r") as config_file: config_form.config.data = config_file.read() files_html = load_files_html() return render_template( - "settings_system/settings.html", config_form=config_form, files_html=files_html + "settings_system/settings.html", config_form=config_form, files_html=files_html, user_form=user_form ) @@ -30,8 +32,8 @@ def save_config(): @settings_system.route("/settings/add_images", methods=["POST"]) def add_images(): - if request.form.get("folder") == "apps": - dest_folder = apps_images_folder + if request.form.get("folder") == "icons": + dest_folder = icons_images_folder elif request.form.get("folder") == "backgrounds": dest_folder = backgrounds_images_folder for cached_file in request.form.get("files").split(","): diff --git a/dashmachine/settings_system/utils.py b/dashmachine/settings_system/utils.py index 41b76d9..3ab494e 100644 --- a/dashmachine/settings_system/utils.py +++ b/dashmachine/settings_system/utils.py @@ -1,13 +1,13 @@ -from dashmachine.paths import backgrounds_images_folder, apps_images_folder +from dashmachine.paths import backgrounds_images_folder, icons_images_folder from flask import render_template from os import listdir def load_files_html(): - background_images = listdir(backgrounds_images_folder) - apps_images = listdir(apps_images_folder) + backgrounds = listdir(backgrounds_images_folder) + icons = listdir(icons_images_folder) return render_template( "settings_system/files.html", - background_images=background_images, - apps_images=apps_images, + backgrounds=backgrounds, + icons=icons, ) diff --git a/dashmachine/static/css/global/dashmachine.css b/dashmachine/static/css/global/dashmachine.css index b490bb2..92aad3f 100644 --- a/dashmachine/static/css/global/dashmachine.css +++ b/dashmachine/static/css/global/dashmachine.css @@ -766,11 +766,6 @@ span.badge.new { position: relative; right: 10px; } -.copy-btn { - position: relative; - top: 2px; - font-size: 1.25rem; -} /*FAB*/ .tap-target-wave::before, .tap-target-wave::after { diff --git a/dashmachine/static/images/icons b/dashmachine/static/images/icons new file mode 120000 index 0000000..445c4a8 --- /dev/null +++ b/dashmachine/static/images/icons @@ -0,0 +1 @@ +/home/ross/Dev/DashMachineEnv/DashMachine/dashmachine/user_data/icons \ No newline at end of file diff --git a/dashmachine/static/js/global/dashmachine.js b/dashmachine/static/js/global/dashmachine.js index 8f9a72f..50d9280 100644 --- a/dashmachine/static/js/global/dashmachine.js +++ b/dashmachine/static/js/global/dashmachine.js @@ -170,22 +170,6 @@ function init_autocomplete_chips(){ }); } -function init_send_doc_email_btns(el) { - el.on('click', function() { - let attachment_deal = $("#attachment-deal") - attachment_deal.val($(this).attr('data-deal_id')); - attachment_deal.trigger('change'); - sleep(100).then(() => { - let deal_doc = $("#deal-doc") - deal_doc.val($(this).attr('data-file')); - deal_doc.trigger('change'); - tinymce.get("email-panel-content").setContent($(this).attr('data-signature')); - $("#attachments").removeClass('hide'); - $("#email-panel").removeClass('hide'); - $("#chips-mailto input").trigger('focus'); - }); - }); -} function toggleDarkMode(){ let mode = localStorage.getItem('mode'); @@ -212,9 +196,10 @@ function toggleTooltips(){ } } -function init_copy_btn(){ +function init_copy_btn(parent_class){ $(".copy-btn").on('click', function(e) { - let target_text = $(this).closest('.col').find('.copy-target').text(); + let target_text = $(this).closest(parent_class).find('.copy-target').text(); + console.log(target_text) let copy_input = $("#copy-input"); copy_input.val(target_text); copy_input.removeClass("hide"); @@ -293,49 +278,6 @@ function initCleave(){ }); } -// TinyMCE Editor -function initTinyMCE(el){ - // Check TinyMCE initialized or not - if(tinyMCE.get(el)){ - // Remove instance by id - tinymce.remove('#' + el); - }else{ - let mode = localStorage.getItem('mode'); - let theme = "" - if (mode === 'dark') { - theme = "dark" - } else { - theme = "light" - } - tinymce.init({ - selector: '#' + el, - height: 200, - menubar: false, - removed_menuitems: 'undo, redo, anchor', - skin: theme, - statusbar: true, - branding: false, - paste_data_images: true, - force_br_newlines: true, - force_p_newlines: false, - forced_root_block: '', - content_style: "body {margin-top: 15px}", - visual_table_class: 'no-border', - mode: "exact", - plugins: [ - 'autolink lists link image charmap print preview anchor textcolor', - 'searchreplace visualblocks code fullscreen', - 'insertdatetime media table paste code help imagetools' - ], - toolbar: 'formatselect | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent fullscreen code', - content_css: [ - '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i', - '//www.tiny.cloud/css/codepen.min.css' - ] - }); - } -} - function hide_sidenav() { $("#main-sidenav").addClass('hide'); $("#main.main-full").css('padding-left', 0); @@ -361,7 +303,6 @@ $(document).ready(function () { init_timepicker(); initCleave(); init_tooltips(); - init_copy_btn(); init_select(); if (localStorage.getItem('sidenav_hidden') === 'true'){ diff --git a/dashmachine/templates/main/base.html b/dashmachine/templates/main/base.html index bb6ff2e..df5ffe1 100644 --- a/dashmachine/templates/main/base.html +++ b/dashmachine/templates/main/base.html @@ -63,7 +63,9 @@ {% block sidenav %}{% endblock sidenav %} - {% block content %}{% endblock content %} + {% block content %} + + {% endblock content %} {% block footer %}{% endblock footer %} diff --git a/dashmachine/templates/main/home.html b/dashmachine/templates/main/home.html index 04d00d1..4af7890 100755 --- a/dashmachine/templates/main/home.html +++ b/dashmachine/templates/main/home.html @@ -27,27 +27,40 @@
Variable | -Value | +Required | +Description | +Options |
---|---|---|---|---|
[Settings] | -config section name. required. | +Yes | +Config section name. | +string |
theme | -UI theme, options are light, dark | +Yes | +UI theme | +light, dark |
accent | -UI accent, options are orange, green, blue, green, pink, grey | +Yes | +UI accent color | +orange, green, blue, green, pink, grey |
background | -Background image. can be either a local link (prefixed by /static/images/backgrounds/) or an external link. Can also be set to random. If not set defaults to blank. | +Yes | +Background image for the UI | +/static/images/backgrounds/yourpicture.png, external link to image, None, random |