Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
83 changes: 64 additions & 19 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,7 +23,11 @@ main {
z-index: 2;
display: block;
}


#mainModal {
width: 25vw;
}

#modalCriarAtividade {
visibility: hidden;
width: 70%;
Expand All @@ -32,7 +36,48 @@ main {
border-radius: 10px;
margin: 17vh auto 0 auto;
}

#categoria {
background-color: #B3ADC0;
border-radius: 10px;
border: 0;
padding-left: 7px;
margin-bottom: 30px;
}

#descrição, #data, #data2, #hora, #hora2 {
background-color: #B3ADC0;
border-radius: 10px;
border: 0;
padding-left: 7px;
}

.data1, .datafim, .inicio, .fim {
margin-top: 25px;
font-size: 20px;
}

.inicio, .fim {
width: 10vw;
height: 30px;
}

.finalizar, .cancelar{
width: 7vw !important;
height: 40px !important;
margin: 20px 10px 0 0;
background-color: #9891A7;
border-radius: 10px;
border: none;
}
.lixeira {
width: 4vw !important;
height: 40px !important;
background-color: #9891A7;
border-radius: 10px;
border: none;
}

#modalVisualizarAtividade {
visibility: hidden;
width: 70%;
Expand All @@ -41,7 +86,7 @@ main {
border-radius: 10px;
margin: 17vh auto 0 auto;
}

#headerModal {
height: 20%;
display: flex;
Expand All @@ -52,47 +97,47 @@ 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%;
background-color: transparent;
border: none;
font-size: 130%;
cursor: pointer;
cursor: text;
margin-left: 1vw;
margin-top: 3px;
}

#headerModal input:focus {
box-shadow: 0 0 0 0;
outline: 0;
}

#navBar {
display: flex;
align-items: center;
justify-content: center;
background-color: #3C3845;
margin-bottom: 5vh;
}

#logo {
width: 250px;
height: 65px;
}

#openModal {
width: 250px;
height: 40px;
Expand All @@ -103,16 +148,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;
Expand All @@ -122,7 +167,7 @@ main {
overflow-y: scroll;
margin: 5vh 0 0 21vw;
}

#atividade {
list-style: none;
width: 40vw;
Expand All @@ -136,7 +181,7 @@ main {
display: flex;
align-items: center;
}

.circle {
width: 12px;
height: 12px;
Expand Down
Binary file added public/imgs/Lixeira.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 83 additions & 1 deletion src/controllers/taskController.js
Original file line number Diff line number Diff line change
@@ -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"});
}
}
}
7 changes: 7 additions & 0 deletions src/db/connection.js
Original file line number Diff line number Diff line change
@@ -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;
Empty file removed src/models/.gitkeep
Empty file.
17 changes: 17 additions & 0 deletions src/models/task.js
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 6 additions & 1 deletion src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 2 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const express = require("express");
const routes = require('./router');
const path = require('path');
const connetiodb = require('./db/connection');

const app = express();
connetiodb();

app.use(express.json());
app.use(express.urlencoded({extended: false}));
Expand Down
Loading