mirror of
https://github.com/Casvt/MIND.git
synced 2026-02-19 11:54:46 -05:00
3
MIND.py
3
MIND.py
@@ -17,7 +17,7 @@ from frontend.ui import ui
|
||||
|
||||
HOST = '0.0.0.0'
|
||||
PORT = '8080'
|
||||
URL_PREFIX = '' # Must start with '/' e.g. '/mind'
|
||||
URL_PREFIX = '' # Must either be empty or start with '/' e.g. '/mind'
|
||||
THREADS = 10
|
||||
DB_FILENAME = 'db', 'MIND.db'
|
||||
|
||||
@@ -74,6 +74,7 @@ def MIND() -> None:
|
||||
# Check python version
|
||||
if (version_info.major < 3) or (version_info.major == 3 and version_info.minor < 7):
|
||||
print('Error: the minimum python version required is python3.7 (currently ' + version_info.major + '.' + version_info.minor + '.' + version_info.micro + ')')
|
||||
exit(1)
|
||||
|
||||
# Register web server
|
||||
# We need to get the value to ui.py but MIND.py imports from ui.py so we get an import loop.
|
||||
|
||||
@@ -8,7 +8,7 @@ from typing import Union
|
||||
|
||||
from flask import g
|
||||
|
||||
__DATABASE_VERSION__ = 3
|
||||
__DATABASE_VERSION__ = 4
|
||||
|
||||
class Singleton(type):
|
||||
_instances = {}
|
||||
@@ -90,6 +90,15 @@ def migrate_db(current_db_version: int) -> None:
|
||||
ADD color VARCHAR(7);
|
||||
""")
|
||||
current_db_version = 3
|
||||
|
||||
if current_db_version == 3:
|
||||
# V3 -> V4
|
||||
cursor.executescript("""
|
||||
UPDATE reminders
|
||||
SET repeat_quantity = repeat_quantity || 's'
|
||||
WHERE repeat_quantity NOT LIKE '%s';
|
||||
""")
|
||||
current_db_version = 4
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from datetime import datetime
|
||||
from sqlite3 import IntegrityError
|
||||
from threading import Thread
|
||||
from time import sleep
|
||||
from time import time as epoch_time
|
||||
from typing import List, Literal
|
||||
|
||||
from apprise import Apprise
|
||||
@@ -24,7 +23,7 @@ filter_function = lambda query, p: (
|
||||
|
||||
def _find_next_time(
|
||||
original_time: int,
|
||||
repeat_quantity: Literal["year", "month", "week", "day", "hours", "minutes"],
|
||||
repeat_quantity: Literal["years", "months", "weeks", "days", "hours", "minutes"],
|
||||
repeat_interval: int
|
||||
) -> int:
|
||||
td = relativedelta(**{repeat_quantity: repeat_interval})
|
||||
@@ -176,7 +175,7 @@ class Reminder:
|
||||
time: int = None,
|
||||
notification_service: int = None,
|
||||
text: str = None,
|
||||
repeat_quantity: Literal["year", "month", "week", "day", "hours", "minutes"] = None,
|
||||
repeat_quantity: Literal["years", "months", "weeks", "days", "hours", "minutes"] = None,
|
||||
repeat_interval: int = None,
|
||||
color: str = None
|
||||
) -> dict:
|
||||
@@ -187,7 +186,7 @@ class Reminder:
|
||||
time (int): The new UTC epoch timestamp the the reminder should be send. Defaults to None.
|
||||
notification_service (int): The new id of the notification service to use to send the reminder. Defaults to None.
|
||||
text (str, optional): The new body of the reminder. Defaults to None.
|
||||
repeat_quantity (Literal["year", "month", "week", "day", "hours", "minutes"], optional): The new quantity of the repeat specified for the reminder. Defaults to None.
|
||||
repeat_quantity (Literal["years", "months", "weeks", "days", "hours", "minutes"], optional): The new quantity of the repeat specified for the reminder. Defaults to None.
|
||||
repeat_interval (int, optional): The new amount of repeat_quantity, like "5" (hours). Defaults to None.
|
||||
color (str, optional): The new hex code of the color of the reminder, which is shown in the web-ui. Defaults to None.
|
||||
|
||||
@@ -358,7 +357,7 @@ class Reminders:
|
||||
time: int,
|
||||
notification_service: int,
|
||||
text: str = '',
|
||||
repeat_quantity: Literal["year", "month", "week", "day", "hours", "minutes"] = None,
|
||||
repeat_quantity: Literal["years", "months", "weeks", "days", "hours", "minutes"] = None,
|
||||
repeat_interval: int = None,
|
||||
color: str = None
|
||||
) -> Reminder:
|
||||
@@ -369,7 +368,7 @@ class Reminders:
|
||||
time (int): The UTC epoch timestamp the the reminder should be send.
|
||||
notification_service (int): The id of the notification service to use to send the reminder.
|
||||
text (str, optional): The body of the reminder. Defaults to ''.
|
||||
repeat_quantity (Literal["year", "month", "week", "day", "hours", "minutes"], optional): The quantity of the repeat specified for the reminder. Defaults to None.
|
||||
repeat_quantity (Literal["years", "months", "weeks", "days", "hours", "minutes"], optional): The quantity of the repeat specified for the reminder. Defaults to None.
|
||||
repeat_interval (int, optional): The amount of repeat_quantity, like "5" (hours). Defaults to None.
|
||||
color (str, optional): The hex code of the color of the reminder, which is shown in the web-ui. Defaults to None.
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ def extract_key(values: dict, key: str, check_existence: bool=True) -> Any:
|
||||
raise InvalidKeyValue(key, value)
|
||||
|
||||
elif key == 'repeat_quantity':
|
||||
if not value in ("year", "month", "week", "day", "hours", "minutes"):
|
||||
if not value in ("years", "months", "weeks", "days", "hours", "minutes"):
|
||||
raise InvalidKeyValue(key, value)
|
||||
|
||||
elif key in ('username', 'password', 'new_password', 'title', 'url',
|
||||
@@ -414,7 +414,7 @@ def api_reminders_list():
|
||||
time (required): the UTC epoch timestamp that the reminder should be sent at
|
||||
notification_service (required): the id of the notification service to use to send the notification
|
||||
text: the body of the reminder
|
||||
repeat_quantity ('year', 'month', 'week', 'day', 'hours', 'minutes'): The quantity of the repeat_interval
|
||||
repeat_quantity ('years', 'months', 'weeks', 'days', 'hours', 'minutes'): The quantity of the repeat_interval
|
||||
repeat_interval: The number of the interval
|
||||
color: The hex code of the color of the reminder, which is shown in the web-ui
|
||||
Returns:
|
||||
@@ -527,7 +527,7 @@ def api_get_reminder(r_id: int):
|
||||
time: The new UTC epoch timestamp the the reminder should be send.
|
||||
notification_service: The new id of the notification service to use to send the reminder.
|
||||
text: The new body of the reminder.
|
||||
repeat_quantity ('year', 'month', 'week', 'day', 'hours', 'minutes'): The new quantity of the repeat_interval.
|
||||
repeat_quantity ('years', 'months', 'weeks', 'days', 'hours', 'minutes'): The new quantity of the repeat_interval.
|
||||
repeat_interval: The new number of the interval.
|
||||
color: The new hex code of the color of the reminder, which is shown in the web-ui.
|
||||
Returns:
|
||||
|
||||
@@ -4,7 +4,7 @@ function logout() {
|
||||
})
|
||||
.then(response => {
|
||||
sessionStorage.removeItem('api_key');
|
||||
window.location.href = url_prefix;
|
||||
window.location.href = url_prefix || '/';
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -174,10 +174,10 @@
|
||||
<select id="repeat-quantity">
|
||||
<option value="minutes">Minute(s)</option>
|
||||
<option value="hours">Hour(s)</option>
|
||||
<option value="day" selected>Day(s)</option>
|
||||
<option value="week">Week(s)</option>
|
||||
<option value="month">Month(s)</option>
|
||||
<option value="year">Year(s)</option>
|
||||
<option value="days" selected>Day(s)</option>
|
||||
<option value="weeks">Week(s)</option>
|
||||
<option value="months">Month(s)</option>
|
||||
<option value="years">Year(s)</option>
|
||||
</select>
|
||||
</div>
|
||||
<textarea id="text-input" cols="30" rows="10" placeholder="Text (optional)"></textarea>
|
||||
@@ -227,10 +227,10 @@
|
||||
<select id="repeat-edit-quantity">
|
||||
<option value="minutes">Minute(s)</option>
|
||||
<option value="hours">Hour(s)</option>
|
||||
<option value="day" selected>Day(s)</option>
|
||||
<option value="week">Week(s)</option>
|
||||
<option value="month">Month(s)</option>
|
||||
<option value="year">Year(s)</option>
|
||||
<option value="days" selected>Day(s)</option>
|
||||
<option value="weeks">Week(s)</option>
|
||||
<option value="months">Month(s)</option>
|
||||
<option value="years">Year(s)</option>
|
||||
</select>
|
||||
</div>
|
||||
<textarea id="text-edit-input" cols="30" rows="10" placeholder="Text (optional)"></textarea>
|
||||
|
||||
Reference in New Issue
Block a user