-
-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Restart Frontend returning an error, add ability to set custom la…
…yout.html
- Loading branch information
Showing
15 changed files
with
161 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
alembic_db/alembic/versions/9bdb60d2a2cd_add_custom_layout.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Add custom_layout | ||
Revision ID: 9bdb60d2a2cd | ||
Revises: d6b624da47f4 | ||
Create Date: 2024-09-03 13:44:20.678365 | ||
""" | ||
import sys | ||
import os | ||
|
||
sys.path.append(os.path.abspath(os.path.join(__file__, "../../../.."))) | ||
|
||
from alembic_db.alembic_post_utils import write_revision_post_alembic | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '9bdb60d2a2cd' | ||
down_revision = 'd6b624da47f4' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
with op.batch_alter_table("misc") as batch_op: | ||
batch_op.add_column(sa.Column('custom_layout', sa.Text)) | ||
|
||
op.execute( | ||
''' | ||
UPDATE misc | ||
SET custom_layout='' | ||
''' | ||
) | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table("misc") as batch_op: | ||
batch_op.drop_column('custom_layout') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# layouts.py - Mycodo core utils | ||
# | ||
# Copyright (C) 2015-2020 Kyle T. Gabriel <[email protected]> | ||
# | ||
# This file is part of Mycodo | ||
# | ||
# Mycodo is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Mycodo is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Mycodo. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Contact at kylegabriel.com | ||
|
||
import logging | ||
import os | ||
import shutil | ||
|
||
from mycodo.config import PATH_TEMPLATE_LAYOUT | ||
from mycodo.config import PATH_TEMPLATE_LAYOUT_DEFAULT | ||
|
||
logger = logging.getLogger("mycodo.utils.layouts") | ||
|
||
|
||
def update_layout(custom_layout): | ||
try: | ||
if custom_layout: | ||
# Use custom layout | ||
with open(PATH_TEMPLATE_LAYOUT, "w") as template: | ||
template.write(custom_layout) | ||
else: | ||
# Use default layout | ||
if (os.path.exists(PATH_TEMPLATE_LAYOUT) and | ||
not os.path.samefile(PATH_TEMPLATE_LAYOUT, PATH_TEMPLATE_LAYOUT_DEFAULT)): | ||
# Delete current layout if it's different from the default | ||
os.remove(PATH_TEMPLATE_LAYOUT) | ||
shutil.copy(PATH_TEMPLATE_LAYOUT_DEFAULT, PATH_TEMPLATE_LAYOUT) | ||
except: | ||
logger.exception("Generating layout") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.