Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a40b06354 | ||
|
|
117d3a2029 | ||
|
|
478091b0ba | ||
|
|
08b3b06089 | ||
|
|
1c7d38fc15 | ||
|
|
350da88802 | ||
|
|
29cdf7bb7e |
@@ -25,7 +25,6 @@ RUN uv pip install . --system
|
|||||||
|
|
||||||
ENV APP_ENV=production
|
ENV APP_ENV=production
|
||||||
ENV PORT=5000
|
ENV PORT=5000
|
||||||
EXPOSE ${PORT}
|
|
||||||
ENV BIND=0.0.0.0
|
ENV BIND=0.0.0.0
|
||||||
|
|
||||||
COPY --from=front-end /app/dist ./dist
|
COPY --from=front-end /app/dist ./dist
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
from tortoise import migrations
|
||||||
|
from tortoise.migrations import operations as ops
|
||||||
|
from tortoise import fields
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [('models', '0001_initial')]
|
||||||
|
|
||||||
|
initial = False
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
ops.AlterField(
|
||||||
|
model_name='Task',
|
||||||
|
name='list_name',
|
||||||
|
field=fields.CharField(db_index=True, max_length=128),
|
||||||
|
),
|
||||||
|
ops.AlterField(
|
||||||
|
model_name='Task',
|
||||||
|
name='reset_cron',
|
||||||
|
field=fields.CharField(null=True, max_length=64),
|
||||||
|
),
|
||||||
|
]
|
||||||
+1
-1
@@ -10,7 +10,7 @@ CRONTAB_REGEX = r"^(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@eve
|
|||||||
|
|
||||||
|
|
||||||
class Task(AbstractModel):
|
class Task(AbstractModel):
|
||||||
list_name = tortoise.fields.CharField(max_length=32, db_index=True, null=False)
|
list_name = tortoise.fields.CharField(max_length=128, db_index=True, null=False)
|
||||||
name = tortoise.fields.TextField(null=False)
|
name = tortoise.fields.TextField(null=False)
|
||||||
reset_cron = tortoise.fields.CharField(
|
reset_cron = tortoise.fields.CharField(
|
||||||
max_length=64,
|
max_length=64,
|
||||||
|
|||||||
+2
-2
@@ -58,13 +58,13 @@ class Server(gunicorn.app.base.BaseApplication):
|
|||||||
|
|
||||||
@self.app.route("/api/lists/<list_name>/tasks", methods=["GET"])
|
@self.app.route("/api/lists/<list_name>/tasks", methods=["GET"])
|
||||||
async def get_tasks(list_name: str) -> list:
|
async def get_tasks(list_name: str) -> list:
|
||||||
return await Task.filter(list_name=list_name).values()
|
return await Task.filter(list_name=list_name[:128]).values()
|
||||||
|
|
||||||
@self.app.route("/api/lists/<list_name>/tasks", methods=["POST"])
|
@self.app.route("/api/lists/<list_name>/tasks", methods=["POST"])
|
||||||
async def post_task(list_name: str) -> typing.Any:
|
async def post_task(list_name: str) -> typing.Any:
|
||||||
data = flask.request.get_json()
|
data = flask.request.get_json()
|
||||||
logging.getLogger(self.__class__.__name__).info("%s", data)
|
logging.getLogger(self.__class__.__name__).info("%s", data)
|
||||||
data["list_name"] = list_name
|
data["list_name"] = list_name[:128]
|
||||||
parsed_data = Task.validate_create(data)
|
parsed_data = Task.validate_create(data)
|
||||||
if parsed_data is None:
|
if parsed_data is None:
|
||||||
flask.abort(400)
|
flask.abort(400)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tout-doux",
|
"name": "tout-doux",
|
||||||
"version": "1.0.1",
|
"version": "1.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "tout-doux"
|
name = "tout-doux"
|
||||||
version = "1.0.1"
|
version = "1.0.4"
|
||||||
description = ""
|
description = ""
|
||||||
requires-python = ">=3.14"
|
requires-python = ">=3.14"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onBeforeMount, ref, watch, computed, defineAsyncComponent } from "vue";
|
import { onBeforeMount, ref, watch, computed, defineAsyncComponent, nextTick } from "vue";
|
||||||
import type { Task } from "@/types";
|
import type { Task } from "@/types";
|
||||||
import { CopyIcon, TrashIcon, SaveIcon, XIcon } from "@lucide/vue";
|
import { CopyIcon, TrashIcon, SaveIcon, XIcon } from "@lucide/vue";
|
||||||
import { updateTask } from "@/api/tasks";
|
import { updateTask } from "@/api/tasks";
|
||||||
@@ -11,7 +11,8 @@ import { relativeTime } from "@/lib/dates";
|
|||||||
import { useAlertStore } from "@/stores/alerts";
|
import { useAlertStore } from "@/stores/alerts";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
const emit = defineEmits<(e: "clone" | "delete" | "updated", task: Task) => void>();
|
const emit =
|
||||||
|
defineEmits<(e: "clone" | "delete" | "updated", task: Task) => void>();
|
||||||
|
|
||||||
const task = defineModel<Task>({ required: true });
|
const task = defineModel<Task>({ required: true });
|
||||||
defineProps<{ showLastChecked: boolean; showNextReset: boolean }>();
|
defineProps<{ showLastChecked: boolean; showNextReset: boolean }>();
|
||||||
@@ -20,6 +21,7 @@ const editMode = ref<boolean>(false);
|
|||||||
const editName = ref<string>("");
|
const editName = ref<string>("");
|
||||||
const editCron = ref<string | null>(null);
|
const editCron = ref<string | null>(null);
|
||||||
const refreshKey = ref<number>(0);
|
const refreshKey = ref<number>(0);
|
||||||
|
const editNameInput = ref<HTMLInputElement | null>(null);
|
||||||
|
|
||||||
const checked = computed<boolean>(() => taskCompleted(task.value));
|
const checked = computed<boolean>(() => taskCompleted(task.value));
|
||||||
const nextReset = computed<Date | null>(() => taskNextReset(task.value));
|
const nextReset = computed<Date | null>(() => taskNextReset(task.value));
|
||||||
@@ -28,13 +30,22 @@ const i18n = useI18n();
|
|||||||
|
|
||||||
const { alertSuccess, alertError } = useAlertStore();
|
const { alertSuccess, alertError } = useAlertStore();
|
||||||
|
|
||||||
|
async function onOpen() {
|
||||||
|
editMode.value = true;
|
||||||
|
await nextTick();
|
||||||
|
editNameInput.value?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
function onClose() {
|
function onClose() {
|
||||||
|
editName.value = task.value.name;
|
||||||
|
editCron.value = task.value.reset_cron;
|
||||||
editMode.value = false;
|
editMode.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSave() {
|
function onSave() {
|
||||||
|
if (editName.value.trim()) {
|
||||||
updateTask(task.value.id, {
|
updateTask(task.value.id, {
|
||||||
name: editName.value,
|
name: editName.value.trim(),
|
||||||
reset_cron: editCron.value,
|
reset_cron: editCron.value,
|
||||||
})
|
})
|
||||||
.then((newTask) => {
|
.then((newTask) => {
|
||||||
@@ -48,6 +59,7 @@ function onSave() {
|
|||||||
task.value.name = editName.value;
|
task.value.name = editName.value;
|
||||||
task.value.reset_cron = editCron.value;
|
task.value.reset_cron = editCron.value;
|
||||||
editMode.value = false;
|
editMode.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCheck() {
|
function onCheck() {
|
||||||
@@ -117,7 +129,7 @@ watch(task, () => {
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="cursor-pointer text-lg select-none"
|
class="cursor-pointer text-lg select-none"
|
||||||
@click.prevent="editMode = true"
|
@click.prevent="onOpen"
|
||||||
>
|
>
|
||||||
<div>{{ task.name }}</div>
|
<div>{{ task.name }}</div>
|
||||||
<div
|
<div
|
||||||
@@ -131,7 +143,8 @@ watch(task, () => {
|
|||||||
v-if="showNextReset && checked && nextReset"
|
v-if="showNextReset && checked && nextReset"
|
||||||
class="font-light text-xs italic"
|
class="font-light text-xs italic"
|
||||||
>
|
>
|
||||||
{{ $t("resets") }} {{ relativeTime(nextReset, $i18n.locale) }}
|
{{ $t("resets") }}
|
||||||
|
{{ relativeTime(nextReset, $i18n.locale) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -141,7 +154,13 @@ watch(task, () => {
|
|||||||
<button class="btn btn-square me-1" @click="onClose">
|
<button class="btn btn-square me-1" @click="onClose">
|
||||||
<x-icon />
|
<x-icon />
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-square me-1" @click="onSave">
|
<button
|
||||||
|
class="btn btn-square me-1"
|
||||||
|
:class="
|
||||||
|
editName.trim().length === 0 ? 'btn-disabled' : ''
|
||||||
|
"
|
||||||
|
@click="onSave"
|
||||||
|
>
|
||||||
<save-icon />
|
<save-icon />
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-square me-1" @click="onClone">
|
<button class="btn btn-square me-1" @click="onClone">
|
||||||
@@ -151,7 +170,13 @@ watch(task, () => {
|
|||||||
<trash-icon />
|
<trash-icon />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<input v-model="editName" type="text" class="input w-full" />
|
<input
|
||||||
|
ref="editNameInput"
|
||||||
|
v-model="editName"
|
||||||
|
type="text"
|
||||||
|
class="input w-full"
|
||||||
|
@keyup.enter="onSave"
|
||||||
|
/>
|
||||||
<cron-input v-model="editCron" :edit-mode="editMode" />
|
<cron-input v-model="editCron" :edit-mode="editMode" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { shareLink } from "@/lib/share";
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const list = ref<string | null>(null);
|
const list = ref<string | null>(null);
|
||||||
|
const loading = ref<boolean>(true);
|
||||||
const taskInput = ref<string>("");
|
const taskInput = ref<string>("");
|
||||||
const tasks = ref<Task[]>([]);
|
const tasks = ref<Task[]>([]);
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ function fetchTasks() {
|
|||||||
.then((data: Task[]) => {
|
.then((data: Task[]) => {
|
||||||
tasks.value = data;
|
tasks.value = data;
|
||||||
reSortTasks();
|
reSortTasks();
|
||||||
|
loading.value = false;
|
||||||
setTimeout(fetchTasks, 10000);
|
setTimeout(fetchTasks, 10000);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -72,7 +74,7 @@ function reSortTasks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onNewTask() {
|
function onNewTask() {
|
||||||
if (taskInput.value.trim() && list.value) {
|
if (taskInput.value.trim() && list.value && !loading.value) {
|
||||||
createTask(list.value, {
|
createTask(list.value, {
|
||||||
name: taskInput.value.trim(),
|
name: taskInput.value.trim(),
|
||||||
reset_cron: null,
|
reset_cron: null,
|
||||||
@@ -150,12 +152,12 @@ function updateTitle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
list.value = route.params.list as string;
|
list.value = (route.params.list as string).slice(0, 128);
|
||||||
fetchTasks();
|
fetchTasks();
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeRouteUpdate((to) => {
|
onBeforeRouteUpdate((to) => {
|
||||||
list.value = to.params.list as string;
|
list.value = (to.params.list as string).slice(0, 128);
|
||||||
fetchTasks();
|
fetchTasks();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -179,7 +181,7 @@ onBeforeRouteUpdate((to) => {
|
|||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
<li
|
<li
|
||||||
v-if="empty"
|
v-if="!loading && empty"
|
||||||
class="list-row italic text-xl font-extralight self-center"
|
class="list-row italic text-xl font-extralight self-center"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -188,7 +190,7 @@ onBeforeRouteUpdate((to) => {
|
|||||||
></span>
|
></span>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
v-else-if="allCompleted && separateCompleted"
|
v-else-if="!loading && allCompleted && separateCompleted"
|
||||||
class="list-row italic text-xl font-extralight self-center"
|
class="list-row italic text-xl font-extralight self-center"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -209,7 +211,7 @@ onBeforeRouteUpdate((to) => {
|
|||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
class="btn btn-square"
|
class="btn btn-square"
|
||||||
:disabled="taskInput.trim().length === 0"
|
:disabled="loading || taskInput.trim().length === 0"
|
||||||
@click="onNewTask"
|
@click="onNewTask"
|
||||||
>
|
>
|
||||||
<circle-plus-icon />
|
<circle-plus-icon />
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ asyncpg = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tout-doux"
|
name = "tout-doux"
|
||||||
version = "1.0.1"
|
version = "1.0.4"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "flask", extra = ["async"] },
|
{ name = "flask", extra = ["async"] },
|
||||||
|
|||||||
Reference in New Issue
Block a user