From 42f752513952d165bd98bc093f999400804f9133 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sun, 11 Dec 2022 03:25:28 -0300 Subject: [PATCH 1/4] add feature create, index, gettask, update, destroy and finishtask --- src/controllers/taskController.js | 84 ++++++++++++++++++++++++++++++- src/db/connection.js | 7 +++ src/models/.gitkeep | 0 src/models/task.js | 17 +++++++ src/router.js | 7 ++- src/server.js | 2 + 6 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 src/db/connection.js delete mode 100644 src/models/.gitkeep create mode 100644 src/models/task.js diff --git a/src/controllers/taskController.js b/src/controllers/taskController.js index 438dea0..dbed74b 100644 --- a/src/controllers/taskController.js +++ b/src/controllers/taskController.js @@ -1,5 +1,87 @@ +const taskModel = require('../models/task'); + module.exports = { async createTask(req, res){ - return res.render("main"); + const { name, category, dateTimeInitial, dateTimeFinal } = req.body; + + try { + const task = await taskModel.create({name, category, dateTimeInitial, dateTimeFinal}); + return res.status(200).json(task); + // return res.status(200).render("main"); + } catch (error) { + console.log(error); + return res.status(404).json({msg: "Error create task"}); + } + }, + + async index(req, res){ + try { + const tasks = await taskModel.find(); + return res.status(200).json(tasks); + // return res.status(200).render("main"); + } catch (error) { + console.log(error); + return res.status(404).json({msg: "Error show tasks"}); + } + }, + + async getTask(req, res){ + const taskId = req.params.taskId; + try { + const task = await taskModel.findById({_id: taskId}); + return res.status(200).json(task); + // return res.status(200).render("main"); + } catch (error) { + console.log(error); + return res.status(404).json({msg: "error show task"}); + } + }, + + async update(req, res){ + const taskId = req.params.taskId; + const { name, category, dateTimeInitial, dateTimeFinal, finished } = req.body; + + try { + const task = await taskModel.updateOne({ + name: name || undefined, + category: category || undefined, + dateTimeInitial: dateTimeInitial || undefined, + dateTimeFinal: dateTimeFinal || undefined, + finished: finished || undefined + }).where({_id: taskId}); + return res.status(200).json(task); + // return res.status(200).render("main"); + } catch (error) { + console.log(error); + return res.status(404).json({msg: "Update error"}); + } + + }, + + async destroy(req, res){ + const taskId = req.params.taskId; + + try { + const task = await taskModel.deleteOne({_id: taskId}); + return res.status(200).json(task); + // return res.status(200).render("main"); + } catch (error) { + console.log(error); + return res.status(404).json({msg: "Delete error"}); + } + }, + + async finishTask(req, res){ + const taskId = req.params.taskId; + const {finished} = req.body; + + try { + const task = await taskModel.updateOne({finished: !finished}).where({_id: taskId}); + return res.status(200).json(task); + // return res.status(200).render("main"); + } catch (error) { + console.log(error); + return res.status(404).json({msg: "error when finishing task"}); + } } } \ No newline at end of file diff --git a/src/db/connection.js b/src/db/connection.js new file mode 100644 index 0000000..7bac8e1 --- /dev/null +++ b/src/db/connection.js @@ -0,0 +1,7 @@ +const mongoose = require('mongoose'); + +async function connetiodb(){ + await mongoose.connect('mongodb+srv://gabriel:gbr81828182@cluster0.spv2phu.mongodb.net/test'); +} + +module.exports = connetiodb; \ No newline at end of file diff --git a/src/models/.gitkeep b/src/models/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/models/task.js b/src/models/task.js new file mode 100644 index 0000000..01ea9e9 --- /dev/null +++ b/src/models/task.js @@ -0,0 +1,17 @@ +const mongoose = require('mongoose'); + +const Schema = mongoose.Schema; +const ObjectId = Schema.ObjectId; + +const taskSchema = new Schema({ + id: ObjectId, + name: String, + category: String, + dateTimeInitial: String, + dateTimeFinal: String, + finished: {type: Boolean, default: false} +}); + +const taskModel = mongoose.model('tasks', taskSchema); + +module.exports = taskModel; \ No newline at end of file diff --git a/src/router.js b/src/router.js index 127f78e..7e3db5d 100644 --- a/src/router.js +++ b/src/router.js @@ -2,6 +2,11 @@ const router = require("express").Router(); const taskController = require('./controllers/taskController'); -router.get('/', taskController.createTask); +router.post('/createtask', taskController.createTask); +router.get('/alltask', taskController.index); +router.get('/gettask/:taskId', taskController.getTask); +router.post('/updatetask/:taskId', taskController.update); +router.get('/deletetask/:taskId', taskController.destroy); +router.post('/finishtask/:taskId', taskController.finishTask); module.exports = router; \ No newline at end of file diff --git a/src/server.js b/src/server.js index 2648e0e..c3b08f4 100644 --- a/src/server.js +++ b/src/server.js @@ -1,7 +1,9 @@ const express = require("express"); const routes = require('./router'); +const connetiodb = require('./db/connection'); const app = express(); +connetiodb(); app.use(express.json()); app.use(express.urlencoded({extended: false})); From 2205ea37ebe413caf0587f25eb80daf11c4ef7d6 Mon Sep 17 00:00:00 2001 From: Tomas Braz Date: Mon, 12 Dec 2022 20:23:50 -0300 Subject: [PATCH 2/4] =?UTF-8?q?Adicionado=20altera=C3=A7=C3=B5es=20das=20m?= =?UTF-8?q?eninas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/style.css | 104 +++++++++++++++++++++++++++++++++++-------- views/home/home.ejs | 44 +++++++++--------- 2 files changed, 108 insertions(+), 40 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 86e0dcf..07f8a98 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -3,16 +3,16 @@ padding: 0; font-family: 'K2D', sans-serif; } - + body { background-color: #1E1E1E; font-family: Arial, Helvetica, sans-serif; } - + main { margin-left: 5vw; } - + #bgModal { visibility: hidden; position: fixed; @@ -23,7 +23,11 @@ main { z-index: 2; display: block; } - + +#mainModal { + width: 250px; +} + #modalCriarAtividade { visibility: hidden; width: 70%; @@ -32,7 +36,71 @@ main { border-radius: 10px; margin: 17vh auto 0 auto; } - + +#titulo { + margin-top: 3px; +} + +#categoria { + background-color: #B3ADC0; + border-radius: 10px; + border: 0; + padding-left: 7px; + margin-bottom: 30px; + padding-bottom: 60px; +} + +#descrição { + background-color: #B3ADC0; + border-radius: 10px; + border: 0; + padding-left: 7px; + padding-top: 120px; +} + +#data { + background-color: #B3ADC0; + border-radius: 10px; + border: 0; + padding-left: 7px; +} + +#data2 { + background-color: #B3ADC0; + border-radius: 10px; + border: 0; + padding-left: 7px; +} + +#time{ + background-color: #B3ADC0; + border-radius: 10px; + border: 0; + padding-left: 7px; +} + +#time2 { + background-color: #B3ADC0; + border-radius: 10px; + border: 0; + padding-left: 7px; +} + +.data1, .datafim, .inicio, .fim { + margin-top: 25px; + font-size: 20px; +} + +.finalizar, .cancelar, .lixeira{ + margin-top: 20px; + margin-left: 10px; + background-color: #9891A7; + border-radius: 10px; + border: 0; + width: 65px; + height: 40px; +} + #modalVisualizarAtividade { visibility: hidden; width: 70%; @@ -41,7 +109,7 @@ main { border-radius: 10px; margin: 17vh auto 0 auto; } - + #headerModal { height: 20%; display: flex; @@ -52,19 +120,19 @@ main { font-size: 90%; color: #00000080; } - + #bodyModal { display: flex; align-items: center; justify-content: space-around; } - + #bodyModal input { width: 100%; height: 50%; font-size: 130%; } - + #headerModal input { width: 50%; height: 50%; @@ -74,12 +142,12 @@ main { cursor: pointer; margin-left: 1vw; } - + #headerModal input:focus { box-shadow: 0 0 0 0; outline: 0; } - + #navBar { display: flex; align-items: center; @@ -87,12 +155,12 @@ main { background-color: #3C3845; margin-bottom: 5vh; } - + #logo { width: 250px; height: 65px; } - + #openModal { width: 250px; height: 40px; @@ -103,16 +171,16 @@ main { cursor: pointer; margin-left: 5vw; } - + #listaDeAtividades::-webkit-scrollbar{ width: 10px; } - + #listaDeAtividades::-webkit-scrollbar-thumb{ background-color: #706c7a71; border-radius: 10px; } - + #listaDeAtividades { display: flex; flex-direction: column; @@ -122,7 +190,7 @@ main { overflow-y: scroll; margin: 5vh 0 0 21vw; } - + #atividade { list-style: none; width: 40vw; @@ -136,7 +204,7 @@ main { display: flex; align-items: center; } - + .circle { width: 12px; height: 12px; diff --git a/views/home/home.ejs b/views/home/home.ejs index e472f48..428d807 100644 --- a/views/home/home.ejs +++ b/views/home/home.ejs @@ -1,60 +1,60 @@
-
+

Título:

-

Categoria:

+

Categoria:

- -

Descrição

+ +

Descrição

-

Data de início:

+

Data de início:

- -

Data de fim:

+ +

Data de fim:

- +
-

Início:

+

Início:

- -

Fim:

+ +

Fim:

- +
- - - + Finalizar + Cancelar +
-
+
- +
× -

apoi tome3

+

apoi tome3

- +
× -

apoi tome4

+

apoi tome4

- +
- +
  • PAIA
  • PAIA
  • From 28886433d0fb73f864618e4c69b928b579f84a4d Mon Sep 17 00:00:00 2001 From: Tomas Braz Date: Tue, 13 Dec 2022 05:13:23 -0300 Subject: [PATCH 3/4] =?UTF-8?q?Grafico=20n=C3=A3o=20esta=20funcionando?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + public/css/style.css | 65 ++++++++++++------------------------ public/imgs/Lixeira.png | Bin 0 -> 815 bytes views/home/home.ejs | 72 ++++++++++++++++++++++++++++++++-------- views/main.ejs | 25 ++++++++++++++ 5 files changed, 105 insertions(+), 58 deletions(-) create mode 100644 public/imgs/Lixeira.png diff --git a/package.json b/package.json index ad4df15..2a73c6c 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ }, "homepage": "https://github.com/Tomas025/PJTProcessoSoftware#readme", "dependencies": { + "chart.js": "^4.0.1", "dotenv": "^16.0.3", "ejs": "^3.1.8", "express": "^4.18.2", diff --git a/public/css/style.css b/public/css/style.css index 07f8a98..5c0fb81 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -25,7 +25,7 @@ main { } #mainModal { - width: 250px; + width: 25vw; } #modalCriarAtividade { @@ -37,49 +37,15 @@ main { margin: 17vh auto 0 auto; } -#titulo { - margin-top: 3px; -} - #categoria { background-color: #B3ADC0; border-radius: 10px; border: 0; padding-left: 7px; margin-bottom: 30px; - padding-bottom: 60px; -} - -#descrição { - background-color: #B3ADC0; - border-radius: 10px; - border: 0; - padding-left: 7px; - padding-top: 120px; } -#data { - background-color: #B3ADC0; - border-radius: 10px; - border: 0; - padding-left: 7px; -} - -#data2 { - background-color: #B3ADC0; - border-radius: 10px; - border: 0; - padding-left: 7px; -} - -#time{ - background-color: #B3ADC0; - border-radius: 10px; - border: 0; - padding-left: 7px; -} - -#time2 { +#descrição, #data, #data2, #hora, #hora2 { background-color: #B3ADC0; border-radius: 10px; border: 0; @@ -90,15 +56,26 @@ main { margin-top: 25px; font-size: 20px; } + +.inicio, .fim { + width: 10vw; + height: 30px; +} -.finalizar, .cancelar, .lixeira{ - margin-top: 20px; - margin-left: 10px; +.finalizar, .cancelar{ + width: 7vw !important; + height: 40px !important; + margin: 20px 10px 0 0; background-color: #9891A7; border-radius: 10px; - border: 0; - width: 65px; - height: 40px; + border: none; +} +.lixeira { + width: 4vw !important; + height: 40px !important; + background-color: #9891A7; + border-radius: 10px; + border: none; } #modalVisualizarAtividade { @@ -129,7 +106,6 @@ main { #bodyModal input { width: 100%; - height: 50%; font-size: 130%; } @@ -139,8 +115,9 @@ main { background-color: transparent; border: none; font-size: 130%; - cursor: pointer; + cursor: text; margin-left: 1vw; + margin-top: 3px; } #headerModal input:focus { diff --git a/public/imgs/Lixeira.png b/public/imgs/Lixeira.png new file mode 100644 index 0000000000000000000000000000000000000000..85c2f2a728e5f48c3ede54feed8a820109f3fca7 GIT binary patch literal 815 zcmV+~1JL}5P)nu~K~#7Fy;jX` z(?AejyH4AL2wD>VL?NlE!hr)PI3lG;yayaPazLUts5rD7c>)f+1`<34LTUskO$j7% zek2kUCruy5qS^ZH!7foxUO)(LxjBrmpK%**=|4ZSsGYD{t_} z%F2qRR5BtNImd`wC3{~<>dM9H6x<lGOM8u)?-No+0utGWj7H)eRkz ze?zG}yf#J(d4c3WkmHp2WVDpv3Hfc=jv~UiK(U|PGlpSw1$j1`ZIb_nLjF5Q*H>8- zmx)a6`6idmX7f+aYqi=Kg75HEIT#fWNsX)sN7f?pu9DQn;QKcdvsa^!%Ye32-muGo3PuQ75Mk4TCZ)a&&g2#WX! zKavUX`vESgQXi1a;pgr+G#FClKFOj?q!0)U27{jb8~akG`TbbsXh&FinJovK$XhXT zY+i%Z99s_C#3Sw-(H6Wgd?QB4d>_Z^HT!qm!rTCFdo46Xu2Oseo}w)WY&p!)_h
    -
    +

    Título:

    @@ -11,7 +11,7 @@

    Descrição

    - +

    Data de início:

    @@ -20,31 +20,73 @@

    Data de fim:

    -
    -

    Início:

    - - -

    Fim:

    - +
    +
    +

    Início:

    + +
    +
    +

    Fim:

    + +
    - -
    - Finalizar - Cancelar - + +
    + +
    + +
    +
    +
    +

    Título:

    + +
    +
    +
    +

    Categoria:

    + + +

    Descrição

    + +
    +
    +

    Data de início:

    + +

    Data de fim:

    + + +
    +
    +

    Início:

    + +
    +
    +

    Fim:

    + +
    +
    + + + + +
    +
    +
    +
    +
    ×

    apoi tome3

    - +
    × @@ -78,4 +120,6 @@
  • PAIA
  • PAIA
+ +
\ No newline at end of file diff --git a/views/main.ejs b/views/main.ejs index 82460a7..2ae5008 100644 --- a/views/main.ejs +++ b/views/main.ejs @@ -7,6 +7,7 @@ + Processo de software @@ -18,14 +19,38 @@