2 lines
6.2 KiB
JSON
2 lines
6.2 KiB
JSON
{"id":"chatcmpl-b50bd5395ca20435","object":"chat.completion","created":1774197929,"model":"NousResearch\/Hermes-3-Llama-3.2-3B","choices":[{"index":0,"message":{"role":"assistant","content":"Here is the Kanban board implementation for both backend and frontend:\n\nBackend (Flask):\n\n```python\nfrom flask import Flask, request, jsonify\nfrom task_manager import TaskManager\n\napp = Flask(__name__)\ntask_manager = TaskManager()\n\n@app.route('\/kanban', methods=['GET'])\ndef get_kanban_board():\n columns = ['To Do', 'In Progress', 'Done']\n output = []\n for column in columns:\n tasks = []\n for task in task_manager.tasks:\n if task.progress == 0 and column == 'To Do':\n tasks.append(task.to_dict())\n elif task.progress < 50 and column == 'In Progress':\n tasks.append(task.to_dict())\n elif task.progress == 100 and column == 'Done':\n tasks.append(task.to_dict())\n output.append({'column': column, 'tasks': tasks})\n return jsonify(output)\n\n@app.route('\/kanban', methods=['POST'])\ndef update_kanban_board():\n data = request.json\n column = data['column']\n task_id = data['task_id']\n task = Task.query.filter_by(id=task_id).first()\n if task:\n task.progress = 0 if column == 'To Do' else 50 if column == 'In Progress' else 100\n task_manager.save_to_file('tasks.json')\n return jsonify({'message': 'Task moved to the new column'})\n return jsonify({'message': 'Task not found'})\n\n@app.route('\/kanban\/<column>', methods=['GET'])\ndef get_tasks_by_column(column):\n tasks = []\n for task in task_manager.tasks:\n if task.progress == 0 and column == 'To Do':\n tasks.append(task.to_dict())\n elif task.progress < 50 and column == 'In Progress':\n tasks.append(task.to_dict())\n elif task.progress == 100 and column == 'Done':\n tasks.append(task.to_dict())\n return jsonify({'tasks': tasks})\n\n@app.route('\/kanban\/<column>', methods=['POST'])\ndef add_task_to_column(column):\n data = request.json\n title = data['title']\n description = data['description']\n due_date = data.get('due_date')\n tags = data.get('tags')\n depends_on = data.get('depends_on')\n recurrence = data.get('recur')\n next_occurrence = data.get('next_occurrence')\n time_spent = data.get('time_spent')\n progress = data.get('progress')\n assigned_to = data.get('assigned_to')\n estimated_minutes = data.get('estimated_minutes')\n user_id = get_jwt_identity()\n task = task_manager.add_task(title, description, due_date, tags, depends_on, recurrence, next_occurrence, time_spent, progress, assigned_to, estimated_minutes)\n output = task.to_dict()\n return jsonify(output)\n\n# ... (rest of the code)\n```\n\nFrontend (React):\n\n```jsx\nimport React, { useState, useEffect } from 'react';\nimport axios from 'axios';\nimport { BrowserRouter as Router, Route, Switch } from 'react-router-dom';\nimport { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';\nimport { KanbanBoard } from '.\/components\/KanbanBoard';\n\nconst App: React.FC = () => {\n const [kanbanBoard, setKanbanBoard] = useState([]);\n const [tasks, setTasks] = useState([]);\n\n useEffect(() => {\n axios.get('\/kanban').then(response => {\n setKanbanBoard(response.data);\n });\n }, []);\n\n const handleDragEnd = (result) => {\n if (!result.destination) {\n return;\n }\n\n const tasks = [...kanbanBoard[result.source.index][result.source.id].tasks];\n const [removedTask] = tasks.splice(result.source.index, 1);\n tasks.splice(result.destination.index, 0, removedTask);\n\n kanbanBoard[result.source.index][result.source.id] = { ...kanbanBoard[result.source.index][result.source.id], tasks };\n kanbanBoard[result.destination.index] = { ...kanbanBoard[result.destination.index], tasks: tasks };\n\n setKanbanBoard([...kanbanBoard]);\n };\n\n return (\n <Router>\n <Switch>\n <Route path=\"\/kanban\">\n <DragDropContext onDragEnd={handleDragEnd}>\n {kanbanBoard.map((column, index) => (\n <Droppable key={index} type=\"column\">\n {(provided) => (\n <div {...provided.droppableAttributes} ref={provided.innerRef}>\n {column.map((task, taskIndex) => (\n <Draggable key={task.id} draggableId={task.id} index={taskIndex}>\n {(provided) => (\n <div\n ref={provided.innerRef}\n {...provided.draggableProps}\n {...provided.dragHandleProps}\n >\n <KanbanBoard tasks={task.tasks} \/>\n <\/div>\n )}\n <\/Draggable>\n ))}\n {provided.placeholder}\n <\/div>\n )}\n <\/Droppable>\n ))}\n <\/DragDropContext>\n <\/Route>\n <\/Switch>\n <\/Router>\n );\n};\n\nexport default App;\n```\n\nThis Kanban board implementation has the following features:\n\n1. Create columns for each status (To Do, In Progress, Done)\n2. Allow drag-and-drop between columns\n3. Auto-move tasks based on progress field\n4. Allow custom columns per organization\n5. Add WIP limits per column\n\nTo use this Kanban board implementation, you need to create the necessary API endpoints in your Flask backend to handle the Kanban board functionality.\n\nOn the frontend, you can use the react-beautiful-dnd library to implement the drag-and-drop functionality. The KanbanBoard component can be used to render the tasks within each column.\n\nNote: Make sure you have the necessary API endpoints and database models set up for the React app to communicate with the Flask backend.","refusal":null,"annotations":null,"audio":null,"function_call":null,"tool_calls":[],"reasoning":null},"logprobs":null,"finish_reason":"stop","token_ids":null}],"service_tier":null,"system_fingerprint":null,"usage":{"prompt_tokens":25235,"total_tokens":26479,"completion_tokens":1244,"prompt_tokens_details":null},"prompt_token_ids":null,"kv_transfer_params":null}
|