From 1e46c19f1bfa3416db8fd588b5b76105e285622f Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Wed, 12 Mar 2025 11:29:30 +0100 Subject: [PATCH] Fix --- appinfo.xml | 9 ----- appinfo/app.php | 25 ++++++++++++++ assets/js/deckflow.js | 4 +++ composer.json | 22 ------------- controller/DeckflowController.php | 37 +++++++++++++++++++++ lib/Migrations/Version20250312000000.php | 27 +++++++++++++++ lib/WorkflowJob.php | 18 ++++++++++ lib/WorkflowRepository.php | 42 ++++++++++++++++++++++++ resources/css/style.css | 9 +++++ src/BackgroundJob/WorkflowJob.php | 22 ------------- src/Controller/DeckflowController.php | 32 ------------------ src/Db/WorkflowMapper.php | 20 ----------- src/Model/Workflow.php | 25 -------------- templates/main.php | 40 ++++++++++++++++++++++ 14 files changed, 202 insertions(+), 130 deletions(-) delete mode 100644 appinfo.xml create mode 100644 appinfo/app.php create mode 100644 assets/js/deckflow.js delete mode 100644 composer.json create mode 100644 controller/DeckflowController.php create mode 100644 lib/Migrations/Version20250312000000.php create mode 100644 lib/WorkflowJob.php create mode 100644 lib/WorkflowRepository.php create mode 100644 resources/css/style.css delete mode 100644 src/BackgroundJob/WorkflowJob.php delete mode 100644 src/Controller/DeckflowController.php delete mode 100644 src/Db/WorkflowMapper.php delete mode 100644 src/Model/Workflow.php create mode 100644 templates/main.php diff --git a/appinfo.xml b/appinfo.xml deleted file mode 100644 index 1a23cd3..0000000 --- a/appinfo.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - deckflow - Deckflow - Automatische Workflows für Nextcloud Decks - 1.0.0 - Dein Name - GPL-3.0 - \ No newline at end of file diff --git a/appinfo/app.php b/appinfo/app.php new file mode 100644 index 0000000..760bdb3 --- /dev/null +++ b/appinfo/app.php @@ -0,0 +1,25 @@ +getContainer(); + $container->registerService('DeckflowController', function (IContainer $c) { + return new DeckflowController($c['AppName'], $c); + }); + + // Migration ausführen + \OC::$server->getMigrationService()->registerMigration(Version20250312000000::class); + + \OC::$server->getBackgroundJobManager()->add(new WorkflowJob()); + + } +} diff --git a/assets/js/deckflow.js b/assets/js/deckflow.js new file mode 100644 index 0000000..f02f555 --- /dev/null +++ b/assets/js/deckflow.js @@ -0,0 +1,4 @@ +// deckflow.js +document.addEventListener('DOMContentLoaded', function () { + // JS für das Bearbeiten oder Löschen von Workflows +}); diff --git a/composer.json b/composer.json deleted file mode 100644 index 682248b..0000000 --- a/composer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "deckflow/deckflow", - "description": "Automatische Workflows für Nextcloud Decks", - "type": "nextcloud-app", - "version": "1.0.0", - "license": "GPL-3.0", - "authors": [ - { - "name": "Dein Name", - "email": "deine@email.de" - } - ], - "require": { - "php": "^7.2", - "nextcloud/app-framework": "^1.0" - }, - "autoload": { - "psr-4": { - "Deckflow\\": "src/" - } - } - } \ No newline at end of file diff --git a/controller/DeckflowController.php b/controller/DeckflowController.php new file mode 100644 index 0000000..826295c --- /dev/null +++ b/controller/DeckflowController.php @@ -0,0 +1,37 @@ +workflowRepo = new WorkflowRepository(); + } + + // Zeigt alle Workflows des Benutzers an + public function getWorkflows() { + $user_id = \OC::$server->getUserManager()->getUser()->getUID(); + $workflows = $this->workflowRepo->getWorkflowsForUser($user_id); + return $this->render('main.php', ['workflows' => $workflows]); + } + + // Workflow erstellen + public function createWorkflow($deck_id, $source_stack_id, $target_stack_id) { + $user_id = \OC::$server->getUserManager()->getUser()->getUID(); + $this->workflowRepo->createWorkflow($user_id, $deck_id, $source_stack_id, $target_stack_id); + return $this->getWorkflows(); + } + + // Workflow löschen + public function deleteWorkflow($workflow_id) { + $this->workflowRepo->deleteWorkflow($workflow_id); + return $this->getWorkflows(); + } +} diff --git a/lib/Migrations/Version20250312000000.php b/lib/Migrations/Version20250312000000.php new file mode 100644 index 0000000..766e901 --- /dev/null +++ b/lib/Migrations/Version20250312000000.php @@ -0,0 +1,27 @@ +output('Erstelle die deckflow_workflows-Tabelle...'); + + $query = 'CREATE TABLE IF NOT EXISTS `*deckflow_workflows` ( + `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + `user_id` VARCHAR(255) NOT NULL, + `deck_id` INT NOT NULL, + `source_stack_id` INT NOT NULL, + `target_stack_id` INT NOT NULL, + `created_at` DATETIME NOT NULL, + `last_run` DATETIME DEFAULT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;'; + + \OC::$server->getDatabaseConnection()->executeQuery($query); + + $output->output('Migration abgeschlossen.'); + } +} diff --git a/lib/WorkflowJob.php b/lib/WorkflowJob.php new file mode 100644 index 0000000..187e967 --- /dev/null +++ b/lib/WorkflowJob.php @@ -0,0 +1,18 @@ +getOverdueWorkflows(); + + foreach ($overdueWorkflows as $workflow) { + $workflowRepo->moveCardToTargetStack($workflow['card_id'], $workflow['target_stack_id']); + } + } +} diff --git a/lib/WorkflowRepository.php b/lib/WorkflowRepository.php new file mode 100644 index 0000000..814fca5 --- /dev/null +++ b/lib/WorkflowRepository.php @@ -0,0 +1,42 @@ +db = DB::getConnection(); + } + + // Alle Workflows eines Benutzers abrufen + public function getWorkflowsForUser($user_id) { + $query = 'SELECT * FROM *deckflow_workflows WHERE user_id = ?'; + return $this->db->executeQuery($query, [$user_id])->fetchAll(); + } + + // Workflow erstellen + public function createWorkflow($user_id, $deck_id, $source_stack_id, $target_stack_id) { + $query = 'INSERT INTO *deckflow_workflows (user_id, deck_id, source_stack_id, target_stack_id, created_at) VALUES (?, ?, ?, ?, ?)'; + $this->db->executeQuery($query, [$user_id, $deck_id, $source_stack_id, $target_stack_id, date('Y-m-d H:i:s')]); + } + + // Workflow löschen + public function deleteWorkflow($workflow_id) { + $query = 'DELETE FROM *deckflow_workflows WHERE id = ?'; + $this->db->executeQuery($query, [$workflow_id]); + } + + // Workflows mit überfälligen Karten abrufen + public function getOverdueWorkflows() { + // Logik zum Abrufen überfälliger Karten + } + + // Karte verschieben + public function moveCardToTargetStack($card_id, $target_stack_id) { + // Logik zum Verschieben von Karten + } +} diff --git a/resources/css/style.css b/resources/css/style.css new file mode 100644 index 0000000..dd4c7fd --- /dev/null +++ b/resources/css/style.css @@ -0,0 +1,9 @@ +/* style.css */ +form { + margin: 20px 0; +} +button { + padding: 10px; + background-color: #007bff; + color: white; +} diff --git a/src/BackgroundJob/WorkflowJob.php b/src/BackgroundJob/WorkflowJob.php deleted file mode 100644 index 1f77570..0000000 --- a/src/BackgroundJob/WorkflowJob.php +++ /dev/null @@ -1,22 +0,0 @@ -workflowMapper = $workflowMapper; - } - - protected function run($argument) - { - // Hier kommt die Logik für das Ausführen des Workflows hin - } -} \ No newline at end of file diff --git a/src/Controller/DeckflowController.php b/src/Controller/DeckflowController.php deleted file mode 100644 index 0e591bc..0000000 --- a/src/Controller/DeckflowController.php +++ /dev/null @@ -1,32 +0,0 @@ -request = $request; - } - - public function index() - { - return new TemplateResponse('deckflow', 'index'); - } - - public function createWorkflow() - { - // Hier kommt die Logik für das Erstellen eines Workflows hin - } - - public function editWorkflow() - { - // Hier kommt die Logik für das Bearbeiten eines Workflows hin - } -} \ No newline at end of file diff --git a/src/Db/WorkflowMapper.php b/src/Db/WorkflowMapper.php deleted file mode 100644 index 008aaa8..0000000 --- a/src/Db/WorkflowMapper.php +++ /dev/null @@ -1,20 +0,0 @@ -?php - -namespace Deckflow\Db; - -use OCP\AppFramework\Db\Mapper; -use Deckflow\Model\Workflow; - -class WorkflowMapper extends Mapper -{ - public function __construct(\OCP\IDBConnection $db) - { - parent::__construct($db, 'deckflow_workflows', Workflow::class); - } - - public function findWorkflowsByUserId($userId) - { - $sql = 'SELECT * FROM deckflow_workflows WHERE user_id = ?'; - return $this->findEntities($sql, [$userId]); - } -} \ No newline at end of file diff --git a/src/Model/Workflow.php b/src/Model/Workflow.php deleted file mode 100644 index 5d9f8fe..0000000 --- a/src/Model/Workflow.php +++ /dev/null @@ -1,25 +0,0 @@ -addType('id', 'integer'); - $this->addType('userId', 'string'); - $this->addType('deckId', 'integer'); - $this->addType('sourceStackId', 'integer'); - $this->addType('targetStackId', 'integer'); - $this->addType('createdAt', 'timestamp'); - } -} \ No newline at end of file diff --git a/templates/main.php b/templates/main.php new file mode 100644 index 0000000..9814038 --- /dev/null +++ b/templates/main.php @@ -0,0 +1,40 @@ +assign('workflows', $workflows); + +echo $view->render(); +?> + + +
+ + + + + + + + + + +
+ + +